|
@@ -0,0 +1,38 @@
|
|
1
|
+<?php
|
|
2
|
+namespace App\Console\Commands;
|
|
3
|
+
|
|
4
|
+use Illuminate\Console\Command;
|
|
5
|
+use DB;
|
|
6
|
+class SyncCustSaler extends Command {
|
|
7
|
+
|
|
8
|
+ protected $signature = 'SyncCustSaler';
|
|
9
|
+
|
|
10
|
+ /**
|
|
11
|
+ * The console command description.
|
|
12
|
+ *
|
|
13
|
+ * @var string
|
|
14
|
+ */
|
|
15
|
+ protected $description = '同步客户第一次下单销售';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+ public function handle()
|
|
19
|
+ {
|
|
20
|
+ $this->SyncCustSaler();
|
|
21
|
+ }
|
|
22
|
+ public function SyncCustSaler(){
|
|
23
|
+ $customers = DB::table('customers')->select('id', 'phone')->where('phone','>','')->get();
|
|
24
|
+ $customers = json_decode(json_encode($customers), true);
|
|
25
|
+ foreach($customers as $k=>$v){
|
|
26
|
+ $order = DB::table('order')->select('admin_id')->where('receiverMobile', $v['phone'])->orderBy('id', 'asc')->first();
|
|
27
|
+ if(empty($order)){
|
|
28
|
+ echo "\n".$v['phone']." 失败,未找到订单:";
|
|
29
|
+ continue;
|
|
30
|
+ }
|
|
31
|
+ $admin_id = $order->admin_id;
|
|
32
|
+ $res = DB::table('customers')->where('id', $v['id'])->update(['admin_id'=>$admin_id]);
|
|
33
|
+ echo "\n".$v['phone']." 结果:".$res;
|
|
34
|
+ }
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+}
|