Bladeren bron

修改退货的导入

lvhao 1 dag geleden
bovenliggende
commit
a8d8e05d42
1 gewijzigde bestanden met toevoegingen van 41 en 18 verwijderingen
  1. 41 18
      core/CoreApp/controllers/Returns.php

+ 41 - 18
core/CoreApp/controllers/Returns.php

@@ -713,11 +713,18 @@ class Returns extends Start_Controller {
 					];
 					continue;
 				}
+				if(empty($value['运单号'])){
+					$err_list[] = [
+						'err'=>"不支持运单号为空的退货登记",
+						'data'=>json_encode($value,JSON_UNESCAPED_UNICODE),
+					];
+					continue;
+				}
 				$list[$value['运单号']][] = [
 					'region'=>($value['收货地址'] == '美国')?2:1,
 					'torderinfo'=>isset($value['运单号'])?$value['运单号']:'',
 					'express'=>isset($value['退件物流方式'])?$value['退件物流方式']:'',
-					'stime'=>isset($value['收到日期'])?$value['收到日期']:'',
+					'stime'=>isset($value['收到日期'])?str_replace("-",".",$value['收到日期']) :'',
 					'ret_regist_no'=>isset($value['退货登记编号'])?$value['退货登记编号']:'',
 					'received'=>isset($value['实际收到货物'])?$value['实际收到货物']:'',
 					'cp_num'=>isset($value['产品数量'])?$value['产品数量']:'',
@@ -726,6 +733,7 @@ class Returns extends Start_Controller {
 					'xh'=>isset($value['退货箱号'])?$value['退货箱号']:'',
 				];
 			}
+
 			foreach($list as $key => $value){
 				$info = $this->returns->get_torderinfo($value[0]['torderinfo']);
 				if(empty($info)){
@@ -743,34 +751,49 @@ class Returns extends Start_Controller {
 					continue;
 				}
 
+				$stime = strtotime(str_replace(".", "-", $value[0]['stime']));
+				if($stime < $info['ftime']){
+					$err_list[] = [
+						'err'=>"发货时间大于收到时间",
+						'data'=>json_encode($value,JSON_UNESCAPED_UNICODE),
+					];
+					continue;
+				}
+				$ret_regist_no = '';
+				if(empty($value[0]['ret_regist_no'])){
+					$err_list[] = [
+						'err'=>"退货登记编号未填写",
+						'data'=>json_encode($value,JSON_UNESCAPED_UNICODE),
+					];
+					continue;
+				}	
+				$ret_regist_no = $value[0]['ret_regist_no'];
+				
+
 
 				$str = $info['degreetext'];
+				$received_str = $info['received'];
 				foreach($value as $k => $v){
+					$received_str .= $v['received'].";";
 					$status = $this->_getStatus($v['whcd']);
-					$str .= $status."~".$v['whcd_bc']."|";
+					for($i = 0;$i < $v['cp_num'];$i++){
+						$str .= $status."~".$v['whcd_bc']."|";
+					}
 				}
 				$info['degreetext'] = $str;
 
-				$xh_str = $info['xh'];
-				if(empty($xh_str)){
-					$xh_arr = [];
-				}else{
-					if(stripos($xh_str,";") === false){
-						$xh_arr = [];
-						$xh_arr[] = $value[0]['xh'];
-					}else{
-						$xh_arr = explode(";",trim($xh_str,";"));
-					}
-				}
+				$xh_str = "";
 				foreach($value as $k => $v){
-					$xh_arr[] = $v['xh'];
+					if(!empty($v['xh'])){
+						$xh_str = $v['xh'];
+					}
 				}
-				$r = array_unique($xh_arr);
-				$info['xh'] = implode(";",$r);
-				$info['xh'] = trim($info['xh'],";");
 				$this->returns->save([
+					'ret_regist_no'=>$ret_regist_no,
+					'stime'=>$stime,
 					'degreetext' => $info['degreetext'],
-					'xh' => $info['xh'],
+					'received' => $received_str,
+					'xh' => $xh_str,
 				],$info['id']);
 
 			}