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