|
|
@@ -86,6 +86,67 @@ class AgentDashboardTest extends TestCase
|
|
|
$this->assertSame(0, $rows[$equity->id]['member_count'], 'admin agent report still counts only the equity agent\'s own members');
|
|
|
}
|
|
|
|
|
|
+ public function test_yearly_dashboard_preserves_third_game_date_boundaries_and_finance_totals(): void
|
|
|
+ {
|
|
|
+ Schema::table('users', function (Blueprint $table) {
|
|
|
+ $table->integer('from')->default(1);
|
|
|
+ $table->integer('user_type')->default(0);
|
|
|
+ });
|
|
|
+ Schema::create('third_game_orders', function (Blueprint $table) {
|
|
|
+ $table->id();
|
|
|
+ $table->unsignedBigInteger('user_id')->nullable();
|
|
|
+ $table->integer('status');
|
|
|
+ $table->dateTime('last_update_time');
|
|
|
+ foreach (['bet_amount', 'valid_amount', 'settled_amount'] as $field) {
|
|
|
+ $table->decimal($field, 18, 4)->nullable();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $joint = $this->agent();
|
|
|
+ $equity = $this->agent(Agent::TYPE_EQUITY);
|
|
|
+ $test = $this->agents->create(['username' => 'dashboard-test', 'password' => 'secret1', 'is_test' => 1]);
|
|
|
+ $users = [];
|
|
|
+ foreach ([['own', $joint->id, 1, 0], ['direct', null, 1, 0], ['guest', null, 2, 1], ['simulation', null, 1, 2], ['test', $test->id, 1, 0]] as [$member, $agentId, $from, $userType]) {
|
|
|
+ $users[$member] = DB::table('users')->insertGetId([
|
|
|
+ 'member_id' => $member, 'username' => $member, 'agent_id' => $agentId, 'from' => $from, 'user_type' => $userType,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $from = '2025-09-08';
|
|
|
+ $to = '2026-09-07';
|
|
|
+ foreach ([
|
|
|
+ [$users['own'], 1, "$from 00:00:00", 10, 8, -2],
|
|
|
+ [$users['own'], 1, "$to 23:59:59", 20, null, 5],
|
|
|
+ [$users['direct'], 1, "$to 12:00:00", 40, 35, 7],
|
|
|
+ [$users['own'], 0, "$to 12:00:00", 999, 999, 999],
|
|
|
+ [$users['own'], 1, '2025-09-07 23:59:59', 999, 999, 999],
|
|
|
+ [$users['own'], 1, '2026-09-08 00:00:00', 999, 999, 999],
|
|
|
+ [$users['guest'], 1, "$to 12:00:00", 999, 999, 999],
|
|
|
+ [$users['simulation'], 1, "$to 12:00:00", 999, 999, 999],
|
|
|
+ [$users['test'], 1, "$to 12:00:00", 999, 999, 999],
|
|
|
+ [null, 1, "$to 12:00:00", 999, 999, 999],
|
|
|
+ ] as [$userId, $status, $at, $bet, $valid, $win]) {
|
|
|
+ DB::table('third_game_orders')->insert(['user_id' => $userId, 'status' => $status, 'last_update_time' => $at,
|
|
|
+ 'bet_amount' => $bet, 'valid_amount' => $valid, 'settled_amount' => $win]);
|
|
|
+ }
|
|
|
+ foreach ([['人工充值', null, 40], ['订单补偿', null, 2], ['人工扣款', null, -3], ['注册赠送', null, 1], ['优惠活动', null, 2],
|
|
|
+ ['即充即送', null, 3], ['充值返现', null, 4], ['老用户回归', null, 5], ['人工充值', 0, 6], ['人工充值', 123, 999],
|
|
|
+ ['比比返', null, 1], ['笔笔返', null, 2], ['返水', null, 3], ['回水', null, 4], ['结算', null, 999],
|
|
|
+ ] as [$type, $relatedId, $amount]) {
|
|
|
+ DB::table('balance_logs')->insert(['member_id' => 'own', 'change_type' => $type, 'related_id' => $relatedId,
|
|
|
+ 'amount' => $amount, 'created_at' => "$from 00:00:00"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $reports = new AgentReportService();
|
|
|
+ $betFields = array_flip(['bet_count', 'bet_amount', 'valid_bet_amount', 'win_loss']);
|
|
|
+ $fundFields = array_flip(['manual_credit', 'manual_debit', 'bonus_amount', 'rebate_amount']);
|
|
|
+ $platform = $reports->dashboard($equity, $from, $to);
|
|
|
+ $own = $reports->dashboard($joint, $from, $to);
|
|
|
+ $this->assertSame([3, '70.0000', '43.0000', '10.0000'], array_values(array_intersect_key($platform, $betFields)));
|
|
|
+ $this->assertSame([2, '30.0000', '8.0000', '3.0000'], array_values(array_intersect_key($own, $betFields)));
|
|
|
+ $this->assertSame(['42.0000', '3.0000', '21.0000', '10.0000'], array_values(array_intersect_key($platform, $fundFields)));
|
|
|
+ $this->assertSame(array_intersect_key($platform, $fundFields), array_intersect_key($own, $fundFields));
|
|
|
+ }
|
|
|
+
|
|
|
public function test_charts_group_registrations_and_deduplicate_successful_daily_deposits_across_channels(): void
|
|
|
{
|
|
|
$agent = $this->agent();
|