|
|
@@ -77,13 +77,18 @@ class ApplyController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 花店注册页:会员费、邀请减免、应付(未登录可访问)
|
|
|
+ * 已登录时传入 mainId,用于拦截自己的邀请码减免
|
|
|
*/
|
|
|
public function actionRegisterFeePreview()
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
$inviteCode = trim($get['inviteCode'] ?? '');
|
|
|
$allowInviteBenefit = $this->canUseRegisterInviteBenefit();
|
|
|
- $data = MainInviteClass::resolveRegisterFeePreview($inviteCode, $allowInviteBenefit);
|
|
|
+ $data = MainInviteClass::resolveRegisterFeePreview(
|
|
|
+ $inviteCode,
|
|
|
+ $allowInviteBenefit,
|
|
|
+ (int) $this->mainId
|
|
|
+ );
|
|
|
util::success($this->appendInviteBenefitFlags($data));
|
|
|
}
|
|
|
|
|
|
@@ -146,9 +151,17 @@ class ApplyController extends BaseController
|
|
|
}
|
|
|
$post = Yii::$app->request->post();
|
|
|
$inviteCode = trim((string) ($post['inviteCode'] ?? ''));
|
|
|
- $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode, true);
|
|
|
- if ($inviteCode !== '' && !empty($fee['inviteNotFound'])) {
|
|
|
- util::fail('邀请人不存在');
|
|
|
+ $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode, true, (int) $this->mainId);
|
|
|
+ // 自邀 / 无效 / 不存在:清空邀请码落库,无减免无佣金,仍允许支付
|
|
|
+ if (
|
|
|
+ $inviteCode !== '' && (
|
|
|
+ !empty($fee['inviteNotFound']) ||
|
|
|
+ !empty($fee['inviteSelf']) ||
|
|
|
+ !empty($fee['inviteInvalid'])
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ $inviteCode = '';
|
|
|
+ $fee = MainInviteClass::resolveRegisterFeeSubmit('', true, (int) $this->mainId);
|
|
|
}
|
|
|
$hdDiscountAmount = round((float) ($fee['hdDiscountAmount'] ?? 0), 2);
|
|
|
$inviteCommissionAmount = round((float) ($fee['inviteCommissionAmount'] ?? 0), 2);
|
|
|
@@ -157,7 +170,7 @@ class ApplyController extends BaseController
|
|
|
'hdDiscountAmount' => $hdDiscountAmount,
|
|
|
'inviteCommissionAmount' => $inviteCommissionAmount,
|
|
|
]);
|
|
|
- $preview = MainInviteClass::resolveRegisterFeePreview($inviteCode, true);
|
|
|
+ $preview = MainInviteClass::resolveRegisterFeePreview($inviteCode, true, (int) $this->mainId);
|
|
|
util::success($this->appendInviteBenefitFlags(array_merge($preview, [
|
|
|
'applyId' => $applyId,
|
|
|
'inviteCode' => $inviteCode,
|
|
|
@@ -321,11 +334,18 @@ class ApplyController extends BaseController
|
|
|
util::fail('申请失败');
|
|
|
}
|
|
|
|
|
|
- // 邀请码快照写入 xhApply(选填)
|
|
|
+ // 邀请码快照写入 xhApply(选填);自邀/无效/不存在则清空后落库,仍可注册支付
|
|
|
$inviteCode = trim((string) ($post['inviteCode'] ?? ''));
|
|
|
- $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode);
|
|
|
- if ($inviteCode !== '' && !empty($fee['inviteNotFound'])) {
|
|
|
- util::fail('邀请人不存在');
|
|
|
+ $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode, true, (int) $this->mainId);
|
|
|
+ if (
|
|
|
+ $inviteCode !== '' && (
|
|
|
+ !empty($fee['inviteNotFound']) ||
|
|
|
+ !empty($fee['inviteSelf']) ||
|
|
|
+ !empty($fee['inviteInvalid'])
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ $inviteCode = '';
|
|
|
+ $fee = MainInviteClass::resolveRegisterFeeSubmit('', true, (int) $this->mainId);
|
|
|
}
|
|
|
ApplyClass::updateById($id, [
|
|
|
'inviteCode' => $inviteCode,
|
|
|
@@ -343,7 +363,11 @@ class ApplyController extends BaseController
|
|
|
$onlyCg = $newShop->onlyCg ?? 1;
|
|
|
|
|
|
ApplyClass::updateById($id, ['shopId' => $newShopId]);
|
|
|
- $inviterMainId = MainInviteClass::resolveInviterMainIdByInviteCode($inviteCode);
|
|
|
+ $inviterMainId = (int) ($fee['inviterMainId'] ?? 0);
|
|
|
+ // 新店 mainId 与邀请人相同(极端自邀)时不挂邀请关系
|
|
|
+ if ($inviterMainId > 0 && $inviterMainId === (int) $newMainId) {
|
|
|
+ $inviterMainId = 0;
|
|
|
+ }
|
|
|
MainInviteClass::createInviteeRecord($newMainId, $inviterMainId);
|
|
|
|
|
|
$shareLogo = imgUtil::groupImg('buy_logo.jpg');
|
|
|
@@ -455,7 +479,7 @@ class ApplyController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
if (empty($apply) && $adminId > 0 && !empty($this->admin)) {
|
|
|
- $mobile = $this->admin->mobile ?? '';
|
|
|
+ $mobile = $this->shop->mobile ?? '';
|
|
|
if ($mobile !== '') {
|
|
|
$row = ApplyClass::getByCondition(['mobile' => $mobile], false);
|
|
|
if (!empty($row)) {
|