|
@@ -42,8 +42,8 @@ class BoxService extends Service
|
|
public function boxIn($data)
|
|
public function boxIn($data)
|
|
{
|
|
{
|
|
|
|
|
|
- if(!isset($data['param'])) return [false,'not found param'];
|
|
|
|
- $param = $data['param'];
|
|
|
|
|
|
+// if(!isset($data['params'])) return [false,'not found params'];
|
|
|
|
+// $param = $data['params'];
|
|
// $param = [
|
|
// $param = [
|
|
// [
|
|
// [
|
|
// 'id' => 716,
|
|
// 'id' => 716,
|
|
@@ -62,26 +62,28 @@ class BoxService extends Service
|
|
|
|
|
|
$ids = [];
|
|
$ids = [];
|
|
$key_list = [];
|
|
$key_list = [];
|
|
- foreach ($param as $v) {
|
|
|
|
|
|
+ foreach ($data as $v) {
|
|
$ids[] = $v['id'];
|
|
$ids[] = $v['id'];
|
|
$total = 0;
|
|
$total = 0;
|
|
|
|
|
|
- foreach ($v['param'] as $vv) {
|
|
|
|
|
|
+ foreach ($v['params'] as $vv) {
|
|
$total += $vv;
|
|
$total += $vv;
|
|
}
|
|
}
|
|
$key_list[$v['id']] = [
|
|
$key_list[$v['id']] = [
|
|
- 'detail' => $v['param'],
|
|
|
|
|
|
+ 'detail' => $v['params'],
|
|
'total' => $total,
|
|
'total' => $total,
|
|
];
|
|
];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $insert = [];
|
|
try{
|
|
try{
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
- $product_list = SaleOrdersProduct::wherein('id', $ids)->get()->toArray();
|
|
|
|
|
|
+ $key = $this->lock_key.'_'.$v['id'];
|
|
|
|
+ $lock_status = $this->isLock($key);
|
|
|
|
+ if(!$lock_status) return [false,'操作过于频繁'];
|
|
|
|
+ $product_list = OrdersProduct::wherein('id', $ids)->get()->toArray();
|
|
|
|
+ $box_insert = [];
|
|
foreach ($product_list as $v) {
|
|
foreach ($product_list as $v) {
|
|
- $key = $this->lock_key.'_'.$v['id'];
|
|
|
|
- $lock_status = $this->isLock($key);
|
|
|
|
- if(!$lock_status) return [false,'操作过于频繁'];
|
|
|
|
|
|
+
|
|
$num_list = $key_list[$v['id']];
|
|
$num_list = $key_list[$v['id']];
|
|
$total = $num_list['total'];
|
|
$total = $num_list['total'];
|
|
$detail = $num_list['detail'];
|
|
$detail = $num_list['detail'];
|
|
@@ -93,10 +95,10 @@ class BoxService extends Service
|
|
$ext_3 = $v['product_no'];
|
|
$ext_3 = $v['product_no'];
|
|
$ext_4 = $v['product_title'];
|
|
$ext_4 = $v['product_title'];
|
|
$ext_5 = $v['product_size'];
|
|
$ext_5 = $v['product_size'];
|
|
- $out_order_no = $v['out_order_no'];
|
|
|
|
- $top_id = $v['id'];
|
|
|
|
|
|
+ $out_order_no = $insert['out_order_no'] = $v['out_order_no'];
|
|
|
|
+ $top_id = $v['sale_orders_product_id'];
|
|
foreach ($detail as $vv){
|
|
foreach ($detail as $vv){
|
|
- $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,
|
|
'ext_1' => $ext_1,
|
|
@@ -107,22 +109,26 @@ class BoxService extends Service
|
|
'num' => $vv,
|
|
'num' => $vv,
|
|
|
|
|
|
];
|
|
];
|
|
- list($status,$msg) = self::$box_hook->boxInsert($box_insert);
|
|
|
|
|
|
|
|
- if(!$status) {
|
|
|
|
- $this->delLock($key);
|
|
|
|
- DB::rollBack();
|
|
|
|
- return [false,$msg];
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
- $this->delLock($key);
|
|
|
|
- SaleOrdersProduct::where('id',$top_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),
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ $insert['detail'] = $box_insert;
|
|
|
|
+ list($status,$msg) = self::$box_hook->boxInsert($insert);
|
|
|
|
+
|
|
|
|
+ if(!$status) {
|
|
|
|
+ $this->delLock($key);
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ return [false,$msg];
|
|
|
|
+ }
|
|
|
|
+ $this->delLock($key);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
return [true,''];
|
|
return [true,''];
|
|
@@ -147,30 +153,77 @@ class BoxService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function boxProductList($data){
|
|
public function boxProductList($data){
|
|
- $box = new Box();
|
|
|
|
if(!isset($data['id'])) return [false,'id not found'];
|
|
if(!isset($data['id'])) return [false,'id not found'];
|
|
- $model = OrdersProduct::where('del_time',0)->wherein('sale_orders_product_id',$data['id'])
|
|
|
|
- ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','production_time','production_no','status','sale_orders_product_id')
|
|
|
|
|
|
+ $sale_order_ids = $data['id'];
|
|
|
|
+ $model = OrdersProduct::where('del_time',0)->wherein('sale_orders_product_id',$sale_order_ids)
|
|
|
|
+ ->select('id','out_order_no','customer_no','customer_name','product_no','product_title','product_size','production_time','production_no','sale_orders_product_id','dispatch_complete_quantity','box_num','technology_name','wood_name','crt_time')
|
|
->orderBy('id','desc')->get()->toArray();
|
|
->orderBy('id','desc')->get()->toArray();
|
|
|
|
+ $sale_list = SaleOrdersProduct::wherein('id',$sale_order_ids)->select('order_quantity','id','production_quantity','box_num')->get()->toArray();
|
|
|
|
+ $sale_key_list = [];
|
|
|
|
+ foreach ($sale_list as $v){
|
|
|
|
+ $sale_key_list[$v['id']] = [
|
|
|
|
+ 'order_quantity' => $v['order_quantity'],
|
|
|
|
+ 'production_quantity' => $v['production_quantity'],
|
|
|
|
+ 'box_num' => $v['box_num'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $return = [];
|
|
|
|
+ $product_key_list = [];
|
|
|
|
+ foreach ($model as $v){
|
|
|
|
+ if(!isset($product_key_list[$v['sale_orders_product_id']])) {
|
|
|
|
+ $p = $sale_key_list[$v['sale_orders_product_id']];
|
|
|
|
+ $product_key_list[$v['sale_orders_product_id']] = [
|
|
|
|
+ 'out_order_no' => $v['out_order_no'],
|
|
|
|
+ 'production_time' => '未下生产',
|
|
|
|
+ 'customer_no' => $v['customer_no'],
|
|
|
|
+ 'customer_name' => $v['customer_name'],
|
|
|
|
+ 'product_no' => $v['production_no'],
|
|
|
|
+ 'product_title' => $v['product_title'],
|
|
|
|
+ 'product_size' => $v['product_size'],
|
|
|
|
+ 'id' => -$v['sale_orders_product_id'],
|
|
|
|
+ 'type' => '2',
|
|
|
|
+ 'is_box_num' => $p['box_num'],
|
|
|
|
+ 'un_box_num' => $p['order_quantity'] - $p['box_num'] - $p['production_quantity'],
|
|
|
|
+ 'sale_num' => $p['order_quantity'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $return[] = [
|
|
|
|
+ 'id' => $v['id'],
|
|
|
|
+ 'out_order_no' => $v['out_order_no'],
|
|
|
|
+ 'production_time' => date('Y-m-d',$v['crt_time']),
|
|
|
|
+ 'customer_no' => $v['customer_no'],
|
|
|
|
+ 'customer_name' => $v['customer_name'],
|
|
|
|
+ 'product_no' => $v['production_no'],
|
|
|
|
+ 'product_title' => $v['product_title'],
|
|
|
|
+ 'product_size' => $v['product_size'],
|
|
|
|
+ 'type' => '1',
|
|
|
|
+ 'is_box_num' => $v['box_num'],
|
|
|
|
+ 'un_box_num' => $v['dispatch_complete_quantity'] - $v['box_num'],
|
|
|
|
+ 'sale_num' => $sale_key_list[$v['sale_orders_product_id']]['order_quantity'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ foreach ($product_key_list as $v){
|
|
|
|
+ $return[] = $v;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// $data = [
|
|
|
|
+// [
|
|
|
|
+// 'id' => 1,
|
|
|
|
+// 'out_order_no' => '销售订单号',
|
|
|
|
+// 'production_time' => '下生产时间',
|
|
|
|
+// 'customer_no' => '客户编码',
|
|
|
|
+// 'customer_name' => '客户名称',
|
|
|
|
+// 'product_no' => '产品编码',
|
|
|
|
+// 'product_title' => '产品名称',
|
|
|
|
+// 'product_size' => '产品规格',
|
|
|
|
+// 'type' => '1生产包装2备用包装',
|
|
|
|
+// 'is_box_num' => '已包装数量',
|
|
|
|
+// 'un_box_num' => '未包装',
|
|
|
|
+// 'sale_num' => '销售数量',
|
|
|
|
+// ]
|
|
|
|
+// ];
|
|
|
|
|
|
- $data = [
|
|
|
|
- [
|
|
|
|
- 'id' => 1,
|
|
|
|
- 'out_order_no' => '销售订单号',
|
|
|
|
- 'production_time' => '下生产时间时间戳',
|
|
|
|
- 'customer_no' => '客户编码',
|
|
|
|
- 'customer_name' => '客户名称',
|
|
|
|
- 'product_no' => '产品编码',
|
|
|
|
- 'product_title' => '产品名称',
|
|
|
|
- 'product_size' => '产品规格',
|
|
|
|
- 'type' => '1生产包装2备用包装',
|
|
|
|
- 'is_box_num' => '已包装数量',
|
|
|
|
- 'un_box_num' => '未包装',
|
|
|
|
- 'sale_num' => '销售数量',
|
|
|
|
- ]
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- return [true,$data];
|
|
|
|
|
|
+ return [true,$return];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|