add tools request libs, migrate for hyperf framework

This commit is contained in:
2025-11-10 16:48:19 +08:00
parent 5b3b0c70f2
commit 08bb2af2c3
11 changed files with 749 additions and 0 deletions
@@ -0,0 +1,52 @@
<?php
namespace App\Platform\Tools\Request;
use App\Platform\Tools\HttpClient;
use Hyperf\Collection\LazyCollection;
class RefundRequest extends HttpClient
{
const BATCH_SIZE = 50;
public static function find(int $id): array
{
$path = "/api/ext/refunds/$id";
return static::get($path);
}
public static function findByOrder(int $t_store_id, int $t_order_id): array|bool
{
$path = "/api/ext/refunds";
$query = [
'store' => $t_store_id,
'order' => $t_order_id,
];
$response = static::get($path, $query);
if(isset($response['data']) && is_array($response['data']) && count($response['data']) == 1) {
return $response['data']['0'];
}
return false;
}
public static function add(array $data): array
{
$path = "/api/ext/refunds";
return static::post($path, [], $data);
}
public static function update(array $data): array
{
$path = "/api/ext/refunds";
return static::put($path, [], $data);
}
public static function queryByStorePlatformOrderIds(int $t_store_id, array $ids) : array
{
$path = "/api/ext/refunds/batch-query-by-ref-order-ids";
return static::post($path, [], ['store' => $t_store_id, 'orderIds' => $ids]);
}
}