更新若干功能

This commit is contained in:
2026-08-19 08:16:49 +08:00
parent 4979bb83d2
commit 72bc6502eb
56 changed files with 3627 additions and 343 deletions

View File

@@ -2,6 +2,7 @@
namespace App\BaseApp;
use App\Models\business\WxUserModel;
use App\Service\common\UtilsService;
use App\Service\wx\WxTokenService;
@@ -45,4 +46,40 @@ class BaseWxService extends BaseNotAuthService
{
return $this->userInfo['price_number'] ?? 1;
}
/**
* 打开分享链接时继承代理商倍率
*
* 商品详情、套餐详情共用:只有「还没有上级、自己也不是代理商」的已登录用户会被绑定;
* 已绑同一上级时同步最新倍率。未登录不写库,只影响本次会话价。
*/
protected function inheritAgentPrice(int $shareUserId): void
{
if ($shareUserId <= 0) {
return;
}
$isAgent = (int) ($this->userInfo['is_p'] ?? 0) === 1;
$pid = (int) ($this->userInfo['pid'] ?? 0);
if ($isAgent) {
return;
}
if ($pid !== 0 && $pid !== $shareUserId) {
return;
}
$agent = WxUserModel::where('id', $shareUserId)->where('deleted_at', 0)->first();
if (empty($agent) || (int) $agent['is_p'] !== 1) {
return;
}
$this->userInfo['show_price'] = 1;
$this->userInfo['price_number'] = $agent['price_number'];
if ($this->userId <= 0) {
return;
}
WxUserModel::where('id', $this->userId)->update([
'pid' => $shareUserId,
'show_price' => 1,
'price_number' => $agent['price_number'],
'updated_at' => time(),
]);
}
}