weizong song 4 months ago
parent 40b2687111
commit bd154f39f2

@ -40,10 +40,11 @@ class ChannelEntryController extends Controller
[$user, $application, $token] = DB::transaction(function () use ($channel, $competition, $parameters): array {
$enteredAt = now();
$name = $this->nullableTrimmed($parameters['name']);
$company = $this->nullableTrimmed($parameters['company_name']);
$user = User::query()->firstOrCreate(
['mobile' => $parameters['mobile']],
['name' => null, 'email' => null, 'company' => $company, 'password' => null]
['name' => $name, 'email' => null, 'company' => $company, 'password' => null]
);
if ($user->wasRecentlyCreated) {
@ -59,6 +60,9 @@ class ChannelEntryController extends Controller
'last_channel_code' => $channel->channel_code,
'last_channel_entered_at' => $enteredAt,
];
if ($name !== null) {
$userPayload['name'] = $name;
}
if ($company !== null) {
$userPayload['company'] = $company;
}

@ -165,6 +165,7 @@ class ChannelSignupIntegrationTest extends TestCase
$this->assertSame('CHANNEL-A', $user->first_channel_code);
$this->assertSame('CHANNEL-A', $user->last_channel_code);
$this->assertSame('张三', $user->name);
$this->assertSame('测试企业', $user->company);
$this->assertSame('CHANNEL-A', $application->signup_channel_code);
$this->assertSame('draft', $application->status);
@ -205,6 +206,7 @@ class ChannelSignupIntegrationTest extends TestCase
$this->get('/channel-entry?'.http_build_query($legacyParameters))
->assertOk()
->assertSee('/admin/c/main-event/apply', false);
$this->assertSame('旧渠道用户', User::query()->where('mobile', '13600136000')->value('name'));
$this->assertSame('旧渠道企业', User::query()->where('mobile', '13600136000')->value('company'));
$legacyParameters['company_name'] = '旧渠道&企业';
$legacyParameters['hash'] = ChannelEntrySignature::make($legacyParameters, $legacyChannel->shared_secret);
@ -259,6 +261,7 @@ class ChannelSignupIntegrationTest extends TestCase
])->save();
$this->get('/channel-entry?'.http_build_query($this->signed($channelB, [
'name' => '李四',
'company_name' => '新渠道企业',
'state' => 'state-B',
])))
@ -268,9 +271,11 @@ class ChannelSignupIntegrationTest extends TestCase
$application->refresh();
$this->assertSame('CHANNEL-A', $user->first_channel_code);
$this->assertSame('CHANNEL-B', $user->last_channel_code);
$this->assertSame('李四', $user->name);
$this->assertSame('新渠道企业', $user->company);
$this->assertSame('CHANNEL-B', $application->signup_channel_code);
$this->assertSame('state-B', $application->signup_channel_state);
$this->assertSame('保留姓名', $application->player_name);
$this->assertSame('保留企业', $application->company_name);
$this->assertSame('保留项目', $application->project_name);

Loading…
Cancel
Save