|
@@ -208,7 +208,7 @@ class SimulationTest extends TestCase
|
|
|
[$member] = array_column(SimulationMemberService::create(1, ['initial_balance' => 1000]), 'member_id');
|
|
[$member] = array_column(SimulationMemberService::create(1, ['initial_balance' => 1000]), 'member_id');
|
|
|
$ledgerCount = DB::table('balance_logs')->count();
|
|
$ledgerCount = DB::table('balance_logs')->count();
|
|
|
LotteryOdds::setOdds('canada28', null, ['id' => 1, 'odds' => '0', 'mininum' => 1, 'maxinum' => 100]);
|
|
LotteryOdds::setOdds('canada28', null, ['id' => 1, 'odds' => '0', 'mininum' => 1, 'maxinum' => 100]);
|
|
|
- $this->assertSame([], SimulationBetService::options()['lottery']['rules']->all());
|
|
|
|
|
|
|
+ $this->assertSame([], SimulationBetService::options('canada28')['lottery']['rules']);
|
|
|
try {
|
|
try {
|
|
|
SimulationBetService::lottery($member, '大', 10);
|
|
SimulationBetService::lottery($member, '大', 10);
|
|
|
$this->fail('The active default template has disabled this play');
|
|
$this->fail('The active default template has disabled this play');
|
|
@@ -222,8 +222,8 @@ class SimulationTest extends TestCase
|
|
|
DB::table('config')->where('field', 'pc28_switch')->update(['val' => '1']);
|
|
DB::table('config')->where('field', 'pc28_switch')->update(['val' => '1']);
|
|
|
DB::table('pc_issues')->insert(['issue_no' => '2200001', 'start_time' => now(), 'end_time' => now()->addMinutes(5), 'status' => 1]);
|
|
DB::table('pc_issues')->insert(['issue_no' => '2200001', 'start_time' => now(), 'end_time' => now()->addMinutes(5), 'status' => 1]);
|
|
|
LotteryOdds::setOdds('jisu28', null, ['id' => 1, 'odds' => '3.25', 'mininum' => 10, 'maxinum' => 20]);
|
|
LotteryOdds::setOdds('jisu28', null, ['id' => 1, 'odds' => '3.25', 'mininum' => 10, 'maxinum' => 20]);
|
|
|
- $rules = SimulationBetService::options()['lottery']['rules'];
|
|
|
|
|
- $this->assertSame(['keywords' => '大', 'odds' => '3.25', 'mininum' => 10, 'maxinum' => 20], $rules->first());
|
|
|
|
|
|
|
+ $rules = SimulationBetService::options('jisu28')['lottery']['rules'];
|
|
|
|
|
+ $this->assertSame(['id' => null, 'keywords' => '大', 'odds' => '3.25', 'mininum' => 10, 'maxinum' => 20], $rules[0]);
|
|
|
try {
|
|
try {
|
|
|
SimulationBetService::lottery($member, '大', 21);
|
|
SimulationBetService::lottery($member, '大', 21);
|
|
|
$this->fail('The selected template caps the stake at 20');
|
|
$this->fail('The selected template caps the stake at 20');
|
|
@@ -431,6 +431,68 @@ class SimulationTest extends TestCase
|
|
|
$this->assertSame($before, $this->realView());
|
|
$this->assertSame($before, $this->realView());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 非 PC28 彩种:注单格式与前台一致(玩法编号、彩种 type、期号规则、流水类型),封盘时不能下。 */
|
|
|
|
|
+ public function test_other_lotteries_bet_on_real_issues_in_the_front_end_order_format(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (['jisu_gameplay', 'lhc_number'] as $table) Schema::table($table, function (Blueprint $t) use ($table) {
|
|
|
|
|
+ $t->string('gameplay')->nullable(); $t->string('number')->nullable();
|
|
|
|
|
+ if ($table === 'lhc_number') $t->string('game')->nullable();
|
|
|
|
|
+ });
|
|
|
|
|
+ Schema::table('lhc_order', function (Blueprint $t) { $t->string('game')->nullable(); $t->string('gameplay')->nullable(); });
|
|
|
|
|
+ Schema::table('lhc_order_item', fn (Blueprint $t) => $t->integer('number_id')->nullable());
|
|
|
|
|
+ foreach (['jisu_lottery', 'lhc_lottery'] as $table) Schema::create($table, function (Blueprint $t) {
|
|
|
|
|
+ $t->id(); $t->string('issue'); $t->integer('type'); $t->integer('status')->default(1); $t->integer('open_time')->nullable();
|
|
|
|
|
+ $t->integer('next_open_time')->nullable(); $t->string('next_issue')->nullable();
|
|
|
|
|
+ });
|
|
|
|
|
+ $racing = DB::table('jisu_gameplay')->insertGetId(['type' => 1, 'gameplay' => '冠军', 'number' => '大', 'odds' => '1.98', 'mininum' => 1, 'maxinum' => 1000]);
|
|
|
|
|
+ $combo = DB::table('jisu_gameplay')->insertGetId(['type' => 1, 'gameplay' => '连码', 'number' => '1,2', 'odds' => '5', 'mininum' => 1, 'maxinum' => 1000]);
|
|
|
|
|
+ $zodiac = DB::table('lhc_number')->insertGetId(['game' => '特码', 'gameplay' => '特码A', 'number' => '08', 'odds' => '47', 'mininum' => 1, 'maxinum' => 1000]);
|
|
|
|
|
+ foreach ([['jisu:1', $racing, '1.98'], ['jisu:1', $combo, '5'], ['lhc:2', $zodiac, '47'], ['lhc:1', $zodiac, '47']] as [$key, $id, $odds]) {
|
|
|
|
|
+ LotteryOdds::setOdds($key, null, ['id' => $id, 'odds' => $odds, 'mininum' => 1, 'maxinum' => 1000]);
|
|
|
|
|
+ }
|
|
|
|
|
+ DB::table('jisu_lottery')->insert(['issue' => '20261113001', 'type' => 1, 'status' => 1, 'open_time' => time() + 120]);
|
|
|
|
|
+ DB::table('lhc_lottery')->insert([['issue' => '2026130', 'type' => 2, 'status' => 1, 'next_open_time' => time() + 3600, 'next_issue' => '2026131'],
|
|
|
|
|
+ ['issue' => '2026317', 'type' => 1, 'status' => 1, 'next_open_time' => null, 'next_issue' => null]]);
|
|
|
|
|
+ $before = $this->realView();
|
|
|
|
|
+ [$member] = array_column(SimulationMemberService::create(1, ['initial_balance' => 1000]), 'member_id');
|
|
|
|
|
+
|
|
|
|
|
+ $games = array_column(SimulationBetService::options('jisu:1')['lottery']['games'], null, 'key');
|
|
|
|
|
+ $this->assertSame(['canada28', 'lhc:1', 'lhc:2', 'lhc:3', 'lhc:4', 'jisu:1', 'jisu:2', 'jisu:3', 'jisu:4', 'jisu:5', 'jisu:6', 'jisu:7'], array_keys($games));
|
|
|
|
|
+ $this->assertSame([true, '20261113001', 7, false], [$games['jisu:1']['open'], $games['jisu:1']['issue'], $games['jisu:1']['type'], $games['jisu:2']['open']]);
|
|
|
|
|
+ $this->assertSame('2026131', $games['lhc:2']['issue'], 'Hong Kong bets on the next issue');
|
|
|
|
|
+ $rules = SimulationBetService::options('jisu:1')['lottery']['rules'];
|
|
|
|
|
+ $this->assertSame([[$racing, '冠军 大']], array_map(fn ($rule) => [$rule['id'], $rule['keywords']], $rules), 'plays that need several numbers are not offered');
|
|
|
|
|
+
|
|
|
|
|
+ $order = SimulationBetService::lottery($member, '', 10, 'jisu:1', $racing);
|
|
|
|
|
+ $this->assertSame([7, '20261113001', '冠军', 'simulation', '1.98'], [(int) $order->type, $order->issue, $order->gameplay, $order->bet_source, (string) $order->odds]);
|
|
|
|
|
+ $this->assertSame([$racing, '大'], [(int) DB::table('lhc_order_item')->where('ordernum', $order->ordernum)->value('number_id'), DB::table('lhc_order_item')->where('ordernum', $order->ordernum)->value('number')]);
|
|
|
|
|
+ $hk = SimulationBetService::lottery($member, '', 20, 'lhc:2', $zodiac);
|
|
|
|
|
+ $this->assertSame([2, '2026131', '特码', '特码A'], [(int) $hk->type, $hk->issue, $hk->game, $hk->gameplay]);
|
|
|
|
|
+ if (date('H:i') < '21:30' || date('H:i') > '21:40') {
|
|
|
|
|
+ $this->assertSame('2026318', SimulationBetService::lottery($member, '', 5, 'lhc:1', $zodiac)->issue, 'New Macau bets on the issue after the latest draw');
|
|
|
|
|
+ $this->assertSame(-5.0, (float) DB::table('balance_logs')->where('member_id', $member)->where('change_type', '新澳门六合彩投注')->sum('amount'));
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->assertSame([-10.0, -20.0], [(float) DB::table('balance_logs')->where('member_id', $member)->where('change_type', '极速赛车投注')->sum('amount'),
|
|
|
|
|
+ (float) DB::table('balance_logs')->where('member_id', $member)->where('change_type', '香港六合彩投注')->sum('amount')]);
|
|
|
|
|
+
|
|
|
|
|
+ // 自动任务的彩票下注在所有开盘的彩种里随机选
|
|
|
|
|
+ $types = [];
|
|
|
|
|
+ for ($i = 0; $i < 40; $i++) $types[(int) SimulationBetService::lotteryRandom($member, 1)->type] = true;
|
|
|
|
|
+ $this->assertArrayHasKey(7, $types);
|
|
|
|
|
+ $this->assertArrayHasKey(2, $types);
|
|
|
|
|
+ $this->assertArrayHasKey(5, $types);
|
|
|
|
|
+
|
|
|
|
|
+ // 封盘:开奖前 15 秒内、状态为封盘都不能下
|
|
|
|
|
+ DB::table('jisu_lottery')->update(['open_time' => time() + 10]);
|
|
|
|
|
+ try { SimulationBetService::lottery($member, '', 10, 'jisu:1', $racing); $this->fail('closed before the draw'); }
|
|
|
|
|
+ catch (\Exception $e) { $this->assertStringContainsString('封盘', $e->getMessage()); }
|
|
|
|
|
+ try { SimulationBetService::lottery($member, '', 10, 'jisu:2', $racing); $this->fail('no issue'); }
|
|
|
|
|
+ catch (\Exception $e) { $this->assertStringContainsString('封盘', $e->getMessage()); }
|
|
|
|
|
+ try { SimulationBetService::lottery($member, '', 10, 'jisu:1', $combo + 99); $this->fail('unknown play'); }
|
|
|
|
|
+ catch (\Exception $e) { $this->assertStringContainsString('封盘', $e->getMessage()); }
|
|
|
|
|
+ $this->assertSame($before, $this->realView());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function test_guards_refuse_real_members_and_a_closed_switch(): void
|
|
public function test_guards_refuse_real_members_and_a_closed_switch(): void
|
|
|
{
|
|
{
|
|
|
foreach ([fn () => SimulationFundService::recharge('r1', 10), fn () => SimulationFundService::adjust('g1', 10, 'credit', 'x'),
|
|
foreach ([fn () => SimulationFundService::recharge('r1', 10), fn () => SimulationFundService::adjust('g1', 10, 'credit', 'x'),
|