|
@@ -4,6 +4,7 @@ namespace App\Service;
|
|
|
|
|
|
use App\Model\BasicType;
|
|
|
use App\Model\Construction;
|
|
|
+use App\Model\ConstructionFile;
|
|
|
use App\Model\ConstructionInfo;
|
|
|
use App\Model\ConstructionProductInfo;
|
|
|
use App\Model\Customer;
|
|
@@ -11,6 +12,7 @@ use App\Model\DeliveryNote;
|
|
|
use App\Model\Depart;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\SalesOrder;
|
|
|
+use App\Model\SalesOrderInfo;
|
|
|
use App\Model\SalesOrderProductInfo;
|
|
|
use App\Model\ScheduleInfo;
|
|
|
use App\Model\SeeRange;
|
|
@@ -72,6 +74,9 @@ class ConstructionService extends Service
|
|
|
ConstructionProductInfo::where('del_time',0)
|
|
|
->where('construction_id',$data['id'])
|
|
|
->update(['del_time' => $time]);
|
|
|
+ ConstructionFile::where('del_time',0)
|
|
|
+ ->where('construction_id',$data['id'])
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
|
|
|
if(! empty($data['construction_contact'])){
|
|
|
$insert = [];
|
|
@@ -125,6 +130,20 @@ class ConstructionService extends Service
|
|
|
|
|
|
if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
|
|
|
|
+ if(! empty($data['file'])){
|
|
|
+ $insert = [];
|
|
|
+ foreach ($data['file'] as $value){
|
|
|
+ $insert[] = [
|
|
|
+ 'construction_id' => $data['id'],
|
|
|
+ 'file' => $value['url'],
|
|
|
+ 'name' => $value['name'],
|
|
|
+ 'mark' => $value['mark'] ?? "",
|
|
|
+ 'crt_time' => $time,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ ConstructionFile::insert($insert);
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -230,6 +249,20 @@ class ConstructionService extends Service
|
|
|
|
|
|
if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
|
|
|
|
+ if(! empty($data['file'])){
|
|
|
+ $insert = [];
|
|
|
+ foreach ($data['file'] as $value){
|
|
|
+ $insert[] = [
|
|
|
+ 'construction_id' => $data['id'],
|
|
|
+ 'file' => $value['url'],
|
|
|
+ 'name' => $value['name'],
|
|
|
+ 'mark' => $value['mark'] ?? "",
|
|
|
+ 'crt_time' => $time,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ ConstructionFile::insert($insert);
|
|
|
+ }
|
|
|
+
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -262,6 +295,9 @@ class ConstructionService extends Service
|
|
|
ConstructionInfo::where('del_time',0)
|
|
|
->where('construction_id',$data['id'])
|
|
|
->update(['del_time' => time()]);
|
|
|
+ ConstructionFile::where('del_time',0)
|
|
|
+ ->where('construction_id',$data['id'])
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
ConstructionProductInfo::where('del_time',0)
|
|
|
->where('construction_id',$data['id'])
|
|
|
->update(['del_time' => time()]);
|
|
@@ -344,6 +380,19 @@ class ConstructionService extends Service
|
|
|
}
|
|
|
$construction = $construction[0];
|
|
|
|
|
|
+ $construction['file'] = [];
|
|
|
+ $file = ConstructionFile::where('del_time',0)
|
|
|
+ ->where('construction_id',$construction['id'])
|
|
|
+ ->select('id','construction_id','file','name','mark')
|
|
|
+ ->get()->toArray();
|
|
|
+ foreach ($file as $value){
|
|
|
+ $construction['file'][] = [
|
|
|
+ 'url' => $value['file'],
|
|
|
+ 'name' => $value['name'],
|
|
|
+ 'mark' => $value['mark'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
$construction_info = ConstructionInfo::where('del_time',0)
|
|
|
->where('construction_id',$construction['id'])
|
|
|
->select('id','construction_id','employee_id','type','contact_type','contact_info')
|
|
@@ -486,12 +535,12 @@ class ConstructionService extends Service
|
|
|
// if(empty($data['construction_contact'])) return [false,'联系方式不能为空'];
|
|
|
// if(empty($data['address1']) || empty($data['address2'])) return [false,'地址不能为空'];
|
|
|
}
|
|
|
- //校验排班
|
|
|
- if(empty($data['schedule_id']) ||empty($data['day_stamp']) || empty($data['day_start_stamp']) || empty($data['day_end_stamp'])) return [false,'排班时间信息不能为空'];
|
|
|
+ //校验排班 todo
|
|
|
+// if(empty($data['schedule_id']) ||empty($data['day_stamp']) || empty($data['day_start_stamp']) || empty($data['day_end_stamp'])) return [false,'排班时间信息不能为空'];
|
|
|
|
|
|
//所属部门 以及 顶级部门
|
|
|
if(empty($data['depart_id'])) {
|
|
|
- $data['depart_id'] = $this->getDepazrt($user);
|
|
|
+ $data['depart_id'] = $this->getDepart($user);
|
|
|
$data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
|
|
|
}
|
|
|
|
|
@@ -547,16 +596,16 @@ class ConstructionService extends Service
|
|
|
->exists();
|
|
|
if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
|
|
|
|
|
|
- $schedule = ScheduleInfo::where('del_time',0)
|
|
|
- ->where('day',$data['day_stamp'])
|
|
|
- ->where('start_time',$data['day_start_stamp'])
|
|
|
- ->where('end_time',$data['day_end_stamp'])
|
|
|
- ->where('is_use',ScheduleInfo::not_use)
|
|
|
- ->first();
|
|
|
- if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
|
|
|
- $data['schedule_info_id'] = $schedule->id;
|
|
|
- list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
|
|
|
- if(! $status) return [false,'操作频繁,请稍等!'];
|
|
|
+// $schedule = ScheduleInfo::where('del_time',0)
|
|
|
+// ->where('day',$data['day_stamp'])
|
|
|
+// ->where('start_time',$data['day_start_stamp'])
|
|
|
+// ->where('end_time',$data['day_end_stamp'])
|
|
|
+// ->where('is_use',ScheduleInfo::not_use)
|
|
|
+// ->first();
|
|
|
+// if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
|
|
|
+// $data['schedule_info_id'] = $schedule->id;
|
|
|
+// list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
|
|
|
+// if(! $status) return [false,'操作频繁,请稍等!'];
|
|
|
}else{
|
|
|
if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
$bool = Construction::where('del_time',0)
|
|
@@ -567,21 +616,21 @@ class ConstructionService extends Service
|
|
|
->exists();
|
|
|
if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
|
|
|
|
|
|
- $construction = Construction::where('id',$data['id'])->first();
|
|
|
- if(empty($construction)) return [false,'施工单不存在或已被删除'];
|
|
|
- $construction = $construction->toArray();
|
|
|
- if($construction['day_stamp'] != $data['day_stamp'] || $construction['day_start_stamp'] != $data['day_start_stamp'] && $construction['day_end_stamp'] != $data['day_end_stamp']) {
|
|
|
- $schedule = ScheduleInfo::where('del_time',0)
|
|
|
- ->where('day',$data['day_stamp'])
|
|
|
- ->where('start_time',$data['day_start_stamp'])
|
|
|
- ->where('end_time',$data['day_end_stamp'])
|
|
|
- ->where('is_use',ScheduleInfo::not_use)
|
|
|
- ->first();
|
|
|
- if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
|
|
|
- $data['schedule_info_id'] = $schedule->id;
|
|
|
- list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
|
|
|
- if(! $status) return [false,'操作频繁,请稍等!'];
|
|
|
- }
|
|
|
+// $construction = Construction::where('id',$data['id'])->first();
|
|
|
+// if(empty($construction)) return [false,'施工单不存在或已被删除'];
|
|
|
+// $construction = $construction->toArray();
|
|
|
+// if($construction['day_stamp'] != $data['day_stamp'] || $construction['day_start_stamp'] != $data['day_start_stamp'] && $construction['day_end_stamp'] != $data['day_end_stamp']) {
|
|
|
+// $schedule = ScheduleInfo::where('del_time',0)
|
|
|
+// ->where('day',$data['day_stamp'])
|
|
|
+// ->where('start_time',$data['day_start_stamp'])
|
|
|
+// ->where('end_time',$data['day_end_stamp'])
|
|
|
+// ->where('is_use',ScheduleInfo::not_use)
|
|
|
+// ->first();
|
|
|
+// if(! empty($schedule)) return [false,'该时间段排班已满或不存在!'];
|
|
|
+// $data['schedule_info_id'] = $schedule->id;
|
|
|
+// list($status,$msg) = $this->limitingSendRequestBackg(ScheduleInfo::limit_key . $schedule->id);
|
|
|
+// if(! $status) return [false,'操作频繁,请稍等!'];
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
return [true, [$product_submit, $product_save]];
|