fix(invitation): 邀请返利改用实际结算利润并修正提号基准
This commit is contained in:
@@ -369,6 +369,14 @@ func (r *Repository) processOrderInvitationRebate(ctx context.Context, tx *gorm.
|
||||
orderGrossProfitCent := order.RentAmountCent - order.OwnerRentAmountCent
|
||||
if opts.GrossProfitCent != nil {
|
||||
orderGrossProfitCent = *opts.GrossProfitCent
|
||||
} else {
|
||||
// 正常结账、仲裁等终态都已落定实际结账单;未显式传基数时优先按实际平台利润,
|
||||
// 避免再次用订单创建时的预收毛利快照给零消耗结账发返利。
|
||||
var committedCheckout model.OrderCheckout
|
||||
if err := tx.Where("order_id = ? AND status IN ?", order.ID, []string{"accepted", "settled"}).
|
||||
Order("id DESC").First(&committedCheckout).Error; err == nil {
|
||||
orderGrossProfitCent = committedCheckout.PlatformFeeCent
|
||||
}
|
||||
}
|
||||
if orderGrossProfitCent <= 0 {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user