修改
This commit is contained in:
parent
26eb0df464
commit
397dd56761
@ -460,24 +460,20 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
|
||||
|
||||
// 构建子订单 map,按 orderAddNo 聚合
|
||||
addMap := make(map[string]*bundle.OrderAddBundleRecordInfo)
|
||||
subAmountMap := make(map[string]float32)
|
||||
for _, sub := range record.BundleOrderValueAdd {
|
||||
orderAddNo := sub.OrderNo
|
||||
|
||||
// SettlementAmount 规则
|
||||
settlementAmount := float32(sub.Amount)
|
||||
if sub.OrderNo == record.OrderNo {
|
||||
settlementAmount = record.TotalAmount
|
||||
}
|
||||
amount := float32(sub.Amount)
|
||||
subAmountMap[orderAddNo] += amount
|
||||
|
||||
if existing, ok := addMap[orderAddNo]; ok {
|
||||
existing.Amount += float32(sub.Amount)
|
||||
existing.SettlementAmount += settlementAmount
|
||||
existing.Amount += amount
|
||||
} else {
|
||||
addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{
|
||||
OrderAddNo: orderAddNo,
|
||||
Amount: float32(sub.Amount),
|
||||
SettlementAmount: settlementAmount,
|
||||
CurrencyType: int32(sub.CurrencyType),
|
||||
OrderAddNo: orderAddNo,
|
||||
Amount: amount,
|
||||
//SettlementAmount: settlementAmount,
|
||||
CurrencyType: int32(sub.CurrencyType),
|
||||
//HandlingFee: float32(sub.HandlingFee),
|
||||
//ExchangeRate: float32(sub.ExchangeRate),
|
||||
OrderAddCreateAt: sub.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
@ -489,10 +485,14 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将聚合后的子订单添加到主订单返回结构中
|
||||
for _, v := range addMap {
|
||||
orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, v)
|
||||
// 第二步:设置 SettlementAmount
|
||||
for orderAddNo, addInfo := range addMap {
|
||||
settlementAmount := subAmountMap[orderAddNo]
|
||||
if orderAddNo == record.OrderNo {
|
||||
settlementAmount += record.TotalAmount
|
||||
}
|
||||
addInfo.SettlementAmount = settlementAmount
|
||||
orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, addInfo)
|
||||
}
|
||||
res.BundleInfo = append(res.BundleInfo, orderItem)
|
||||
}
|
||||
@ -589,7 +589,7 @@ func GetReconciliationList(req *bundle.GetReconciliationListReq) (*bundle.GetRec
|
||||
return res, nil
|
||||
}
|
||||
offset := (req.Page - 1) * req.PageSize
|
||||
if err := modelObj.Offset(int(offset)).Limit(int(req.PageSize)).Find(&records).Error; err != nil {
|
||||
if err := modelObj.Offset(int(offset)).Limit(int(req.PageSize)).Order("created_at desc").Find(&records).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询记录失败: %v", err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user