From 7c4c7b0faa2203c23141f8825d9cc2b892842910 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Sun, 4 Jan 2026 16:20:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Updata=EF=BC=9A=E6=9B=B4=E6=96=B0=E4=BD=99?= =?UTF-8?q?=E9=87=8F=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=8F=91=E6=94=BE?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index 7829a50..24fade4 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -694,9 +694,9 @@ inner join ( // 当月增值限制类会过期型数据分析可使用额度 v.MonthlyIncreaseLimitExpiredDataAnalysisNumber = cal(v.IncreaseLimitDataAnalysisExpiredNumber, v.MonthlyLimitDataAnalysisQuotaNumber) // 当月套餐限制类型数据分析可使用额度 - v.MonthlyBundleLimitDataAnalysisNumber = v.MonthlyBundleLimitDataAnalysisNumber - v.MonthlyBundleLimitDataAnalysisConsumptionNumber + cal(v.BundleLimitImageNumber, v.MonthlyLimitImageQuotaNumber) + v.MonthlyBundleLimitDataAnalysisNumber = v.MonthlyBundleLimitDataAnalysisNumber - v.MonthlyBundleLimitDataAnalysisConsumptionNumber + cal(v.BundleLimitDataAnalysisNumber, v.MonthlyLimitDataAnalysisQuotaNumber) // 当月增值限制类型数据分析可使用额度 - v.MonthlyIncreaseLimitDataAnalysisNumber = v.MonthlyIncreaseLimitDataAnalysisNumber - v.MonthlyIncreaseLimitDataAnalysisConsumptionNumber + cal(v.IncreaseLimitImageNumber, v.MonthlyLimitImageQuotaNumber) + v.MonthlyIncreaseLimitDataAnalysisNumber = v.MonthlyIncreaseLimitDataAnalysisNumber - v.MonthlyIncreaseLimitDataAnalysisConsumptionNumber + cal(v.IncreaseLimitDataAnalysisNumber, v.MonthlyLimitDataAnalysisQuotaNumber) // 重置单月消耗数量 v.MonthlyBundleVideoConsumptionNumber = 0 From 71f7be5716a6a97e92642b0b9f5ab66affbf6813 Mon Sep 17 00:00:00 2001 From: zhoujunyao Date: Wed, 7 Jan 2026 10:50:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=89=8B=E7=BB=AD=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/orderRecordsDao.go | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/internal/dao/orderRecordsDao.go b/internal/dao/orderRecordsDao.go index 72f972f..eaf629a 100644 --- a/internal/dao/orderRecordsDao.go +++ b/internal/dao/orderRecordsDao.go @@ -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) }