|
@@ -422,7 +422,7 @@ class Orderback extends Base
|
|
|
$goon = Db::name('good')->where(['spuCode' => $sale['good_code']])->find();
|
|
|
$isZx=0;
|
|
|
}
|
|
|
- $spuCode = $this->CheckGood($goon,$isZx);
|
|
|
+ $spuCode = $this->CheckGood($goon,$isZx,$param['thNo']);
|
|
|
}
|
|
|
$out =Db::name("order_out")->where(['outCode'=>$info['outCode']])->find();
|
|
|
if($out==false){
|
|
@@ -764,9 +764,30 @@ class Orderback extends Base
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- private function CheckGood($good,$isZx){
|
|
|
+ /**
|
|
|
+ * @param $good
|
|
|
+ * @param $isZx
|
|
|
+ * @param string $thNo
|
|
|
+ * @return mixed|string
|
|
|
+ * @throws \think\Exception
|
|
|
+ */
|
|
|
+ private function CheckGood($good,$isZx,$thNo=''){
|
|
|
$spuCode= makeNo("SKU");
|
|
|
+ //查询是否存在转库存品记录 存在则返回库存编号
|
|
|
+ $newCode= Db::name("good_change_log")->where(["oldCode"=>$good['spuCode']])->value("newCode",'');
|
|
|
+ if($newCode==''){
|
|
|
+ $log=["oldCode"=>$good['spuCode'],
|
|
|
+ "order_type"=>$isZx,
|
|
|
+ "newCode"=>$spuCode,
|
|
|
+ "thCode"=>$thNo,
|
|
|
+ "createrid"=>$this->uid,
|
|
|
+ "creater"=>$this->uname,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ return $newCode;
|
|
|
+ }
|
|
|
+
|
|
|
if($isZx==1){
|
|
|
$supplier =Db::name("supplier")->where(["code"=>$good['supplierNo']])->findOrEmpty();
|
|
|
if(empty($supplier)) throw new Exception('非库存商品转库存失败');
|
|
@@ -841,6 +862,8 @@ class Orderback extends Base
|
|
|
}
|
|
|
$insert =Db::name("good_basic")->insert($good);
|
|
|
if($insert==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
+ $newAdd=Db::name("good_change_log")->insert($log);
|
|
|
+ if($newAdd==false) throw new \Exception("非库存商品转库存失败",1005);
|
|
|
return $spuCode;
|
|
|
|
|
|
}
|