|
@@ -46,20 +46,19 @@ class DispatchService extends Service
|
|
|
public function add($data,$user){
|
|
|
//数据校验以及填充
|
|
|
list($status,$msg) = $this->orderRule($data);
|
|
|
- if(!$status) return [$status,$msg];
|
|
|
-
|
|
|
- $dispatch_no = $this->setOrderNO();
|
|
|
- if(empty($dispatch_no)) return [false,'单据号生成失败!'];
|
|
|
+ if(! $status) return [$status,$msg];
|
|
|
|
|
|
try{
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
if($data['is_split']){
|
|
|
foreach ($msg as $value){
|
|
|
- $this->insertDispatch([$value],$data,$user,$dispatch_no);
|
|
|
+ list($s,$m) = $this->insertDispatch([$value],$data,$user);
|
|
|
+ if(! $s) return [false,$m];
|
|
|
}
|
|
|
}else{
|
|
|
- $this->insertDispatch($msg,$data,$user,$dispatch_no);
|
|
|
+ list($s,$m) = $this->insertDispatch($msg,$data,$user);
|
|
|
+ if(! $s) return [false, $m];
|
|
|
}
|
|
|
|
|
|
//反写已派工数量
|
|
@@ -148,11 +147,14 @@ class DispatchService extends Service
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
- public function insertDispatch($msg, $data, $user,$dispatch_no){
|
|
|
+ public function insertDispatch($msg, $data, $user){
|
|
|
//生产数据的源数据
|
|
|
$result = $msg;
|
|
|
$time = time();
|
|
|
|
|
|
+ $dispatch_no = $this->setOrderNO();
|
|
|
+ if(! $dispatch_no) return [false,'单号生成失败!'];
|
|
|
+
|
|
|
//主表
|
|
|
Dispatch::insert(['dispatch_no' => $dispatch_no,'crt_time' => $time]);
|
|
|
|
|
@@ -191,6 +193,8 @@ class DispatchService extends Service
|
|
|
DispatchSub::insert($result);
|
|
|
|
|
|
if(! empty($insert_emp_sub)) DispatchEmpSub::insert($insert_emp_sub);
|
|
|
+
|
|
|
+ return [true,''];
|
|
|
}
|
|
|
|
|
|
public function del($data){
|