Merge pull request 'feat: 修改仓库产品逻辑和库存发送队列,增加财务PM判断逻辑' (#74) from erp into rose

Reviewed-on: #74
This commit is contained in:
mkm 2024-08-01 16:47:05 +08:00
commit af6e8e2387
2 changed files with 13 additions and 5 deletions

View File

@ -51,7 +51,7 @@ class WarehouseProductLogic extends BaseLogic
$data['expiration_date']=strtotime($params['expiration_date']); $data['expiration_date']=strtotime($params['expiration_date']);
} }
$res=WarehouseProduct::create($data); $res=WarehouseProduct::create($data);
self::enter($res['id']); self::enter($res['id'],$params['financial_pm']);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -107,18 +107,27 @@ class WarehouseProductLogic extends BaseLogic
* @author admin * @author admin
* @date 2024/07/31 16:55 * @date 2024/07/31 16:55
*/ */
public static function enter($id) public static function enter($id,$financial_pm=0)
{ {
Db::startTrans(); Db::startTrans();
try { try {
$find=WarehouseProduct::where('id',$id)->find(); $find=WarehouseProduct::where('id',$id)->find();
$find->status=1; $find->status=1;
$find->save(); $find->save();
StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update();
$storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find(); $storege=WarehouseProductStorege::where('warehouse_id',$find['warehouse_id'])->where('product_id',$find['product_id'])->find();
if($financial_pm==0){
StoreProduct::where('id',$find['product_id'])->dec('stock',$find['nums'])->update();
}else{
StoreProduct::where('id',$find['product_id'])->inc('stock',$find['nums'])->update();
}
if($storege){ if($storege){
$storege->nums=$storege->nums+$find['nums']; if($financial_pm==0){
$storege->nums=bcsub($storege->nums,$find['nums']);
}else{
$storege->nums=bcadd($storege->nums,$find['nums']);
}
$storege->save(); $storege->save();
}else{ }else{
WarehouseProductStorege::create([ WarehouseProductStorege::create([
'warehouse_id' => $find['warehouse_id'], 'warehouse_id' => $find['warehouse_id'],

View File

@ -191,7 +191,6 @@ class StoreStorageSend implements Consumer
} else { } else {
SystemStoreStorage::create($storage); SystemStoreStorage::create($storage);
WarehouseProductLogic::add($data); WarehouseProductLogic::add($data);
StoreProduct::where('id', $product_arr['id'])->dec('stock', $product_arr['stock'])->update();
} }
} }