|
@@ -47,6 +47,7 @@ class BoxService extends Service
|
|
|
// $param = [
|
|
|
// [
|
|
|
// 'id' => 716,
|
|
|
+// 'order_no' => 716,
|
|
|
// 'param' => [
|
|
|
// '1',
|
|
|
// '1'
|
|
@@ -62,6 +63,7 @@ class BoxService extends Service
|
|
|
|
|
|
$ids = [];
|
|
|
$key_list = [];
|
|
|
+ $top_order_no = $data['order_no'];
|
|
|
foreach ($data as $v) {
|
|
|
$ids[] = $v['id'];
|
|
|
$total = 0;
|
|
@@ -121,6 +123,7 @@ class BoxService extends Service
|
|
|
|
|
|
}
|
|
|
$insert['detail'] = $box_insert;
|
|
|
+ $insert['top_order_no'] = $top_order_no;
|
|
|
list($status,$msg) = self::$box_hook->boxInsert($insert);
|
|
|
|
|
|
if(!$status) {
|
|
@@ -141,7 +144,7 @@ class BoxService extends Service
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 包装详情1
|
|
|
+ * 包装详情1用于包装前
|
|
|
* @param $data
|
|
|
* @return array
|
|
|
*/
|
|
@@ -155,51 +158,69 @@ class BoxService extends Service
|
|
|
public function boxProductList($data){
|
|
|
if(!isset($data['id'])) return [false,'id not found'];
|
|
|
$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')
|
|
|
+ $model = SaleOrdersProduct::where('del_time',0)->wherein('id',$sale_order_ids)
|
|
|
+ ->select('id','out_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')
|
|
|
->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'],
|
|
|
+ $product_list = ordersProduct::wherein('sale_orders_product_id',$sale_order_ids)->select('id','out_order_no','customer_no','customer_name','product_no','sale_orders_product_id','product_title','product_size','dispatch_complete_quantity','box_num','technology_name','wood_name','crt_time','production_quantity')->get()->toArray();
|
|
|
+
|
|
|
+ $model_key_list = [];
|
|
|
+ foreach ($model as $v){
|
|
|
+ $model_key_list[$v['id']] = $v;
|
|
|
+ }
|
|
|
+
|
|
|
+ $product_key_list = [];
|
|
|
+ $product_key_num_list = [];
|
|
|
+ foreach ($product_list as $v){
|
|
|
+ if(!isset($product_key_num_list[$v['sale_orders_product_id']]))$product_key_num_list[$v['sale_orders_product_id']] = [
|
|
|
+ 'product_num' => 0 ,
|
|
|
+ 'box_num' => 0 ,
|
|
|
];
|
|
|
+ $product_key_num_list[$v['sale_orders_product_id']]['product_num'] += $v['production_quantity'];
|
|
|
+ $product_key_num_list[$v['sale_orders_product_id']]['box_num'] += $v['box_num'];
|
|
|
+ $detail = $model_key_list[$v['sale_orders_product_id']];
|
|
|
+ $detail['box_type'] = 1;
|
|
|
+ $detail['is_box_num'] = $v['box_num'];
|
|
|
+ $detail['un_box_num'] = $v['production_quantity'] - $v['box_num'];
|
|
|
+ $detail['type'] = 1;
|
|
|
+ $model[] = $detail;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
$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']];
|
|
|
+ if(!isset($v['box_type'])) {
|
|
|
+ $product_num = isset($product_key_num_list[$v['id']]) ? $product_key_num_list[$v['id']]['product_num'] : 0;
|
|
|
+ $box_num = isset($product_key_num_list[$v['id']]) ? $product_key_num_list[$v['id']]['box_num'] : 0;
|
|
|
$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_no' => $v['product_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'],
|
|
|
+ 'is_box_num' => $v['box_num'] - $box_num,
|
|
|
+ 'un_box_num' => $v['order_quantity'] - $v['box_num'] - $product_num,
|
|
|
+ 'sale_num' => $v['order_quantity'],
|
|
|
];
|
|
|
}
|
|
|
+ if($v['box_num'] === 0 && ($v['dispatch_complete_quantity'] - $v['box_num']) === 0) continue;
|
|
|
$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_no' => $v['product_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'],
|
|
|
+ 'sale_num' => $v['order_quantity'],
|
|
|
];
|
|
|
}
|
|
|
foreach ($product_key_list as $v){
|
|
@@ -226,5 +247,33 @@ class BoxService extends Service
|
|
|
return [true,$return];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 包装详情2用于包装后
|
|
|
+ * @param $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function boxOrderDetail($data)
|
|
|
+ {
|
|
|
+ list($status, $data) = self::$box_hook->boxDetail($data);
|
|
|
+// var_dump($data);die;
|
|
|
+ $sale_orders_product_ids = [];
|
|
|
+ foreach ($data as $v){
|
|
|
+ $sale_orders_product_ids[] = $v['top_id'];
|
|
|
+ }
|
|
|
+ $list = SaleOrdersProduct::wherein('id',$sale_orders_product_ids)->get()->toArray();
|
|
|
+ $key_list = [];
|
|
|
+ foreach ($list as $v){
|
|
|
+ $key_list[$v['id']] = $v;
|
|
|
+ }
|
|
|
+ foreach ($data as &$v){
|
|
|
+ $v['wood_name'] = $key_list[$v['top_id']]['wood_name'];
|
|
|
+ $v['process_remark'] = $key_list[$v['top_id']]['process_mark'];
|
|
|
+ }
|
|
|
+ if (!$status) return [false, $data];
|
|
|
+ return [true, $data];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|