Merge branch 'feat-zjy-fixbug-023' into dev
# Conflicts: # internal/dao/bundleExtend.go
This commit is contained in:
commit
fa79376e51
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/shopspring/decimal"
|
||||
"micro-bundle/internal/model"
|
||||
"micro-bundle/pb/bundle"
|
||||
"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{}).
|
||||
@ -807,6 +828,19 @@ func UpdateReconciliationStatusBySerialNumber(req *bundle.UpdateStatusAndPayTime
|
||||
PayStatus: int(req.PaymentStatus),
|
||||
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 {
|
||||
return nil, fmt.Errorf("更新对账单失败: %v", err)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user