Jelajahi Sumber

提交测试

lvhao 5 bulan lalu
induk
melakukan
177ce19794
1 mengubah file dengan 42 tambahan dan 28 penghapusan
  1. 42 28
      core/CoreApp/controllers/Apipf.php

+ 42 - 28
core/CoreApp/controllers/Apipf.php

@@ -12,11 +12,20 @@ class Apipf extends Start_Controller{
         $this->load->_model('Model_customer','customer');
         $this->load->_model('Model_typeclass','typeclass');
         
-    }          
+    }    
+    private $url = "http://wholesale.hnwmzp.cn/syncerp/customer";      
     private $key = "bpng!pjgirv6amnfr"; //加密所需要到的key
     private $iv = "k4k!94m66oojtm2w";//加密所需要到的iv
     private $api = "202503121009@ly";
     private $filter_words = ['bonus','flashsale','clearance','giftpack','gift'];
+    private $shop_list = [
+        1=>'h',
+        2=>'as',
+        3=>'ap',
+        4=>"wk",
+        5=>"y",
+        6=>"wg",
+    ];
 
     //定义方法的调用规则 获取URI第二段值
     public function _remap($arg,$arg_array)
@@ -89,6 +98,7 @@ class Apipf extends Start_Controller{
                 'ordered_mount'=>$orderinfo['order_mount'],
                 'ordered_num'=>$orderinfo['order_num'],
                 'ordered_qty'=>$orderinfo['order_qty'],
+                'brand'=>isset($this->shop_list[$v['shop']])?$this->shop_list[$v['shop']]:"other",
                 // 'country'=>$v['country'],
                 // 'province'=>$v['province'],
                 // 'city'=>$v['city'],
@@ -103,7 +113,7 @@ class Apipf extends Start_Controller{
           die("There is no customer data to be synchronized");  
        }
        $header = [];
-       $url = "";
+       $url = $this->url;
        
        var_dump($send_list);
        die;
@@ -116,20 +126,14 @@ class Apipf extends Start_Controller{
                 ],$item['customer_id']);
                continue;
            }
-            // $res = $this->sendHttp($url,$header,$item);
-            // if($res){
-            //     $this->customer->save([
-            //         'more_three'=>3,
-            //         'is_tb'=>1,
-            //     ],$item['customer_id']);
-            // }
+            $res = $this->sendHttp($url,$header,$item);
+            if($res){
+                $this->customer->save([
+                    'more_three'=>3,
+                    'is_tb'=>1,
+                ],$item['customer_id']);
+            }
        }
-    //    die("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
-    //    $this->db->query("update crowd_customer set more_three = 3,is_tb = 1 where id in (".implode(",",$list_ids).")");
-    //    $res = $this->sendHttp($url,$header,$send_list);
-    //    if($res){
-    //      $this->db->query("update crowd_customer set more_three = 3,is_tb = 1 where id in (".implode(",",$list_ids).")");
-    //    }
     }
     //同步已经同步过的订单客户近期订单
     public function  _customerDepartTbData(){
@@ -154,6 +158,7 @@ class Apipf extends Start_Controller{
                  'ordered_mount'=>$orderinfo['order_mount'],
                  'ordered_num'=>$orderinfo['order_num'],
                  'ordered_qty'=>$orderinfo['order_qty'],
+                 'brand'=>isset($this->shop_list[$v['shop']])?$this->shop_list[$v['shop']]:"other",
                  // 'country'=>$v['country'],
                  // 'province'=>$v['province'],
                  // 'city'=>$v['city'],
@@ -168,7 +173,7 @@ class Apipf extends Start_Controller{
            die("There is no customer data to be synchronized");  
         }
         $header = [];
-        $url = "";
+        $url = $this->url;
         
         var_dump($send_list);
         die;
@@ -177,13 +182,13 @@ class Apipf extends Start_Controller{
                 
                 continue;
             }
-             // $res = $this->sendHttp($url,$header,$item);
-             // if($res){
-             //     $this->customer->save([
-             //         'more_three'=>3,
-             //         'is_tb'=>1,
-             //     ],$item['customer_id']);
-             // }
+             $res = $this->sendHttp($url,$header,$item);
+             if($res){
+                 $this->customer->save([
+                     'more_three'=>3,
+                     'is_tb'=>1,
+                 ],$item['customer_id']);
+             }
         }
     }
     /**
@@ -304,17 +309,26 @@ class Apipf extends Start_Controller{
         }
         $final_list = [];
         foreach($ret_list as $k=>$v){
+            $orderitems = [];
+            foreach($sku_list as $key1 => $val1){
+                $orderitems[] = [
+                    'product_name'=>$val1['product_name'],
+                    'sku'=>$val1['sku'],
+                    'qty'=>$val1['qty'],
+                ];
+            }
             $final_list[] = [
                 'shop'=>$v['shop'],
-                'orderinfo'=>$v['orderinfo'],
+                'increment id'=>$v['orderinfo'],
                 'status'=>$v['state'],
                 'grand_total'=>$v['shouldmoney'],
                 'order_created'=>$v['dtime'],
-                'product_name'=>array_column($sku_list,'product_name'),
-                'sku'=>array_column($sku_list,'sku'),
-                'erp_goods_name'=>array_column($goods_list,'goods_name'),
-                'qty'=>array_column($sku_list,'qty'),
+                //'product_name'=>array_column($sku_list,'product_name'),
+                //'sku'=>array_column($sku_list,'sku'),
+                //'erp_goods_name'=>array_column($goods_list,'goods_name'),
+                //'qty'=>array_column($sku_list,'qty'),
                 //'price'=>$v['shouldmoney'],
+                'orderitems'=>$orderitems,
             ];
         }
         return [