Compare commits
10 Commits
feat-cjy-t
...
main
Author | SHA1 | Date | |
---|---|---|---|
6cded5543f | |||
f0dbb9c9be | |||
76390c3f66 | |||
6c5ae80059 | |||
24e1eaed14 | |||
422d2acb5a | |||
5edac38772 | |||
61b7fedf0d | |||
17b557df77 | |||
64c56d5ca3 |
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal 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/*
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
})
|
||||
}
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -524,6 +524,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"];
|
||||
|
||||
}
|
||||
//增值服务列表
|
||||
@ -706,11 +707,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 {
|
||||
@ -734,6 +736,7 @@ message WorkCastItem{
|
||||
string operatorName = 13; // 操作人名称
|
||||
string operatorPhone = 14; // 操作人手机号
|
||||
uint32 status = 15; // 1 有效 2 失效
|
||||
uint32 costType = 16;
|
||||
}
|
||||
|
||||
message GetImageWorkDetailReq {
|
||||
@ -777,6 +780,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
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.5
|
||||
// - protoc v6.32.0
|
||||
// - protoc-gen-go-triple v1.0.8
|
||||
// - protoc v3.12.4
|
||||
// source: pb/bundle.proto
|
||||
|
||||
package bundle
|
||||
|
Loading…
Reference in New Issue
Block a user