fix: 仲裁实际结算发放邀请返利
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/adminnotification"
|
||||
"hfb_sys/backend/internal/modules/distribution"
|
||||
"hfb_sys/backend/internal/modules/invitation"
|
||||
"hfb_sys/backend/internal/modules/notification"
|
||||
ordermodule "hfb_sys/backend/internal/modules/order"
|
||||
"hfb_sys/backend/internal/modules/rentergrowth"
|
||||
@@ -134,6 +135,24 @@ func (r *Repository) Arbitrate(ctx context.Context, adminID uint64, id uint64, r
|
||||
if err := tx.Save(&order).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if order.Status == "completed" {
|
||||
if actualSettlement == nil {
|
||||
return ErrInvalidDispute
|
||||
}
|
||||
// 仲裁按实际消耗结算后,订单仍保留原预收金额快照;返利必须使用实际平台毛利。
|
||||
grossProfitCent := actualSettlement.PlatformFeeCent
|
||||
if err := invitation.ProcessOrderInvitationRebateWithOptionsTx(tx, order.ID, invitation.OrderRebateOptions{
|
||||
GrossProfitCent: &grossProfitCent,
|
||||
RateReferenceAt: now,
|
||||
}); err != nil {
|
||||
logging.FromContext(ctx).Error("仲裁结算邀请返利失败",
|
||||
zap.String("module", "dispute"),
|
||||
zap.Uint64("order_id", order.ID),
|
||||
zap.Int64("actual_platform_fee_cent", grossProfitCent),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
if order.DistributionSiteID != nil && *order.DistributionSiteID > 0 {
|
||||
if err := distribution.ApplyRefundTx(tx, order.ID, refundAmountCent); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user