fix: preserve channel code params for miniapp signup
This commit is contained in:
@@ -122,7 +122,7 @@ class RoutineServices extends BaseServices
|
||||
$wechatInfo['spread_code'] = $spread_code;
|
||||
$wechatInfo['session_key'] = $userInfoConfig['session_key'] ?? '';
|
||||
$wechatInfo['phone'] = $phone;
|
||||
$createData = [$openid, $wechatInfo, $spread_uid, 'routine', 'routine'];
|
||||
[$openid, $wechatInfo, $spread_uid, $login_type, $userType] = $createData = $this->routineOauth($wechatInfo);
|
||||
}
|
||||
/** @var WechatUserServices $wechatUserServices */
|
||||
$wechatUserServices = app()->make(WechatUserServices::class);
|
||||
@@ -268,20 +268,44 @@ class RoutineServices extends BaseServices
|
||||
$routineInfo['user_type'] = 'routine';//用户类型
|
||||
$routineInfo['phone'] = $routine['phone'] ?? $routine['purePhoneNumber'] ?? '';
|
||||
$spread_uid = (int)($routine['spread_uid'] ?? 0);//绑定关系uid
|
||||
if (!$spread_uid && isset($routine['spread_code']) && $routine['spread_code']) {
|
||||
//获取是否有扫码进小程序
|
||||
/** @var QrcodeServices $qrcode */
|
||||
$qrcode = app()->make(QrcodeServices::class);
|
||||
$info = $qrcode->get((int)$routine['spread_code']);
|
||||
if ($info) {
|
||||
$spread_uid = $info['third_id'];
|
||||
$routineInfo['spread_qrcode_id'] = (int)$info['id'];
|
||||
$routineInfo['spread_qrcode_type'] = $info['third_type'] ?? '';
|
||||
}
|
||||
$routineInfo = $this->appendSpreadQrcodeInfo($routineInfo, $routine, $spread_uid);
|
||||
if (!$spread_uid && isset($routineInfo['spread_uid'])) {
|
||||
$spread_uid = (int)$routineInfo['spread_uid'];
|
||||
}
|
||||
return [$routine['openid'] ?? '', $routineInfo, $spread_uid, $routine['login_type'] ?? 'routine', 'routine'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 尽量根据扫码参数补齐二维码信息,避免前端同时传 spread_uid / spread_code 时丢失渠道码来源。
|
||||
*/
|
||||
protected function appendSpreadQrcodeInfo(array $routineInfo, array $routine, int $spread_uid = 0): array
|
||||
{
|
||||
$spreadCode = (int)($routine['spread_code'] ?? 0);
|
||||
if ($spreadCode <= 0) {
|
||||
if ($spread_uid > 0) {
|
||||
$routineInfo['spread_uid'] = $spread_uid;
|
||||
}
|
||||
return $routineInfo;
|
||||
}
|
||||
|
||||
/** @var QrcodeServices $qrcode */
|
||||
$qrcode = app()->make(QrcodeServices::class);
|
||||
$info = $qrcode->get($spreadCode);
|
||||
if (!$info) {
|
||||
if ($spread_uid > 0) {
|
||||
$routineInfo['spread_uid'] = $spread_uid;
|
||||
}
|
||||
return $routineInfo;
|
||||
}
|
||||
|
||||
$qrcodeSpreadUid = (int)($info['third_id'] ?? 0);
|
||||
$routineInfo['spread_qrcode_id'] = (int)($info['id'] ?? 0);
|
||||
$routineInfo['spread_qrcode_type'] = $info['third_type'] ?? '';
|
||||
$routineInfo['spread_uid'] = $qrcodeSpreadUid ?: $spread_uid;
|
||||
|
||||
return $routineInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取返回信息
|
||||
* @param $user
|
||||
|
||||
Reference in New Issue
Block a user