Merge branch 'feat-zjy-fixbug-023' into dev

# Conflicts:
#	internal/dao/bundleExtend.go
This commit is contained in:
周俊耀 2026-01-07 10:53:29 +08:00
commit fa79376e51

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/shopspring/decimal"
"micro-bundle/internal/model" "micro-bundle/internal/model"
"micro-bundle/pb/bundle" "micro-bundle/pb/bundle"
"micro-bundle/pkg/app" "micro-bundle/pkg/app"
@ -127,6 +128,26 @@ func UpdateOrderRecordByOrderNO(orderRecord *model.BundleOrderRecords) (res *bun
} }
} }
} }
tempRecord := new(model.BundleOrderRecords)
if err := app.ModuleClients.BundleDB.Where("deleted_at is null and order_no = ?", orderRecord.OrderNo).First(&tempRecord).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errors.New("订单记录不存在")
}
return nil, fmt.Errorf("查询订单失败: %v", err)
}
if orderRecord.Status == 2 && tempRecord.AmountType == 2 && tempRecord.TotalAmount > 0 {
// 当回调支付成功币种是美元且订单金额大于0计算美元手续费订单金额*0.019(四舍五入保留两位小数字)+0.1
amount := decimal.NewFromFloat32(tempRecord.TotalAmount)
rate, _ := decimal.NewFromString("0.019")
fee := amount.Mul(rate)
// 4. 四舍五入保留两位小数
feeRounded := fee.Round(2)
addition, _ := decimal.NewFromString("0.1")
result := feeRounded.Add(addition)
valueAdd.HandlingFee = result.String()
}
} }
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}). err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).
@ -807,6 +828,19 @@ func UpdateReconciliationStatusBySerialNumber(req *bundle.UpdateStatusAndPayTime
PayStatus: int(req.PaymentStatus), PayStatus: int(req.PaymentStatus),
SerialNumber: req.SerialNumber, SerialNumber: req.SerialNumber,
} }
if req.PaymentStatus == 2 && existing.CurrencyType == 2 && existing.PayAmount > 0 {
// 当回调支付成功币种是美元且订单金额大于0计算美元手续费订单金额*0.019(四舍五入保留两位小数字)+0.1
amount := decimal.NewFromFloat32(existing.PayAmount)
rate, _ := decimal.NewFromString("0.019")
fee := amount.Mul(rate)
// 4. 四舍五入保留两位小数
feeRounded := fee.Round(2)
addition, _ := decimal.NewFromString("0.1")
result := feeRounded.Add(addition)
updates.HandlingFee = result.String()
}
if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil { if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil {
return nil, fmt.Errorf("更新对账单失败: %v", err) return nil, fmt.Errorf("更新对账单失败: %v", err)
} }