Merge branch 'jng' into dev
This commit is contained in:
commit
c25157b661
@ -480,24 +480,20 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
|
|||||||
|
|
||||||
// 构建子订单 map,按 orderAddNo 聚合
|
// 构建子订单 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)
|
||||||
// SettlementAmount 规则
|
subAmountMap[orderAddNo] += amount
|
||||||
settlementAmount := float32(sub.Amount)
|
|
||||||
if sub.OrderNo == record.OrderNo {
|
|
||||||
settlementAmount = record.TotalAmount
|
|
||||||
}
|
|
||||||
|
|
||||||
if existing, ok := addMap[orderAddNo]; ok {
|
if existing, ok := addMap[orderAddNo]; ok {
|
||||||
existing.Amount += float32(sub.Amount)
|
existing.Amount += amount
|
||||||
existing.SettlementAmount += settlementAmount
|
|
||||||
} else {
|
} else {
|
||||||
addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{
|
addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{
|
||||||
OrderAddNo: orderAddNo,
|
OrderAddNo: orderAddNo,
|
||||||
Amount: float32(sub.Amount),
|
Amount: amount,
|
||||||
SettlementAmount: settlementAmount,
|
//SettlementAmount: settlementAmount,
|
||||||
CurrencyType: int32(sub.CurrencyType),
|
CurrencyType: int32(sub.CurrencyType),
|
||||||
//HandlingFee: float32(sub.HandlingFee),
|
//HandlingFee: float32(sub.HandlingFee),
|
||||||
//ExchangeRate: float32(sub.ExchangeRate),
|
//ExchangeRate: float32(sub.ExchangeRate),
|
||||||
OrderAddCreateAt: sub.CreatedAt.Format("2006-01-02 15:04:05"),
|
OrderAddCreateAt: sub.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
@ -509,10 +505,14 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 第二步:设置 SettlementAmount
|
||||||
// 将聚合后的子订单添加到主订单返回结构中
|
for orderAddNo, addInfo := range addMap {
|
||||||
for _, v := range addMap {
|
settlementAmount := subAmountMap[orderAddNo]
|
||||||
orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, v)
|
if orderAddNo == record.OrderNo {
|
||||||
|
settlementAmount += record.TotalAmount
|
||||||
|
}
|
||||||
|
addInfo.SettlementAmount = settlementAmount
|
||||||
|
orderItem.AddBundleInfo = append(orderItem.AddBundleInfo, addInfo)
|
||||||
}
|
}
|
||||||
res.BundleInfo = append(res.BundleInfo, orderItem)
|
res.BundleInfo = append(res.BundleInfo, orderItem)
|
||||||
}
|
}
|
||||||
@ -609,7 +609,7 @@ func GetReconciliationList(req *bundle.GetReconciliationListReq) (*bundle.GetRec
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
offset := (req.Page - 1) * req.PageSize
|
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)
|
return nil, fmt.Errorf("查询记录失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user