|
@@ -295,6 +295,46 @@ class Purchin extends BaseController
|
|
|
if($upd){
|
|
|
GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
ActionLog::logAdd($this->post['token'],$order,"RKD", 1,$good );
|
|
|
+ if($cgdinfo['send_status']==3){
|
|
|
+ $send=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"status"=>1])->column("outCode");
|
|
|
+ if(!empty($send)){
|
|
|
+ $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->select()
|
|
|
+ ->toArray();
|
|
|
+ if(!empty($out)){
|
|
|
+ $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->update
|
|
|
+ (["status"=>1,"updatetime"=>date('Y-m-d H:i:s')]);
|
|
|
+ if($up==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"出库单出库失败");
|
|
|
+ }
|
|
|
+ $good1 = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
|
+ if($good1==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"未找到对应商品库存");
|
|
|
+ }
|
|
|
+ $out_num = intval(array_sum(array_column($out,"send_num")));
|
|
|
+ if($out_num>$good1['usable_stock']){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存数量不足发货");
|
|
|
+ }
|
|
|
+ $good1['usable_stock']-=$out_num;
|
|
|
+ $good1['wait_out_stock']+=$out_num;
|
|
|
+ $good1['total_stock']=$good1['usable_stock']+$good1['wait_out_stock'];
|
|
|
+ $good1['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $upd= Db::name("good_stock")->save($good1);
|
|
|
+ if($upd==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存数量更新失败");
|
|
|
+ }
|
|
|
+ $sendp=Db::name("order_send")->where(["cgdNo"=>$cgdNo,"outCode"=>$out,
|
|
|
+ "status"=>1])->save (["status"=>2]);
|
|
|
+ if($sendp==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"库存发货失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
return app_show(0,'商品入库成功',["wsm_in_code"=>$wsm_in_code]);
|
|
|
}else{
|
|
@@ -554,6 +594,45 @@ class Purchin extends BaseController
|
|
|
if($upd){
|
|
|
GoodLog::LogAdd($this->post['token'],$good_data,'RKD');
|
|
|
ActionLog::logAdd($this->post['token'],$order,"RKD", 1,$good );
|
|
|
+// if($cgdinfo['send_status']==3){
|
|
|
+// $send=Db::name("order_send")->where(["cgdNo"=>$info['cgdNo'],"status"=>1])->column("outCode");
|
|
|
+// if(!empty($send)){
|
|
|
+// $out =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->select()
|
|
|
+// ->toArray();
|
|
|
+// if(!empty($out)){
|
|
|
+// $up =Db::name("order_out")->where(["outCode"=>$send,"status"=>0,"is_del"=>0])->update
|
|
|
+// (["status"=>1,"updatetime"=>date('Y-m-d H:i:s')]);
|
|
|
+// if($up==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1004,"出库单出库失败");
|
|
|
+// }
|
|
|
+// $good1 = Db::name("good_stock")->where(["wsm_code"=>$cgdinfo['wsm_code'], "spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
|
+// if($good1==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1004,"未找到对应商品库存");
|
|
|
+// }
|
|
|
+// $out_num = intval(array_sum(array_column($out,"send_num")));
|
|
|
+// if($out_num>$good1['usable_stock']){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1004,"库存数量不足发货");
|
|
|
+// }
|
|
|
+// $good1['usable_stock']-=$out_num;
|
|
|
+// $good1['wait_out_stock']+=$out_num;
|
|
|
+// $good1['total_stock']=$good1['usable_stock']+$good1['wait_out_stock'];
|
|
|
+// $good1['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+// $upd= Db::name("good_stock")->save($good1);
|
|
|
+// if($upd==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1004,"库存数量更新失败");
|
|
|
+// }
|
|
|
+// $sendp=Db::name("order_send")->where(["cgdNo"=>$info['cgdNo'],"outCode"=>$out,"status"=>1])->save (["status"=>2]);
|
|
|
+// if($sendp==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1004,"库存发货失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
Db::commit();
|
|
|
return app_show(0,'商品入库成功');
|
|
|
}else{
|