|
@@ -6,6 +6,7 @@ use App\Model\ApplyOrder;
|
|
use App\Model\ApplyOrderDetail;
|
|
use App\Model\ApplyOrderDetail;
|
|
use App\Model\Box;
|
|
use App\Model\Box;
|
|
use App\Model\BoxDetail;
|
|
use App\Model\BoxDetail;
|
|
|
|
+use App\Model\BoxWithDispatch;
|
|
use App\Model\Dispatch;
|
|
use App\Model\Dispatch;
|
|
use App\Model\DispatchSub;
|
|
use App\Model\DispatchSub;
|
|
use App\Model\Employee;
|
|
use App\Model\Employee;
|
|
@@ -1960,10 +1961,11 @@ class ApplyOrderService extends Service
|
|
if(empty($data['type'])) return [false, '单据联查类型不能为空'];
|
|
if(empty($data['type'])) return [false, '单据联查类型不能为空'];
|
|
if(empty($data['data_id'])) return [false, '依据单据ID不能为空'];
|
|
if(empty($data['data_id'])) return [false, '依据单据ID不能为空'];
|
|
//不管进来的是什么单据id 转换为销售订单
|
|
//不管进来的是什么单据id 转换为销售订单
|
|
- $sales_id = $this->changeIdToOrder($data);
|
|
|
|
- list($status, $msg) = $this->forSearch($data, $sales_id);
|
|
|
|
|
|
+ $result = $this->changeIdToOrderNew($data);
|
|
|
|
+// $sales_id = $this->changeIdToOrder($data);
|
|
|
|
+// list($status, $msg) = $this->forSearch($data, $sales_id);
|
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
|
+ return [true, $result];
|
|
}
|
|
}
|
|
|
|
|
|
private function changeIdToOrder($data)
|
|
private function changeIdToOrder($data)
|
|
@@ -2247,63 +2249,1632 @@ class ApplyOrderService extends Service
|
|
return [true, $result];
|
|
return [true, $result];
|
|
}
|
|
}
|
|
|
|
|
|
- public function reportList($data){
|
|
|
|
- $model = ReportMessage::where('del_time',0)
|
|
|
|
- ->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use')
|
|
|
|
- ->orderBy('id','desc');
|
|
|
|
|
|
+ private function changeIdToOrderNew1($data)
|
|
|
|
+ {
|
|
|
|
+ $id = $data['data_id'];
|
|
|
|
+ $search_id = $result = [];
|
|
|
|
+ if ($data['type'] == 1) {
|
|
|
|
|
|
- $list = $this->limit($model,'',$data);
|
|
|
|
- $list = $this->fillRData($list);
|
|
|
|
|
|
+ } elseif ($data['type'] == 2) {
|
|
|
|
+ $result[1] = OrdersProduct::where('del_time', 0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ } elseif ($data['type'] == 3) {
|
|
|
|
+ $array = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->where('id', $data['data_id'])
|
|
|
|
+ ->select('sale_orders_product_id', 'order_product_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($array as $value){
|
|
|
|
+ $result[1][] = $value['sale_orders_product_id'];
|
|
|
|
+ $result[2][] = $value['order_product_id'];
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 4) {
|
|
|
|
+ $detail = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time', 0)
|
|
|
|
+ ->select('data_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $array = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail, 'data_id')))
|
|
|
|
+ ->select('sale_orders_product_id', 'order_product_id','id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($array as $value){
|
|
|
|
+ $result[1][] = $value['sale_orders_product_id'];
|
|
|
|
+ $result[2][] = $value['order_product_id'];
|
|
|
|
+ $result[3][] = $value['id'];
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 5) {
|
|
|
|
+ $array = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->where('finished_num', '>', 0)
|
|
|
|
+ ->select('sale_orders_product_id', 'order_product_id','id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($array as $value){
|
|
|
|
+ $result[1][] = $value['sale_orders_product_id'];
|
|
|
|
+ $result[2][] = $value['order_product_id'];
|
|
|
|
+ $result[3][] = $value['id'];
|
|
|
|
+ }
|
|
|
|
+ $detail = ReportWorkingDetail::where('data_id', $id)
|
|
|
|
+ ->where('del_time', 0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($detail as $value){
|
|
|
|
+ $result[4][] = $value['report_working_id'];
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 6) {
|
|
|
|
+ $first = Box::where('del_time', 0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select("top_order_no", 'order_no','id')
|
|
|
|
+ ->first();
|
|
|
|
+ if (! empty($first)) {
|
|
|
|
+ $first = $first->toArray();
|
|
|
|
+ $boxArray = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id',$first['id'])
|
|
|
|
+ ->select('dispatch_id','num')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ if(! empty($boxArray)){
|
|
|
|
+ $dispatch_id = array_column($boxArray,'dispatch_id');
|
|
|
|
+ $array = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->whereIn('id',$dispatch_id)
|
|
|
|
+ ->select('sale_orders_product_id', 'order_product_id','id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($array as $value){
|
|
|
|
+ $result[1][] = $value['sale_orders_product_id'];
|
|
|
|
+ $result[2][] = $value['order_product_id'];
|
|
|
|
+ $result[3][] = $value['id'];
|
|
|
|
+ }
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time', 0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ foreach ($detail as $value){
|
|
|
|
+ $result[4][] = $value['report_working_id'];
|
|
|
|
+ }
|
|
|
|
+ $result[5] = $dispatch_id;
|
|
|
|
+ }else{
|
|
|
|
+ $array = [];
|
|
|
|
+ $box_detail = new BoxDetail(['channel' => $first['top_order_no']]);
|
|
|
|
+ $detail = $box_detail->where('order_no', $first['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
|
+ foreach ($detail as $value){
|
|
|
|
+ if(! in_array($value['id'], $array)) $array[] = $value['id'];
|
|
|
|
+ }
|
|
|
|
+ $result[1] = $array;
|
|
|
|
+ $result[2] = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('sale_orders_product_id',$array)
|
|
|
|
+ ->pluck('id')->toArray();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 7) {
|
|
|
|
+ $result = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select('sale_orders_product_id as id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ } elseif ($data['type'] == 8) {
|
|
|
|
+ $result = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->where('scrapp_num', '>', 0)
|
|
|
|
+ ->select('sale_orders_product_id as id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ } elseif ($data['type'] == 9) {
|
|
|
|
+ $detail = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('apply_order_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->select('data_id as dispatch_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->where('id', array_unique(array_column($detail, 'dispatch_id')))
|
|
|
|
+ ->select('sale_orders_product_id as id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ } elseif ($data['type'] == 10) {
|
|
|
|
+ $detail = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('apply_order_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->select('data_id as dispatch_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time', 0)
|
|
|
|
+ ->where('id', array_unique(array_column($detail, 'dispatch_id')))
|
|
|
|
+ ->select('sale_orders_product_id as id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ } elseif ($data['type'] == 11) {
|
|
|
|
+ $detail = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('apply_order_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->select('data_id as box_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $first = Box::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail, 'box_id')))
|
|
|
|
+ ->select("top_order_no", 'order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ if (!empty($first)) {
|
|
|
|
+ foreach ($first as $value) {
|
|
|
|
+ $box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
|
|
|
|
+ $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $t);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 12) {
|
|
|
|
+ $detail = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('apply_order_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->select('data_id as box_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $first = Box::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail, 'box_id')))
|
|
|
|
+ ->select("top_order_no", 'order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ if (!empty($first)) {
|
|
|
|
+ foreach ($first as $value) {
|
|
|
|
+ $box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
|
|
|
|
+ $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $t);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } elseif ($data['type'] == 13) {
|
|
|
|
+ $detail = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('apply_order_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->select('data_id as zj_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail, 'zj_id')))
|
|
|
|
+ ->select('sale_orders_product_id as id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+ foreach ($result as $value) {
|
|
|
|
+ if (!in_array($value['id'], $search_id)) {
|
|
|
|
+ $search_id[] = $value['id'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- $count = ReportMessage::where('del_time',0)
|
|
|
|
- ->where('is_use',0)
|
|
|
|
- ->count();
|
|
|
|
|
|
+ return $search_id;
|
|
|
|
|
|
- return [true, ['list'=> $list, 'count' => $count]];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public function fillRData($data){
|
|
|
|
- if(empty($data['data'])) return $data;
|
|
|
|
|
|
+ private function changeIdToOrderNew($data)
|
|
|
|
+ {
|
|
|
|
+ $id = $data['data_id'];
|
|
|
|
+ $result = [];
|
|
|
|
+ $type = $data['type'];
|
|
|
|
+ $for_type = $data['for_type'];
|
|
|
|
+ if ($data['type'] == 1) {
|
|
|
|
+ $result = $this->typeOne($for_type, $id);
|
|
|
|
+ } elseif ($type == 2) {
|
|
|
|
+ $result = $this->typeTwo($for_type, $id);
|
|
|
|
+ } elseif ($type == 3) {
|
|
|
|
+ $result = $this->typeThree($for_type, $id);
|
|
|
|
+ } elseif ($type == 4) {
|
|
|
|
+ $result = $this->typeFour($for_type, $id);
|
|
|
|
+ } elseif ($type == 5) {
|
|
|
|
+ $result = $this->typeFive($for_type, $id);
|
|
|
|
+ } elseif ($type == 6) {
|
|
|
|
+ $result = $this->typeSix($for_type, $id);
|
|
|
|
+ } elseif ($type == 7) {
|
|
|
|
+ $result = $this->typeSeven($for_type, $id);
|
|
|
|
+ } elseif ($type == 8) {
|
|
|
|
+ $result = $this->typeEight($for_type, $id);
|
|
|
|
+ } elseif ($type == 9) {
|
|
|
|
+
|
|
|
|
+ } elseif ($type == 10) {
|
|
|
|
+
|
|
|
|
+ } elseif ($type == 11) {
|
|
|
|
+
|
|
|
|
+ } elseif ($type == 12) {
|
|
|
|
+
|
|
|
|
+ } elseif ($type == 13) {
|
|
|
|
|
|
- $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
|
|
|
|
- ->select('id','dispatch_no','process_id')
|
|
|
|
- ->get()->toArray();
|
|
|
|
- $process = Process::where('del_time',0)
|
|
|
|
- ->whereIn('id',array_unique(array_column($dispatch,'process_id')))
|
|
|
|
- ->pluck('title','id')
|
|
|
|
- ->toArray();
|
|
|
|
- $map = [];
|
|
|
|
- foreach ($dispatch as $value){
|
|
|
|
- $map[$value['id']] = $value;
|
|
|
|
- }
|
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
|
|
|
|
- ->pluck("emp_name",'id')
|
|
|
|
- ->toArray();
|
|
|
|
- foreach ($data['data'] as $key => $value){
|
|
|
|
- $time = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
|
- $data['data'][$key]['crt_time'] = $time;
|
|
|
|
- $t = $map[$value['order_id']] ?? [];
|
|
|
|
- $e = $emp_map[$value['user_id']] ?? "";
|
|
|
|
- $p = $process[$t['process_id']] ?? "";
|
|
|
|
- $data['data'][$key]['message'] = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p)报工,请及时处理";
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return $data;
|
|
|
|
|
|
+ return $result;
|
|
}
|
|
}
|
|
|
|
|
|
- public function reportRemainUpdate($data){
|
|
|
|
- if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
- if(empty($data['type'])) return [false, 'type不能为空'];
|
|
|
|
- $type = $data['type'];
|
|
|
|
|
|
+ private function typeOne($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 2){
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->select('id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', array_column($dispatch,'id'))
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale = SaleOrdersProduct::where('id', $id)->select('order_no')->get()->toArray();
|
|
|
|
|
|
- if($type == 1){
|
|
|
|
- ReportMessage::where('id', $data['id'])
|
|
|
|
- ->update(['is_use' => 1]);
|
|
|
|
- }else{
|
|
|
|
- ReportMessage::where('id', $data['id'])
|
|
|
|
- ->update(['del_time' => time()]);
|
|
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $sale = SaleOrdersProduct::where('id', $id)->select('order_no','id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $sale = SaleOrdersProduct::where('id', $id)->select('order_no','id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('sale_orders_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
}
|
|
}
|
|
|
|
|
|
- return [true, ''];
|
|
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeTwo($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $sale_orders_product_id = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->select('id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', array_column($dispatch,'id'))
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale_orders_product_id = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $sale = OrdersProduct::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $sale = OrdersProduct::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('order_product_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeThree($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $order_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('order_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $order_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select('id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', array_column($dispatch,'id'))
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $sale = DispatchSub::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $sale = DispatchSub::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeFour($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $order_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->pluck('order_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $order_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->select('id','dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->whereIn('dispatch_sub_id', $dispatch_id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->whereIn('dispatch_sub_id', $dispatch_id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $dispatch_id = ReportWorkingDetail::where('report_working_id', $id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('data_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no', 'sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('report_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeFive($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $order_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('order_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $order_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select('id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', array_column($dispatch,'id'))
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale_orders_product_id = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $sale = DispatchSub::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $sale = DispatchSub::where('id', $id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->where('dispatch_sub_id', $id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeSix($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ $box = Box::where('id', $id)->select('top_order_no')->first();
|
|
|
|
+ if(empty($box)) return $result;
|
|
|
|
+ $top_order_no = $box->top_order_no;
|
|
|
|
+ $order_no = $box->order_no;
|
|
|
|
+
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $top_order_no]);
|
|
|
|
+ $sale_orders_product_id = $box_detail->where('del_time',0)
|
|
|
|
+ ->where('order_no',$order_no)
|
|
|
|
+ ->pluck('top_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $top_order_no]);
|
|
|
|
+ $sale_orders_product_id = $box_detail->where('del_time',0)
|
|
|
|
+ ->where('order_no',$order_no)
|
|
|
|
+ ->pluck('top_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('sale_orders_product_id', $sale_orders_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $dispatch_id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $report_working_id = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('report_working_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->whereIn('report_id', $report_working_id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $report_working_id = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->pluck('report_working_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->whereIn('report_id', $report_working_id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::where('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $dispatch_id = BoxWithDispatch::where('del_time',0)
|
|
|
|
+ ->where('box_id', $id)
|
|
|
|
+ ->pluck('dispatch_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $s_id = ScrappCount::where('del_time', 0)
|
|
|
|
+ ->whereIn('dispatch_sub_id', $dispatch_id)
|
|
|
|
+ ->pluck('id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $s_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeSeven($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $sale_orders_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $order_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('order_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $order_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $dispatch_id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $dispatch_id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale_orders_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 8){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->where('scrapp_num','>', 0)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function typeEight($for_type, $id){
|
|
|
|
+ $result = [];
|
|
|
|
+ if($for_type == 1){
|
|
|
|
+ $sale_orders_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('id','out_order_no as order')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 2){
|
|
|
|
+ $order_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('order_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = OrdersProduct::where('del_time',0)
|
|
|
|
+ ->whereIn('id', $order_product_id)
|
|
|
|
+ ->select('id', 'production_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 3){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $dispatch_id)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 4){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $detail = ReportWorkingDetail::whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
+ ->select('report_working_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = ReportWorking::where('del_time',0)
|
|
|
|
+ ->whereIn('id', array_unique(array_column($detail,'report_working_id')))
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 5){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->where('id', $dispatch_id)
|
|
|
|
+ ->where('finished_num','>',0)
|
|
|
|
+ ->select('id', 'dispatch_no as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 6){
|
|
|
|
+ $sale_orders_product_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('sale_orders_product_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = SaleOrdersProduct::whereIn('id', $sale_orders_product_id)->select('order_no')->get()->toArray();
|
|
|
|
+
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$id)->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->select("id","order_no")
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $result = array_merge($result, $tmp);
|
|
|
|
+ }
|
|
|
|
+ }elseif ($for_type == 7){
|
|
|
|
+ $result = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->select('id', 'order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 9){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_one)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 10){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $dispatch_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_two)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 11){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_four)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 12){
|
|
|
|
+ $dispatch_id = ScrappCount::where('del_time',0)
|
|
|
|
+ ->where('id', $id)
|
|
|
|
+ ->pluck('dispatch_sub_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $sale = DispatchSub::whereIn('id', $dispatch_id)->select('order_no','sale_orders_product_id as id')->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($sale as $value){
|
|
|
|
+ $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$value['id'])->select('order_no')->get()->toArray();
|
|
|
|
+ $tmp = Box::where('del_time',0)
|
|
|
|
+ ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
|
+ ->pluck("id")
|
|
|
|
+ ->toArray();
|
|
|
|
+ $box_id = array_merge($box_id, $tmp);
|
|
|
|
+ }
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->whereIn('data_id', $box_id)
|
|
|
|
+ ->where('type', ApplyOrder::type_three)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }elseif ($for_type == 13){
|
|
|
|
+ $apply_order_id = ApplyOrderDetail::where('del_time', 0)
|
|
|
|
+ ->where('data_id', $id)
|
|
|
|
+ ->where('type', ApplyOrder::type_five)
|
|
|
|
+ ->pluck('apply_order_id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $result = ApplyOrder::where('del_time', 0)
|
|
|
|
+ ->whereIn('id', $apply_order_id)
|
|
|
|
+ ->select('id','order_number as order_no')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function reportList($data){
|
|
|
|
+ $model = ReportMessage::where('del_time',0)
|
|
|
|
+ ->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use')
|
|
|
|
+ ->orderBy('id','desc');
|
|
|
|
+
|
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
|
+ $list = $this->fillRData($list);
|
|
|
|
+
|
|
|
|
+ $count = ReportMessage::where('del_time',0)
|
|
|
|
+ ->where('is_use',0)
|
|
|
|
+ ->count();
|
|
|
|
+
|
|
|
|
+ return [true, ['list'=> $list, 'count' => $count]];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function fillRData($data){
|
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
|
+
|
|
|
|
+ $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
|
|
|
|
+ ->select('id','dispatch_no','process_id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $process = Process::where('del_time',0)
|
|
|
|
+ ->whereIn('id',array_unique(array_column($dispatch,'process_id')))
|
|
|
|
+ ->pluck('title','id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ $map = [];
|
|
|
|
+ foreach ($dispatch as $value){
|
|
|
|
+ $map[$value['id']] = $value;
|
|
|
|
+ }
|
|
|
|
+ $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
|
|
|
|
+ ->pluck("emp_name",'id')
|
|
|
|
+ ->toArray();
|
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
|
+ $time = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
|
+ $data['data'][$key]['crt_time'] = $time;
|
|
|
|
+ $t = $map[$value['order_id']] ?? [];
|
|
|
|
+ $e = $emp_map[$value['user_id']] ?? "";
|
|
|
|
+ $p = $process[$t['process_id']] ?? "";
|
|
|
|
+ $data['data'][$key]['message'] = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p)报工,请及时处理";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function reportRemainUpdate($data){
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
+ if(empty($data['type'])) return [false, 'type不能为空'];
|
|
|
|
+ $type = $data['type'];
|
|
|
|
+
|
|
|
|
+ if($type == 1){
|
|
|
|
+ ReportMessage::where('id', $data['id'])
|
|
|
|
+ ->update(['is_use' => 1]);
|
|
|
|
+ }else{
|
|
|
|
+ ReportMessage::where('id', $data['id'])
|
|
|
|
+ ->update(['del_time' => time()]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return [true, ''];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function filldatas(){
|
|
|
|
+ $box = Box::where('del_time',0)
|
|
|
|
+ ->where('crt_time','>=',1750727777)
|
|
|
|
+ ->select("top_order_no", 'order_no','id')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $box_id = [];
|
|
|
|
+ foreach ($box as $value) {
|
|
|
|
+ $box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
|
|
|
|
+ $t = $box_detail->where('order_no', $value['order_no'])->where('del_time',0)->select('top_id as id')->first()->toArray();
|
|
|
|
+ $box_id[$value['id']] = $t['id'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $result = DispatchSub::where('del_time',0)
|
|
|
|
+ ->whereIn('sale_orders_product_id', array_values($box_id))
|
|
|
|
+ ->where('process_id',14)
|
|
|
|
+ ->where('finished_num', '>', '0.000')
|
|
|
|
+ ->select('id','dispatch_quantity','finished_num','order_product_id','sale_orders_product_id','technology_name')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $map = [];
|
|
|
|
+ $return = [];
|
|
|
|
+ foreach ($result as $key => $value){
|
|
|
|
+ if($value['finished_num'] < 1){
|
|
|
|
+ $new_key = $value['order_product_id'] . $value['sale_orders_product_id'] . $value['technology_name'];
|
|
|
|
+ $tmp = bcsub(0.750,$value['finished_num'],3);
|
|
|
|
+ $map[$new_key][] = $tmp;
|
|
|
|
+ $return[] = $value;
|
|
|
|
+ }
|
|
|
|
+ }dump(count($return));
|
|
|
|
+ $return2= [];
|
|
|
|
+ foreach ($result as $key => $value){
|
|
|
|
+ if($value['finished_num'] >= 1){
|
|
|
|
+ $new_key = $value['order_product_id'] . $value['sale_orders_product_id'] . $value['technology_name'];
|
|
|
|
+ if(isset($map[$new_key])){
|
|
|
|
+ foreach ($map[$new_key] as $val){
|
|
|
|
+ $return[] = [
|
|
|
|
+ 'id' => $value['id'],
|
|
|
|
+ 'dispatch_quantity' => $val,
|
|
|
|
+ 'finished_num' => $val,
|
|
|
|
+ 'order_product_id' => $value['order_product_id'],
|
|
|
|
+ 'sale_orders_product_id' => $value['sale_orders_product_id'],
|
|
|
|
+ 'technology_name' => $value['technology_name'],
|
|
|
|
+ ];
|
|
|
|
+ $value['finished_num'] = bcsub($value['finished_num'], $val,3);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $return2[] = $value;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dd($return2);
|
|
}
|
|
}
|
|
}
|
|
}
|