lvhao hai 5 meses
pai
achega
1457be5e98
Modificáronse 1 ficheiros con 63 adicións e 8 borrados
  1. 63 8
      core/CoreApp/controllers/Apipf.php

+ 63 - 8
core/CoreApp/controllers/Apipf.php

@@ -131,16 +131,71 @@ class Apipf extends Start_Controller{
     //      $this->db->query("update crowd_customer set more_three = 3,is_tb = 1 where id in (".implode(",",$list_ids).")");
     //    }
     }
+    //同步已经同步过的订单客户近期订单
+    public function  _customerDepartTbData(){
+        $api = $this->input->get('api',true);
+        if($api != $this->api){
+             die("No data to be executed");
+        }
+        $list = $this->customer->find_all("more_three = 3 and is_tb = 0","id,shop,source,name,email,phone,money,num,country,province,city,street,address,address2,zipcode",'id asc',0,100);
+        //$list = $this->customer->find_all("id = 71015","id,shop,source,name,email,phone,money,num,country,province,city,street,address,address2,zipcode",'id asc',0,100);
+        if(empty($list)){
+            die("This is a request without data");  
+        }
+        
+        $send_list = [];
+        foreach($list as $k=>$v){
+             $orderinfo = $this->getOrderList($v['email'],$v['shop'],2);
+             $send_list[] = [
+                 'customer_id'=>$v['id'],
+                 'name'=>$v['name'],
+                 'email'=>$v['email'],
+                 'telephone'=>$v['phone'],
+                 'ordered_mount'=>$orderinfo['order_mount'],
+                 'ordered_num'=>$orderinfo['order_num'],
+                 'ordered_qty'=>$orderinfo['order_qty'],
+                 // 'country'=>$v['country'],
+                 // 'province'=>$v['province'],
+                 // 'city'=>$v['city'],
+                 // 'street'=>$v['street'],
+                 // 'address'=>$v['address'].$v['address2'],
+                 // 'zipcode'=>$v['zipcode']
+                 'orders'=>$orderinfo['orders'],
+             ];
+        }
+       
+        if(empty($send_list)){
+           die("There is no customer data to be synchronized");  
+        }
+        $header = [];
+        $url = "";
+        
+        var_dump($send_list);
+        die;
+        foreach($send_list as $item){
+            if(empty($item['orders'])){
+                
+                continue;
+            }
+             // $res = $this->sendHttp($url,$header,$item);
+             // if($res){
+             //     $this->customer->save([
+             //         'more_three'=>3,
+             //         'is_tb'=>1,
+             //     ],$item['customer_id']);
+             // }
+        }
+    }
     /**
      * $email  邮箱
      * $shop   店铺id
      * $type   1 获取全部订单列表  2 只获取昨天新增的订单列表  一般在凌晨1点执行
      */
     //要求订单必须为线下单,并且为processing或complete
-    public function getOrderList($email,$shop,$type = 2){
-        var_dump('email = "'.$email.'" and shop = "'.$shop.'" and source != 1 and state in (207,216) ');
+    private function getOrderList($email,$shop,$type = 2){
+        //var_dump('email = "'.$email.'" and shop = "'.$shop.'" and source != 1 and state in (207,216) ');
         $fdata =  $this->fullorder->find_all('email = "'.$email.'" and shop = "'.$shop.'" and source != 1 and state in (207,216) ','shop,orderinfo,issku,quantity,fpdata,state,product,name,email,dtime,shouldmoney,shipremarks,librarytime,source','id desc');
-        var_dump($fdata);
+        //var_dump($fdata);
         $ret_list = [];
         $order_mount = 0;//订单总金额
         $order_num = 0;//下单次数
@@ -204,10 +259,10 @@ class Apipf extends Start_Controller{
             if(($tmp_type <2) && ($tmp_qty < 2)){
                 continue;
             }
-            var_dump($v['orderinfo']);
-            var_dump($tmp_type);
-            var_dump($tmp_qty);
-            var_dump("------------------");
+            // var_dump($v['orderinfo']);
+            // var_dump($tmp_type);
+            // var_dump($tmp_qty);
+            // var_dump("------------------");
             $order_mount = $order_mount +$v['shouldmoney']*1;//订单总金额
             $order_num++;//下单次数
             $order_qty =  $order_qty + $jisuan_qty;//订单产品总数
@@ -229,7 +284,7 @@ class Apipf extends Start_Controller{
                 $end_time = strtotime(date("Y-m-d"));
                 $start_time = $end_time - 24* 60 *60;
                 //这里只按照出库时间算 
-                if(($v['librarytime'] >= $start_time)&&($v['librarytime'] < $end_time)){
+                if(($v['dtime'] >= $start_time)&&($v['dtime'] < $end_time)){
                     $ret_list[] = [
                         'shop'=>$v['shop'],
                         'orderinfo'=>$v['orderinfo'],