|
@@ -210,7 +210,7 @@ class BoxService extends Service
|
|
|
if(! $status) return [false, $msg];
|
|
|
|
|
|
//组织数据
|
|
|
- $yongyou_data = [];
|
|
|
+ $yongyou_data = $update = [];
|
|
|
foreach ($data['out_data'] as $value){
|
|
|
$pro_tmp = [];
|
|
|
foreach ($value['product'] as $p){
|
|
@@ -238,6 +238,10 @@ class BoxService extends Service
|
|
|
'product' => $pro_tmp
|
|
|
];
|
|
|
}
|
|
|
+
|
|
|
+ foreach ($value['box_no'] as $box_no){
|
|
|
+ $update[$box_no] = $value['cdlcode'];
|
|
|
+ }
|
|
|
}
|
|
|
if(empty($yongyou_data)) return [false, '暂无写入用友发货出库数据!'];
|
|
|
|
|
@@ -246,6 +250,15 @@ class BoxService extends Service
|
|
|
list($status,$msg) = $service->U8Rdrecord32Save($yongyou_data,$user);
|
|
|
if(! $status) return [false, $msg];
|
|
|
|
|
|
+ //本地数据更新
|
|
|
+ if(! empty($update)){
|
|
|
+ foreach ($update as $key => $value){
|
|
|
+ Box::where('order_no', $key)->update([
|
|
|
+ 'shipment_order_no' => $value
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return [true, ''];
|
|
|
}
|
|
|
|
|
@@ -255,6 +268,23 @@ class BoxService extends Service
|
|
|
$customer_code = array_column($data['out_data'],'customer_code');
|
|
|
$isAllSame = count(array_unique($customer_code)) === 1;
|
|
|
if(! $isAllSame) return [false, '发货出库,请选择同一个客户的订单!'];
|
|
|
+ $box_no = array_column($data['out_data'],'box_no');
|
|
|
+ if(empty($box_no)) return [false, '包装单信息不能为空'];
|
|
|
+ $box_arr = [];
|
|
|
+ foreach ($box_no as $value){
|
|
|
+ foreach ($value as $val){
|
|
|
+ $box_arr[] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $box_map = Box::where('del_time',0)
|
|
|
+ ->whereIn('order_no',$box_arr)
|
|
|
+ ->pluck('shipment_order_no', "order_no")
|
|
|
+ ->toArray();
|
|
|
+ foreach ($box_arr as $value){
|
|
|
+ $tmp = $box_map[$value] ?? "";
|
|
|
+ if($tmp != "") return [false, "包装单:" . $value . "已在发货单(" . $tmp .")中发出!"];
|
|
|
+ }
|
|
|
+
|
|
|
//用友发货数据查询
|
|
|
$cdlcode = array_column($data['out_data'],'cdlcode');
|
|
|
$service = new FyySqlServerService($user);
|
|
@@ -889,4 +919,38 @@ class BoxService extends Service
|
|
|
|
|
|
return [true,array_values($return)];
|
|
|
}
|
|
|
+
|
|
|
+ public function boxOrderDetailByOrderNoNew($data){
|
|
|
+ if(empty($data['order_nos'])) return [false, '包装单号不能为空'];
|
|
|
+ $order_nos = $data['order_nos'];
|
|
|
+ $order_nos = array_unique($order_nos);
|
|
|
+ $list = Box::where('del_time',0)
|
|
|
+ ->whereIn('order_no',$order_nos)
|
|
|
+ ->select('order_no','out_order_no','top_order_no','shipment_order_no as transport_no')
|
|
|
+ ->get()->toArray();
|
|
|
+ $detail_list = [];
|
|
|
+ foreach ($list as $v){
|
|
|
+ if(empty($v['transport_no'])) return [false, "包装单:" . $v['transport_no'] . "已在发货单(" . $v['transport_no'] .")中发出!"];
|
|
|
+ $model = new BoxDetail(['channel'=>$v['top_order_no']]);
|
|
|
+ $detail_list = array_merge($detail_list,$model->where('order_no',$v['order_no'])->where('top_order_no',$v['top_order_no'])->get()->toArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ $return = [];
|
|
|
+ foreach ($detail_list as $value){
|
|
|
+ //销售订单号 包装单号 产品编码 颜色
|
|
|
+ $key = $value['ext_1'] . $value['ext_3'];
|
|
|
+ if(isset($return[$key])){
|
|
|
+ $return[$key]['num'] += $value['num'];
|
|
|
+ }else{
|
|
|
+ $return[$key] = [
|
|
|
+ 'ext_1' => $value['ext_1'],
|
|
|
+ 'ext_3' => $value['ext_3'],
|
|
|
+ 'ext_8' => $value['ext_8'],
|
|
|
+ 'num' => $value['num'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, array_values($return)];
|
|
|
+ }
|
|
|
}
|