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
7b890922
Commit
7b890922
authored
Jul 08, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(command): 新增InitCommissionGoods命令及优化佣金日志
parent
e44eec3a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
command.php
application/command.php
+1
-0
AgentOrderCommission.php
application/command/AgentOrderCommission.php
+10
-10
InitCommissionGoods.php
application/command/InitCommissionGoods.php
+2
-0
No files found.
application/command.php
View file @
7b890922
...
@@ -26,5 +26,6 @@ return [
...
@@ -26,5 +26,6 @@ return [
'app\command\DataStatsCenter'
,
'app\command\DataStatsCenter'
,
'app\command\TestLogDb'
,
'app\command\TestLogDb'
,
'app\command\AgentOrderCommission'
,
'app\command\AgentOrderCommission'
,
'app\command\InitCommissionGoods'
,
];
];
application/command/AgentOrderCommission.php
View file @
7b890922
...
@@ -168,7 +168,7 @@ class AgentOrderCommission extends Command
...
@@ -168,7 +168,7 @@ class AgentOrderCommission extends Command
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$errorCount
++
;
$errorCount
++
;
$this
->
customLog
(
'error'
,
"订单[
{
$order
[
'order_sn'
]
}
]处理异常: "
.
$e
->
getMessage
());
$this
->
customLog
(
'error'
,
"订单[
{
$order
[
'
id'
]
}
][
{
$order
[
'
order_sn'
]
}
]处理异常: "
.
$e
->
getMessage
());
}
}
}
}
...
@@ -270,7 +270,7 @@ class AgentOrderCommission extends Command
...
@@ -270,7 +270,7 @@ class AgentOrderCommission extends Command
// 查找两级代理商,确保代理商申请成功后的订单才分佣
// 查找两级代理商,确保代理商申请成功后的订单才分佣
$agents
=
$this
->
findAgentChain
(
$buyerUserId
,
$order
[
'createtime'
],
2
);
$agents
=
$this
->
findAgentChain
(
$buyerUserId
,
$order
[
'createtime'
],
2
);
if
(
empty
(
$agents
))
{
if
(
empty
(
$agents
))
{
$this
->
customLog
(
'info'
,
"订单[
{
$orderSn
}
]跳过: 未找到有效的上级代理商, 买家[
{
$buyerUserId
}
]"
);
$this
->
customLog
(
'info'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]跳过: 未找到有效的上级代理商, 买家[
{
$buyerUserId
}
]"
);
return
'skip'
;
return
'skip'
;
}
}
...
@@ -290,12 +290,12 @@ class AgentOrderCommission extends Command
...
@@ -290,12 +290,12 @@ class AgentOrderCommission extends Command
$commissionRate
=
floatval
(
$agentRecord
[
'commission_rate'
]);
$commissionRate
=
floatval
(
$agentRecord
[
'commission_rate'
]);
if
(
!
$agentRecord
)
{
if
(
!
$agentRecord
)
{
$this
->
customLog
(
'warning'
,
"订单[
{
$orderSn
}
]代理商[
{
$recordAgentId
}
}]用户[
{
$agentUserId
}
]在shopro_agent表中不存在, 跳过"
);
$this
->
customLog
(
'warning'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]代理商[
{
$recordAgentId
}
}]用户[
{
$agentUserId
}
]在shopro_agent表中不存在, 跳过"
);
continue
;
continue
;
}
}
if
(
$commissionRate
<=
0
)
{
if
(
$commissionRate
<=
0
)
{
$this
->
customLog
(
'warning'
,
"订单[
{
$orderSn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]commission_rate为0或未设置, 跳过"
);
$this
->
customLog
(
'warning'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]commission_rate为0或未设置, 跳过"
);
continue
;
continue
;
}
}
...
@@ -303,7 +303,7 @@ class AgentOrderCommission extends Command
...
@@ -303,7 +303,7 @@ class AgentOrderCommission extends Command
$commissionAmount
=
round
(
$payFee
*
(
$commissionRate
/
100
),
2
);
$commissionAmount
=
round
(
$payFee
*
(
$commissionRate
/
100
),
2
);
if
(
$commissionAmount
<=
0
)
{
if
(
$commissionAmount
<=
0
)
{
$this
->
customLog
(
'warning'
,
"订单[
{
$orderSn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]计算佣金为0, 跳过"
);
$this
->
customLog
(
'warning'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]计算佣金为0, 跳过"
);
continue
;
continue
;
}
}
...
@@ -350,7 +350,7 @@ class AgentOrderCommission extends Command
...
@@ -350,7 +350,7 @@ class AgentOrderCommission extends Command
if
(
$exists
)
{
if
(
$exists
)
{
Db
::
rollback
();
Db
::
rollback
();
$this
->
customLog
(
'info'
,
"订单[
{
$orderSn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]第
{
$agentLevel
}
级已存在佣金记录(事务内), 跳过"
);
$this
->
customLog
(
'info'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]第
{
$agentLevel
}
级已存在佣金记录(事务内), 跳过"
);
continue
;
continue
;
}
}
...
@@ -362,19 +362,19 @@ class AgentOrderCommission extends Command
...
@@ -362,19 +362,19 @@ class AgentOrderCommission extends Command
Db
::
rollback
();
Db
::
rollback
();
// 捕获唯一索引冲突(如有索引),说明真的重复了
// 捕获唯一索引冲突(如有索引),说明真的重复了
if
(
stripos
(
$e
->
getMessage
(),
'Duplicate entry'
)
!==
false
)
{
if
(
stripos
(
$e
->
getMessage
(),
'Duplicate entry'
)
!==
false
)
{
$this
->
customLog
(
'info'
,
"订单[
{
$orderSn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]唯一索引冲突,已存在记录, 跳过"
);
$this
->
customLog
(
'info'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]唯一索引冲突,已存在记录, 跳过"
);
}
else
{
}
else
{
$this
->
customLog
(
'error'
,
"订单[
{
$orderSn
}
]写入异常: "
.
$e
->
getMessage
());
$this
->
customLog
(
'error'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]写入异常: "
.
$e
->
getMessage
());
}
}
continue
;
continue
;
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
Db
::
rollback
();
$this
->
customLog
(
'error'
,
"订单[
{
$orderSn
}
]事务异常: "
.
$e
->
getMessage
());
$this
->
customLog
(
'error'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]事务异常: "
.
$e
->
getMessage
());
continue
;
continue
;
}
}
if
(
$inserted
)
{
if
(
$inserted
)
{
$this
->
customLog
(
'info'
,
"订单[
{
$orderSn
}
]第
{
$agentLevel
}
级代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]佣金: ¥
{
$commissionAmount
}
(订单金额: ¥
{
$payFee
}
)"
);
$this
->
customLog
(
'info'
,
"订单[
{
$order
Id
}
][
{
$order
Sn
}
]第
{
$agentLevel
}
级代理商[
{
$recordAgentId
}
]用户[
{
$agentUserId
}
]佣金: ¥
{
$commissionAmount
}
(订单金额: ¥
{
$payFee
}
)"
);
$this
->
affectedAgentIds
[
$recordAgentId
]
=
true
;
$this
->
affectedAgentIds
[
$recordAgentId
]
=
true
;
$processedCount
++
;
$processedCount
++
;
}
}
...
...
application/command/InitCommissionGoods.php
View file @
7b890922
...
@@ -125,8 +125,10 @@ class InitCommissionGoods extends Command
...
@@ -125,8 +125,10 @@ class InitCommissionGoods extends Command
if
(
$result
>
0
)
{
if
(
$result
>
0
)
{
$insertCount
++
;
$insertCount
++
;
$this
->
customLog
(
'info'
,
"商品[
{
$goodsId
}
]新增分销记录"
);
}
else
{
}
else
{
$skipCount
++
;
$skipCount
++
;
$this
->
customLog
(
'info'
,
"商品[
{
$goodsId
}
]已存在分销记录,跳过"
);
}
}
}
}
...
...
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