87 lines
2.3 KiB
PHP
87 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Platform\Tools\Request;
|
||
|
|
|
||
|
|
use App\Platform\Tools\HttpClient;
|
||
|
|
|
||
|
|
class WarehouseInventoryRequest extends HttpClient
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
public static function find(int $id): array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory/$id";
|
||
|
|
return static::get($path);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 根据仓库物品条件查询库存记录
|
||
|
|
*
|
||
|
|
* @param string $sku SKU编号
|
||
|
|
* @param string $barcode 条形码
|
||
|
|
* @param int $companyId 公司ID
|
||
|
|
* @param int $warehouseId 仓库ID
|
||
|
|
* @param string $warehouseSubId 子仓库ID
|
||
|
|
* @param int $inventoryType 库存类型,默认为1(良品库存)
|
||
|
|
* @return array|null 返回库存记录或null
|
||
|
|
*/
|
||
|
|
public static function findByWarehouseItem(
|
||
|
|
string $sku,
|
||
|
|
string $barcode,
|
||
|
|
int $companyId,
|
||
|
|
int $warehouseId,
|
||
|
|
string $warehouseSubId,
|
||
|
|
int $inventoryType = 1
|
||
|
|
): array|null {
|
||
|
|
$path = "/api/ext/warehouse-inventory";
|
||
|
|
$query = [
|
||
|
|
'sku' => $sku,
|
||
|
|
'barcode' => $barcode,
|
||
|
|
'company_id' => $companyId,
|
||
|
|
'warehouse_id' => $warehouseId,
|
||
|
|
'warehouse_sub_id' => $warehouseSubId,
|
||
|
|
'inventory_type' => $inventoryType,
|
||
|
|
];
|
||
|
|
|
||
|
|
$response = static::get($path, $query);
|
||
|
|
|
||
|
|
if (isset($response['data']) && is_array($response['data']) && count($response['data']) == 1) {
|
||
|
|
return $response['data'][0];
|
||
|
|
}
|
||
|
|
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function add(array $data): array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory";
|
||
|
|
return static::post($path, [], $data);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function update(int $id, array $data): array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory/$id";
|
||
|
|
return static::put($path, [], $data);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function list(array $query) : array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory";
|
||
|
|
return static::get($path, $query);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function remove(int $id): array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory/$id";
|
||
|
|
return static::delete($path);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public static function updateHistory(array $data): array
|
||
|
|
{
|
||
|
|
$path = "/api/ext/warehouse-inventory-history";
|
||
|
|
return static::post($path, [], $data);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|