|
@@ -62,7 +62,8 @@ class CombindStock extends Base
|
|
|
if($isT->usable_stock< $param['stock_num'])return error_show(1004,'商品库存数不足');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ $isTs = $this->combindStock->where(["spuCode"=>$param['spuCode'],"status"=>1])->findOrEmpty();
|
|
|
+ if($isTs->isEmpty()==false) return error_show(1004,"组合商品库存变化存在未完成得流程{$isTs->stockCode}");
|
|
|
$combindList = $this->combind->where(["spuCode"=>$param["spuCode"],"is_del"=>0])->select()->toArray();
|
|
|
if(empty($combindList)) return error_show(1004,"未找到组合商品的商品组合信息");
|
|
|
$childarr= Db::name('good')->whereIn('spuCode',array_unique(array_column($combindList,'childCode')))->column("spuCode,usable_stock,is_combind","spuCode");
|
|
@@ -86,7 +87,7 @@ class CombindStock extends Base
|
|
|
if($up==false) throw new \Exception("创建失败");
|
|
|
if($param["flag"]==0){
|
|
|
if($isT->isEmpty()==false){
|
|
|
- $stockup = Db::name('good')->where('spuCode',$param['spuCode'])->dec('usable_stock',$param["stock_num"])->update();
|
|
|
+ $stockup = Db::name('good')->where('spuCode',$param['spuCode'])->dec('usable_stock',intval($param['stock_num']))->update();
|
|
|
if($stockup==false) throw new \Exception('组合商品库存占用失败');
|
|
|
}
|
|
|
$stock->usable_stock = bcsub($stock->usable_stock,$param['stock_num']);
|
|
@@ -107,7 +108,7 @@ class CombindStock extends Base
|
|
|
$bnArr=array_merge($bnArr,$bnlist);
|
|
|
}
|
|
|
if(empty($bnArr)) throw new \Exception('组合商品的子商品信息库存占用失败');
|
|
|
- (new CombindBninfo())->AaddBNLog($param['spuCode'],$data['bnCode'],$bnArr);
|
|
|
+ (new CombindBninfo())->AaddBNLog($param['spuCode'],$data['bnCode'],$bnArr,$stockCode);
|
|
|
}
|
|
|
$this->combindStock->commit();
|
|
|
}catch (\Exception $exception){
|
|
@@ -183,7 +184,7 @@ class CombindStock extends Base
|
|
|
$origin_price = $origin['nake_total'];
|
|
|
$stcoc=GoodStockInfo::AddBn(intval($id),$bn,intval($row->stock_num),floatval($origin_price) );
|
|
|
if($stcoc==false) throw new \Exception( '组合商品bn库存生成失败');
|
|
|
- $stockCodeLog= (new CombindStockInfo())->save(["stockCode"=>$row->stockCode,"flag"=>1,
|
|
|
+ $stockCodeLog= $this->combindStockInfo->save(["stockCode"=>$row->stockCode,"flag"=>1,
|
|
|
"stock_num"=>$row->stock_num,"bnCode"=>$bn,"origin_price"=>$origin_price]);
|
|
|
if($stockCodeLog==false)throw new \Exception( '组合商品bn库存生成失败');
|
|
|
}
|
|
@@ -191,8 +192,11 @@ class CombindStock extends Base
|
|
|
$up =GoodStockInfo::StockBnSub($stock->id,intval($row->stock_num));
|
|
|
if(empty($up)) throw new \Exception('未找到对应子商品BN库存信息');
|
|
|
foreach ($up as $item){
|
|
|
- $bnlist =$this->combind->subStock($row->spuCode,$item['bnCode'],$item['num']);
|
|
|
+ $bnlist =$this->combind->subStock($row->spuCode,$item['bnCode'],$item['num'],$row->stockCode);
|
|
|
if($bnlist==false)throw new \Exception('子商品BN库存信息更新失败');
|
|
|
+ $stockLog=$this->combindStockInfo->save(["stockCode"=>$row->stockCode,"flag"=>$row->flag,
|
|
|
+ 'stock_num'=>$item['num'],'bnCode'=>$item['bnCode'],'origin_price'=>$item['origin_price']]);
|
|
|
+ if($stockLog==false)throw new \Exception( '组合商品bn库存修改失败');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -208,10 +212,9 @@ class CombindStock extends Base
|
|
|
$reld=$stock->save();
|
|
|
if($reld==false) throw new \Exception('组合商品库存解除驳回失败');
|
|
|
}else{
|
|
|
-
|
|
|
- $bnlist =$this->combind->subStock($row->spuCode,$row->bnCode,$row->stock_num);
|
|
|
- if($bnlist==false)throw new \Exception('子商品BN库存信息更新失败');
|
|
|
-
|
|
|
+ $bnlist =$this->combind->subStock($row->spuCode,$row->bnCode,$row->stock_num,
|
|
|
+ $row->stockCode,1);
|
|
|
+ if($bnlist==false)throw new \Exception('子商品BN库存信息更新失败');
|
|
|
}
|
|
|
}
|
|
|
|