feat: 增强奖池与钱包管理功能
更新 AdminJackpotPoolUpdateController 校验规则,禁止传入 current_amount。 优化 AdminRiskPoolManualStatusController:更新奖池状态后同步 Redis 状态。 在 TransferOrderReconcileController 中新增 completeCredit 方法,用于处理卡住的转账订单对账。 调整 TransferOrderListController:优化转账订单处理条件。 在 TicketItemsIndexController 中实现支持时区的日期筛选,提升日期处理准确性。 扩展 JackpotPool 模型,新增 adjustments 关联关系。 改进票据与钱包相关服务中的错误处理和事务管理。
This commit is contained in:
@@ -61,14 +61,14 @@ final class TicketDrawMyMatchController extends Controller
|
||||
$itemIds = TicketItem::query()
|
||||
->where('draw_id', $draw->id)
|
||||
->where('player_id', $player->id)
|
||||
->whereIn('status', ['pending_draw', 'settled_win', 'settled_lose'])
|
||||
->whereIn('status', ['pending_draw', 'pending_payout', 'settled_win', 'settled_lose'])
|
||||
->pluck('id');
|
||||
|
||||
$hasBets = $itemIds->isNotEmpty();
|
||||
$winningItemIds = TicketItem::query()
|
||||
->where('draw_id', $draw->id)
|
||||
->where('player_id', $player->id)
|
||||
->where('status', 'settled_win')
|
||||
->whereIn('status', ['settled_win', 'pending_payout'])
|
||||
->where(function ($q): void {
|
||||
$q->where('win_amount', '>', 0)
|
||||
->orWhere('jackpot_win_amount', '>', 0);
|
||||
@@ -90,7 +90,7 @@ final class TicketDrawMyMatchController extends Controller
|
||||
$sums = TicketItem::query()
|
||||
->where('draw_id', $draw->id)
|
||||
->where('player_id', $player->id)
|
||||
->whereIn('status', ['settled_win', 'settled_lose'])
|
||||
->whereIn('status', ['settled_win', 'settled_lose', 'pending_payout'])
|
||||
->selectRaw('coalesce(sum(win_amount),0) as sum_win, coalesce(sum(jackpot_win_amount),0) as sum_jackpot')
|
||||
->first();
|
||||
|
||||
|
||||
@@ -62,12 +62,13 @@ final class TicketItemShowController extends Controller
|
||||
->where('biz_no', $order?->order_no)
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
$payoutTxn = WalletTxn::query()
|
||||
->where('player_id', $player->id)
|
||||
->where('biz_type', 'settle_payout')
|
||||
->where('biz_no', 'like', 'SB%')
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
$payoutTxn = $settlementBatch !== null
|
||||
? WalletTxn::query()
|
||||
->where('player_id', $player->id)
|
||||
->where('biz_type', 'settle_payout')
|
||||
->where('biz_no', 'SB'.$settlementBatch->id)
|
||||
->first()
|
||||
: null;
|
||||
|
||||
$timeline = [];
|
||||
if ($order?->created_at !== null) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Ticket;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Player;
|
||||
use App\Models\TicketItem;
|
||||
use App\Models\WalletTxn;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Support\PaginationTrait;
|
||||
@@ -65,11 +65,13 @@ final class TicketItemsIndexController extends Controller
|
||||
}
|
||||
|
||||
if ($startDate !== null) {
|
||||
$query->whereHas('order', fn ($q) => $q->whereDate('created_at', '>=', $startDate));
|
||||
$fromUtc = $this->scheduleDateStartUtc($startDate);
|
||||
$query->whereHas('order', fn ($q) => $q->where('created_at', '>=', $fromUtc));
|
||||
}
|
||||
|
||||
if ($endDate !== null) {
|
||||
$query->whereHas('order', fn ($q) => $q->whereDate('created_at', '<=', $endDate));
|
||||
$toUtc = $this->scheduleDateEndUtc($endDate);
|
||||
$query->whereHas('order', fn ($q) => $q->where('created_at', '<=', $toUtc));
|
||||
}
|
||||
|
||||
$paginator = $query->paginate(perPage: $perPage, page: $page);
|
||||
@@ -119,4 +121,23 @@ final class TicketItemsIndexController extends Controller
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function scheduleTimezone(): string
|
||||
{
|
||||
return (string) config('lottery.draw.timezone', 'UTC');
|
||||
}
|
||||
|
||||
private function scheduleDateStartUtc(string $ymd): Carbon
|
||||
{
|
||||
return Carbon::createFromFormat('Y-m-d', $ymd, $this->scheduleTimezone())
|
||||
->startOfDay()
|
||||
->utc();
|
||||
}
|
||||
|
||||
private function scheduleDateEndUtc(string $ymd): Carbon
|
||||
{
|
||||
return Carbon::createFromFormat('Y-m-d', $ymd, $this->scheduleTimezone())
|
||||
->endOfDay()
|
||||
->utc();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user