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
03afae08
Commit
03afae08
authored
Jul 08, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(commission): 扣减积分抵扣部分的佣金基数
parent
8ef9d665
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
Commission.php
addons/shopro/listener/Commission.php
+19
-0
FixMissedCommission.php
application/command/FixMissedCommission.php
+19
-1
No files found.
addons/shopro/listener/Commission.php
View file @
03afae08
...
...
@@ -72,9 +72,28 @@ class Commission
// 先记录分佣 再处理记录业绩、升级等情况
$items
=
$order
?
$order
[
'items'
]
:
[];
// 积分抵扣部分需按比例从佣金基数中扣除
// order_item.pay_fee 在创建时未扣减积分抵扣,只有 order.pay_fee 扣减了
$deductScore
=
isset
(
$order
[
'deduct_score'
])
?
intval
(
$order
[
'deduct_score'
])
:
0
;
$scoreDeductAmount
=
$deductScore
>
0
?
round
(
$deductScore
/
100
,
2
)
:
0
;
$totalItemsPayFee
=
0
;
if
(
$scoreDeductAmount
>
0
)
{
foreach
(
$items
as
$it
)
{
$totalItemsPayFee
=
bcadd
(
$totalItemsPayFee
,
$it
[
'pay_fee'
],
2
);
}
}
foreach
(
$items
as
$item
)
{
if
(
isset
(
$item
[
'ext'
][
'is_commission'
])
&&
!
$item
[
'ext'
][
'is_commission'
])
continue
;
// 按比例从 pay_fee 中扣减积分抵扣金额
if
(
$scoreDeductAmount
>
0
&&
$totalItemsPayFee
>
0
)
{
$itemPayFee
=
floatval
(
$item
[
'pay_fee'
]);
$totalPayFee
=
floatval
(
$totalItemsPayFee
);
$itemScoreDeduction
=
round
(
$scoreDeductAmount
*
$itemPayFee
/
$totalPayFee
,
2
);
$item
[
'pay_fee'
]
=
round
(
$itemPayFee
-
$itemScoreDeduction
,
2
);
}
$commission
=
new
OrderService
(
$item
);
// 检查能否分销
if
(
!
$commission
->
checkAndSetCommission
())
continue
;
...
...
application/command/FixMissedCommission.php
View file @
03afae08
...
...
@@ -98,7 +98,7 @@ class FixMissedCommission extends Command
$orders
=
Db
::
name
(
'shopro_order'
)
->
where
(
'status'
,
'completed'
)
->
where
(
'type'
,
'<>'
,
'score'
)
->
field
(
'id, user_id, order_sn'
)
->
field
(
'id, user_id, order_sn
, deduct_score
'
)
->
order
(
'id'
,
'asc'
)
->
page
(
$page
,
self
::
PAGE_SIZE
)
->
select
();
...
...
@@ -128,6 +128,16 @@ class FixMissedCommission extends Command
continue
;
}
// 积分抵扣部分需按比例从佣金基数中扣除
$deductScore
=
isset
(
$order
[
'deduct_score'
])
?
intval
(
$order
[
'deduct_score'
])
:
0
;
$scoreDeductAmount
=
$deductScore
>
0
?
round
(
$deductScore
/
100
,
2
)
:
0
;
$totalItemsPayFee
=
0
;
if
(
$scoreDeductAmount
>
0
)
{
foreach
(
$items
as
$it
)
{
$totalItemsPayFee
=
bcadd
(
$totalItemsPayFee
,
$it
[
'pay_fee'
],
2
);
}
}
// 第一步:为每个缺失分佣记录的商品创建 commission_order + commission_reward(模拟支付成功流程)
foreach
(
$items
as
$item
)
{
$itemId
=
$item
[
'id'
];
...
...
@@ -148,6 +158,14 @@ class FixMissedCommission extends Command
// 补充 user_id(OrderService 需要)
$item
[
'user_id'
]
=
$orderUserId
;
// 按比例从 pay_fee 中扣减积分抵扣金额
if
(
$scoreDeductAmount
>
0
&&
$totalItemsPayFee
>
0
)
{
$itemPayFee
=
floatval
(
$item
[
'pay_fee'
]);
$totalPayFee
=
floatval
(
$totalItemsPayFee
);
$itemScoreDeduction
=
round
(
$scoreDeductAmount
*
$itemPayFee
/
$totalPayFee
,
2
);
$item
[
'pay_fee'
]
=
round
(
$itemPayFee
-
$itemScoreDeduction
,
2
);
}
try
{
// 模拟订单支付成功后的分佣流程
$commission
=
new
OrderService
(
$item
);
...
...
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