public function handleWithdraw($id, $status, $rejectReason = '')
{
$withdraw = $this->dao->get($id);
if (!$withdraw) {
throw new AdminException('提现记录不存在');
}
if ($withdraw['status'] != 0) {
throw new AdminException('提现已处理');
}
// 更新状态
$updateData = [
'status' => $status,
'handle_time' => time()
];
if ($status == 2) { // 拒绝
$updateData['reject_reason'] = $rejectReason;
$this->dao->update($id, $updateData);
// 返还金额到用户余额
$this->returnAmountToUser($withdraw);
} else { // 通过
$this->dao->update($id, $updateData);
// 实际打款操作
$this->transferToUser($withdraw);
}
// 发送通知
$this->sendWithdrawResultNotify($withdraw['uid'], $status, $rejectReason);
}
手动打款
自动打款(需配置)
SELECT
a.uid,
u.nickname,
COUNT(DISTINCT o.order_id) AS order_count,
SUM(o.pay_price) AS order_amount,
SUM(c.commission_amount) AS total_commission,
COUNT(DISTINCT s.uid) AS spread_count
FROM
eb_user_agent a
LEFT JOIN
eb_user u ON a.uid = u.uid
LEFT JOIN
eb_store_order o ON o.uid = a.uid AND o.paid = 1
LEFT JOIN
eb_agent_commission c ON c.uid = a.uid AND c.status = 1
LEFT JOIN
eb_user_spread s ON s.spread_uid = a.uid
GROUP BY
a.uid
ORDER BY
total_commission DESC
public function getTeamPerformance($uid, $startTime, $endTime)
{
// 获取团队用户ID
$teamUids = $this->getTeamUids($uid);
// 查询团队业绩
return $this->dao->getPerformanceByUids(
$teamUids,
$startTime,
$endTime
);
}
| 接口名称 | 请求方式 | 路径 | 描述 |
|---|---|---|---|
| 申请成为分销商 | POST | /api/agent/apply | 提交分销申请 |
| 获取分销信息 | GET | /api/agent/info | 获取分销商信息 |
| 获取佣金明细 | GET | /api/agent/commission | 佣金记录查询 |
| 提现申请 | POST | /api/agent/withdraw | 提交提现申请 |
| 获取团队列表 | GET | /api/agent/team | 获取下级分销商 |
| 版本 | 日期 | 更新内容 |
|---|---|---|
| v1.0 | 2024-01-17 | 初版文档创建 |
| v1.1 | 2024-01-18 | 增加多级分销配置 |
文档维护:技术团队
最后更新:2024-01-17
💡 提示:分销系统涉及资金流转,请定期审核佣金计算和提现记录,确保财务数据准确。
提示:该文档由AI生成,仅供参考。