Browse Source

短信脚本仓管

sunhao 5 years ago
parent
commit
635768bb45
2 changed files with 51 additions and 0 deletions
  1. 50 0
      app/Console/Commands/SendOrder.php
  2. 1 0
      app/Console/Kernel.php

+ 50 - 0
app/Console/Commands/SendOrder.php

@@ -0,0 +1,50 @@
1
+<?php 
2
+namespace App\Console\Commands;
3
+
4
+use Illuminate\Console\Command;
5
+use Symfony\Component\Console\Input\InputOption;
6
+use Symfony\Component\Console\Input\InputArgument;
7
+use TopClient;
8
+use DB;
9
+use YPSMS;
10
+class SendOrder extends Command {
11
+
12
+    protected $signature = 'SendOrder';
13
+
14
+    /**
15
+     * The console command description.
16
+     *
17
+     * @var string
18
+     */
19
+    protected $description = '提醒仓管新订单短信';
20
+
21
+
22
+    public function handle()
23
+    {
24
+        $this->SendOrder();
25
+    }
26
+    public function SendOrder(){
27
+        #今日
28
+        $today = date('Y-m-d');
29
+        //A仓
30
+        $orders = DB::table('order')->where('delivery_date', $today)->where('warehouse', 1)->where(function($query) use($today){
31
+            $query->where('logistics_id','=','')->orWhere('logistics_id','is',null);
32
+        })->lists('id');
33
+        if(!empty($orders)){
34
+            $orders = json_decode(json_encode($orders), true);
35
+            $order_ids = implode(',',$orders);
36
+            $res = YPSMS::sendMsg('15695966629', 2, $order_ids, $today);
37
+        } 
38
+
39
+        //B仓
40
+        $orders = DB::table('order')->where('delivery_date', $today)->where('warehouse', 2)->where(function($query) use($today){
41
+            $query->where('logistics_id','=','')->orWhere('logistics_id','is',null);
42
+        })->lists('id');
43
+        if(!empty($orders)){
44
+            $orders = json_decode(json_encode($orders), true);
45
+            $order_ids = implode(',',$orders);
46
+            $res = YPSMS::sendMsg('13055396000', 2, $order_ids, $today);
47
+        } 
48
+    }
49
+
50
+}

+ 1 - 0
app/Console/Kernel.php

@@ -18,6 +18,7 @@ class Kernel extends ConsoleKernel {
18 18
         'App\Console\Commands\OrderRateByDayHistory',
19 19
         'App\Console\Commands\TeamOrderRateByDay',
20 20
         'App\Console\Commands\TeamOrderRateByDayHistory',
21
+        'App\Console\Commands\SendOrder',
21 22
         
22 23
     ];
23 24