|
|
@@ -3,6 +3,7 @@
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use biz\renew\classes\RenewClass;
|
|
|
use biz\shop\services\ShopAdminService;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
@@ -81,8 +82,9 @@ class ApplyController extends BaseController
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
$inviteCode = trim($get['inviteCode'] ?? '');
|
|
|
- $data = MainInviteClass::resolveRegisterFeePreview($inviteCode);
|
|
|
- util::success($data);
|
|
|
+ $allowInviteBenefit = $this->canUseRegisterInviteBenefit();
|
|
|
+ $data = MainInviteClass::resolveRegisterFeePreview($inviteCode, $allowInviteBenefit);
|
|
|
+ util::success($this->appendInviteBenefitFlags($data));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -117,7 +119,7 @@ class ApplyController extends BaseController
|
|
|
$data['inviteCommissionAmount'] = round((float) ($apply['inviteCommissionAmount'] ?? 0), 2);
|
|
|
}
|
|
|
}
|
|
|
- util::success($data);
|
|
|
+ util::success($this->appendInviteBenefitFlags($data));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -128,14 +130,23 @@ class ApplyController extends BaseController
|
|
|
if ($this->adminId <= 0 || $this->shopId <= 0) {
|
|
|
util::fail('请先登录并选择门店');
|
|
|
}
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $inviteCode = trim((string) ($post['inviteCode'] ?? ''));
|
|
|
+ $allowInviteBenefit = $this->canUseRegisterInviteBenefit();
|
|
|
$apply = $this->findRegisterApplyForAdmin($this->adminId, $this->shopId);
|
|
|
if (empty($apply)) {
|
|
|
util::fail('未找到注册申请记录');
|
|
|
}
|
|
|
$applyId = (int) ($apply['id'] ?? 0);
|
|
|
- $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode);
|
|
|
+ // 已有 xhRenew 付费成功:续费不再更新邀请减免
|
|
|
+ if (!$allowInviteBenefit) {
|
|
|
+ $preview = MainInviteClass::resolveRegisterFeePreview('', false);
|
|
|
+ util::success($this->appendInviteBenefitFlags(array_merge($preview, [
|
|
|
+ 'applyId' => $applyId,
|
|
|
+ ])));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $inviteCode = trim((string) ($post['inviteCode'] ?? ''));
|
|
|
+ $fee = MainInviteClass::resolveRegisterFeeSubmit($inviteCode, true);
|
|
|
if ($inviteCode !== '' && !empty($fee['inviteNotFound'])) {
|
|
|
util::fail('邀请人不存在');
|
|
|
}
|
|
|
@@ -146,13 +157,13 @@ class ApplyController extends BaseController
|
|
|
'hdDiscountAmount' => $hdDiscountAmount,
|
|
|
'inviteCommissionAmount' => $inviteCommissionAmount,
|
|
|
]);
|
|
|
- $preview = MainInviteClass::resolveRegisterFeePreview($inviteCode);
|
|
|
- util::success(array_merge($preview, [
|
|
|
+ $preview = MainInviteClass::resolveRegisterFeePreview($inviteCode, true);
|
|
|
+ util::success($this->appendInviteBenefitFlags(array_merge($preview, [
|
|
|
'applyId' => $applyId,
|
|
|
'inviteCode' => $inviteCode,
|
|
|
'hdDiscountAmount' => $hdDiscountAmount,
|
|
|
'inviteCommissionAmount' => $inviteCommissionAmount,
|
|
|
- ]));
|
|
|
+ ])));
|
|
|
}
|
|
|
|
|
|
//邀请花店海报 ssh 20210610
|
|
|
@@ -455,4 +466,26 @@ class ApplyController extends BaseController
|
|
|
return $apply;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否仍可使用邀请码减免与佣金(无 xhRenew 付费成功记录时为 true)
|
|
|
+ */
|
|
|
+ private function canUseRegisterInviteBenefit(): bool
|
|
|
+ {
|
|
|
+ if ($this->mainId <= 0 && $this->shopId <= 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return !RenewClass::hasPaidMemberRenew((int) $this->mainId, (int) $this->shopId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 补充首次付费邀请权益标记
|
|
|
+ */
|
|
|
+ private function appendInviteBenefitFlags(array $data): array
|
|
|
+ {
|
|
|
+ $available = $this->canUseRegisterInviteBenefit();
|
|
|
+ $data['inviteBenefitAvailable'] = $available ? 1 : 0;
|
|
|
+ $data['hasPaidRegisterRenew'] = $available ? 0 : 1;
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
}
|