feat: 修改了仓库产品逻辑和仓库产品库存逻辑,增加了产品ID到仓库产品的存储中,并修复了相关操作的错误。同时删除了仓库产品库存模型,并更新了相关文档。

This commit is contained in:
mkm 2024-08-13 12:00:00 +08:00
parent ea4716f661
commit f57cebc649
4 changed files with 5 additions and 41 deletions

View File

@ -89,7 +89,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
}
if($item->product_id){
$find=StoreProduct::where('id',$item->product_id)->field('image,store_name')->find();
$item->store_name=$find->store_name;
$item->store_name=$find->store_name.'|'.$item->product_id;
$item->image=$find->image;
}else{
$item->store_name='';

View File

@ -148,7 +148,7 @@ class WarehouseProductLogic extends BaseLogic
if ($res) {
$res->delete();
if ($res['financial_pm'] == 1) {
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->dec('nums', $res['nums'])->update();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id',$res['product_id'])->dec('nums', $res['nums'])->update();
} elseif ($res['financial_pm'] == 0) {
$find = SystemStoreStorage::where(['outbound_id' => $res['id']])->find();
if ($find) {
@ -162,7 +162,7 @@ class WarehouseProductLogic extends BaseLogic
}
$find->delete();
}
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->inc('nums', $res['nums'])->update();
WarehouseProductStorege::where('warehouse_id', $res['warehouse_id'])->where('product_id',$res['product_id'])->inc('nums', $res['nums'])->update();
}
return true;

View File

@ -26,24 +26,7 @@ class WarehouseProductStoregeLogic extends BaseLogic
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
WarehouseProductStorege::create([
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'nums' => $params['nums'],
'price' => $params['price'],
'total_price' => $params['total_price'],
'status' => $params['status']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
return true;
}
@ -57,24 +40,6 @@ class WarehouseProductStoregeLogic extends BaseLogic
public static function edit(array $params): bool
{
return true;
Db::startTrans();
try {
WarehouseProductStorege::where('id', $params['id'])->update([
'warehouse_id' => $params['warehouse_id'],
'product_id' => $params['product_id'],
'nums' => $params['nums'],
'price' => $params['price'],
'total_price' => $params['total_price'],
'status' => $params['status']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
@ -100,6 +65,6 @@ class WarehouseProductStoregeLogic extends BaseLogic
*/
public static function detail($params): array
{
return WarehouseProductStorege::findOrEmpty($params['id'])->toArray();
return [];
}
}

View File

@ -10,7 +10,6 @@ use app\common\model\store_branch_product_exchange\StoreBranchProductExchange;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_attr_value\StoreProductAttrValue;
use app\common\model\system_store_storage\SystemStoreStorage;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use Webman\RedisQueue\Consumer;
use support\Log;
use think\facade\Db;