37 lines
862 B
Go
37 lines
862 B
Go
package admin
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
)
|
|
|
|
// calcLivestreamOrderAmount returns the effective revenue contribution for a Douyin order.
|
|
// For regular paid orders it returns actual_pay_amount; for 次卡订单 (actual pay is 0 but
|
|
// pay_type_desc contains 次卡), it falls back to the activity ticket price.
|
|
func calcLivestreamOrderAmount(order *model.DouyinOrders, ticketPrice int64) int64 {
|
|
if order == nil {
|
|
return 0
|
|
}
|
|
|
|
amount := int64(order.ActualPayAmount)
|
|
if amount > 0 || ticketPrice <= 0 {
|
|
return amount
|
|
}
|
|
|
|
desc := strings.ReplaceAll(strings.TrimSpace(order.PayTypeDesc), " ", "")
|
|
if desc == "" {
|
|
return amount
|
|
}
|
|
|
|
if strings.Contains(desc, "次卡") {
|
|
multiplier := int64(order.ProductCount)
|
|
if multiplier <= 0 {
|
|
multiplier = 1
|
|
}
|
|
return ticketPrice * multiplier
|
|
}
|
|
|
|
return amount
|
|
}
|