|
@@ -790,45 +790,46 @@ class Resign extends BaseController
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
];
|
|
];
|
|
$in =Db::name("order_bk")->insert($data);
|
|
$in =Db::name("order_bk")->insert($data);
|
|
- if($in){
|
|
|
|
- $good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'],"spuCode"=>$info['spuCode'],"is_del"=>0])->find();
|
|
|
|
- if($good==false) {
|
|
|
|
- $good=[
|
|
|
|
- "spuCode"=>$info['spuCode'],
|
|
|
|
- "wsm_code"=>$info['wsm_code'],
|
|
|
|
- "usable_stock"=>0,
|
|
|
|
- "wait_out_stock"=>0,
|
|
|
|
- "wait_in_stock"=>0,
|
|
|
|
- "total_stock"=>0,
|
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
|
- "updatetime"=>date("Y-m-d H:i:s"),
|
|
|
|
- ];
|
|
|
|
- $order = ["order_code"=>$info['spuCode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
|
|
|
|
- }else{
|
|
|
|
- $order = ["order_code"=>$info['spuCode'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
|
|
|
|
|
|
+ if($in) {
|
|
|
|
+ $good = Db::name("good_stock")->where(["wsm_code" => $info['wsm_code'], "spuCode" => $info['spuCode'], "is_del" => 0])->find();
|
|
|
|
+ if ($good == false) {
|
|
|
|
+ $good = [
|
|
|
|
+ "spuCode" => $info['spuCode'],
|
|
|
|
+ "wsm_code" => $info['wsm_code'],
|
|
|
|
+ "usable_stock" => 0,
|
|
|
|
+ "wait_out_stock" => 0,
|
|
|
|
+ "wait_in_stock" => 0,
|
|
|
|
+ "total_stock" => 0,
|
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
|
+ "updatetime" => date("Y-m-d H:i:s"),
|
|
|
|
+ ];
|
|
|
|
+ $order = ["order_code" => $info['spuCode'], "status" => 1, "action_remark" => '', "action_type" => "create"];
|
|
|
|
+ } else {
|
|
|
|
+ $order = ["order_code" => $info['spuCode'], "status" => 1, "action_remark" => '', "action_type" => "edit"];
|
|
|
|
+ }
|
|
|
|
+ $good['wait_in_stock'] += $info['good_num'];
|
|
|
|
+ $good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+ $upd = Db::name("good_stock")->save($good);
|
|
|
|
+ $good_data[] = ["stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1,
|
|
|
|
+ 'stock' => $info['good_num'], "stock_name" => "wait_in_stock"];
|
|
|
|
+ if ($upd) {
|
|
|
|
+ GoodLog::LogAdd($this->post['token'], $good_data, 'RKD');
|
|
|
|
+ ActionLog::logAdd($this->post['token'], $order, "RKD", 1, $good);
|
|
|
|
+ $process = ["order_code" => $cgdCode, "order_id" => Db::name("purchease_order")->getLastInsID(), "order_status" => $cg['status'], "order_type" => 'CGD'];
|
|
|
|
+ ProcessOrder::AddProcess($this->post['token'], $process);
|
|
|
|
+ $info['wsm_code'] = $wsm_code;
|
|
|
|
+ $info['status'] = 2;
|
|
|
|
+ $info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+ $bas = Db::name("purchease")->save($info);
|
|
|
|
+ if ($bas) {
|
|
|
|
+ Db::commit();
|
|
|
|
+ return app_show(0, "采购单新建成功", ["cgdNo" => $cgdCode]);
|
|
}
|
|
}
|
|
- $good['wait_in_stock']+=$info['good_num'];
|
|
|
|
- $good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
- $upd= Db::name("good_stock")->save($good);
|
|
|
|
- $good_data[]=["stock_id"=>isset($good['id'])? $good['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,
|
|
|
|
- 'stock'=>$info['good_num'],"stock_name"=>"wait_in_stock"];
|
|
|
|
- if($upd) {
|
|
|
|
- GoodLog::LogAdd($this->post['token'], $good_data, 'RKD');
|
|
|
|
- ActionLog::logAdd($this->post['token'], $order, "RKD", 1, $good);
|
|
|
|
- $process=["order_code"=>$cgdCode,"order_id"=>Db::name("purchease_order")->getLastInsID(),"order_status"=>$cg['status'],"order_type"=>'CGD'];
|
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
|
- $info['wsm_code']=$wsm_code;
|
|
|
|
- $info['status']=2;
|
|
|
|
- $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
|
- $bas= Db::name("purchease")->save($info);
|
|
|
|
- if($bas){
|
|
|
|
- Db::commit();
|
|
|
|
- return app_show(0, "采购单新建成功", ["cgdNo" => $cgdCode]);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+
|
|
Db::rollback();
|
|
Db::rollback();
|
|
return error_show(1004,"采购单新建失败");
|
|
return error_show(1004,"采购单新建失败");
|
|
}catch (\Exception $e){
|
|
}catch (\Exception $e){
|