This commit is contained in:
桀尼龟 2025-06-26 13:53:16 +08:00
parent 397dd56761
commit 7c0027f624

View File

@ -447,6 +447,7 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
} }
for _, record := range records { for _, record := range records {
customerID, _ := strconv.ParseInt(record.CustomerID, 10, 64) customerID, _ := strconv.ParseInt(record.CustomerID, 10, 64)
orderItem := &bundle.OrderBundleRecordInfo{ orderItem := &bundle.OrderBundleRecordInfo{
OrderNo: record.OrderNo, OrderNo: record.OrderNo,
BundleName: record.BundleName, BundleName: record.BundleName,
@ -458,24 +459,20 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
CustomerId: customerID, CustomerId: customerID,
} }
// 构建子订单 map按 orderAddNo 聚合 // 聚合子订单
addMap := make(map[string]*bundle.OrderAddBundleRecordInfo) addMap := make(map[string]*bundle.OrderAddBundleRecordInfo)
subAmountMap := make(map[string]float32)
for _, sub := range record.BundleOrderValueAdd { for _, sub := range record.BundleOrderValueAdd {
orderAddNo := sub.OrderNo orderAddNo := sub.OrderNo
amount := float32(sub.Amount) amount := float32(sub.Amount)
subAmountMap[orderAddNo] += amount
if existing, ok := addMap[orderAddNo]; ok { if existing, ok := addMap[orderAddNo]; ok {
existing.Amount += amount existing.Amount += amount
} else { } else {
addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{ addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{
OrderAddNo: orderAddNo, OrderAddNo: orderAddNo,
Amount: amount, Amount: amount,
//SettlementAmount: settlementAmount, CurrencyType: int32(sub.CurrencyType),
CurrencyType: int32(sub.CurrencyType),
//HandlingFee: float32(sub.HandlingFee),
//ExchangeRate: float32(sub.ExchangeRate),
OrderAddCreateAt: sub.CreatedAt.Format("2006-01-02 15:04:05"), OrderAddCreateAt: sub.CreatedAt.Format("2006-01-02 15:04:05"),
AddPayStatus: int32(sub.PaymentStatus), AddPayStatus: int32(sub.PaymentStatus),
Contract: sub.SignContract, Contract: sub.SignContract,
@ -485,15 +482,17 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
} }
} }
} }
// 第二步:设置 SettlementAmount
// 设置 SettlementAmount 并追加到主订单中
for orderAddNo, addInfo := range addMap { for orderAddNo, addInfo := range addMap {
settlementAmount := subAmountMap[orderAddNo]
if orderAddNo == record.OrderNo { if orderAddNo == record.OrderNo {
settlementAmount += record.TotalAmount addInfo.SettlementAmount = record.TotalAmount
} else {
addInfo.SettlementAmount = addInfo.Amount
} }
addInfo.SettlementAmount = settlementAmount
orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, addInfo) orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, addInfo)
} }
res.BundleInfo = append(res.BundleInfo, orderItem) res.BundleInfo = append(res.BundleInfo, orderItem)
} }
res.Total = int32(count) res.Total = int32(count)