|
@@ -11,6 +11,7 @@ use App\Model\Depart;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\SalesOrder;
|
|
|
use App\Model\SalesOrderProductInfo;
|
|
|
+use App\Model\ScheduleInfo;
|
|
|
use App\Model\SeeRange;
|
|
|
use App\Model\Storehouse;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
@@ -57,6 +58,10 @@ class ConstructionService extends Service
|
|
|
$model->storehouse_id = $data['storehouse_id'] ?? 0;
|
|
|
$model->start_time = $data['start_time'] ?? 0;
|
|
|
$model->end_time = $data['end_time'] ?? 0;
|
|
|
+ $model->schedule_id = $data['schedule_id'] ?? 0;
|
|
|
+ $model->day_stamp = $data['day_stamp'] ?? 0;
|
|
|
+ $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
|
|
|
+ $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
|
|
|
$model->save();
|
|
|
$time = time();
|
|
|
|
|
@@ -117,6 +122,8 @@ class ConstructionService extends Service
|
|
|
ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
|
|
|
}
|
|
|
|
|
|
+ if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
|
+
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -163,6 +170,10 @@ class ConstructionService extends Service
|
|
|
$model->storehouse_id = $data['storehouse_id'] ?? 0;
|
|
|
$model->start_time = $data['start_time'] ?? 0;
|
|
|
$model->end_time = $data['end_time'] ?? 0;
|
|
|
+ $model->schedule_id = $data['schedule_id'] ?? 0;
|
|
|
+ $model->day_stamp = $data['day_stamp'] ?? 0;
|
|
|
+ $model->day_start_stamp = $data['day_start_stamp'] ?? 0;
|
|
|
+ $model->day_end_stamp = $data['day_end_stamp'] ?? 0;
|
|
|
$model->save();
|
|
|
$time = time();
|
|
|
|
|
@@ -216,6 +227,8 @@ class ConstructionService extends Service
|
|
|
ProductInventoryService::changeLockNumber($user,$msg[0],[]);
|
|
|
}
|
|
|
|
|
|
+ if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
|
+
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -256,6 +269,15 @@ class ConstructionService extends Service
|
|
|
//锁定库存释放
|
|
|
ProductInventoryService::changeLockNumber($user,[],$product_save);
|
|
|
|
|
|
+ //排班修改
|
|
|
+ $schedule = ScheduleInfo::where('del_time',0)
|
|
|
+ ->where('schedule_id',$construction['schedule_id'])
|
|
|
+ ->where('start_time',$construction['day_start_stamp'])
|
|
|
+ ->where('end_time',$construction['day_end_stamp'])
|
|
|
+ ->where('is_use','>', ScheduleInfo::not_use)
|
|
|
+ ->first();
|
|
|
+ if(! empty($schedule)) ScheduleInfo::where('id',$schedule->id)->update(['is_use' => ScheduleInfo::not_use]);
|
|
|
+
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -452,7 +474,6 @@ class ConstructionService extends Service
|
|
|
if(! empty($data['service_price'])){
|
|
|
$res = $this->checkNumber($data['service_price']);
|
|
|
if(! $res) return [false,'服务价格请输入不超过两位小数并且大于0的数值'];
|
|
|
- if(! $res) return [false,'服务价格请输入不超过两位小数并且大于0的数值'];
|
|
|
}
|
|
|
if(! empty($data['construction_time'])) $data['construction_time'] = $this->changeDateToDateMin($data['construction_time']);
|
|
|
if(! empty($data['handover_time'])) $data['handover_time'] = $this->changeDateToDateMin($data['handover_time']);
|
|
@@ -464,9 +485,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,'排班时间信息不能为空'];
|
|
|
+
|
|
|
//所属部门 以及 顶级部门
|
|
|
if(empty($data['depart_id'])) {
|
|
|
- $data['depart_id'] = $this->getDepart($user);
|
|
|
+ $data['depart_id'] = $this->getDepazrt($user);
|
|
|
$data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
|
|
|
}
|
|
|
|
|
@@ -520,7 +544,18 @@ class ConstructionService extends Service
|
|
|
->where('start_time', '<=', $data['end_time'])
|
|
|
->where('end_time', '>=', $data['start_time'])
|
|
|
->exists();
|
|
|
- if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
|
|
|
+ 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,'操作频繁,请稍等!'];
|
|
|
}else{
|
|
|
if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
$bool = Construction::where('del_time',0)
|
|
@@ -530,6 +565,22 @@ class ConstructionService extends Service
|
|
|
->where('end_time', '>=', $data['start_time'])
|
|
|
->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,'操作频繁,请稍等!'];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return [true, [$product_submit, $product_save]];
|