添加复制到仓库

This commit is contained in:
lewis 2025-03-22 11:45:20 +08:00
parent fcef927257
commit 0fc761e915
2 changed files with 40 additions and 0 deletions

View File

@ -124,6 +124,18 @@ class StoreProductController extends BaseAdminController
return $this->success('复制成功', [], 1, 1);
}
/**
* @notes 复制商品到仓库
* @author likeadmin
* @date 2024/05/31 10:53
*/
public function copyWarehouse()
{
$params = $this->request->post();
StoreProductLogic::copyWarehouse($params);
return $this->success('复制成功', [], 1, 1);
}
/**
* 商品导入到门店
*/

View File

@ -462,4 +462,32 @@ class StoreProductLogic extends BaseLogic
// }
// }
}
/**
* 复制商品到仓库
* @param $params
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function copyWarehouse($params)
{
$exist = WarehouseProductStorege::where(['product_id' => $params['product_id'], 'warehouse_id' => $params['warehouse_id']])->find();
if ($exist) {
throw new BusinessException('该商品已存在该仓库');
}
$storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty();
if (!$storeProduct) {
throw new BusinessException('商品不存在');
}
$data = [
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'nums' => 0,
'total_price' => 0
];
WarehouseProductStorege::create($data);
}
}