feat(commission): 支持计奖商品参与设置、独立分成与多规格规则,完善团队中心与微信快捷登录
这个提交包含在:
@@ -6,6 +6,7 @@ use think\Db;
|
||||
use app\admin\model\shopro\user\User as UserModel;
|
||||
use app\admin\model\shopro\commission\Agent as AgentModel;
|
||||
use app\admin\model\shopro\goods\Goods as GoodsModel;
|
||||
use app\admin\model\shopro\partner\Reward as RewardModel;
|
||||
use addons\shopro\service\Wallet;
|
||||
|
||||
|
||||
@@ -268,11 +269,21 @@ class Agent extends Commission
|
||||
|
||||
$user->team_level = ($user->parent_user_id == $agentId) ? 1 : 2;
|
||||
$rawMobile = $user->mobile ? (string) $user->mobile : '';
|
||||
$maskedMobile = $rawMobile ? (strlen($rawMobile) == 11 ? substr_replace($rawMobile, '****', 3, 4) : $rawMobile) : '';
|
||||
$user->mobile = $maskedMobile;
|
||||
$user->mobile_hide = $maskedMobile;
|
||||
$user->mobile_raw = $rawMobile;
|
||||
$user->mobile_hide = $rawMobile ? (strlen($rawMobile) == 11 ? substr_replace($rawMobile, '****', 3, 4) : $rawMobile) : '';
|
||||
|
||||
// 间推所属推荐人手机号脱敏
|
||||
if ($user->parentUser && $user->parentUser->mobile) {
|
||||
$pMobile = (string) $user->parentUser->mobile;
|
||||
$pMasked = strlen($pMobile) == 11 ? substr_replace($pMobile, '****', 3, 4) : $pMobile;
|
||||
$user->parentUser->mobile = $pMasked;
|
||||
$user->parentUser->mobile_hide = $pMasked;
|
||||
}
|
||||
});
|
||||
|
||||
// 9. 计算整体团队健康度统计
|
||||
// 9. 计算整体团队健康度与综合收益业绩统计
|
||||
$summary = $this->getTeamHealthSummary($agentId, $level1Ids, $windowStart, $expiringStart);
|
||||
|
||||
$result = $data->toArray();
|
||||
@@ -282,7 +293,7 @@ class Agent extends Commission
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算团队保活健康度统计
|
||||
* 计算团队保活健康度与综合收益统计
|
||||
*/
|
||||
protected function getTeamHealthSummary($agentId, $level1Ids, $windowStart, $expiringStart)
|
||||
{
|
||||
@@ -298,6 +309,10 @@ class Agent extends Commission
|
||||
'expiring_count' => 0,
|
||||
'inactive_count' => 0,
|
||||
'partner_count' => 0,
|
||||
'team_total_consume' => '0.00',
|
||||
'team_total_reward' => '0.00',
|
||||
'team_month_reward' => '0.00',
|
||||
'team_order_count' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -306,6 +321,7 @@ class Agent extends Commission
|
||||
$expiringCount = 0;
|
||||
$inactiveCount = 0;
|
||||
$partnerCount = 0;
|
||||
$teamOrderCount = 0;
|
||||
|
||||
foreach ($agents as $ag) {
|
||||
$level = intval($ag->level ?? 0);
|
||||
@@ -323,6 +339,8 @@ class Agent extends Commission
|
||||
} else {
|
||||
$inactiveCount++;
|
||||
}
|
||||
|
||||
$teamOrderCount += intval($ag->child_order_count_0 ?? 0);
|
||||
}
|
||||
|
||||
$missingAgentCount = count($teamUserIds) - count($agents);
|
||||
@@ -330,12 +348,31 @@ class Agent extends Commission
|
||||
$inactiveCount += $missingAgentCount;
|
||||
}
|
||||
|
||||
// 1. 团队累计自购总业绩
|
||||
$teamTotalConsume = UserModel::whereIn('id', $teamUserIds)->sum('total_consume');
|
||||
|
||||
// 2. 团队成员为当前用户贡献的累计收益与本月收益
|
||||
$monthStart = strtotime(date('Y-m-01 00:00:00'));
|
||||
$teamTotalReward = RewardModel::where('user_id', $agentId)
|
||||
->whereIn('buyer_id', $teamUserIds)
|
||||
->where('status', 1)
|
||||
->sum('amount');
|
||||
$teamMonthReward = RewardModel::where('user_id', $agentId)
|
||||
->whereIn('buyer_id', $teamUserIds)
|
||||
->where('status', 1)
|
||||
->where('createtime', '>=', $monthStart)
|
||||
->sum('amount');
|
||||
|
||||
return [
|
||||
'total_count' => count($teamUserIds),
|
||||
'active_count' => $activeCount,
|
||||
'expiring_count' => $expiringCount,
|
||||
'inactive_count' => $inactiveCount,
|
||||
'partner_count' => $partnerCount,
|
||||
'team_total_consume' => \addons\shopro\service\partner\IdentityService::formatMoney($teamTotalConsume),
|
||||
'team_total_reward' => \addons\shopro\service\partner\IdentityService::formatMoney($teamTotalReward),
|
||||
'team_month_reward' => \addons\shopro\service\partner\IdentityService::formatMoney($teamMonthReward),
|
||||
'team_order_count' => $teamOrderCount,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class Index extends Commission
|
||||
{
|
||||
$userId = $this->service->user->id;
|
||||
$tab = $this->request->param('tab', 'all');
|
||||
$buyerId = intval($this->request->param('buyer_id', 0));
|
||||
$query = RewardModel::where('user_id', $userId)->with(['buyer', 'order']);
|
||||
|
||||
$tabMap = [
|
||||
@@ -52,6 +53,9 @@ class Index extends Commission
|
||||
if ($tab !== 'all' && isset($tabMap[$tab])) {
|
||||
$query->whereIn('reward_type', $tabMap[$tab]);
|
||||
}
|
||||
if ($buyerId > 0) {
|
||||
$query->where('buyer_id', $buyerId);
|
||||
}
|
||||
|
||||
$list = $query->order('id', 'desc')->paginate($this->request->param('list_rows', 10));
|
||||
$rows = [];
|
||||
@@ -74,11 +78,26 @@ class Index extends Commission
|
||||
];
|
||||
}
|
||||
|
||||
$buyerInfo = null;
|
||||
if ($buyerId > 0) {
|
||||
$buyerUser = \app\admin\model\shopro\user\User::get($buyerId);
|
||||
if ($buyerUser) {
|
||||
$rawMobile = (string) ($buyerUser->mobile ?? '');
|
||||
$buyerInfo = [
|
||||
'id' => $buyerUser->id,
|
||||
'nickname' => $buyerUser->nickname,
|
||||
'avatar' => $buyerUser->avatar,
|
||||
'mobile' => $rawMobile ? (strlen($rawMobile) == 11 ? substr_replace($rawMobile, '****', 3, 4) : $rawMobile) : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$this->success('ok', [
|
||||
'total' => $list->total(),
|
||||
'per_page' => $list->listRows(),
|
||||
'current_page' => $list->currentPage(),
|
||||
'data' => $rows,
|
||||
'buyer_info' => $buyerInfo,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ class Wechat extends Common
|
||||
});
|
||||
|
||||
if ($result) {
|
||||
$this->success('登陆成功');
|
||||
$auth = \app\common\library\Auth::instance();
|
||||
$this->success('登陆成功', [
|
||||
'token' => $auth->isLogin() ? $auth->getToken() : ''
|
||||
]);
|
||||
}
|
||||
$this->error('登陆失败');
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户