multi-store/app/admin/logic/inventory_transfer/InventoryTransferLogic.php

91 lines
2.2 KiB
PHP
Raw Normal View History

2024-08-13 18:00:08 +08:00
<?php
namespace app\admin\logic\inventory_transfer;
use app\admin\logic\warehouse_product\WarehouseProductLogic;
2024-08-13 18:00:08 +08:00
use app\common\model\inventory_transfer\InventoryTransfer;
use app\common\logic\BaseLogic;
use app\common\model\store_branch_product\StoreBranchProduct;
2025-01-11 16:15:52 +08:00
use app\common\model\store_product\StoreProduct;
2024-08-13 18:00:08 +08:00
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use support\exception\BusinessException;
2024-08-13 18:00:08 +08:00
use think\facade\Db;
/**
* 商品调拨逻辑
* Class InventoryTransferLogic
* @package app\admin\logic\inventory_transfer
*/
class InventoryTransferLogic extends BaseLogic
{
/**
* @notes 添加商品调拨
* @param array $params
* @return bool
* @author admin
* @date 2024/08/13 16:18
*/
public static function add(array $params,$admin_id=0): bool
2024-08-13 18:00:08 +08:00
{
return true;
2024-08-13 18:00:08 +08:00
}
/**
* @notes 编辑商品调拨
* @param array $params
* @return bool
* @author admin
* @date 2024/08/13 16:18
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
InventoryTransfer::where('id', $params['id'])->update([
'product_id' => $params['product_id'],
'nums' => $params['nums'],
'before_nums' => $params['before_nums'],
'after_nums' => $params['after_nums'],
'type' => $params['type'],
'one_id' => $params['one_id'],
'two_id' => $params['two_id']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
throw new BusinessException($e->getMessage());
2024-08-13 18:00:08 +08:00
}
}
/**
* @notes 删除商品调拨
* @param array $params
* @return bool
* @author admin
* @date 2024/08/13 16:18
*/
public static function delete(array $params): bool
{
return InventoryTransfer::destroy($params['id']);
}
/**
* @notes 获取商品调拨详情
* @param $params
* @return array
* @author admin
* @date 2024/08/13 16:18
*/
public static function detail($params): array
{
return InventoryTransfer::findOrEmpty($params['id'])->toArray();
}
}