|
@@ -91,6 +91,8 @@ class BoxService extends Service
|
|
|
$ext_3 = $v['technology_name'];//工艺名称 改为颜色
|
|
|
$ext_4 = $v['wood_name'];//木皮 废弃
|
|
|
$ext_5 = $v['process_mark'];//工艺备注 废弃
|
|
|
+ $ext_8 = $v['product_title'];//产品名称
|
|
|
+
|
|
|
$out_order_no = $insert['out_order_no'] = $v['out_order_no'];
|
|
|
$top_id = $v['sale_orders_product_id'];
|
|
|
foreach ($detail as $vv){
|
|
@@ -103,6 +105,7 @@ class BoxService extends Service
|
|
|
'ext_3' => $ext_3,//颜色
|
|
|
'ext_4' => $ext_4,
|
|
|
'ext_5' => $ext_5,
|
|
|
+ 'ext_8' => $ext_8,//产品名称
|
|
|
'num' => $vv,
|
|
|
'price' => $v['price'],
|
|
|
'box_type' => 1,
|
|
@@ -139,6 +142,7 @@ class BoxService extends Service
|
|
|
$ext_3 = $v['technology_name'];//工艺名称 改为颜色
|
|
|
$ext_4 = $v['wood_name'];//木皮 废弃
|
|
|
$ext_5 = $v['process_mark'];//工艺备注 废弃
|
|
|
+ $ext_8 = $v['product_title'];//产品名称
|
|
|
$out_order_no = $insert['out_order_no'] = $v['out_order_no'];
|
|
|
$top_id = $v['id'];
|
|
|
foreach ($detail as $vv){
|
|
@@ -151,6 +155,7 @@ class BoxService extends Service
|
|
|
'ext_3' => $ext_3,
|
|
|
'ext_4' => $ext_4,
|
|
|
'ext_5' => $ext_5,
|
|
|
+ 'ext_8' => $ext_8,
|
|
|
'num' => $vv,
|
|
|
'price' => $v['price'],
|
|
|
'box_type' => $box_type,
|
|
@@ -200,6 +205,10 @@ class BoxService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function saveOutOrder($data,$user){
|
|
|
+ //todo
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据发货单包装(恒诚塑业不需要)
|
|
|
* @param $data
|
|
@@ -292,12 +301,12 @@ class BoxService extends Service
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
protected function getKey($data){
|
|
|
|
|
|
return $data['product_no'].'_'.$data['technology_material'].'_'.$data['technology_name'].'_'.$data['wood_name'].'_'.$data['process_mark'];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 包装详情1用于包装前
|
|
|
* @param $data
|
|
@@ -326,32 +335,49 @@ class BoxService extends Service
|
|
|
}
|
|
|
|
|
|
public function boxProductList($data){
|
|
|
- if(empty($data['id'])) return [false,'请选择数据!'];
|
|
|
- $sale_order_ids = $data['id'];
|
|
|
- $model = SaleOrdersProduct::where('del_time',0)->wherein('id',$sale_order_ids)
|
|
|
+ if(empty($data['id']) && empty($data['out_order_no'])) return [false,'请选择数据!'];
|
|
|
+ if(! empty($data['id'])){
|
|
|
+ $sale_order_ids = $data['id'];
|
|
|
+ }else{
|
|
|
+ $ids = SaleOrdersProduct::where('del_time',0)
|
|
|
+ ->where('out_order_no','Like','%'. $data['out_order_no'] . '%')
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $sale_order_ids = array_column($ids,'id');
|
|
|
+ if(empty($sale_order_ids)) return [false, '暂无数据!'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $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')
|
|
|
- ->orderBy('id','desc')->get()->toArray();
|
|
|
- $product_list = ordersProduct::where('del_time',0)->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',DB::raw('(production_quantity - scrapp_num) as production_quantity'),DB::raw('finished_num as dispatch_complete_quantity'),'technology_material','technology_name','wood_name','process_mark')->get()->toArray();
|
|
|
+ ->orderBy('id','desc')
|
|
|
+ ->get()->toArray();
|
|
|
+ $product_list = ordersProduct::where('del_time',0)
|
|
|
+ ->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','box_num','technology_name','wood_name','crt_time',DB::raw('(production_quantity - scrapp_num) as production_quantity'),DB::raw('finished_num as dispatch_complete_quantity'),'technology_material','technology_name','wood_name','process_mark',"production_no")->get()->toArray();
|
|
|
$model_key_list = [];
|
|
|
foreach ($model as $v){
|
|
|
$model_key_list[$v['id']] = $v;
|
|
|
}
|
|
|
|
|
|
- $product_key_num_list = [];
|
|
|
- foreach ($product_list as $v){
|
|
|
- if(!isset($product_key_num_list[$v['sale_orders_product_id']][$v['id']]))$product_key_num_list[$v['sale_orders_product_id']][$v['id']] = [
|
|
|
- 'product_num' => 0 ,
|
|
|
- 'box_num' => 0 ,
|
|
|
- ];
|
|
|
- $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['product_num'] += $v['production_quantity'];
|
|
|
- $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['box_num'] += $v['box_num'];
|
|
|
- $detail = $model_key_list[$v['sale_orders_product_id']];
|
|
|
- $detail['box_type'] = 1;
|
|
|
- $detail['id'] = $v['id'];
|
|
|
- $detail['box_num'] = $v['box_num'];
|
|
|
- $detail['un_box_num'] = $v['dispatch_complete_quantity'] - $v['box_num'];
|
|
|
- $detail['type'] = 1;
|
|
|
- $model[] = $detail;
|
|
|
+ //存在生产订单,组织数据
|
|
|
+ if(! empty($product_list)){
|
|
|
+ $product_key_num_list = [];
|
|
|
+ foreach ($product_list as $v){
|
|
|
+ if(!isset($product_key_num_list[$v['sale_orders_product_id']][$v['id']]))$product_key_num_list[$v['sale_orders_product_id']][$v['id']] = [
|
|
|
+ 'product_num' => 0 ,
|
|
|
+ 'box_num' => 0 ,
|
|
|
+ ];
|
|
|
+ $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['product_num'] += $v['production_quantity'];
|
|
|
+ $product_key_num_list[$v['sale_orders_product_id']][$v['id']]['box_num'] += $v['box_num'];
|
|
|
+ $detail = $model_key_list[$v['sale_orders_product_id']];
|
|
|
+ $detail['box_type'] = 1;
|
|
|
+ $detail['id'] = $v['id'];
|
|
|
+ $detail['box_num'] = $v['box_num'];
|
|
|
+ $detail['un_box_num'] = $v['dispatch_complete_quantity'] - $v['box_num'];
|
|
|
+ $detail['type'] = 1;
|
|
|
+ $detail['production_no'] = $v['production_no'];
|
|
|
+ $model[] = $detail;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$return = [];
|
|
@@ -370,6 +396,7 @@ class BoxService extends Service
|
|
|
$product_key_list[$v['sale_orders_product_id']] = [
|
|
|
'out_order_no' => $v['out_order_no'],
|
|
|
'order_no' => $v['order_no'],
|
|
|
+ 'production_no' => "",
|
|
|
'production_time' => '未下生产',
|
|
|
'customer_no' => $v['customer_no'],
|
|
|
'customer_name' => $v['customer_name'],
|
|
@@ -393,6 +420,7 @@ class BoxService extends Service
|
|
|
'technology_name' => $v['technology_name'],
|
|
|
'wood_name' => $v['wood_name'],
|
|
|
'order_no' => $v['order_no'],
|
|
|
+ 'production_no' => $v['production_no'],
|
|
|
'process_mark' => $v['process_mark'],
|
|
|
'out_order_no' => $v['out_order_no'],
|
|
|
'production_time' => date('Y-m-d',$v['crt_time']),
|
|
@@ -510,21 +538,81 @@ class BoxService extends Service
|
|
|
|
|
|
public function boxOrderGroup($data){
|
|
|
$list = new Box();
|
|
|
- if(empty($data['top_order_no'])&&empty($data['transport_no'])) return [false,'销售单或发货单必选一个'];
|
|
|
- if(isset($data['top_order_no'])&&!empty($data['top_order_no'])) $list = $list->wherein('top_order_no',$data['top_order_no']);
|
|
|
- if(!empty($data['transport_no'])) {
|
|
|
+ if(empty($data['top_order_no']) && empty($data['transport_no'])) return [false,'请输入单号!'];
|
|
|
+
|
|
|
+ if(! empty($data['top_order_no'])) $list = $list->whereIn('top_order_no',$data['top_order_no']);
|
|
|
+ if(! empty($data['transport_no'])) {
|
|
|
if(is_array($data['transport_no'])){
|
|
|
- $list = $list->wherein('shipment_order_no',$data['transport_no']);
|
|
|
+ $list = $list->whereIn('shipment_order_no',$data['transport_no']);
|
|
|
}else{
|
|
|
$list = $list->where('shipment_order_no','Like','%'. $data['transport_no'] . '%');
|
|
|
}
|
|
|
}
|
|
|
- $list = $list->select('top_order_no','order_no','crt_time','shipment_order_no')->where('del_time',0)->get()->toArray();
|
|
|
|
|
|
+ $list = $list->select('top_order_no','order_no','crt_time','shipment_order_no')->where('del_time',0)
|
|
|
+ ->get()->toArray();
|
|
|
|
|
|
return [true,$list];
|
|
|
}
|
|
|
|
|
|
+ public function boxOrderGroupGwp($data){
|
|
|
+ $out_order_no = $data['out_order_no'] ?? "";
|
|
|
+ $model = Box::where('del_time',0)
|
|
|
+ ->when(! empty($out_order_no), function ($query) use ($out_order_no) {
|
|
|
+ return $query->where('out_order_no','Like','%'. $out_order_no . '%');
|
|
|
+ })
|
|
|
+ ->select('out_order_no','ext_1','top_order_no','order_no','crt_time','shipment_order_no',DB::raw("count(id) as package_num"))
|
|
|
+ ->groupBy('out_order_no');
|
|
|
+
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillData($list);
|
|
|
+
|
|
|
+ return [true, $list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fillData($data){
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
+
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
+ $model = new BoxDetail(['channel'=> $value['top_order_no']]);
|
|
|
+ $tmp = $model->where('del_time',0)
|
|
|
+ ->where('out_order_no',$value['out_order_no'])
|
|
|
+ ->select('num')
|
|
|
+ ->get()->toArray();
|
|
|
+ $data['data'][$key]['num'] = array_sum(array_column($tmp,'num'));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function boxOrderGroupGwpDetail($data){
|
|
|
+ if(empty($data['top_order_no']) || empty($data['out_order_no'])) return [false, '请选择数据!'];
|
|
|
+ $top_order_no = $data['top_order_no'];
|
|
|
+ $model = new BoxDetail(['channel'=> $top_order_no]);
|
|
|
+ $detail_list = $model->where('del_time',0)
|
|
|
+ ->where('out_order_no',$data['out_order_no'])
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ $return = [];
|
|
|
+ foreach ($detail_list as $value){
|
|
|
+ //销售订单号 包装单号 产品编码 颜色
|
|
|
+ $key = $value['out_order_no'] . $value['order_no'] . $value['ext_1'] . $value['ext_3'];
|
|
|
+ if(isset($return[$key])){
|
|
|
+ $return[$key]['num'] += $value['num'];
|
|
|
+ }else{
|
|
|
+ $return[$key] = [
|
|
|
+ 'out_order_no' => $value['out_order_no'],
|
|
|
+ 'ext_8' => $value['ext_8'],
|
|
|
+ 'ext_3' => $value['ext_3'],
|
|
|
+ 'num' => $value['num'],
|
|
|
+ 'crt_time' => date("Y-m-d",$value['crt_time']),
|
|
|
+ 'top_order_no' => $value['top_order_no'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, array_values($return)];
|
|
|
+ }
|
|
|
|
|
|
public function transportNo(){
|
|
|
$list = Box::where('del_time',0)->where('shipment_order_no','<>','')->groupBy('shipment_order_no')->pluck('shipment_order_no')->toArray();
|