|
@@ -75,6 +75,8 @@ class BoxService extends Service
|
|
if(!$lock_status) return [false,'操作过于频繁'];
|
|
if(!$lock_status) return [false,'操作过于频繁'];
|
|
$product_list = OrdersProduct::wherein('id', $ids)->get()->toArray();
|
|
$product_list = OrdersProduct::wherein('id', $ids)->get()->toArray();
|
|
$sale_product_list = SaleOrdersProduct::wherein('id', $sale_ids)->get()->toArray();
|
|
$sale_product_list = SaleOrdersProduct::wherein('id', $sale_ids)->get()->toArray();
|
|
|
|
+
|
|
|
|
+ //生产订单包装----------------
|
|
$box_insert = [];
|
|
$box_insert = [];
|
|
foreach ($product_list as $v) {
|
|
foreach ($product_list as $v) {
|
|
$num_list = $key_list[$v['id']];
|
|
$num_list = $key_list[$v['id']];
|
|
@@ -95,9 +97,10 @@ class BoxService extends Service
|
|
$box_insert[] = [
|
|
$box_insert[] = [
|
|
'out_order_no' => $out_order_no,
|
|
'out_order_no' => $out_order_no,
|
|
'top_id' => $top_id,
|
|
'top_id' => $top_id,
|
|
- 'ext_1' => $ext_1,
|
|
|
|
|
|
+ 'orders_product_id' => $v['id'],
|
|
|
|
+ 'ext_1' => $ext_1,//产品编号
|
|
'ext_2' => $ext_2,
|
|
'ext_2' => $ext_2,
|
|
- 'ext_3' => $ext_3,
|
|
|
|
|
|
+ 'ext_3' => $ext_3,//颜色
|
|
'ext_4' => $ext_4,
|
|
'ext_4' => $ext_4,
|
|
'ext_5' => $ext_5,
|
|
'ext_5' => $ext_5,
|
|
'num' => $vv,
|
|
'num' => $vv,
|
|
@@ -107,7 +110,7 @@ class BoxService extends Service
|
|
'shipment_order_no' => $transport_no,
|
|
'shipment_order_no' => $transport_no,
|
|
];
|
|
];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //修改销售订单 生产订单 包装数量
|
|
SaleOrdersProduct::where('id',$v['sale_orders_product_id'])->update([
|
|
SaleOrdersProduct::where('id',$v['sale_orders_product_id'])->update([
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
]);
|
|
]);
|
|
@@ -115,6 +118,8 @@ class BoxService extends Service
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //销售订单包装----------------
|
|
foreach ($sale_product_list as $v) {
|
|
foreach ($sale_product_list as $v) {
|
|
$box_type = 0;
|
|
$box_type = 0;
|
|
if($v['id'] < 0) {
|
|
if($v['id'] < 0) {
|
|
@@ -140,6 +145,7 @@ class BoxService extends Service
|
|
$box_insert[] = [
|
|
$box_insert[] = [
|
|
'out_order_no' => $out_order_no,
|
|
'out_order_no' => $out_order_no,
|
|
'top_id' => $top_id,
|
|
'top_id' => $top_id,
|
|
|
|
+ 'orders_product_id' => 0,
|
|
'ext_1' => $ext_1,
|
|
'ext_1' => $ext_1,
|
|
'ext_2' => $ext_2,
|
|
'ext_2' => $ext_2,
|
|
'ext_3' => $ext_3,
|
|
'ext_3' => $ext_3,
|
|
@@ -153,6 +159,7 @@ class BoxService extends Service
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //修改销售订单 包装数量
|
|
SaleOrdersProduct::where('id',$v['id'])->update([
|
|
SaleOrdersProduct::where('id',$v['id'])->update([
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
'box_num' => DB::raw('box_num + '.$total),
|
|
]);
|
|
]);
|
|
@@ -168,12 +175,11 @@ class BoxService extends Service
|
|
$insert['order_no'] = $box_no;
|
|
$insert['order_no'] = $box_no;
|
|
$insert['shipment_order_no'] = $transport_no;
|
|
$insert['shipment_order_no'] = $transport_no;
|
|
list($status,$msg) = self::$box_hook->boxInsert($insert);
|
|
list($status,$msg) = self::$box_hook->boxInsert($insert);
|
|
- if(!$status) {
|
|
|
|
|
|
+ if(! $status) {
|
|
$this->delLock($key);
|
|
$this->delLock($key);
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
return [false,$msg];
|
|
return [false,$msg];
|
|
- }
|
|
|
|
- $this->delLock($key);
|
|
|
|
|
|
+ }$this->delLock($key);
|
|
|
|
|
|
//用友 ------产成品入库
|
|
//用友 ------产成品入库
|
|
$package_data = $msg->toArray();
|
|
$package_data = $msg->toArray();
|
|
@@ -181,7 +187,6 @@ class BoxService extends Service
|
|
$service = new FinishedOrderService();
|
|
$service = new FinishedOrderService();
|
|
list($status,$msg) = $service->U8Rdrecord10Save($package_data,$user);
|
|
list($status,$msg) = $service->U8Rdrecord10Save($package_data,$user);
|
|
if(! $status) {
|
|
if(! $status) {
|
|
- (new FyySqlServerService())->recordErrorTable($msg,$user,$package_data,$time,1);
|
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
return [false, $msg];
|
|
return [false, $msg];
|
|
}
|
|
}
|
|
@@ -196,7 +201,7 @@ class BoxService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 根据发货单包装
|
|
|
|
|
|
+ * 根据发货单包装(恒诚塑业不需要)
|
|
* @param $data
|
|
* @param $data
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
@@ -321,7 +326,7 @@ class BoxService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function boxProductList($data){
|
|
public function boxProductList($data){
|
|
- if(!isset($data['id'])) return [false,'id not found'];
|
|
|
|
|
|
+ if(empty($data['id'])) return [false,'请选择数据!'];
|
|
$sale_order_ids = $data['id'];
|
|
$sale_order_ids = $data['id'];
|
|
$model = SaleOrdersProduct::where('del_time',0)->wherein('id',$sale_order_ids)
|
|
$model = SaleOrdersProduct::where('del_time',0)->wherein('id',$sale_order_ids)
|
|
->select('id','out_order_no','order_no','customer_no','customer_name','product_no','product_title','product_size','crt_time as production_time','id as sale_orders_product_id','finished_num as dispatch_complete_quantity','box_num','technology_name','wood_name','crt_time','order_quantity','technology_material','technology_name','wood_name','process_mark')
|
|
->select('id','out_order_no','order_no','customer_no','customer_name','product_no','product_title','product_size','crt_time as production_time','id as sale_orders_product_id','finished_num as dispatch_complete_quantity','box_num','technology_name','wood_name','crt_time','order_quantity','technology_material','technology_name','wood_name','process_mark')
|
|
@@ -528,30 +533,31 @@ class BoxService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function delBoxDetail($data){
|
|
public function delBoxDetail($data){
|
|
|
|
+ if(empty($data['order_nos'])) return [false, '请选择包装单!'];
|
|
$order_nos = $data['order_nos'];
|
|
$order_nos = $data['order_nos'];
|
|
- foreach ($order_nos as $v){
|
|
|
|
- $list = self::$box_hook->delBox($v);
|
|
|
|
- foreach ($list as $vv){
|
|
|
|
- SaleOrdersProduct::where('id',$vv['top_id'])->update([
|
|
|
|
- 'box_num' => DB::raw('box_num - '.$vv['num'])
|
|
|
|
- ]);
|
|
|
|
- if($vv['box_type'] == 1){
|
|
|
|
- // $ext_1 = $v['product_no'];//产品编号
|
|
|
|
- // $ext_2 = $v['technology_material']; //工艺材质
|
|
|
|
- // $ext_3 = $v['technology_name'];//工艺名称
|
|
|
|
- // $ext_4 = $v['wood_name'];//木皮
|
|
|
|
- // $ext_5 = $v['process_mark'];//工艺备注
|
|
|
|
- // toDO 有问题
|
|
|
|
- OrdersProduct::where('product_no',$vv['ext_1'])->where('technology_material',$vv['ext_2'])->where('technology_name',$vv['ext_3'])->where('wood_name',$vv['ext_4'])->where('process_mark',$vv['ext_5'])->where('sale_orders_product_id',$vv['top_id'])
|
|
|
|
- ->update([
|
|
|
|
|
|
+ try {
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+
|
|
|
|
+ foreach ($order_nos as $v){
|
|
|
|
+ $list = self::$box_hook->delBox($v);
|
|
|
|
+ foreach ($list as $vv){
|
|
|
|
+ SaleOrdersProduct::where('id',$vv['top_id'])->update([
|
|
|
|
+ 'box_num' => DB::raw('box_num - '.$vv['num'])
|
|
|
|
+ ]);
|
|
|
|
+ if($vv['box_type'] == 1){
|
|
|
|
+ OrdersProduct::where('id',$vv['orders_product_id'])->update([
|
|
'box_num' => DB::raw('box_num - '.$vv['num'])
|
|
'box_num' => DB::raw('box_num - '.$vv['num'])
|
|
]);
|
|
]);
|
|
-
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ DB::commit();
|
|
|
|
+ }catch (\Throwable $exception){
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ return [false, $exception->getMessage()];
|
|
}
|
|
}
|
|
|
|
|
|
- return [true,'删除成功'];
|
|
|
|
|
|
+ return [true, ''];
|
|
}
|
|
}
|
|
|
|
|
|
public function boxAdd($data)
|
|
public function boxAdd($data)
|