|
@@ -430,6 +430,24 @@ class ConstructionService extends Service
|
|
|
$construction['construction_period'] = $start_time . '——' . $end_time;
|
|
|
$sales = SalesOrder::where('id',$construction['sales_order_id'])->value('order_number');
|
|
|
$construction['sales_order_number'] = $sales;
|
|
|
+ $sales_info = SalesOrderInfo::where('del_time',0)
|
|
|
+ ->where('sales_order_id',$construction['sales_order_id'])
|
|
|
+ ->where('type', SalesOrderInfo::type_two)
|
|
|
+ ->get()->toArray();
|
|
|
+ $emp = Employee::whereIn('id',array_unique(array_column($sales_info,'data_id')))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $sale_man = [];
|
|
|
+ foreach ($sales_info as $value){
|
|
|
+ $tt = $emp[$value['data_id']] ?? '';
|
|
|
+ $tmp = [
|
|
|
+ 'id' => $value['data_id'],
|
|
|
+ 'name' => $tt?? '',
|
|
|
+ ];
|
|
|
+ $sale_man[] = $tmp;
|
|
|
+ }
|
|
|
+ $construction['sale_man'] = $sale_man;
|
|
|
+
|
|
|
$customer_title = Customer::where('id',$construction['customer_id'])->value('title');
|
|
|
$construction['customer_title'] = $customer_title ?? "";
|
|
|
$info = CustomerInfo::from('customer_info as a')
|
|
@@ -1067,6 +1085,7 @@ class ConstructionService extends Service
|
|
|
try {
|
|
|
$model->upd_id = $id;
|
|
|
$model->construction_order_number = $data['construction_order_number'] ?? '';
|
|
|
+ $model->sales_order_number = $data['sales_order_number'] ?? '';
|
|
|
$model->start_time = $data['start_time'] ?? '';
|
|
|
$model->end_time = $data['end_time'] ?? '';
|
|
|
$model->vin_no = $data['vin_no'] ?? '';
|
|
@@ -1090,41 +1109,108 @@ class ConstructionService extends Service
|
|
|
$model->img2 = $data['img2'] ?? '';
|
|
|
$model->img3 = $data['img3'] ?? '';
|
|
|
$model->save();
|
|
|
- return [true,'保存成功!'];
|
|
|
}catch (\Throwable $e){
|
|
|
- return [true,'保存成功!'];
|
|
|
+ return [false, $e->getMessage()];
|
|
|
}
|
|
|
+
|
|
|
+ return [true,''];
|
|
|
}
|
|
|
|
|
|
public function deliveryNoteList($data)
|
|
|
{
|
|
|
- $list = DeliveryNote::where('del_time',0);
|
|
|
- $list = $this->limit($list,'*',$data);
|
|
|
+ $model = DeliveryNote::where('del_time',0)
|
|
|
+ ->select("*")
|
|
|
+ ->orderBy("id","desc");
|
|
|
+ $list = $this->limit($model,'', $data);
|
|
|
+
|
|
|
return [true,$list];
|
|
|
}
|
|
|
|
|
|
+ public function fillDeliveryNoteData($data){
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
+
|
|
|
+ $emp = $this->returnMan($data['data']);
|
|
|
+
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
+ $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
+ $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
|
|
|
+ $data['data'][$key]['sale_man_title'] = $this->returnMan2($value['sale_man']);
|
|
|
+ $data['data'][$key]['install_man_title'] = $this->returnMan2($value['install_man']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function returnMan($data = []){
|
|
|
+ if(empty($data)) return [];
|
|
|
+
|
|
|
+ $man = [];
|
|
|
+ foreach ($data as $value){
|
|
|
+ if(! empty($value['sale_man'])){
|
|
|
+ $tmp = explode(',', $value['sale_man']);
|
|
|
+ foreach ($tmp as $t){
|
|
|
+ if(! in_array($t, $man)) $man[] = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(! empty($value['install_man'])){
|
|
|
+ $tmp = explode(',', $value['install_man']);
|
|
|
+ foreach ($tmp as $t){
|
|
|
+ if(! in_array($t, $man)) $man[] = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(! in_array($value['crt_id'], $man)) $man[] = $value['crt_id'];
|
|
|
+ }
|
|
|
+ $emp = Employee::whereIn('id', $man)
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ return $emp;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function returnMan2($value){
|
|
|
+ $str_man = "";
|
|
|
+ if(! empty($value)){
|
|
|
+ $tmp = explode(',', $value);
|
|
|
+ foreach ($tmp as $t){
|
|
|
+ $t2 = $emp[$t] ?? "";
|
|
|
+ if($t2) $str_man .= $t2 . ",";
|
|
|
+ }
|
|
|
+ $str_man = rtrim($str_man, ',');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $str_man;
|
|
|
+ }
|
|
|
+
|
|
|
public function deliveryNoteDetail($data){
|
|
|
if(isset($data['id'])) $model = DeliveryNote::where('id',$data['id'])->where('del_time',0)->first();
|
|
|
if(isset($data['construction_order_number'])) $model = DeliveryNote::where('id',$data['construction_order_number'])->where('del_time',0)->first();
|
|
|
- if(empty($model)) return [false,'数据不存在!'];
|
|
|
- $employee_key_list = Employee::pluck('emp_name','id')->toArray();
|
|
|
+ if(empty($model)) return [false,'单据不存在或已被删除'];
|
|
|
$detail = $model->toArray();
|
|
|
+ $emp = $this->returnMan([$detail]);
|
|
|
|
|
|
- $detail['install_man_title'] = $employee_key_list[$detail['install_man']] ?? "";
|
|
|
- $detail['sale_man_title'] = $employee_key_list[$detail['sale_man']] ?? "";
|
|
|
- $img_list = ConstructionFile::where('order_number',$detail['construction_order_number'])->where('del_time',0)->select('file as url','name','mark')->get()->toArray();
|
|
|
+ $detail['sale_man_title'] = $emp[$detail['sale_man']] ?? "";
|
|
|
+ $detail['install_man_title'] = $emp[$detail['install_man']] ?? "";
|
|
|
+ $detail['crt_name'] = $emp[$detail['crt_id']] ?? "";
|
|
|
+ $detail['crt_time'] = $detail['crt_time'] ? date('Y-m-d H:i:s',$detail['crt_time']) : '';
|
|
|
+ $img_list = ConstructionFile::where('order_number',$detail['construction_order_number'])
|
|
|
+ ->where('del_time',0)
|
|
|
+ ->select('file as url','name','mark')->get()->toArray();
|
|
|
$detail['file'] = $img_list;
|
|
|
- return [true,$detail];
|
|
|
+
|
|
|
+ return [true, $detail];
|
|
|
}
|
|
|
|
|
|
public function deliveryNoteDel($data,$user){
|
|
|
+ if(empty($data['id'])) return [false, '请选择删除的交车单数据'];
|
|
|
+
|
|
|
DeliveryNote::where('id',$data['id'])->update(
|
|
|
[
|
|
|
'del_time' => time(),
|
|
|
'upd_id' => $user['id'],
|
|
|
]
|
|
|
);
|
|
|
- return [true,'删除成功!'];
|
|
|
+
|
|
|
+ return [true,''];
|
|
|
}
|
|
|
|
|
|
public function constructionPdf($data, $user){
|