|
@@ -591,7 +591,92 @@ class BoxService extends Service
|
|
|
|
|
|
return [true,'删除成功'];
|
|
|
}
|
|
|
-// public function
|
|
|
|
|
|
+ public function boxAdd($data)
|
|
|
+ {
|
|
|
+ list($status,$msg) = $this->boxAddRule($data);
|
|
|
+ if(! $status) return [false,$msg];
|
|
|
+
|
|
|
+ try{
|
|
|
+ DB::beginTransaction();
|
|
|
+ $box = new Box();
|
|
|
+ $box->order_no = $msg['order_no'];
|
|
|
+ $box->save();
|
|
|
|
|
|
+ DB::table('box_detail')->insert($msg['detail']);
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+ return [true,''];
|
|
|
+ }catch (\Exception $e){
|
|
|
+
|
|
|
+ DB::rollBack();
|
|
|
+ return [false,$e->getLine().':'.$e->getMessage()];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function boxAddRule($data)
|
|
|
+ {
|
|
|
+ if(empty($data['param'])) return [false,'请选择包装数据'];
|
|
|
+ $order_no = (new BoxHookService())->setOrderNo();
|
|
|
+ $detail = [];
|
|
|
+ foreach ($data['param'] as $value) {
|
|
|
+ $key = $this->lock_key.'_'.$value['idlsid'];
|
|
|
+ list($status,$msg) = $this->limitingSendRequestBackg($key);
|
|
|
+ if(! $status) return [false,$msg];
|
|
|
+
|
|
|
+ if(empty($value['submit_quantity']) || ! is_numeric($value['submit_quantity']) || $value['submit_quantity'] > $value['quantity']) return [false,'包装数量错误'];
|
|
|
+ if(empty($value['team_id'])) return [false,'班组必须选择'];
|
|
|
+
|
|
|
+ $detail[] = [
|
|
|
+ 'order_no' => $order_no,
|
|
|
+ 'out_order_no' => $value['csocode'],
|
|
|
+ 'crt_time' => time(),
|
|
|
+ 'upd_time' => time(),
|
|
|
+ 'type' => 1,
|
|
|
+ 'ext_1' => $value['cinvcode'],
|
|
|
+ 'ext_2' => $value['technology_material'],
|
|
|
+ 'ext_3' => $value['cfree1'] ?? "",
|
|
|
+ 'ext_4' => $value['cfree2'] ?? "",
|
|
|
+ 'ext_5' => $value['process_mark'],
|
|
|
+ 'ext_6' => $value['customer_name'] ?? "",
|
|
|
+ 'ext_7' => $value['cuscode'] ?? "",
|
|
|
+ 'ext_8' => $value['product_title'],
|
|
|
+ 'ext_9' => $value['product_size'],
|
|
|
+ 'top_id' => $value['idlsid'],
|
|
|
+ 'state' => 0,
|
|
|
+ 'num' => $value['submit_quantity'],
|
|
|
+ 'box_type' => 2,
|
|
|
+ 'team_id' => $value['team_id'],
|
|
|
+ 'shipment_order_no' => $value['cdlcode'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true,['order_no' => $order_no, 'detail' => $detail]];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function boxFhDetail($data){
|
|
|
+ if(empty($data['idlsid'])) return [false,'请选择数据'];
|
|
|
+
|
|
|
+ $result = DB::table('box_detail')->where('del_time',0)
|
|
|
+ ->select('order_no','ext_6','ext_7','ext_1','ext_8','ext_9','num','ext_2','ext_3','ext_4','ext_5')
|
|
|
+ ->get()->toArray();
|
|
|
+ if(! empty($result)){
|
|
|
+ foreach ($result as $key => $value){
|
|
|
+ $result[$key] = (array)$value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true,$result];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function boxFhDel($data){
|
|
|
+ if(empty($data['order_nos'])) return [false,'包装单号不能为空'];
|
|
|
+
|
|
|
+ $box = Box::whereIn('order_no',$data['order_nos'])->update(['del_time' => time()]);
|
|
|
+
|
|
|
+ DB::table('box_detail')->whereIn('order_no',$data['order_nos'])->where('del_time',0)->update([
|
|
|
+ 'del_time' => time()
|
|
|
+ ]);
|
|
|
+ return [true,''];
|
|
|
+ }
|
|
|
}
|