|
@@ -146,7 +146,7 @@ class ConstructionService extends Service
|
|
|
ConstructionProductInfo::insert($insert);
|
|
|
|
|
|
//锁定库存
|
|
|
- ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
|
|
|
+ if($data['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,$msg[0],$msg[1]);
|
|
|
}
|
|
|
|
|
|
if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
@@ -286,7 +286,7 @@ class ConstructionService extends Service
|
|
|
ConstructionProductInfo::insert($insert);
|
|
|
|
|
|
//锁定库存
|
|
|
- ProductInventoryService::changeLockNumber($user,$msg[0],[]);
|
|
|
+ if($data['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,$msg[0],[]);
|
|
|
}
|
|
|
|
|
|
if(! empty($data['schedule_info_id'])) ScheduleInfo::where('id',$data['schedule_info_id'])->update(['is_use' => 1]);
|
|
@@ -368,7 +368,7 @@ class ConstructionService extends Service
|
|
|
(new RangeService())->RangeDelete($data['id'],SeeRange::type_two);
|
|
|
|
|
|
//锁定库存释放
|
|
|
- ProductInventoryService::changeLockNumber($user,[],$product_save);
|
|
|
+ if($construction['model_type'] == Construction::Model_type_one) ProductInventoryService::changeLockNumber($user,[],$product_save);
|
|
|
|
|
|
//排班修改
|
|
|
// $schedule = ScheduleInfo::where('del_time',0)
|
|
@@ -446,7 +446,7 @@ class ConstructionService extends Service
|
|
|
->select('b.title','a.contact_info')
|
|
|
->get()->toArray();
|
|
|
$construction['customer_array'] = $info;
|
|
|
- $construction['storehouse_title'] = Storehouse::where('id',$construction['storehouse_id'])->value('title');
|
|
|
+ $construction['storehouse_title'] = $construction['storehouse_id'] > 0 ? Storehouse::where('id',$construction['storehouse_id'])->value('title') : "";
|
|
|
$emp_title = Employee::where('id',$construction['customer_contact_id'])->value('emp_name');
|
|
|
$construction['customer_contact_title'] = $emp_title;
|
|
|
$construction['employee_two'] = $construction['employee_one'] = $construction['construction_contact'] = $construction['product'] = [];
|
|
@@ -632,7 +632,7 @@ class ConstructionService extends Service
|
|
|
if(empty($data['model_type'])) return [false,'工单模板类型不能为空'];
|
|
|
if(! in_array($data['model_type'],Construction::$model_type)) return [false,'工单模板类型错误'];
|
|
|
if(empty($data['order_number'])) return [false,'工单编号不能为空'];
|
|
|
- if(empty($data['storehouse_id'])) return [false,'请选择仓库'];
|
|
|
+ if($data['model_type'] == Construction::Model_type_one && empty($data['storehouse_id'])) return [false,'请选择仓库'];
|
|
|
if(empty($data['menu_id'])) return [false, '菜单信息不能为空'];
|
|
|
if(empty($data['sales_order_id'])) return [false,'请选择合同'];
|
|
|
$sale = SalesOrder::where('del_time',0)->where('id',$data['sales_order_id'])->first();
|
|
@@ -711,35 +711,23 @@ class ConstructionService extends Service
|
|
|
//是否校验库存
|
|
|
ProductInventoryService::is_check($user,$data);
|
|
|
|
|
|
- list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
|
|
|
- if(! $status) return [false, $msg];
|
|
|
+ if($data['model_type'] == Construction::Model_type_one){
|
|
|
+ //到店安装 才校验库存
|
|
|
+ list($status,$msg) = (new ProductInventoryService())->compareStock($user,$product_id, $product_submit, $product_save);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+ }
|
|
|
|
|
|
- $start_time = date("Y-m-d H:i",$data['start_time']);
|
|
|
- $end_time = date("Y-m-d H:i",$data['end_time']);
|
|
|
if($is_add){
|
|
|
$bool = Construction::where('del_time',0)
|
|
|
->where('order_number',$data['order_number'])
|
|
|
->exists();
|
|
|
if($bool) return [false,'工单编号已存在,请重新获取'];
|
|
|
-// $bool = Construction::where('del_time',0)
|
|
|
-// ->where('sales_order_id',$data['sales_order_id'])
|
|
|
-// ->where('start_time', '<=', $data['end_time'])
|
|
|
-// ->where('end_time', '>=', $data['start_time'])
|
|
|
-// ->exists();
|
|
|
-// if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
|
|
|
}else{
|
|
|
if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
$construction = Construction::where('del_time',0)
|
|
|
->where('id',$data['id'])->first();
|
|
|
if(empty($construction)) return [false, '施工单单据不存在或已被删除'];
|
|
|
if($construction->state > Construction::STATE_ZERO) return [false,'请确认施工单单据状态,修改失败'];
|
|
|
-// $bool = Construction::where('del_time',0)
|
|
|
-// ->where('id','<>',$data['id'])
|
|
|
-// ->where('sales_order_id',$data['sales_order_id'])
|
|
|
-// ->where('start_time', '<=', $data['end_time'])
|
|
|
-// ->where('end_time', '>=', $data['start_time'])
|
|
|
-// ->exists();
|
|
|
-// if($bool) return [false,'合同:' . $sale['order_number'] . '在' . $start_time . '——' . $end_time . '已下施工单'];
|
|
|
}
|
|
|
|
|
|
return [true, [$product_submit, $product_save]];
|