dong025 3 дней назад
Родитель
Сommit
acac6ca9ac
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      application/api/controller/Chabao.php

+ 7 - 4
application/api/controller/Chabao.php

@@ -30,6 +30,7 @@ class Chabao extends Api
     protected $params = [];
 
     protected $type = 'goods';
+    protected $id_name = 'order_id';
 
     public function _initialize()
     {
@@ -163,13 +164,15 @@ class Chabao extends Api
             switch ($this->type) {
                 case 'local':
                     $this->type='CFB_LOCAL_';
+                    
+                    $this->id_name='id';
                     break;
                 default:
                     $this->type='CFB_';
                     break;
             }
             $mobile_list = array_column($data, 'mobile');
-            $order_id_arr = array_column($data, 'order_id');
+            $order_id_arr = array_column($data, $this->id_name);
             $order_id_arr = array_map(function($item) {
                 return $this->type.$item; // 自动将数字转为字符串
             }, $order_id_arr);
@@ -180,11 +183,11 @@ class Chabao extends Api
             $ret_data=[];
             foreach ($data as &$item) {
                 
-                $item_order_id=$this->type.$item['order_id'];
+                $item_order_id=$this->type.$item[$this->id_name];
                 if(!in_array($item_order_id,$product_arr)){
                     foreach($user as &$item_1){
                         if($item['mobile']==$item_1['phone']){
-                            $ret = $order_model->setGiverwagoods($this->type.$item['order_id'], 0, $item['product_id'], $item_1['id'], $order_model::Airdrop);
+                            $ret = $order_model->setGiverwagoods($this->type.$item[$this->id_name], 0, $item['product_id'], $item_1['id'], $order_model::Airdrop);
                             $add_data[]=$ret;
                             // if ($ret) {
                             //     $item['gift_record_type'] = 1;
@@ -203,7 +206,7 @@ class Chabao extends Api
                             
                         }
                     }
-                    $item['order_id']=(int)$item['order_id'];
+                    $item['order_id']=(int)$item[$this->id_name];
                     $ret_data[]=$item;
                 }else{
                     // $item['order_id']=(int)$item['order_id'];