Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
3743f53f
Commit
3743f53f
authored
Jul 08, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(commission): 修复代理商链层级计算逻辑
parent
7b890922
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
AgentOrderCommission.php
application/command/AgentOrderCommission.php
+5
-5
No files found.
application/command/AgentOrderCommission.php
View file @
3743f53f
...
...
@@ -268,7 +268,7 @@ class AgentOrderCommission extends Command
$orderItems
=
$this
->
getOrderItems
(
$orderId
);
// 查找两级代理商,确保代理商申请成功后的订单才分佣
$agents
=
$this
->
findAgentChain
(
$buyerUserId
,
$order
[
'createtime'
]
,
2
);
$agents
=
$this
->
findAgentChain
(
$buyerUserId
,
$order
,
2
);
if
(
empty
(
$agents
))
{
$this
->
customLog
(
'info'
,
"订单[
{
$orderId
}
][
{
$orderSn
}
]跳过: 未找到有效的上级代理商, 买家[
{
$buyerUserId
}
]"
);
return
'skip'
;
...
...
@@ -404,15 +404,16 @@ class AgentOrderCommission extends Command
* 最多向上追溯两级。仅收集状态为 normal 或 freeze 的代理商。
*
* @param int $buyerUserId 买家用户ID
* @param
int $order_create_time 订单创建时间(时间戳)
* @param
array $order 订单信息
* @param int $maxLevel 最大追溯层级(默认2级)
* @return array [['user_id' => xxx, 'level' => 1], ...]
*/
protected
function
findAgentChain
(
$buyerUserId
,
int
$order_create_time
,
$maxLevel
=
2
)
protected
function
findAgentChain
(
$buyerUserId
,
$order
,
$maxLevel
=
2
)
{
$agents
=
[];
$currentUserId
=
$buyerUserId
;
$currentLevel
=
1
;
$order_create_time
=
$order
[
'createtime'
];
while
(
$currentLevel
<=
$maxLevel
)
{
// 查找当前用户的上级
...
...
@@ -420,7 +421,6 @@ class AgentOrderCommission extends Command
->
where
(
'id'
,
$currentUserId
)
->
field
(
'id, parent_user_id'
)
->
find
();
if
(
!
$user
||
empty
(
$user
[
'parent_user_id'
])
||
$user
[
'parent_user_id'
]
<=
0
)
{
break
;
}
...
...
@@ -441,11 +441,11 @@ class AgentOrderCommission extends Command
'agent_user_id'
=>
$agent
[
'user_id'
],
'level'
=>
$currentLevel
,
];
$currentLevel
++
;
}
// 继续向上追溯(即使上级不是代理商,也继续向上找)
$currentUserId
=
$parentUserId
;
$currentLevel
++
;
}
return
$agents
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment