Compare commits

..

No commits in common. "main" and "feat-zjy-issue-013" have entirely different histories.

11 changed files with 2009 additions and 2169 deletions

36
.gitignore vendored
View File

@ -1,36 +0,0 @@
# local env files
.env.local
.env.*.local
# Log files
*.log
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.iml
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
/cmd/runtime
/cmd/logs/*.log
/cmd/runtime/log/*.log
/build/*
.vscode
.idea/*
/.idea/*

View File

@ -1,4 +1,2 @@
protoc --proto_path=. --go_out=./pb --go-triple_out=./pb --govalidators_out=./pb ./pb/bundle.proto
ls pb/bundle/*.pb.go | xargs -n1 -IX bash -c 'sed s/,omitempty// X > X.tmp && mv X{.tmp,}';

2
go.mod
View File

@ -1,6 +1,6 @@
module micro-bundle
go 1.23.3
go 1.18
require (
dubbo.apache.org/dubbo-go/v3 v3.0.2

View File

@ -505,17 +505,10 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
for _, sub := range record.BundleOrderValueAdd {
orderAddNo := sub.OrderNo
amount := float32(sub.Amount)
if existing, ok := addMap[orderAddNo]; ok {
existing.Amount += amount
// 仅当 VideoNum 尚未设置且当前是 ServiceType == 1 时赋值
if existing.VideoNum == 0 && sub.ServiceType == 1 {
existing.VideoNum = sub.Num
}
} else {
var videoNum int32
if sub.ServiceType == 1 {
videoNum = sub.Num
}
addMap[orderAddNo] = &bundle.OrderAddBundleRecordInfo{
OrderAddNo: orderAddNo,
Amount: amount,
@ -527,7 +520,6 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
Snapshot: sub.Snapshot,
CheckoutSessionId: sub.CheckoutSessionId,
CustomerID: sub.CustomerID,
VideoNum: videoNum,
}
}
}
@ -671,7 +663,6 @@ func CreateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonRes
PayStatus: int(req.PayStatus),
SerialNumber: req.SerialNumber,
CreationTime: time.Now().Format("2006-01-02 15:04:05"),
HandlingFee: req.HandlingFee,
}
// 创建记录
@ -702,7 +693,6 @@ func UpdateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonRes
PayTime: req.PayTime,
PayStatus: int(req.PayStatus),
SerialNumber: req.SerialNumber,
HandlingFee: req.HandlingFee,
}
if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil {
return nil, fmt.Errorf("更新对账单失败: %v", err)

View File

@ -165,18 +165,7 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
price, parseErr1 := strconv.ParseFloat(option.Price, 32)
if parseErr1 != nil {
fmt.Println("优惠单价转换失败: ", parseErr1)
return res, errors.New("单价不能为空: " + parseErr1.Error())
}
if option.TotalPrice == "" {
if option.Symbol == "=" {
return res, errors.New("总价不能为空")
}
option.TotalPrice = "0"
}
totalPrice, parseErr2 := strconv.ParseFloat(option.TotalPrice, 32)
if parseErr2 != nil {
fmt.Println("总价转换失败: ", parseErr2)
return res, errors.New("总价转换失败: " + parseErr2.Error())
return res, errors.New("优惠单价转换失败")
}
if option.Num < 0 || option.Num > 99 {
return res, errors.New("数量参数需为0-99")
@ -185,11 +174,10 @@ func SaveValueAddService(in *bundle.ValueAddServiceLang) (res *bundle.SaveRespon
return res, errors.New("优惠单价需小于等于原价")
}
options = append(options, &model.PriceOption{
Id: int32(index),
Num: option.Num,
Symbol: option.Symbol,
Price: float32(price),
TotalPrice: float32(totalPrice),
Id: int32(index),
Num: option.Num,
Symbol: option.Symbol,
Price: float32(price),
})
index++
}
@ -370,12 +358,7 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
price := decimal.NewFromFloat(float64(option.Price))
num := decimal.NewFromInt(int64(option.Num))
totalPrice := decimal.NewFromFloat(float64(option.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
saveAmount = original.Sub(price).Mul(num)
case 2:
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
//price := decimal.NewFromFloat(float64(option.Price))
@ -388,7 +371,6 @@ func ValueAddServiceList(req *bundle.ValueAddServiceListRequest) (res *bundle.Va
Num: option.Num,
Symbol: option.Symbol,
Price: fmt.Sprintf("%.2f", option.Price),
TotalPrice: fmt.Sprintf("%.2f", option.TotalPrice),
SaveAmount: saveAmount.StringFixed(2),
})
}
@ -434,12 +416,7 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
price := decimal.NewFromFloat(float64(opt.Price))
num := decimal.NewFromInt(int64(opt.Num))
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
saveAmount = original.Sub(price).Mul(num)
case 2:
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -452,7 +429,6 @@ func ValueAddServiceDetail(req *bundle.ValueAddServiceDetailRequest) (res *bundl
Num: opt.Num,
Symbol: opt.Symbol,
Price: fmt.Sprintf("%.2f", opt.Price),
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
SaveAmount: saveAmount.StringFixed(2),
})
}
@ -523,12 +499,7 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
original := decimal.NewFromFloat(float64(detail.OriginalPrice))
price := decimal.NewFromFloat(float64(opt.Price))
num := decimal.NewFromInt(int64(opt.Num))
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
saveAmount = original.Sub(price).Mul(num)
case 2:
//original := decimal.NewFromFloat(float64(detail.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -541,7 +512,6 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
Num: opt.Num,
Symbol: opt.Symbol,
Price: fmt.Sprintf("%.2f", opt.Price),
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
SaveAmount: saveAmount.StringFixed(2),
})
}
@ -616,12 +586,7 @@ func BatchGetValueAddServiceLang(req *bundle.BatchGetValueAddServiceLangRequest)
original := decimal.NewFromFloat(float64(v.OriginalPrice))
price := decimal.NewFromFloat(float64(opt.Price))
num := decimal.NewFromInt(int64(opt.Num))
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
saveAmount = original.Sub(price).Mul(num)
case 2:
//original := decimal.NewFromFloat(float64(v.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -634,7 +599,6 @@ func BatchGetValueAddServiceLang(req *bundle.BatchGetValueAddServiceLangRequest)
Num: opt.Num,
Symbol: opt.Symbol,
Price: fmt.Sprintf("%.2f", opt.Price),
TotalPrice: fmt.Sprintf("%.2f", opt.TotalPrice),
SaveAmount: saveAmount.StringFixed(2),
})
}

View File

@ -116,7 +116,6 @@ type BundleExtendRecordItemPo struct {
OperatorName string
OperatorPhoneNumber string
AssociatedOrderNumber string `gorm:"column:associated_order_number;type:varchar(256);comment:关联订单号" json:"associatedOrderNumber"`
TimeUnit uint `gorm:"column:time_unit;type:int(11) unsigned;comment:时间单位" json:"timeUnit"`
OrderUUID string
CreatedAt time.Time
}

View File

@ -17,5 +17,4 @@ type Reconciliation struct {
PayStatus int `gorm:"column:pay_status;comment:支付状态" json:"payStatus"`
SerialNumber string `gorm:"column:serial_number;comment:流水号" json:"serialNumber"`
CreationTime string `gorm:"column:creation_time;comment:创建时间" json:"creationTime"`
HandlingFee string `gorm:"column:handling_fee;comment:手续费" json:"handlingFee"`
}

View File

@ -51,7 +51,7 @@ type ValueAddServiceLang struct {
ServiceType int32 `json:"serviceType" gorm:"column:service_type;type:int;comment:服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长"`
PriceMode int32 `json:"priceMode" gorm:"column:price_mode;type:int;comment:套餐价格类型 1:单价 2:总价"`
OriginalPrice float32 `json:"originalPrice" gorm:"column:original_price;type:decimal(12,2);comment:原单价"`
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值服务总价"` //总价模式不合理,该字段暂时无用
TotalPrice float32 `json:"totalPrice" gorm:"column:total_price;type:decimal(12,2);comment:增值服务总价"`
Unit string `json:"unit" gorm:"column:unit;type:varchar(50);comment:单位 1:个 2:条 3:天 4:月 5:年"`
Language string `json:"language" gorm:"column:language;type:varchar(32);comment:套餐语言 zh-CN zh-TW EN de-DE ja-JP(中繁英德日)"`
PriceType int64 `json:"priceType" gorm:"column:price_type;type:int;comment:币种 1:人民币 2:美元 3:日元 4:欧元"`
@ -74,11 +74,10 @@ type ValueAddServiceHistory struct {
type PriceOptions []*PriceOption
type PriceOption struct {
Id int32 `json:"id"`
Num int32 `json:"num"`
Symbol string `json:"symbol"` // 符号> < = >= <=
Price float32 `json:"price"` // 价格(根据priceMode决定是单价还是总价)
TotalPrice float32 `json:"totalPrice"` // 总价-新加
Id int32 `json:"id"`
Num int32 `json:"num"`
Symbol string `json:"symbol"` // 符号> < = >= <=
Price float32 `json:"price"` // 价格(根据priceMode决定是单价还是总价)
}
// 实现 driver.Valuer 接口
@ -151,7 +150,6 @@ func (m *ValueAddServiceHistory) TableName() string {
func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, error) {
for _, opt := range options {
match := false
last := false
switch opt.Symbol {
case "=":
match = target == opt.Num
@ -159,7 +157,6 @@ func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, er
match = target > opt.Num
case ">=":
match = target >= opt.Num
last = true
case "<":
match = target < opt.Num
case "<=":
@ -171,12 +168,6 @@ func (options PriceOptions) CalculatePrice(priceMode, target int32) (float32, er
if match {
switch priceMode { //1 单价模式
case 1:
if last {
return float32(target) * opt.Price, nil
}
if opt.TotalPrice > 0 {
return opt.TotalPrice, nil
}
return float32(target) * opt.Price, nil
case 2:
return opt.Price, nil

View File

@ -120,8 +120,6 @@ message ReconciliationInfo{
int32 payStatus = 12;
string serialNumber = 13;
uint64 userID = 14;
string handlingFee = 15;
string subNum = 16;
}
message OrderInfoByOrderNoRequest{
string orderNo = 1;
@ -208,7 +206,6 @@ message OrderBundleRecordInfo{
repeated OrderAddBundleRecordInfo addBundleInfo = 8;
int64 customerId = 9;
string payTime = 10;
string subNum = 11;
}
message OrderAddBundleRecordInfo{
string orderAddNo = 1;
@ -223,7 +220,6 @@ message OrderAddBundleRecordInfo{
string snapshot = 10;
string CheckoutSessionId = 11;
string CustomerID = 12;
int32 videoNum = 13;
}
message PackagePriceAndTimeResponse{
float price = 1 [json_name = "price"];
@ -524,7 +520,6 @@ message ValueAddPriceOptions {
string symbol = 3 [json_name = "symbol"];
string price = 4 [json_name = "price"];
string saveAmount = 5 [json_name = "saveAmount"];
string totalPrice = 6 [json_name = "totalPrice"];
}
//
@ -614,9 +609,8 @@ message BundleExtendRecordItem{
uint64 createdAt = 9;
string remark = 10;
string associatedOrderNumber = 11;
uint32 timeUnit = 12;
string operatorName = 13;
string operatorPhoneNumber = 14;
string operatorName = 12;
string operatorPhoneNumber = 13;
}
message GetBundleBalanceListReq{

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v3.20.3
// - protoc v4.24.0--rc1
// source: pb/bundle.proto
package bundle