1.对局新增查看异常订单
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\admin\controller\game;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use support\think\Db;
|
||||
use support\Response;
|
||||
use Webman\Http\Request as WebmanRequest;
|
||||
|
||||
@@ -66,4 +67,93 @@ class Record extends Backend
|
||||
}
|
||||
return $this->error('游戏对局记录不可删除');
|
||||
}
|
||||
|
||||
public function abnormalList(WebmanRequest $request): Response
|
||||
{
|
||||
$response = $this->initializeBackend($request);
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$limitRaw = $request->get('limit', 30);
|
||||
$limit = is_numeric((string) $limitRaw) ? (int) $limitRaw : 30;
|
||||
if ($limit < 1) {
|
||||
$limit = 1;
|
||||
}
|
||||
if ($limit > 200) {
|
||||
$limit = 200;
|
||||
}
|
||||
|
||||
$rows = Db::name('game_record')
|
||||
->where('status', 5)
|
||||
->whereLike('void_reason', 'system_recover:%')
|
||||
->field(['id', 'period_no', 'void_reason', 'update_time'])
|
||||
->order('id', 'desc')
|
||||
->limit($limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$list = [];
|
||||
foreach ($rows as $row) {
|
||||
$meta = $this->parseRecoverVoidReason(is_string($row['void_reason'] ?? null) ? $row['void_reason'] : '');
|
||||
$list[] = [
|
||||
'id' => (int) ($row['id'] ?? 0),
|
||||
'period_no' => (string) ($row['period_no'] ?? ''),
|
||||
'abnormal_from_status' => $meta['from_status'],
|
||||
'refunded_user_count' => $meta['users'],
|
||||
'refunded_order_count' => $meta['orders'],
|
||||
'refunded_total_amount' => $meta['amount'],
|
||||
'recovered_at' => (int) ($row['update_time'] ?? 0),
|
||||
'void_reason' => (string) ($row['void_reason'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->success('', [
|
||||
'list' => $list,
|
||||
'total' => count($list),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{from_status:int,users:int,orders:int,amount:string}
|
||||
*/
|
||||
private function parseRecoverVoidReason(string $reason): array
|
||||
{
|
||||
$meta = [
|
||||
'from_status' => -1,
|
||||
'users' => 0,
|
||||
'orders' => 0,
|
||||
'amount' => '0.00',
|
||||
];
|
||||
if ($reason === '' || str_starts_with($reason, 'system_recover:') === false) {
|
||||
return $meta;
|
||||
}
|
||||
$payload = substr($reason, strlen('system_recover:'));
|
||||
$parts = explode('|', $payload);
|
||||
foreach ($parts as $part) {
|
||||
$item = trim($part);
|
||||
if ($item === '' || !str_contains($item, '=')) {
|
||||
continue;
|
||||
}
|
||||
[$key, $value] = explode('=', $item, 2);
|
||||
$key = trim($key);
|
||||
$value = trim($value);
|
||||
if ($key === 'from' && is_numeric($value)) {
|
||||
$meta['from_status'] = (int) $value;
|
||||
continue;
|
||||
}
|
||||
if ($key === 'users' && is_numeric($value)) {
|
||||
$meta['users'] = (int) $value;
|
||||
continue;
|
||||
}
|
||||
if ($key === 'orders' && is_numeric($value)) {
|
||||
$meta['orders'] = (int) $value;
|
||||
continue;
|
||||
}
|
||||
if ($key === 'amount' && $value !== '') {
|
||||
$meta['amount'] = $value;
|
||||
}
|
||||
}
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user