lvhao 15 часов назад
Родитель
Сommit
f42fc8afc6
1 измененных файлов с 140 добавлено и 0 удалено
  1. 140 0
      core/CoreApp/controllers/Lyerpapi/v2/Skutoysjm.php

+ 140 - 0
core/CoreApp/controllers/Lyerpapi/v2/Skutoysjm.php

@@ -200,4 +200,144 @@ class Skutoysjm extends Lyapi_Controller
         }
             
     }
+
+    //获取订单信息
+    public function getorderlist(){
+
+        $json_str = $this->input->raw_input_stream;
+        $data = json_decode($json_str,true);
+
+        $table_name = "";
+        if($data['plat'] == 'dlz'){
+            $table_name = "fullorder";
+        }
+        if($data['plat'] == 'smt'){
+            $table_name = "fullordersmt";
+        }
+        if($data['plat'] == 'tt'){
+            $table_name = "fullordertt";
+        }
+        if($data['plat'] == 'amz'){
+            $table_name = "fullorderamz";
+        }
+
+        if(empty($data['plat'])){
+             $this->_json_error("平台未配置",400 ,$data = []);
+        }
+
+        $token = $data['token'];
+        if(empty($token)){
+            $this->_json_error("无权访问该方法",404 ,$data = []);
+        }
+        $jiemi_str = $this->logic_tools->toolsjiemi($token,$this->key,$this->iv);
+
+        
+        $now_time = time();
+
+        $jiemi_arr = explode("+",$jiemi_str);
+        $jiemi_key = isset($jiemi_arr[0])?$jiemi_arr[0]:"";
+        $jiemi_time = isset($jiemi_arr[1])?$jiemi_arr[1]:"";
+        
+        if( $now_time - $jiemi_time > 10){
+            $this->_json_error("请求已超时",404 ,$data = []);
+        }
+        
+
+        if($jiemi_key != $this->salt_str){
+            $this->_json_error("凭证不正确",404 ,$data = []);
+        }
+
+        if(empty($data['start_time'])){
+            $this->_json_error("筛选开始时间不能为空",400 ,$data = []);
+        }
+
+        if(empty($data['end_time'])){
+            $this->_json_error("结束开始时间不能为空",400 ,$data = []);
+        }
+
+        if(!in_array($data['plat'],['dlz','smt','tt','amz'])){
+            $this->_json_error("平台参数错误",400 ,$data = []);
+        }
+
+        $page = empty($data['page'])?1:$data['page'];
+        $size = empty($data['size'])?50:$data['size'];
+        $start_ts = ($page - 1) * $size;
+        if($start_ts < 0){
+             $this->_json_error("页码参数错误",400 ,$data = []);
+        }
+
+        if($size > 500){
+             $this->_json_error("每次请求条数不能超过500条",400 ,$data = []);
+        }
+    
+        $list = $this->db->select('id,number ,shop, dtime,fpdata')->where("dtime >= ", $data['start_time'])
+                    ->where("dtime <= ", $data['end_time'])
+                    ->limit($size,$start_ts)
+                    ->get($table_name)
+                    ->result_array();
+        
+        if(empty($list)){
+            $list = [];
+            $this->_json_error("SUCCESS",200 ,[]);
+
+        }
+
+        $typeclass = [];
+
+        $classid = $this->classid->sku();
+        $tcall = $this->typeclass->find_all();
+        foreach ($tcall as $v)
+        {
+            //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+            $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+        }
+        $shop_list  = $this->shop->find_all();
+        $shop_list = array_column($shop_list,"shopname","id");
+       
+        $final_all  = [];
+        foreach($list as $k => $v){
+            if(empty($v['fpdata'])){
+                $final_all[] = [
+                    "shop"=>$v['shop'],
+                    "shop_name"=>isset($shop_list[$v['shop']])?$shop_list[$v['shop']]:"",
+                    "number"=>$v['number'],
+                    'dtime'=>$v['dtime'],
+                    'dtime_show'=>date("Y-m-d H:i:s",$v['dtime']),
+                    "u9_code"=>"",
+                    "qty"=>0,
+                    "en"=>"",
+                    "zh"=>"",
+                ];
+
+                continue;
+            } 
+            $tmp = explode(';',trim($v['fpdata'],";"));
+
+            foreach($tmp as $key => $val){
+                $arr_tmp = explode('|',$val);
+                if(strpos($arr_tmp[0],',')!== false){
+                    $sku  = "-".str_replace(',','-',$arr_tmp[0]);
+                }else{
+                    $sku = $arr_tmp[0];
+                }
+                $r = $this->logic_u9tools->getOneU9bmHasGift($sku,$classid,$typeclass);
+                $final_all[] = [
+                    "shop"=>$v['shop'],
+                    "shop_name"=>isset($shop_list[$v['shop']])?$shop_list[$v['shop']]:"",
+                    "number"=>$v['number'],
+                    'dtime'=>$v['dtime'],
+                    'dtime_show'=>date("Y-m-d H:i:s",$v['dtime']),
+                    "u9_code"=>$r['jm'],
+                    "qty"=>$arr_tmp[2],
+                    "en"=>$arr_tmp[1],
+                    "zh"=>$r['zh'],
+                ];
+
+            }
+        }
+        //
+        $this->_json_error("SUCCESS",200 ,$final_all);
+        
+    }
+
 }