Compare commits

...

13 Commits

Author SHA1 Message Date
cjy
6d0ccb0c9d Merge branch 'main' into feat-cjy-taskBench
# Conflicts:
#	pb/bundle/bundle.pb.go
#	pb/bundle/bundle_triple.pb.go
2025-10-16 16:45:28 +08:00
lzh
6cded5543f 过滤软删除 2025-10-10 17:11:55 +08:00
lzh
f0dbb9c9be 过滤重复作品 2025-10-10 17:07:43 +08:00
lzh
76390c3f66 使用记录查询条件 2025-10-10 16:39:19 +08:00
lzh
6c5ae80059 添加使用类型过滤 2025-10-10 14:14:13 +08:00
lzh
24e1eaed14 新增使用类型字段 2025-10-10 10:24:20 +08:00
lzh
422d2acb5a 添加使用类型字段 2025-10-09 17:09:43 +08:00
lzh
5edac38772 更新proto 2025-09-28 14:18:11 +08:00
sxy
61b7fedf0d 修改 2025-09-11 15:12:13 +08:00
sxy
17b557df77 修改条件 2025-09-11 15:10:26 +08:00
sxy
64c56d5ca3 单价模式新加总价字段 2025-09-11 14:47:07 +08:00
81e5d2f440 Update go.mod 2025-08-27 10:42:24 +08:00
52c23bdd43 更新 2025-08-27 10:23:22 +08:00
11 changed files with 693 additions and 838 deletions

36
.gitignore vendored Normal file
View File

@ -0,0 +1,36 @@
# 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,2 +1,4 @@
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.18
go 1.23.3
require (
dubbo.apache.org/dubbo-go/v3 v3.0.2

View File

@ -218,39 +218,46 @@ func CreateBundleBalance(data model.BundleBalance) error {
return app.ModuleClients.BundleDB.Create(&data).Error
}
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, total int64, err error) {
session := app.ModuleClients.BundleDB.Model(&model.CostLog{})
if req.Title != "" {
session = session.Where("title = ?", req.Title)
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, total int64, err error) {
session := app.ModuleClients.BundleDB.
Table("cast_cost_log ccl").
Select("ccl.*,cwl.cost_type").
Joins("left join cast_work_log cwl on cwl.work_uuid = ccl.work_uuid").
Where("cwl.work_status = 1 and cwl.deleted_at = 0 and ccl.deleted_at = 0")
if req.WorkTitle != "" {
session = session.Where("ccl.work_title like ?", "%"+req.WorkTitle+"%")
}
if req.Platform != 0 {
session = session.Where(fmt.Sprintf("JSON_CONTAINS(platform_ids,'%d')", req.Platform))
session = session.Where(fmt.Sprintf("JSON_CONTAINS(ccl.platform_ids,'%d')", req.Platform))
}
if req.Account != "" {
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(media_names,'"%s"')`, req.Account))
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(ccl.media_names,'"%s"')`, req.Account))
}
if req.SubmitTimeEnd != 0 {
session = session.Where("submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
session = session.Where("ccl.submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
}
if req.SubmitTimeStart != 0 {
session = session.Where("submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
session = session.Where("ccl.submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
}
if req.CostType != 0 {
session = session.Where("cwl.cost_type = ?", req.CostType)
}
if req.User != "" {
if utils.IsPhoneNumber(req.User) {
session = session.Where("artist_phone = ?", req.User)
session = session.Where("ccl.artist_phone = ?", req.User)
} else {
session = session.Where("artist_name like ?", "%"+req.User+"%")
session = session.Where("ccl.artist_name like ?", "%"+req.User+"%")
}
}
if req.Operator != "" {
if utils.IsPhoneNumber(req.Operator) {
session = session.Where("operator_phone = ?", req.Operator)
session = session.Where("ccl.operator_phone = ?", req.Operator)
} else {
session = session.Where("operator_name like ?", "%"+req.Operator+"%")
session = session.Where("ccl.operator_name like ?", "%"+req.Operator+"%")
}
}
if req.Type != 0 {
session = session.Where("work_category = ?", req.Type)
session = session.Where("ccl.work_category = ?", req.Type)
}
if err = session.Count(&total).Error; err != nil {
return
@ -258,7 +265,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, tota
if req.Page != 0 && req.PageSize != 0 {
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
}
err = session.Order("updated_at desc").Find(&data).Error
err = session.Order("ccl.updated_at desc").Find(&data).Error
return
}

View File

@ -123,7 +123,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (*bundle.GetUsedRecordListR
}
resp := &bundle.GetUsedRecordListResp{}
resp.Total = total
resp.Data = lo.Map(data, func(m model.CostLog, _ int) *bundle.WorkCastItem {
resp.Data = lo.Map(data, func(m model.CostLogPo, _ int) *bundle.WorkCastItem {
result := &bundle.WorkCastItem{}
copier.Copy(result, &m)
return result

View File

@ -165,7 +165,18 @@ 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("优惠单价转换失败")
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())
}
if option.Num < 0 || option.Num > 99 {
return res, errors.New("数量参数需为0-99")
@ -174,10 +185,11 @@ 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),
Id: int32(index),
Num: option.Num,
Symbol: option.Symbol,
Price: float32(price),
TotalPrice: float32(totalPrice),
})
index++
}
@ -358,7 +370,12 @@ 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))
saveAmount = original.Sub(price).Mul(num)
totalPrice := decimal.NewFromFloat(float64(option.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
case 2:
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
//price := decimal.NewFromFloat(float64(option.Price))
@ -371,6 +388,7 @@ 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),
})
}
@ -416,7 +434,12 @@ 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))
saveAmount = original.Sub(price).Mul(num)
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
case 2:
//original := decimal.NewFromFloat(float64(serviceLang.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -429,6 +452,7 @@ 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),
})
}
@ -499,7 +523,12 @@ func ValueAddServiceDetailByUuidAndLanguage(req *bundle.ValueAddServiceDetailReq
original := decimal.NewFromFloat(float64(detail.OriginalPrice))
price := decimal.NewFromFloat(float64(opt.Price))
num := decimal.NewFromInt(int64(opt.Num))
saveAmount = original.Sub(price).Mul(num)
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
case 2:
//original := decimal.NewFromFloat(float64(detail.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -512,6 +541,7 @@ 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),
})
}
@ -586,7 +616,12 @@ func BatchGetValueAddServiceLang(req *bundle.BatchGetValueAddServiceLangRequest)
original := decimal.NewFromFloat(float64(v.OriginalPrice))
price := decimal.NewFromFloat(float64(opt.Price))
num := decimal.NewFromInt(int64(opt.Num))
saveAmount = original.Sub(price).Mul(num)
totalPrice := decimal.NewFromFloat(float64(opt.TotalPrice))
if !totalPrice.IsZero() {
saveAmount = (original.Mul(num)).Sub(totalPrice)
} else {
saveAmount = original.Sub(price).Mul(num)
}
case 2:
//original := decimal.NewFromFloat(float64(v.OriginalPrice))
//price := decimal.NewFromFloat(float64(opt.Price))
@ -599,6 +634,7 @@ 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

@ -101,6 +101,7 @@ type CastWorkLog struct {
ArtistUuid string `gorm:"column:artist_uuid;type:varchar(50);comment:艺人ID;NOT NULL" json:"artist_uuid"`
MediaAccUserIds string `gorm:"column:media_acc_user_ids;type:json;comment:自媒体账号user_ids集合;NOT NULL" json:"media_acc_user_ids"`
MediaNames string `gorm:"column:media_names;type:varchar(600);comment:自媒体账号名称集合;NOT NULL" json:"media_names"`
CostType int `gorm:"column:cost_type;type:int(11)" json:"costType"`
ConfirmedAt int64 `gorm:"column:confirmed_at;type:int(11)" json:"confirmedAt"`
CreatedAt int `gorm:"column:created_at;type:int(11)" json:"created_at"`
UpdatedAt int `gorm:"column:updated_at;type:int(11)" json:"updated_at"`
@ -110,3 +111,8 @@ type CastWorkLog struct {
func (m *CastWorkLog) TableName() string {
return "cast_work_log"
}
type CostLogPo struct {
CostLog
CostType int `gorm:"column:cost_type;type:int(11)" json:"costType"`
}

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,10 +74,11 @@ 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决定是单价还是总价)
Id int32 `json:"id"`
Num int32 `json:"num"`
Symbol string `json:"symbol"` // 符号> < = >= <=
Price float32 `json:"price"` // 价格(根据priceMode决定是单价还是总价)
TotalPrice float32 `json:"totalPrice"` // 总价-新加
}
// 实现 driver.Valuer 接口
@ -150,6 +151,7 @@ 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
@ -157,6 +159,7 @@ 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 "<=":
@ -168,6 +171,12 @@ 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

@ -535,6 +535,7 @@ 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"];
}
//
@ -717,11 +718,12 @@ message GetUsedRecordListReq{
string account = 3;
int32 platform = 4;
int32 type = 5;
string title = 6;
string workTitle = 6;
int64 submitTimeStart = 7;
int64 submitTimeEnd = 8;
int32 page = 9;
int32 pageSize = 10;
int32 costType = 11;
}
message GetUsedRecordListResp {
@ -745,6 +747,7 @@ message WorkCastItem{
string operatorName = 13; //
string operatorPhone = 14; //
uint32 status = 15; // 1 2
uint32 costType = 16;
}
message GetImageWorkDetailReq {
@ -788,6 +791,7 @@ message workItem{
int64 createdAt = 11; //
string artistName = 12;
string artistUuid = 13;
uint32 costType = 14;
}
message ToBeComfirmedWorksResp{

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.21.1
// - protoc v3.12.4
// source: pb/bundle.proto
package bundle
@ -50,7 +50,7 @@ type BundleClient interface {
OrderRecordsListV2(ctx context.Context, in *OrderRecordsRequestV2, opts ...grpc_go.CallOption) (*OrderRecordsResponseV2, common.ErrorWithAttachment)
OrderListByOrderNo(ctx context.Context, in *OrderInfoByOrderNoRequest, opts ...grpc_go.CallOption) (*OrderInfoByOrderNoResp, common.ErrorWithAttachment)
OnlyAddValueListByOrderNo(ctx context.Context, in *OnlyAddValueListByOrderNoRequest, opts ...grpc_go.CallOption) (*OnlyAddValueListByOrderNoResp, common.ErrorWithAttachment)
// 增值套餐
// 增值套餐
CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment)
ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment)
ValueAddBundleDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment)