|
@@ -93,24 +93,33 @@ class Allot extends BaseController
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
$pd=Db::name('allot_stock')->insert($data,true);
|
|
|
- if($pd>0){
|
|
|
- $pdinfo=[
|
|
|
- "good_type_code"=>$good_type_code,
|
|
|
- "allot_num"=>$allot_num,
|
|
|
- // "good_name"=>$good_name,
|
|
|
- "allot_code"=>$allot_code,
|
|
|
-// "usable_num"=>$usable_num,
|
|
|
-// "error_num"=>$error_num,
|
|
|
-// "error_remark"=>$error_remark,
|
|
|
-// "stock_num"=>$stock_num,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s"),
|
|
|
- ];
|
|
|
- $cpd = Db::name('allot_info')->insert($pdinfo);
|
|
|
- if($cpd){
|
|
|
- DB::commit();
|
|
|
- error_show(0,"调拨创建成功");
|
|
|
- }
|
|
|
+ $dn = [];
|
|
|
+ if($pd>0) {
|
|
|
+ foreach ($dain as $value) {
|
|
|
+ $st = Db::name("good_type")->alias("b")->join("good a", "a.good_code = b.good_code", "left")
|
|
|
+ ->join("good_stock c", "c.good_type_code = b.type_code", "left")->where(['wsm_code' => $wsm_out, 'good_type_code' => $value['type_code'], 'b.is_del' => 0, 'a.is_del' => 0])->where("c.is_del=0 or c.is_del is null")
|
|
|
+ ->field("b.type_code,a.good_name,a.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock")->find();
|
|
|
+ if (empty($st)) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "商品不能为空");
|
|
|
+ }
|
|
|
+ $temp = [];
|
|
|
+ $temp['good_name'] = $st['good_name'];
|
|
|
+ $temp['good_type_code'] = $value['good_code'];
|
|
|
+ $temp['allot_num'] = $value['allot_num'];
|
|
|
+ $temp['usable_num'] = 0;
|
|
|
+ $temp['error_num'] = 0;
|
|
|
+ $temp['error_remark'] = "";
|
|
|
+ $temp['stock_num'] = 0;
|
|
|
+ $temp['addtime'] = date("Y-m-d H:i:s");
|
|
|
+ $temp['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $dn[] = $temp;
|
|
|
+ $io = db::name('allot_info')->insertAll($dn);
|
|
|
+ if ($io) {
|
|
|
+ DB::commit();
|
|
|
+ return error_show(0, "调拨创建成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"调拨创建失败");
|
|
@@ -200,7 +209,7 @@ class Allot extends BaseController
|
|
|
$temp = [];
|
|
|
$temp['id'] = $value['id'];
|
|
|
$temp['good_name'] = $st['good_name'];
|
|
|
- $temp['good_type_code'] = $value['good_type_code'];
|
|
|
+ $temp['good_type_code'] = $value['good_code'];
|
|
|
$temp['allot_num'] = $value['allot_num'];
|
|
|
$temp['usable_num'] = 0;
|
|
|
$temp['error_num'] = 0;
|
|
@@ -208,13 +217,13 @@ class Allot extends BaseController
|
|
|
$temp['allot_code'] = $etid['allot_code'];
|
|
|
$temp['stock_num'] = 0;
|
|
|
$temp['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $dn [] = $temp;
|
|
|
- $np = Db::name('allot_info')->save(['updatetime' => date('Y-m-d H:i:s')]);
|
|
|
+ $dn[] = $temp;
|
|
|
+ $np = Db::name('allot_info')->where(['allot_code' => $etid['id']])->save(['updatetime' => date('Y-m-d H:i:s')]);
|
|
|
$io = db::name('allot_info')->insertAll($dn);
|
|
|
- if ($io) {
|
|
|
- Db::commit();
|
|
|
- return error_show(0, "调拨更新成功");
|
|
|
- }
|
|
|
+ if ($io) {
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0, "调拨更新成功");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Db::rollback();
|