Merge branch 'dev-lzh-0905' into dev
This commit is contained in:
commit
b01909e7f8
@ -5,6 +5,7 @@ import (
|
|||||||
"micro-bundle/internal/controller"
|
"micro-bundle/internal/controller"
|
||||||
_ "micro-bundle/internal/handler"
|
_ "micro-bundle/internal/handler"
|
||||||
"micro-bundle/pkg/app"
|
"micro-bundle/pkg/app"
|
||||||
|
"micro-bundle/pkg/cron"
|
||||||
"micro-bundle/pkg/db"
|
"micro-bundle/pkg/db"
|
||||||
"micro-bundle/pkg/tracing"
|
"micro-bundle/pkg/tracing"
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ func main() {
|
|||||||
if err = config.Load(); err != nil {
|
if err = config.Load(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
cron.InitCronJob() // 定时任务
|
||||||
select {}
|
select {}
|
||||||
// dao.AddBundleExtendRecord(model.BundleExtensionRecords{
|
// dao.AddBundleExtendRecord(model.BundleExtensionRecords{
|
||||||
// UserId: 57,
|
// UserId: 57,
|
||||||
|
@ -7,12 +7,8 @@ import (
|
|||||||
"micro-bundle/pb/bundle"
|
"micro-bundle/pb/bundle"
|
||||||
"micro-bundle/pkg/app"
|
"micro-bundle/pkg/app"
|
||||||
"micro-bundle/pkg/utils"
|
"micro-bundle/pkg/utils"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
|
||||||
"github.com/duke-git/lancet/v2/datetime"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,33 +18,12 @@ func AddBundleExtendRecord(data model.BundleExtensionRecords) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if data.AvailableDurationAdditional != 0 && data.TimeUnit != 0 {
|
if data.AvailableDurationAdditional != 0 && data.TimeUnit != 0 {
|
||||||
record := model.BundleOrderRecords{}
|
record := model.BundleBalance{}
|
||||||
if err := tx.Model(&model.BundleOrderRecords{}).Where(&model.BundleOrderRecords{CustomerID: strconv.Itoa(data.UserId)}).Order("created_at desc").First(&record).Error; err != nil {
|
if err := tx.Model(&model.BundleBalance{}).Where(&model.BundleBalance{UserId: data.UserId}).Order("month desc").First(&record).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var expireTime time.Time
|
record.ExpiredAt = record.ExpiredAt.Add(time.Hour * 24 * time.Duration(data.AvailableDurationAdditional))
|
||||||
if record.ExpirationTime != "" {
|
return tx.Save(record).Error
|
||||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
|
||||||
et, _ := time.ParseInLocation(time.DateTime, record.ExpirationTime, loc)
|
|
||||||
expireTime = et
|
|
||||||
} else {
|
|
||||||
t, _ := time.Parse("2006-01-02 15:04:05", record.PayTime)
|
|
||||||
expireTime = t
|
|
||||||
logger.Infof("过期时间为空,使用默认过期时间" + expireTime.Format(time.DateTime))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch data.TimeUnit {
|
|
||||||
case 1:
|
|
||||||
expireTime = datetime.AddDay(expireTime, int64(data.AvailableDurationAdditional))
|
|
||||||
case 2:
|
|
||||||
expireTime = datetime.AddMonth(expireTime, int64(data.AvailableDurationAdditional))
|
|
||||||
case 3:
|
|
||||||
expireTime = datetime.AddYear(expireTime, int64(data.AvailableDurationAdditional))
|
|
||||||
default:
|
|
||||||
return errors.New("时间单位有误")
|
|
||||||
}
|
|
||||||
record.ExpirationTime = expireTime.Format(time.DateTime)
|
|
||||||
return tx.Model(&model.BundleOrderRecords{}).Where(&model.BundleOrderRecords{UUID: record.UUID}).Updates(&record).Error
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -107,15 +82,17 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun
|
|||||||
FROM bundle_order_records
|
FROM bundle_order_records
|
||||||
GROUP BY customer_id
|
GROUP BY customer_id
|
||||||
) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`)
|
) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`)
|
||||||
session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").
|
session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").Unscoped().
|
||||||
Select(`bb.*, bor.expiration_time as expired_time, bor.bundle_name, bor.status,
|
Select(`bb.*, bor.bundle_name, bor.status,
|
||||||
bor.uuid as order_uuid, rn.name as user_name,
|
bor.uuid as order_uuid, rn.name as user_name,bc.activate,
|
||||||
u.tel_num as user_phone_number, u.id as user_id`).
|
u.tel_num as user_phone_number, u.id as user_id`).
|
||||||
Joins("LEFT JOIN `micro-account`.real_name rn ON u.real_name_id = rn.id").
|
Joins("LEFT JOIN `micro-account`.real_name rn ON u.real_name_id = rn.id").
|
||||||
Joins("LEFT JOIN (?) as bor ON bor.customer_id = u.id", subQuery).
|
Joins("LEFT JOIN (?) as bor ON bor.customer_id = u.id", subQuery).
|
||||||
Joins("LEFT JOIN fiee_bundle.bundle_balance bb ON u.id = bb.user_id AND bb.order_uuid = bor.uuid").
|
Joins("LEFT JOIN fiee_bundle.bundle_balance bb ON u.id = bb.user_id AND bb.order_uuid = bor.uuid").
|
||||||
|
Joins("LEFT JOIN bundle_activate bc on bc.user_id = u.id").
|
||||||
Where("rn.name IS NOT NULL").
|
Where("rn.name IS NOT NULL").
|
||||||
Where("u.deleted_at = 0").
|
Where("u.deleted_at = 0").
|
||||||
|
Where("bb.month = ?", req.Month).
|
||||||
Order("bor.expiration_time desc")
|
Order("bor.expiration_time desc")
|
||||||
if req.UserName != "" {
|
if req.UserName != "" {
|
||||||
if utils.IsPhoneNumber(req.UserName) {
|
if utils.IsPhoneNumber(req.UserName) {
|
||||||
@ -131,10 +108,10 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun
|
|||||||
session = session.Where("bor.bundle_name like ?", "%"+req.BundleName+"%")
|
session = session.Where("bor.bundle_name like ?", "%"+req.BundleName+"%")
|
||||||
}
|
}
|
||||||
if req.ExpiredTimeEnd != 0 {
|
if req.ExpiredTimeEnd != 0 {
|
||||||
session = session.Where("bor.expiration_time <= ?", time.UnixMilli(req.ExpiredTimeEnd))
|
session = session.Where("bb.expired_at <= ?", time.UnixMilli(req.ExpiredTimeEnd))
|
||||||
}
|
}
|
||||||
if req.ExpiredTimeStart != 0 {
|
if req.ExpiredTimeStart != 0 {
|
||||||
session = session.Where("bor.expiration_time >= ?", time.UnixMilli(req.ExpiredTimeStart))
|
session = session.Where("bb.expired_at >= ?", time.UnixMilli(req.ExpiredTimeStart))
|
||||||
}
|
}
|
||||||
if req.Bought == 2 {
|
if req.Bought == 2 {
|
||||||
session = session.Where("bor.uuid IS NOT NULL")
|
session = session.Where("bor.uuid IS NOT NULL")
|
||||||
@ -154,63 +131,246 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (data model.UserBundleBalancePo, err error) {
|
func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (data model.UserBundleBalancePo, err error) {
|
||||||
err = app.ModuleClients.BundleDB.Table("fiee_bundle.bundle_balance AS bb").
|
subQuery := app.ModuleClients.BundleDB.Table("bundle_order_records as bor1").
|
||||||
Select("bb.*,bor.uuid AS order_uuid, bor.bundle_name AS bundle_name, bor.status AS bundle_status, bor.pay_time AS pay_time, bor.expiration_time AS expired_time,bor.amount AS payment_amount,bor.amount_type AS payment_type").
|
Select("bor1.*").
|
||||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid").
|
Joins(`INNER JOIN (
|
||||||
Joins("LEFT JOIN `micro-account`.`user` u ON u.id = bb.user_id").
|
SELECT customer_id, MAX(created_at) AS max_created_time
|
||||||
Where("bor.deleted_at IS NULL").
|
FROM bundle_order_records
|
||||||
Where("bb.user_id = ?", req.UserId).
|
GROUP BY customer_id
|
||||||
// Where("bor.expiration_time > ?", time.Now()).
|
) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`)
|
||||||
Order("bb.created_at desc").
|
session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").Unscoped().
|
||||||
First(&data).Error
|
Select(`bb.*, bor.bundle_name, bor.status,bor.amount AS payment_amount,bor.amount_type AS payment_type,
|
||||||
if err != nil {
|
bor.uuid as order_uuid, rn.name as user_name,bc.activate,
|
||||||
return
|
u.tel_num as user_phone_number, u.id as user_id`).
|
||||||
}
|
Joins("LEFT JOIN `micro-account`.real_name rn ON u.real_name_id = rn.id").
|
||||||
var additionalInfo model.UserBundleBalancePo
|
Joins("LEFT JOIN (?) as bor ON bor.customer_id = u.id", subQuery).
|
||||||
err = app.ModuleClients.BundleDB.Model(&model.BundleExtensionRecords{}).
|
Joins("LEFT JOIN fiee_bundle.bundle_balance bb ON u.id = bb.user_id AND bb.order_uuid = bor.uuid").
|
||||||
Select("SUM(account_additional) as account_additional, SUM(images_additional) as image_additional, SUM(video_additional) as video_additional, SUM(data_additional) as data_additional").
|
Joins("LEFT JOIN bundle_activate bc on bc.user_id = u.id").
|
||||||
Where("type = 1"). // 手动扩展
|
Where("rn.name IS NOT NULL").
|
||||||
Where("user_id = ?", req.UserId).
|
Where("u.deleted_at = 0").
|
||||||
Where("created_at > ?", data.PayTime). // 判断扩展是否生效
|
Where("u.id = ?", req.UserId).
|
||||||
First(&additionalInfo).Error
|
Where("bb.month = ?", time.Now().Format("2006-01")).
|
||||||
if err != nil {
|
Order("bor.expiration_time desc")
|
||||||
return
|
err = session.First(&data).Error
|
||||||
}
|
|
||||||
data.AccountAdditional = additionalInfo.AccountAdditional
|
|
||||||
data.VideoAdditional = additionalInfo.VideoAdditional
|
|
||||||
data.ImageAdditional = additionalInfo.ImageAdditional
|
|
||||||
data.DataAnalysisAdditional = additionalInfo.DataAnalysisAdditional
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddBundleBalanceByUserId(data model.BundleBalance) error {
|
func AddBundleBalanceByUserId(data model.BundleBalanceUsePo) (usedType int, err error) {
|
||||||
|
err = app.ModuleClients.BundleDB.Transaction(func(tx *gorm.DB) (err error) {
|
||||||
|
ba := model.BundleActivate{}
|
||||||
|
if err := tx.Model(&model.BundleActivate{}).Where("user_id = ?", data.UserId).First(&ba).Error; err != nil || ba.Activate != 2 {
|
||||||
|
return errors.New("套餐未激活")
|
||||||
|
}
|
||||||
|
oldData := model.BundleBalance{}
|
||||||
|
if err := tx.Model(&model.BundleBalance{}).Where("user_id = ?", data.UserId).Where("month = ?", time.Now().Format("2006-01")).Order("created_at desc").First(&oldData).Error; err != nil {
|
||||||
|
return errors.New("用户还没有套餐信息")
|
||||||
|
}
|
||||||
|
if data.AccountNumber > 0 { // 增加账号消耗数
|
||||||
|
if oldData.BundleAccountConsumptionNumber < oldData.BundleAccountNumber { // 消耗账号数优先套餐内
|
||||||
|
oldData.BundleAccountConsumptionNumber++
|
||||||
|
usedType = 1
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseAccountConsumptionNumber < oldData.IncreaseAccountNumber { // 其次消耗增值的
|
||||||
|
oldData.IncreaseAccountConsumptionNumber++
|
||||||
|
usedType = 2
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.ManualAccountConsumptionNumber < oldData.ManualAccountNumber { // 最后消耗手动扩展的
|
||||||
|
oldData.ManualAccountConsumptionNumber++
|
||||||
|
oldData.MonthlyManualAccountConsumptionNumber++
|
||||||
|
usedType = 3
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
return errors.New("账号数不足")
|
||||||
|
} else if data.AccountNumber < 0 { // 减少账号消耗数,用于解绑账号
|
||||||
|
if oldData.ManualAccountConsumptionNumber > 0 { // 最后消耗手动扩展的
|
||||||
|
oldData.ManualAccountConsumptionNumber--
|
||||||
|
oldData.MonthlyManualAccountConsumptionNumber--
|
||||||
|
usedType = 3
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseAccountConsumptionNumber > 0 {
|
||||||
|
oldData.IncreaseAccountConsumptionNumber--
|
||||||
|
usedType = 2
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.BundleAccountConsumptionNumber > 0 {
|
||||||
|
oldData.BundleAccountConsumptionNumber--
|
||||||
|
usedType = 1
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
return errors.New("当前未绑定账号")
|
||||||
|
}
|
||||||
|
if data.VideoNumber > 0 {
|
||||||
|
if oldData.MonthlyLimitVideoExpireNumber > oldData.MonthlyLimitVideoExpireConsumptionNumber { // 当月可使用的会过期的限制类型充足
|
||||||
|
if oldData.BundleLimitVideoExpiredConsumptionNumber < oldData.BundleLimitVideoExpiredNumber { // 套餐内会过期的限制类型视频充足
|
||||||
|
oldData.MonthlyLimitVideoExpireConsumptionNumber++
|
||||||
|
oldData.BundleLimitVideoExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleVideoConsumptionNumber++
|
||||||
|
usedType = 1
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitVideoExpiredConsumptionNumber < oldData.IncreaseLimitVideoExpiredNumber { // 增值服务会过期的限制类型视频充足
|
||||||
|
oldData.MonthlyLimitVideoExpireConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitVideoExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseVideoConsumptionNumber++
|
||||||
|
usedType = 2
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.MonthlyLimitVideoNumber > oldData.MonthlyLimitVideoConsumptionNumber { // 当月可使用的不过期的限制类型充足
|
||||||
|
if oldData.BundleLimitVideoConsumptionNumber < oldData.BundleLimitVideoNumber { // 套餐内不过期的限制类型视频充足
|
||||||
|
oldData.MonthlyLimitVideoConsumptionNumber++
|
||||||
|
oldData.BundleLimitVideoConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleVideoConsumptionNumber++
|
||||||
|
usedType = 1
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitVideoConsumptionNumber < oldData.IncreaseLimitVideoNumber { // 增值服务不过期的限制类型视频充足
|
||||||
|
oldData.MonthlyLimitVideoConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitVideoConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseVideoConsumptionNumber++
|
||||||
|
usedType = 2
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.BundleVideoConsumptionNumber < oldData.BundleVideoNumber { //套餐内非限制类型的视频充足
|
||||||
|
oldData.BundleVideoConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleVideoConsumptionNumber++
|
||||||
|
usedType = 1
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseVideoConsumptionNumber < oldData.IncreaseVideoNumber { //增值服务非限制类型的视频充足
|
||||||
|
oldData.IncreaseVideoConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseVideoConsumptionNumber++
|
||||||
|
usedType = 2
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.ManualVideoConsumptionNumber < oldData.ManualDataAnalysisNumber { // 手动扩展类型充足
|
||||||
|
oldData.ManualVideoConsumptionNumber++
|
||||||
|
oldData.MonthlyManualVideoConsumptionNumber++ // 记录本月使用的手动扩展
|
||||||
|
usedType = 3
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
return errors.New("可用视频数不足")
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.ImageNumber > 0 {
|
||||||
|
if oldData.MonthlyLimitImageExpireNumber > oldData.MonthlyLimitImageExpireConsumptionNumber { // 当月可使用的会过期的限制类型充足
|
||||||
|
if oldData.BundleLimitImageExpiredConsumptionNumber < oldData.BundleLimitImageExpiredNumber { // 套餐内会过期的限制类型图文充足
|
||||||
|
oldData.MonthlyLimitImageExpireConsumptionNumber++
|
||||||
|
oldData.BundleLimitImageExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitImageExpiredConsumptionNumber < oldData.IncreaseLimitImageExpiredNumber { // 增值服务会过期的限制类型图文充足
|
||||||
|
oldData.MonthlyLimitImageExpireConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitImageExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.MonthlyLimitImageNumber > oldData.MonthlyLimitImageConsumptionNumber { // 当月可使用的不过期的限制类型充足
|
||||||
|
if oldData.BundleLimitImageConsumptionNumber < oldData.BundleLimitImageNumber { // 套餐内不过期的限制类型图文充足
|
||||||
|
oldData.MonthlyLimitImageConsumptionNumber++
|
||||||
|
oldData.BundleLimitImageConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitImageConsumptionNumber < oldData.IncreaseLimitImageNumber { // 增值服务不过期的限制类型图文充足
|
||||||
|
oldData.MonthlyLimitImageConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitImageConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.BundleImageConsumptionNumber < oldData.BundleImageNumber { //套餐内非限制类型的图文充足
|
||||||
|
oldData.BundleImageConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseImageConsumptionNumber < oldData.IncreaseImageNumber { //增值服务非限制类型的图文充足
|
||||||
|
oldData.IncreaseImageConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseImageConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.ManualImageConsumptionNumber < oldData.ManualDataAnalysisNumber { // 手动扩展类型充足
|
||||||
|
oldData.ManualImageConsumptionNumber++
|
||||||
|
oldData.MonthlyManualImageConsumptionNumber++ // 记录本月使用的手动扩展
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
return errors.New("可用图文数不足")
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.DataAnalysisNumber > 0 {
|
||||||
|
if oldData.MonthlyLimitDataAnalysisExpireNumber > oldData.MonthlyLimitDataAnalysisExpireConsumptionNumber { // 当月可使用的会过期的限制类型充足
|
||||||
|
if oldData.BundleLimitDataAnalysisExpiredConsumptionNumber < oldData.BundleLimitDataAnalysisExpiredNumber { // 套餐内会过期的限制类型数据分析充足
|
||||||
|
oldData.MonthlyLimitDataAnalysisExpireConsumptionNumber++
|
||||||
|
oldData.BundleLimitDataAnalysisExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitDataAnalysisExpiredConsumptionNumber < oldData.IncreaseLimitDataAnalysisExpiredNumber { // 增值服务会过期的限制类型数据分析充足
|
||||||
|
oldData.MonthlyLimitDataAnalysisExpireConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitDataAnalysisExpiredConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.MonthlyLimitDataAnalysisNumber > oldData.MonthlyLimitDataAnalysisConsumptionNumber { // 当月可使用的不过期的限制类型充足
|
||||||
|
if oldData.BundleLimitDataAnalysisConsumptionNumber < oldData.BundleLimitDataAnalysisNumber { // 套餐内不过期的限制类型数据分析充足
|
||||||
|
oldData.MonthlyLimitDataAnalysisConsumptionNumber++
|
||||||
|
oldData.BundleLimitDataAnalysisConsumptionNumber++
|
||||||
|
oldData.MonthlyBundleDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseLimitDataAnalysisConsumptionNumber < oldData.IncreaseLimitDataAnalysisNumber { // 增值服务不过期的限制类型数据分析充足
|
||||||
|
oldData.MonthlyLimitDataAnalysisConsumptionNumber++
|
||||||
|
oldData.IncreaseLimitDataAnalysisConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if oldData.BundleLimitDataAnalysisNumber < oldData.BundleDataAnalysisNumber { //套餐内非限制类型的数据分析充足
|
||||||
|
oldData.BundleLimitDataAnalysisNumber++
|
||||||
|
oldData.MonthlyBundleDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.IncreaseDataAnalysisConsumptionNumber < oldData.IncreaseDataAnalysisNumber { //增值服务非限制类型的数据分析充足
|
||||||
|
oldData.IncreaseDataAnalysisConsumptionNumber++
|
||||||
|
oldData.MonthlyIncreaseDataAnalysisConsumptionNumber++
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
if oldData.ManualDataAnalysisConsumptionNumber < oldData.ManualDataAnalysisNumber { // 手动扩展类型充足
|
||||||
|
oldData.ManualDataAnalysisConsumptionNumber++
|
||||||
|
oldData.MonthlyManualDataAnalysisConsumptionNumber++ // 记录本月使用的手动扩展
|
||||||
|
goto Over
|
||||||
|
}
|
||||||
|
return errors.New("可用数据分析数不足")
|
||||||
|
}
|
||||||
|
Over:
|
||||||
|
return tx.Model(&model.BundleBalance{}).Where("id = ?", oldData.ID).Save(&oldData).Error
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateUsedRecord(tx *gorm.DB, data model.BundleUsedRecord) error {
|
||||||
|
return tx.Create(&data).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExtendBundleBalanceByUserId(data model.BundleBalanceExtendPo) error {
|
||||||
return app.ModuleClients.BundleDB.Transaction(func(tx *gorm.DB) error {
|
return app.ModuleClients.BundleDB.Transaction(func(tx *gorm.DB) error {
|
||||||
oldData := model.BundleBalance{}
|
oldData := model.BundleBalance{}
|
||||||
if err := tx.Model(&model.BundleBalance{}).Where("user_id = ?", data.UserId).Order("created_at desc").First(&oldData).Error; err != nil {
|
if err := tx.Model(&model.BundleBalance{}).Where("user_id = ?", data.UserId).Order("created_at desc").First(&oldData).Error; err != nil {
|
||||||
return errors.New("用户还没有套餐信息")
|
return errors.New("用户还没有套餐信息")
|
||||||
}
|
}
|
||||||
newData := model.BundleBalance{
|
oldData.ManualImageNumber += data.ImageNumber
|
||||||
Model: oldData.Model,
|
oldData.ManualDataAnalysisNumber += data.DataAnalysisNumber
|
||||||
UserId: oldData.UserId,
|
oldData.ManualVideoNumber += data.VideoNumber
|
||||||
OrderUUID: oldData.OrderUUID,
|
oldData.MonthlyNewDurationNumber += data.DurationNumber // 记录本月新增手动扩展时长
|
||||||
AccountNumber: oldData.AccountNumber + data.AccountNumber,
|
oldData.ExpiredAt.Add(time.Hour * 24 * time.Duration(data.DurationNumber))
|
||||||
AccountConsumptionNumber: oldData.AccountConsumptionNumber + data.AccountConsumptionNumber,
|
return tx.Model(&model.BundleBalance{}).Where("id = ?", oldData.ID).Save(&oldData).Error
|
||||||
VideoNumber: oldData.VideoNumber + data.VideoNumber,
|
|
||||||
VideoConsumptionNumber: oldData.VideoConsumptionNumber + data.VideoConsumptionNumber,
|
|
||||||
ImageNumber: oldData.ImageNumber + data.ImageNumber,
|
|
||||||
ImageConsumptionNumber: oldData.ImageConsumptionNumber + data.ImageConsumptionNumber,
|
|
||||||
DataAnalysisNumber: oldData.DataAnalysisNumber + data.DataAnalysisNumber,
|
|
||||||
DataAnalysisConsumptionNumber: oldData.DataAnalysisConsumptionNumber + data.DataAnalysisConsumptionNumber,
|
|
||||||
ExpansionPacksNumber: oldData.ExpansionPacksNumber + data.ExpansionPacksNumber,
|
|
||||||
}
|
|
||||||
|
|
||||||
if newData.AccountConsumptionNumber > newData.AccountNumber ||
|
|
||||||
newData.VideoConsumptionNumber > newData.VideoNumber ||
|
|
||||||
newData.ImageConsumptionNumber > newData.ImageNumber ||
|
|
||||||
newData.DataAnalysisConsumptionNumber > newData.DataAnalysisNumber {
|
|
||||||
return errors.New("套餐余量不足")
|
|
||||||
}
|
|
||||||
return tx.Model(&model.BundleBalance{}).Where("id = ?", oldData.ID).Save(&newData).Error
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,41 +382,42 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, to
|
|||||||
session := app.ModuleClients.BundleDB.
|
session := app.ModuleClients.BundleDB.
|
||||||
Table("cast_cost_log ccl").
|
Table("cast_cost_log ccl").
|
||||||
Select("ccl.*,cwl.cost_type").
|
Select("ccl.*,cwl.cost_type").
|
||||||
Joins("left join cast_work_log cwl on cwl.work_uuid = ccl.work_uuid")
|
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 != "" {
|
if req.WorkTitle != "" {
|
||||||
session = session.Where("work_title like ?", "%"+req.WorkTitle+"%")
|
session = session.Where("ccl.work_title like ?", "%"+req.WorkTitle+"%")
|
||||||
}
|
}
|
||||||
if req.Platform != 0 {
|
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 != "" {
|
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 {
|
if req.SubmitTimeEnd != 0 {
|
||||||
session = session.Where("artist_confirmed_time <= ?", req.SubmitTimeEnd/1000) // 转换为秒级时间戳
|
session = session.Where("ccl.submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
|
||||||
}
|
}
|
||||||
if req.SubmitTimeStart != 0 {
|
if req.SubmitTimeStart != 0 {
|
||||||
session = session.Where("artist_confirmed_time >= ?", req.SubmitTimeStart/1000)
|
session = session.Where("ccl.submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
|
||||||
}
|
}
|
||||||
if req.CostType != 0 {
|
if req.CostType != 0 {
|
||||||
session = session.Where("cwl.cost_type = ?", req.CostType)
|
session = session.Where("cwl.cost_type = ?", req.CostType)
|
||||||
}
|
}
|
||||||
if req.User != "" {
|
if req.User != "" {
|
||||||
if utils.IsPhoneNumber(req.User) {
|
if utils.IsPhoneNumber(req.User) {
|
||||||
session = session.Where("artist_phone = ?", req.User)
|
session = session.Where("ccl.artist_phone = ?", req.User)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("artist_name like ?", "%"+req.User+"%")
|
session = session.Where("ccl.artist_name like ?", "%"+req.User+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Operator != "" {
|
if req.Operator != "" {
|
||||||
if utils.IsPhoneNumber(req.Operator) {
|
if utils.IsPhoneNumber(req.Operator) {
|
||||||
session = session.Where("operator_phone = ?", req.Operator)
|
session = session.Where("ccl.operator_phone = ?", req.Operator)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("operator_name like ?", "%"+req.Operator+"%")
|
session = session.Where("ccl.operator_name like ?", "%"+req.Operator+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Type != 0 {
|
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 {
|
if err = session.Count(&total).Error; err != nil {
|
||||||
return
|
return
|
||||||
@ -315,9 +476,117 @@ func ConfirmWork(req *bundle.ConfirmWorkReq) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BundleActivate(ids []uint32) error {
|
func BundleActivate(ids []uint32) error {
|
||||||
batch := []model.BundleActivate{}
|
|
||||||
for _, v := range ids {
|
for _, v := range ids {
|
||||||
batch = append(batch, model.BundleActivate{UserId: int(v), Activate: true})
|
app.ModuleClients.BundleDB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
activate := model.BundleActivate{}
|
||||||
|
if err := tx.Model(&model.BundleActivate{}).Where("user_id = ?", v).First(&activate).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if activate.Activate == 2 { // 第一次激活重新计算余量的开始时间和过期时间
|
||||||
|
balance := model.BundleBalance{}
|
||||||
|
if err := tx.Model(&model.BundleBalance{}).Where("user_id = ?", v).First(&balance).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
balance.ExpiredAt = balance.ExpiredAt.Add(time.Since(balance.StartAt))
|
||||||
|
balance.StartAt = time.Now()
|
||||||
|
if err := tx.Model(&model.BundleBalance{}).Save(balance).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
activate.Activate = 2
|
||||||
|
return tx.Model(&model.BundleActivate{}).Save(activate).Error
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return app.ModuleClients.BundleDB.Model(&model.BundleActivate{}).Where("user_id = ?").Save(batch).Error
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetValueAddByOrderUUID(orderUUID string) (data []model.BundleOrderValueAdd, err error) {
|
||||||
|
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).Where("order_uuid = ?", orderUUID).Find(&data).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateBundleBalance() error {
|
||||||
|
bl := []model.BundleBalance{}
|
||||||
|
if err := app.ModuleClients.BundleDB.Raw(`select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
bundle_balance bb
|
||||||
|
inner join (
|
||||||
|
select
|
||||||
|
max(bb.month) as month ,
|
||||||
|
user_id
|
||||||
|
from
|
||||||
|
bundle_balance bb
|
||||||
|
group by
|
||||||
|
bb.user_id
|
||||||
|
) newest on
|
||||||
|
newest.month = bb.month
|
||||||
|
and bb.user_id = newest.user_id
|
||||||
|
and bb.expired_at > now()`).Find(&bl).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
month := time.Now().Format("2006-01")
|
||||||
|
for _, v := range bl {
|
||||||
|
if v.Month == month {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
cal := func(total, limit int) int { // 计算本月发放的限制类型数量
|
||||||
|
var released int // 已释放的次数
|
||||||
|
if v.StartAt.Month() == now.Month() && v.StartAt.Year() == now.Year() {
|
||||||
|
} else if v.StartAt.Day() >= 16 { //第一个月释放的
|
||||||
|
released += limit/2 + 1
|
||||||
|
} else {
|
||||||
|
released += limit
|
||||||
|
}
|
||||||
|
interval := now.Year()*12 + int(now.Month()) - (v.StartAt.Year()*12 + int(v.StartAt.Month())) // 后续月份释放的
|
||||||
|
released += interval * limit
|
||||||
|
remaining := max(total-released, 0) // 还剩余多少次没有发放
|
||||||
|
|
||||||
|
if v.StartAt.Month() == now.Month() && v.StartAt.Year() == now.Year() && v.StartAt.Day() >= 16 { // 本月为第一个月并且16号后购买只给一半(向上取整)
|
||||||
|
return min(limit/2+1, remaining)
|
||||||
|
}
|
||||||
|
if v.ExpiredAt.Month() == now.Month() && v.ExpiredAt.Year() == now.Year() && v.ExpiredAt.Day() < 16 { // 本月为最后一个月并且16号前到期只给一半(向下取整)
|
||||||
|
return min(limit/2, remaining)
|
||||||
|
}
|
||||||
|
return min(limit, remaining)
|
||||||
|
}
|
||||||
|
|
||||||
|
v.MonthlyInvalidBundleVideoNumber = v.MonthlyLimitVideoExpireNumber - v.MonthlyLimitVideoExpireConsumptionNumber // 当月过期的视频数
|
||||||
|
v.InvalidBundleVideoNumber += v.MonthlyInvalidBundleVideoNumber
|
||||||
|
v.MonthlyInvalidBundleImageNumber = v.MonthlyLimitImageExpireNumber - v.MonthlyLimitImageExpireConsumptionNumber
|
||||||
|
v.InvalidBundleImageNumber += v.MonthlyInvalidBundleImageNumber
|
||||||
|
v.MonthlyInvalidBundleDataAnalysisNumber = v.MonthlyLimitDataAnalysisExpireNumber - v.MonthlyLimitDataAnalysisExpireConsumptionNumber
|
||||||
|
v.InvalidBundleDataAnalysisNumber += v.MonthlyInvalidBundleDataAnalysisNumber
|
||||||
|
|
||||||
|
// 当月可用的限制类型数等于本月方法的套餐和增值两种类型的总和
|
||||||
|
v.MonthlyLimitVideoExpireNumber = cal(v.BundleLimitVideoExpiredNumber, v.MonthlyLimitVideoQuotaNumber) + cal(v.IncreaseLimitVideoExpiredNumber, v.MonthlyLimitVideoQuotaNumber)
|
||||||
|
v.MonthlyLimitVideoNumber = v.MonthlyLimitVideoNumber - v.MonthlyLimitVideoConsumptionNumber + cal(v.BundleLimitVideoNumber, v.MonthlyLimitVideoQuotaNumber) + cal(v.IncreaseLimitVideoNumber, v.MonthlyLimitVideoQuotaNumber)
|
||||||
|
v.MonthlyLimitImageExpireNumber = cal(v.BundleLimitImageExpiredNumber, v.MonthlyLimitImageQuotaNumber) + cal(v.IncreaseLimitImageExpiredNumber, v.MonthlyLimitImageQuotaNumber)
|
||||||
|
v.MonthlyLimitImageNumber = v.MonthlyLimitImageNumber - v.MonthlyLimitImageConsumptionNumber + cal(v.BundleLimitImageNumber, v.MonthlyLimitImageQuotaNumber) + cal(v.IncreaseLimitImageNumber, v.MonthlyLimitImageQuotaNumber)
|
||||||
|
v.MonthlyLimitDataAnalysisExpireNumber = cal(v.BundleLimitDataAnalysisExpiredNumber, v.MonthlyLimitDataAnalysisQuotaNumber) + cal(v.IncreaseLimitDataAnalysisExpiredNumber, v.MonthlyLimitDataAnalysisQuotaNumber)
|
||||||
|
v.MonthlyLimitDataAnalysisNumber = v.MonthlyLimitDataAnalysisNumber - v.MonthlyLimitDataAnalysisConsumptionNumber + cal(v.BundleLimitDataAnalysisNumber, v.MonthlyLimitDataAnalysisQuotaNumber) + cal(v.IncreaseLimitDataAnalysisNumber, v.MonthlyLimitDataAnalysisQuotaNumber)
|
||||||
|
|
||||||
|
v.MonthlyLimitVideoConsumptionNumber = 0 // 重置单月消耗数量
|
||||||
|
v.MonthlyLimitVideoExpireConsumptionNumber = 0
|
||||||
|
v.MonthlyManualVideoConsumptionNumber = 0
|
||||||
|
v.MonthlyLimitImageConsumptionNumber = 0
|
||||||
|
v.MonthlyLimitImageExpireConsumptionNumber = 0
|
||||||
|
v.MonthlyManualImageConsumptionNumber = 0
|
||||||
|
v.MonthlyLimitDataAnalysisConsumptionNumber = 0
|
||||||
|
v.MonthlyLimitDataAnalysisExpireConsumptionNumber = 0
|
||||||
|
v.MonthlyManualDataAnalysisConsumptionNumber = 0
|
||||||
|
v.MonthlyBundleVideoConsumptionNumber = 0
|
||||||
|
v.MonthlyBundleImageConsumptionNumber = 0
|
||||||
|
v.MonthlyBundleDataAnalysisConsumptionNumber = 0
|
||||||
|
v.MonthlyIncreaseVideoConsumptionNumber = 0
|
||||||
|
v.MonthlyIncreaseImageConsumptionNumber = 0
|
||||||
|
v.MonthlyIncreaseDataAnalysisConsumptionNumber = 0
|
||||||
|
v.Month = month
|
||||||
|
v.ID = 0
|
||||||
|
app.ModuleClients.BundleDB.Create(&v)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"micro-bundle/internal/dao"
|
"micro-bundle/internal/dao"
|
||||||
"micro-bundle/internal/model"
|
"micro-bundle/internal/model"
|
||||||
"micro-bundle/pb/bundle"
|
"micro-bundle/pb/bundle"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
||||||
@ -17,13 +18,13 @@ func BundleExtend(req *bundle.BundleExtendRequest) (*bundle.BundleExtendResponse
|
|||||||
if err := copier.CopyWithOption(&data, req, copier.Option{DeepCopy: true}); err != nil {
|
if err := copier.CopyWithOption(&data, req, copier.Option{DeepCopy: true}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := dao.AddBundleBalanceByUserId(model.BundleBalance{
|
if err := dao.ExtendBundleBalanceByUserId(model.BundleBalanceExtendPo{
|
||||||
UserId: int(req.UserId),
|
UserId: int(req.UserId),
|
||||||
VideoNumber: int(req.VideoAdditional),
|
VideoNumber: int(req.VideoAdditional),
|
||||||
ImageNumber: int(req.ImagesAdditional),
|
ImageNumber: int(req.ImagesAdditional),
|
||||||
DataAnalysisNumber: int(req.DataAdditional),
|
DataAnalysisNumber: int(req.DataAdditional),
|
||||||
AccountNumber: int(req.AccountAdditional),
|
AccountNumber: int(req.AccountAdditional),
|
||||||
ExpansionPacksNumber: 1,
|
DurationNumber: int(req.DataAdditional),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, errors.New("用户没有余量信息")
|
return nil, errors.New("用户没有余量信息")
|
||||||
}
|
}
|
||||||
@ -60,17 +61,75 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (*bundle.GetBundl
|
|||||||
}
|
}
|
||||||
resp := &bundle.GetBundleBalanceListResp{}
|
resp := &bundle.GetBundleBalanceListResp{}
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
|
date, err := time.Parse("2006-01", req.Month)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.New("请求时间有误")
|
||||||
|
}
|
||||||
resp.Data = lo.Map(data, func(m model.BundleBalancePo, _ int) *bundle.BundleBalanceItem {
|
resp.Data = lo.Map(data, func(m model.BundleBalancePo, _ int) *bundle.BundleBalanceItem {
|
||||||
result := &bundle.BundleBalanceItem{}
|
result := &bundle.BundleBalanceItem{
|
||||||
copier.Copy(result, &m)
|
UserId: int32(m.UserId),
|
||||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
UserName: m.UserName,
|
||||||
t, _ := time.ParseInLocation(time.DateTime, m.ExpirationTime, loc)
|
UserPhoneNumber: m.UserPhoneNumber,
|
||||||
|
Status: int32(m.Status),
|
||||||
|
BundleName: m.BundleName,
|
||||||
|
ExpiredTime: m.ExpiredAt.UnixMilli(),
|
||||||
|
// 账号类
|
||||||
|
BundleAccountNumber: int32(m.BundleAccountNumber),
|
||||||
|
IncreaseAccountNumber: int32(m.IncreaseAccountNumber),
|
||||||
|
BundleAccountConsumptionNumber: int32(m.BundleAccountConsumptionNumber),
|
||||||
|
IncreaseAccountConsumptionNumber: int32(m.IncreaseAccountConsumptionNumber),
|
||||||
|
// 视频类
|
||||||
|
BundleVideoNumber: int32(m.BundleVideoNumber) + int32(m.BundleLimitVideoNumber) + int32(m.BundleLimitVideoExpiredNumber),
|
||||||
|
IncreaseVideoNumber: int32(m.IncreaseVideoNumber) + int32(m.IncreaseLimitVideoNumber) + int32(m.IncreaseLimitVideoExpiredNumber),
|
||||||
|
BundleVideoConsumptionNumber: int32(m.BundleVideoConsumptionNumber) + int32(m.BundleLimitVideoConsumptionNumber) + int32(m.BundleLimitVideoExpiredConsumptionNumber),
|
||||||
|
IncreaseVideoConsumptionNumber: int32(m.IncreaseVideoConsumptionNumber) + int32(m.IncreaseLimitVideoConsumptionNumber) + int32(m.IncreaseLimitVideoExpiredConsumptionNumber),
|
||||||
|
InvalidBundleVideoNumber: int32(m.InvalidBundleVideoNumber),
|
||||||
|
InvalidIncreaseVideoNumber: int32(m.InvalidIncreaseVideoNumber),
|
||||||
|
MonthlyNewBundleVideoNumber: int32(cal(m.BundleBalance, m.BundleLimitVideoNumber, m.MonthlyLimitVideoQuotaNumber, date) + cal(m.BundleBalance, m.BundleLimitVideoExpiredNumber, m.MonthlyLimitVideoQuotaNumber, date)),
|
||||||
|
MonthlyNewIncreaseVideoNumber: int32(cal(m.BundleBalance, m.IncreaseLimitVideoNumber, m.MonthlyLimitVideoQuotaNumber, date) + cal(m.BundleBalance, m.IncreaseLimitVideoExpiredNumber, m.MonthlyLimitVideoQuotaNumber, date)),
|
||||||
|
MonthlyInvalidBundleVideoNumber: int32(m.MonthlyInvalidBundleVideoNumber),
|
||||||
|
MonthlyInvalidIncreaseVideoNumber: int32(m.MonthlyInvalidIncreaseVideoNumber),
|
||||||
|
// 图文类
|
||||||
|
BundleImageNumber: int32(m.BundleImageNumber) + int32(m.BundleLimitImageNumber) + int32(m.BundleLimitImageExpiredNumber),
|
||||||
|
IncreaseImageNumber: int32(m.IncreaseImageNumber) + int32(m.IncreaseLimitImageNumber) + int32(m.IncreaseLimitImageExpiredNumber),
|
||||||
|
BundleImageConsumptionNumber: int32(m.BundleImageConsumptionNumber) + int32(m.BundleLimitImageConsumptionNumber) + int32(m.BundleLimitImageExpiredConsumptionNumber),
|
||||||
|
IncreaseImageConsumptionNumber: int32(m.IncreaseImageConsumptionNumber) + int32(m.IncreaseLimitImageConsumptionNumber) + int32(m.IncreaseLimitImageExpiredConsumptionNumber),
|
||||||
|
InvalidBundleImageNumber: int32(m.InvalidBundleImageNumber),
|
||||||
|
InvalidIncreaseImageNumber: int32(m.InvalidIncreaseImageNumber),
|
||||||
|
MonthlyNewBundleImageNumber: int32(cal(m.BundleBalance, m.BundleLimitImageNumber, m.MonthlyLimitImageQuotaNumber, date) + cal(m.BundleBalance, m.BundleLimitImageExpiredNumber, m.MonthlyLimitImageQuotaNumber, date)),
|
||||||
|
MonthlyNewIncreaseImageNumber: int32(cal(m.BundleBalance, m.IncreaseLimitImageNumber, m.MonthlyLimitImageQuotaNumber, date) + cal(m.BundleBalance, m.IncreaseLimitImageExpiredNumber, m.MonthlyLimitImageQuotaNumber, date)),
|
||||||
|
MonthlyInvalidBundleImageNumber: int32(m.MonthlyInvalidBundleImageNumber),
|
||||||
|
MonthlyInvalidIncreaseImageNumber: int32(m.MonthlyInvalidIncreaseImageNumber),
|
||||||
|
// 数据分析类
|
||||||
|
BundleDataAnalysisNumber: int32(m.BundleDataAnalysisNumber) + int32(m.BundleLimitDataAnalysisNumber) + int32(m.BundleLimitDataAnalysisExpiredNumber),
|
||||||
|
IncreaseDataAnalysisNumber: int32(m.IncreaseDataAnalysisNumber) + int32(m.IncreaseLimitDataAnalysisNumber) + int32(m.IncreaseLimitDataAnalysisExpiredNumber),
|
||||||
|
BundleDataAnalysisConsumptionNumber: int32(m.BundleDataAnalysisConsumptionNumber) + int32(m.BundleLimitDataAnalysisConsumptionNumber) + int32(m.BundleLimitDataAnalysisExpiredConsumptionNumber),
|
||||||
|
IncreaseDataAnalysisConsumptionNumber: int32(m.IncreaseDataAnalysisConsumptionNumber) + int32(m.IncreaseLimitDataAnalysisConsumptionNumber) + int32(m.IncreaseLimitDataAnalysisExpiredConsumptionNumber),
|
||||||
|
InvalidBundleDataAnalysisNumber: int32(m.InvalidBundleDataAnalysisNumber),
|
||||||
|
InvalidIncreaseDataAnalysisNumber: int32(m.InvalidIncreaseDataAnalysisNumber),
|
||||||
|
MonthlyNewBundleDataAnalysisNumber: int32(cal(m.BundleBalance, m.BundleLimitDataAnalysisNumber, m.MonthlyLimitDataAnalysisQuotaNumber, date) + cal(m.BundleBalance, m.BundleLimitDataAnalysisExpiredNumber, m.MonthlyLimitDataAnalysisQuotaNumber, date)),
|
||||||
|
MonthlyNewIncreaseDataAnalysisNumber: int32(cal(m.BundleBalance, m.IncreaseLimitDataAnalysisNumber, m.MonthlyLimitDataAnalysisQuotaNumber, date) + cal(m.BundleBalance, m.IncreaseLimitDataAnalysisExpiredNumber, m.MonthlyLimitDataAnalysisQuotaNumber, date)),
|
||||||
|
MonthlyInvalidBundleDataAnalysisNumber: int32(m.MonthlyInvalidBundleDataAnalysisNumber),
|
||||||
|
MonthlyInvalidIncreaseDataAnalysisNumber: int32(m.MonthlyInvalidIncreaseDataAnalysisNumber),
|
||||||
|
// 手动扩展类
|
||||||
|
MonthlyNewManualAccountNumber: int32(m.MonthlyNewAccountNumber),
|
||||||
|
MonthlyNewManualVideoNumber: int32(m.MonthlyNewManualVideoNumber),
|
||||||
|
MonthlyNewManualImageNumber: int32(m.MonthlyNewManualImageNumber),
|
||||||
|
MonthlyNewManualDataAnalysisNumber: int32(m.MonthlyNewManualDataAnalysisNumber),
|
||||||
|
MonthlyNewDurationNumber: int32(m.MonthlyNewDurationNumber),
|
||||||
|
MonthlyManualAccountConsumptionNumber: int32(m.MonthlyManualAccountConsumptionNumber),
|
||||||
|
MonthlyManualVideoConsumptionNumber: int32(m.MonthlyManualVideoConsumptionNumber),
|
||||||
|
MonthlyManualImageConsumptionNumber: int32(m.MonthlyManualImageConsumptionNumber),
|
||||||
|
MonthlyManualDataAnalysisConsumptionNumber: int32(m.MonthlyManualDataAnalysisConsumptionNumber),
|
||||||
|
|
||||||
|
Activate: int32(m.Activate),
|
||||||
|
}
|
||||||
|
|
||||||
if m.OrderUUID != "" {
|
if m.OrderUUID != "" {
|
||||||
result.Bought = 2
|
result.Bought = 2
|
||||||
} else {
|
} else {
|
||||||
result.Bought = 1
|
result.Bought = 1
|
||||||
}
|
}
|
||||||
result.ExpiredTime = t.UnixMilli()
|
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -80,34 +139,188 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (*bundle.
|
|||||||
data, err := dao.GetBundleBalanceByUserId(req)
|
data, err := dao.GetBundleBalanceByUserId(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
return nil, errors.New("查询失败")
|
return nil, errors.New("无套餐数据")
|
||||||
|
}
|
||||||
|
if data.Activate != 2 {
|
||||||
|
return nil, errors.New("套餐未激活")
|
||||||
|
}
|
||||||
|
result := &bundle.GetBundleBalanceByUserIdResp{
|
||||||
|
OrderUUID: data.OrderUUID,
|
||||||
|
BundleName: data.BundleName,
|
||||||
|
PayTime: data.StartAt.UnixMilli(),
|
||||||
|
ExpiredTime: data.ExpiredAt.UnixMilli(),
|
||||||
|
PaymentAmount: data.PaymentAmount,
|
||||||
|
PaymentType: data.PaymentType,
|
||||||
|
AccountNumber: int32(data.BundleAccountNumber) + int32(data.IncreaseAccountNumber) + int32(data.ManualAccountNumber),
|
||||||
|
AccountAdditional: int32(data.ManualAccountNumber),
|
||||||
|
AccountConsumptionNumber: int32(data.BundleAccountConsumptionNumber) + int32(data.IncreaseAccountConsumptionNumber),
|
||||||
|
VideoNumber: int32(data.BundleVideoNumber) + int32(data.BundleLimitVideoNumber) + int32(data.BundleLimitVideoExpiredNumber) + int32(data.IncreaseVideoNumber) + int32(data.IncreaseLimitVideoNumber) + int32(data.IncreaseLimitVideoExpiredNumber),
|
||||||
|
VideoAdditional: int32(data.ManualVideoNumber),
|
||||||
|
VideoConsumptionNumber: int32(data.BundleVideoConsumptionNumber) + int32(data.BundleLimitVideoConsumptionNumber) + int32(data.BundleLimitVideoExpiredConsumptionNumber) + int32(data.IncreaseVideoConsumptionNumber) + int32(data.IncreaseLimitVideoConsumptionNumber) + int32(data.IncreaseLimitVideoExpiredConsumptionNumber),
|
||||||
|
ImageNumber: int32(data.BundleImageNumber) + int32(data.BundleLimitImageNumber) + int32(data.BundleLimitImageExpiredNumber) + int32(data.IncreaseImageNumber) + int32(data.IncreaseLimitImageNumber) + int32(data.IncreaseLimitImageExpiredNumber),
|
||||||
|
ImageAdditional: int32(data.ManualImageNumber),
|
||||||
|
ImageConsumptionNumber: int32(data.BundleImageConsumptionNumber) + int32(data.BundleLimitImageConsumptionNumber) + int32(data.BundleLimitImageExpiredConsumptionNumber) + int32(data.IncreaseImageConsumptionNumber) + int32(data.IncreaseLimitImageConsumptionNumber) + int32(data.IncreaseLimitImageExpiredConsumptionNumber),
|
||||||
|
DataAnalysisNumber: int32(data.BundleDataAnalysisNumber) + int32(data.BundleLimitDataAnalysisNumber) + int32(data.BundleLimitDataAnalysisExpiredNumber) + int32(data.IncreaseDataAnalysisNumber) + int32(data.IncreaseLimitDataAnalysisNumber) + int32(data.IncreaseLimitDataAnalysisExpiredNumber),
|
||||||
|
DataAnalysisAdditional: int32(data.ManualDataAnalysisNumber),
|
||||||
|
DataAnalysisConsumptionNumber: int32(data.BundleDataAnalysisConsumptionNumber) + int32(data.BundleLimitDataAnalysisConsumptionNumber) + int32(data.BundleLimitDataAnalysisExpiredConsumptionNumber) + int32(data.IncreaseDataAnalysisConsumptionNumber) + int32(data.IncreaseLimitDataAnalysisConsumptionNumber) + int32(data.IncreaseLimitDataAnalysisExpiredConsumptionNumber),
|
||||||
}
|
}
|
||||||
result := &bundle.GetBundleBalanceByUserIdResp{}
|
|
||||||
copier.Copy(result, &data)
|
|
||||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
|
||||||
t, _ := time.ParseInLocation(time.DateTime, data.ExpiredTime, loc)
|
|
||||||
result.ExpiredTime = t.UnixMilli()
|
|
||||||
t, _ = time.ParseInLocation(time.DateTime, data.PayTime, loc)
|
|
||||||
result.PayTime = t.UnixMilli()
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddBundleBalance(req *bundle.AddBundleBalanceReq) (*bundle.AddBundleBalanceResp, error) {
|
func AddBundleBalance(req *bundle.AddBundleBalanceReq) (*bundle.AddBundleBalanceResp, error) {
|
||||||
var data model.BundleBalance
|
data := model.BundleBalanceUsePo{
|
||||||
if err := copier.Copy(&data, req); err != nil {
|
UserId: int(req.UserId),
|
||||||
logger.Error(err)
|
AccountNumber: int(req.AccountConsumptionNumber),
|
||||||
return nil, errors.New("操作失败")
|
ImageNumber: int(req.ImageConsumptionNumber),
|
||||||
|
VideoNumber: int(req.VideoConsumptionNumber),
|
||||||
|
DataAnalysisNumber: int(req.DataAnalysisConsumptionNumber),
|
||||||
}
|
}
|
||||||
return nil, dao.AddBundleBalanceByUserId(data)
|
uesdType, err := dao.AddBundleBalanceByUserId(data)
|
||||||
|
return &bundle.AddBundleBalanceResp{
|
||||||
|
UsedType: uint32(uesdType),
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算本月发放的限制类型数量
|
||||||
|
func cal(data model.BundleBalance, total, limit int, date time.Time) int {
|
||||||
|
var released int // 已释放的次数
|
||||||
|
if data.StartAt.Month() == date.Month() && data.StartAt.Year() == date.Year() {
|
||||||
|
} else if data.StartAt.Day() >= 16 { //第一个月释放的
|
||||||
|
released += limit/2 + 1
|
||||||
|
} else {
|
||||||
|
released += limit
|
||||||
|
}
|
||||||
|
interval := date.Year()*12 + int(date.Month()) - (data.StartAt.Year()*12 + int(data.StartAt.Month())) // 后续月份释放的
|
||||||
|
released += interval * limit
|
||||||
|
remaining := max(total-released, 0) // 还剩余多少次没有发放
|
||||||
|
|
||||||
|
if data.StartAt.Month() == date.Month() && data.StartAt.Year() == date.Year() && data.StartAt.Day() >= 16 { // 本月为第一个月并且16号后购买只给一半(向上取整)
|
||||||
|
return min(limit/2+1, remaining)
|
||||||
|
}
|
||||||
|
if data.ExpiredAt.Month() == date.Month() && data.ExpiredAt.Year() == date.Year() && data.ExpiredAt.Day() < 16 { // 本月为最后一个月并且16号前到期只给一半(向下取整)
|
||||||
|
return min(limit/2, remaining)
|
||||||
|
}
|
||||||
|
return min(limit, remaining)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBundleBalance(req *bundle.CreateBundleBalanceReq) (*bundle.CreateBundleBalanceResp, error) {
|
func CreateBundleBalance(req *bundle.CreateBundleBalanceReq) (*bundle.CreateBundleBalanceResp, error) {
|
||||||
var data model.BundleBalance
|
var data model.BundleBalance
|
||||||
if err := copier.Copy(&data, req); err != nil {
|
|
||||||
logger.Error(err)
|
addValues, err := dao.GetValueAddByOrderUUID(req.OrderUUID)
|
||||||
return nil, errors.New("操作失败")
|
if err != nil || len(addValues) == 0 {
|
||||||
|
return nil, errors.New("获取增值服务失败")
|
||||||
}
|
}
|
||||||
err := dao.CreateBundleBalance(data)
|
data.StartAt = time.Now()
|
||||||
|
data.ExpiredAt = time.Now()
|
||||||
|
userId, err := strconv.Atoi(addValues[0].CustomerID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
data.Month = time.Now().Format("2006-01")
|
||||||
|
data.UserId = userId
|
||||||
|
data.OrderUUID = req.OrderUUID
|
||||||
|
for _, v := range addValues {
|
||||||
|
switch v.ServiceType {
|
||||||
|
case 1: // 视频类型
|
||||||
|
if v.EquityType == 1 { // 套餐权益
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitVideoQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.BundleLimitVideoExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.BundleLimitVideoNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.BundleVideoNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitVideoQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.IncreaseLimitVideoExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.IncreaseLimitVideoNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.IncreaseVideoNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2: // 图文类型
|
||||||
|
if v.EquityType == 1 { // 套餐权益
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitImageQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.BundleLimitImageExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.BundleLimitImageNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.BundleImageNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitImageQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.IncreaseLimitImageExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.IncreaseLimitImageNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.IncreaseImageNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 3: // 数据分析
|
||||||
|
if v.EquityType == 1 { // 套餐权益
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitDataAnalysisQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.BundleLimitDataAnalysisExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.BundleLimitDataAnalysisNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.BundleDataAnalysisNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if v.QuotaType == 2 { // 限制额度
|
||||||
|
data.MonthlyLimitDataAnalysisQuotaNumber = int(v.QuotaValue)
|
||||||
|
if v.IsExpired { // 会过期的限制类型
|
||||||
|
data.IncreaseLimitDataAnalysisExpiredNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.IncreaseLimitDataAnalysisNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
data.IncreaseDataAnalysisNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 4: // 账号数
|
||||||
|
if v.EquityType == 1 { // 套餐权益
|
||||||
|
data.BundleAccountNumber += int(v.Num)
|
||||||
|
} else {
|
||||||
|
data.IncreaseAccountNumber += int(v.Num)
|
||||||
|
}
|
||||||
|
case 5: // 可用时长
|
||||||
|
switch v.Unit {
|
||||||
|
case "天":
|
||||||
|
data.ExpiredAt = data.ExpiredAt.Add(time.Hour * 24 * time.Duration(v.Num))
|
||||||
|
case "月":
|
||||||
|
data.ExpiredAt = data.ExpiredAt.Add(time.Hour * 24 * 30 * time.Duration(v.Num))
|
||||||
|
case "年":
|
||||||
|
data.ExpiredAt = data.ExpiredAt.Add(time.Hour * 24 * 365 * time.Duration(v.Num))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
// 当月可用的限制类型数等于本月方法的套餐和增值两种类型的总和
|
||||||
|
data.MonthlyLimitVideoExpireNumber = cal(data, data.BundleLimitVideoExpiredNumber, data.MonthlyLimitVideoQuotaNumber, now) + cal(data, data.IncreaseLimitVideoExpiredNumber, data.MonthlyLimitVideoQuotaNumber, now)
|
||||||
|
data.MonthlyLimitVideoNumber = cal(data, data.BundleLimitVideoNumber, data.MonthlyLimitVideoQuotaNumber, now) + cal(data, data.IncreaseLimitVideoNumber, data.MonthlyLimitVideoQuotaNumber, now)
|
||||||
|
data.MonthlyLimitImageExpireNumber = cal(data, data.BundleLimitImageExpiredNumber, data.MonthlyLimitImageQuotaNumber, now) + cal(data, data.IncreaseLimitImageExpiredNumber, data.MonthlyLimitImageQuotaNumber, now)
|
||||||
|
data.MonthlyLimitImageNumber = cal(data, data.BundleLimitImageNumber, data.MonthlyLimitImageQuotaNumber, now) + cal(data, data.IncreaseLimitImageNumber, data.MonthlyLimitImageQuotaNumber, now)
|
||||||
|
data.MonthlyLimitDataAnalysisExpireNumber = cal(data, data.BundleLimitDataAnalysisExpiredNumber, data.MonthlyLimitDataAnalysisQuotaNumber, now) + cal(data, data.IncreaseLimitDataAnalysisExpiredNumber, data.MonthlyLimitDataAnalysisQuotaNumber, now)
|
||||||
|
data.MonthlyLimitDataAnalysisNumber = cal(data, data.BundleLimitDataAnalysisNumber, data.MonthlyLimitDataAnalysisQuotaNumber, now) + cal(data, data.IncreaseLimitDataAnalysisNumber, data.MonthlyLimitDataAnalysisQuotaNumber, now)
|
||||||
|
|
||||||
|
err = dao.CreateBundleBalance(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
return nil, errors.New("创建余量信息失败")
|
return nil, errors.New("创建余量信息失败")
|
||||||
@ -181,3 +394,7 @@ func ConfirmWork(req *bundle.ConfirmWorkReq) (*bundle.ConfirmWorkResp, error) {
|
|||||||
func BundleActivate(req *bundle.BundleActivateReq) error {
|
func BundleActivate(req *bundle.BundleActivateReq) error {
|
||||||
return dao.BundleActivate(req.Ids)
|
return dao.BundleActivate(req.Ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateBundleBalance() {
|
||||||
|
dao.UpdateBundleBalance()
|
||||||
|
}
|
||||||
|
@ -649,6 +649,7 @@ func diffUpdateBundleToValueAddService(tx *gorm.DB, bundleUuid string, selectSer
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveBundleHistory(tx *gorm.DB, bundleUuid string, operator string, operatorId uint64) error {
|
func saveBundleHistory(tx *gorm.DB, bundleUuid string, operator string, operatorId uint64) error {
|
||||||
// 保存历史记录
|
// 保存历史记录
|
||||||
data, err := dao.GetBundleDetailByUuid(bundleUuid)
|
data, err := dao.GetBundleDetailByUuid(bundleUuid)
|
||||||
|
@ -144,61 +144,139 @@ type BundleExtendRecordItemDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BundleBalancePo struct {
|
type BundleBalancePo struct {
|
||||||
UserId int `gorm:"column:user_id"`
|
UserId int `gorm:"column:user_id"`
|
||||||
UserName string `gorm:"column:user_name"`
|
UserName string `gorm:"column:user_name"`
|
||||||
UserPhoneNumber string `gorm:"column:user_phone_number"`
|
UserPhoneNumber string `gorm:"column:user_phone_number"`
|
||||||
BundleName string `gorm:"column:bundle_name"`
|
BundleName string `gorm:"column:bundle_name"`
|
||||||
ExpirationTime string `gorm:"column:expired_time"`
|
Status int `gorm:"column:status"`
|
||||||
Status int `gorm:"column:status"`
|
OrderUUID string `gorm:"column:order_uuid"`
|
||||||
OrderUUID string `gorm:"column:order_uuid"`
|
Activate int `gorm:"column:activate"`
|
||||||
AccountNumber int `gorm:"column:account_number;not null"`
|
BundleBalance
|
||||||
AccountConsumptionNumber int `gorm:"column:account_consumption_number;not null"`
|
|
||||||
VideoNumber int `gorm:"column:video_number;not null"`
|
|
||||||
VideoConsumptionNumber int `gorm:"column:video_consumption_number;not null"`
|
|
||||||
ImageNumber int `gorm:"column:image_number;not null"`
|
|
||||||
ImageConsumptionNumber int `gorm:"column:image_consumption_number;not null"`
|
|
||||||
DataAnalysisNumber int `gorm:"column:data_analysis_number;not null"`
|
|
||||||
DataAnalysisConsumptionNumber int `gorm:"column:data_analysis_consumption_number;not null"`
|
|
||||||
ExpansionPacksNumber int `gorm:"column:expansion_packs_number;not null"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserBundleBalancePo struct {
|
type UserBundleBalancePo struct {
|
||||||
OrderUUID string `json:"orderUUID" gorm:"column:order_uuid"`
|
OrderUUID string `json:"orderUUID" gorm:"column:order_uuid"`
|
||||||
BundleUuid string `json:"bundleUuid" gorm:"column:bundle_uuid"`
|
BundleUuid string `json:"bundleUuid" gorm:"column:bundle_uuid"`
|
||||||
BundleName string `json:"bundleName" gorm:"column:bundle_name"`
|
BundleName string `json:"bundleName" gorm:"column:bundle_name"`
|
||||||
BundleStatus string `json:"bundleStatus" gorm:"column:bundle_status"`
|
BundleStatus string `json:"bundleStatus" gorm:"column:bundle_status"`
|
||||||
PayTime string `json:"payTime" gorm:"column:pay_time"`
|
PayTime string `json:"payTime" gorm:"column:pay_time"`
|
||||||
ExpiredTime string `json:"expiredTime" gorm:"column:expired_time"`
|
ExpiredTime string `json:"expiredTime" gorm:"column:expired_time"`
|
||||||
PaymentAmount string `json:"paymentAmount" gorm:"column:payment_amount"`
|
PaymentAmount string `json:"paymentAmount" gorm:"column:payment_amount"`
|
||||||
PaymentType int32 `json:"paymentType" gorm:"column:payment_type"`
|
PaymentType int32 `json:"paymentType" gorm:"column:payment_type"`
|
||||||
AccountNumber int32 `json:"accountNumber" gorm:"column:account_number"`
|
Activate int `gorm:"column:activate"`
|
||||||
AccountAdditional int32 `json:"accountAdditional" gorm:"column:account_additional"`
|
BundleBalance
|
||||||
AccountConsumptionNumber int32 `json:"accountConsumptionNumber" gorm:"column:account_consumption_number"`
|
|
||||||
VideoNumber int32 `json:"videoNumber" gorm:"column:video_number"`
|
|
||||||
VideoAdditional int32 `json:"videoAdditional" gorm:"column:video_additional"`
|
|
||||||
VideoConsumptionNumber int32 `json:"videoConsumptionNumber" gorm:"column:video_consumption_number"`
|
|
||||||
ImageNumber int32 `json:"imageNumber" gorm:"column:image_number"`
|
|
||||||
ImageAdditional int32 `json:"imageAdditional" gorm:"column:image_additional"`
|
|
||||||
ImageConsumptionNumber int32 `json:"imageConsumptionNumber" gorm:"column:image_consumption_number"`
|
|
||||||
DataAnalysisNumber int32 `json:"dataAnalysisNumber" gorm:"column:data_analysis_number"`
|
|
||||||
DataAnalysisAdditional int32 `json:"dataAnalysisAdditional" gorm:"column:data_analysis_additional"`
|
|
||||||
DataAnalysisConsumptionNumber int32 `json:"dataAnalysisConsumptionNumber" gorm:"column:data_analysis_consumption_number"`
|
|
||||||
ExpansionPacksNumber int32 `json:"expansionPacksNumber" gorm:"column:expansion_packs_number"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BundleBalance struct {
|
type BundleBalance struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UserId int `gorm:"column:user_id;not null"`
|
UserId int `gorm:"column:user_id;not null"`
|
||||||
OrderUUID string `gorm:"column:order_uuid;type:varchar(1024);not null"`
|
Month string `gorm:"column:month;type:varchar(32);not null"`
|
||||||
AccountNumber int `gorm:"column:account_number;not null"`
|
OrderUUID string `gorm:"column:order_uuid;type:varchar(1024);not null"`
|
||||||
AccountConsumptionNumber int `gorm:"column:account_consumption_number;not null"`
|
ExpiredAt time.Time `gorm:"column:expired_at;type:datetime;comment:套餐过期时间"`
|
||||||
VideoNumber int `gorm:"column:video_number;not null"`
|
StartAt time.Time `gorm:"column:start_at;type:datetime;comment:套餐开始时间"`
|
||||||
VideoConsumptionNumber int `gorm:"column:video_consumption_number;not null"`
|
|
||||||
ImageNumber int `gorm:"column:image_number;not null"`
|
// 套餐与增值账号
|
||||||
ImageConsumptionNumber int `gorm:"column:image_consumption_number;not null"`
|
BundleAccountNumber int `gorm:"column:bundle_account_number;not null;comment:套餐账号总数"`
|
||||||
DataAnalysisNumber int `gorm:"column:data_analysis_number;not null"`
|
IncreaseAccountNumber int `gorm:"column:increase_account_number;not null;comment:增值账号总数"`
|
||||||
DataAnalysisConsumptionNumber int `gorm:"column:data_analysis_consumption_number;not null"`
|
BundleAccountConsumptionNumber int `gorm:"column:bundle_account_consumption_number;not null;comment:套餐账号使用数"`
|
||||||
ExpansionPacksNumber int `gorm:"column:expansion_packs_number;not null"`
|
IncreaseAccountConsumptionNumber int `gorm:"column:increase_account_consumption_number;not null;comment:增值账号使用数"`
|
||||||
|
|
||||||
|
// 手动账号扩展
|
||||||
|
MonthlyNewAccountNumber int `gorm:"column:monthly_new_account_number;comment:当月手动扩展账号新增数"`
|
||||||
|
MonthlyManualAccountConsumptionNumber int `gorm:"column:monthly_manual_account_consumption_number;comment:当月手动扩展账号使用数"`
|
||||||
|
ManualAccountNumber int `gorm:"column:manual_account_number;comment:手动扩展账号总数"`
|
||||||
|
ManualAccountConsumptionNumber int `gorm:"column:manual_account_consumption_number;comment:手动扩展账号使用数"`
|
||||||
|
MonthlyNewManualAccountNumber int `gorm:"column:monthly_new_manual_account_number;comment:当月手动扩展账号新增数"`
|
||||||
|
|
||||||
|
// ===== 视频类 =====
|
||||||
|
BundleVideoNumber int `gorm:"column:bundle_video_number;not null;comment:非限制类型套餐权益视频总数"`
|
||||||
|
IncreaseVideoNumber int `gorm:"column:increase_video_number;not null;comment:非限制类型增值权益视频总数"`
|
||||||
|
BundleLimitVideoNumber int `gorm:"column:bundle_limit_video_number;not null;comment:套餐权益限制类型非过期总数"`
|
||||||
|
IncreaseLimitVideoNumber int `gorm:"column:increase_limit_video_number;not null;comment:增值权益限制类型非过期总数"`
|
||||||
|
BundleLimitVideoExpiredNumber int `gorm:"column:bundle_limit_video_expired_number;not null;comment:套餐权益限制类型会过期总数"`
|
||||||
|
IncreaseLimitVideoExpiredNumber int `gorm:"column:increase_limit_video_expired_number;not null;comment:增值权益限制类型会过期总数"`
|
||||||
|
MonthlyInvalidBundleVideoNumber int `gorm:"column:monthly_invalid_bundle_video_number;not null;comment:当月失效的套餐权益视频总数"`
|
||||||
|
InvalidBundleVideoNumber int `gorm:"column:invalid_bundle_video_number;not null;comment:历史失效的套餐权益视频总数"`
|
||||||
|
MonthlyInvalidIncreaseVideoNumber int `gorm:"column:monthly_invalid_increase_video_number;not null;comment:当月失效的增值权益视频总数"`
|
||||||
|
InvalidIncreaseVideoNumber int `gorm:"column:invalid_increase_video_number;not null;comment:历史失效的增值权益视频总数"`
|
||||||
|
BundleVideoConsumptionNumber int `gorm:"column:bundle_video_consumption_number;not null;comment:非限制类型套餐权益视频使用数"`
|
||||||
|
IncreaseVideoConsumptionNumber int `gorm:"column:increase_video_consumption_number;not null;comment:非限制类型增值权益视频使用数"`
|
||||||
|
BundleLimitVideoConsumptionNumber int `gorm:"column:bundle_limit_video_consumption_number;not null;comment:套餐权益限制类型非过期使用数"`
|
||||||
|
IncreaseLimitVideoConsumptionNumber int `gorm:"column:increase_limit_video_consumption_number;not null;comment:增值权益限制类型非过期使用数"`
|
||||||
|
BundleLimitVideoExpiredConsumptionNumber int `gorm:"column:bundle_limit_video_expired_consumption_number;not null;comment:套餐权益限制类型会过期使用数"`
|
||||||
|
IncreaseLimitVideoExpiredConsumptionNumber int `gorm:"column:increase_limit_video_expired_consumption_number;not null;comment:增值权益限制类型会过期使用数"`
|
||||||
|
MonthlyLimitVideoNumber int `gorm:"column:monthly_limit_video_number;not null;comment:当月限制类型视频可用数"`
|
||||||
|
MonthlyLimitVideoConsumptionNumber int `gorm:"column:monthly_limit_video_consumption_number;not null;comment:当月限制类型视频已使用额度"`
|
||||||
|
MonthlyLimitVideoExpireNumber int `gorm:"column:monthly_limit_video_expired_number;not null;comment:当月限制类型视频会过期可用数"`
|
||||||
|
MonthlyLimitVideoExpireConsumptionNumber int `gorm:"column:monthly_limit_video_expired_consumption_number;not null;comment:当月限制类型视频会过期已使用额度"`
|
||||||
|
MonthlyBundleVideoConsumptionNumber int `gorm:"column:monthly_bundle_video_consumption_number;not null;comment:当月套餐类型总使用数"`
|
||||||
|
MonthlyIncreaseVideoConsumptionNumber int `gorm:"column:monthly_increase_video_consumption_number;not null;comment:当月增值类型总使用数"`
|
||||||
|
MonthlyLimitVideoQuotaNumber int `gorm:"column:monthly_limit_video_quota_number;not null;comment:当月限制类型视频额度"`
|
||||||
|
ManualVideoNumber int `gorm:"column:manual_video_number;comment:手动扩展视频总数"`
|
||||||
|
ManualVideoConsumptionNumber int `gorm:"column:manual_video_consumption_number;comment:手动扩展视频使用数"`
|
||||||
|
MonthlyNewManualVideoNumber int `gorm:"column:monthly_new_manual_video_number;comment:当月手动扩展视频新增数"`
|
||||||
|
MonthlyManualVideoConsumptionNumber int `gorm:"column:monthly_manual_video_consumption_number;comment:当月手动扩展视频使用数"`
|
||||||
|
|
||||||
|
// ===== 图片类 =====
|
||||||
|
BundleImageNumber int `gorm:"column:bundle_image_number;not null;comment:非限制类型套餐权益图片总数"`
|
||||||
|
IncreaseImageNumber int `gorm:"column:increase_image_number;not null;comment:非限制类型增值权益图片总数"`
|
||||||
|
BundleLimitImageNumber int `gorm:"column:bundle_limit_image_number;not null;comment:套餐权益限制类型非过期总数"`
|
||||||
|
IncreaseLimitImageNumber int `gorm:"column:increase_limit_image_number;not null;comment:增值权益限制类型非过期总数"`
|
||||||
|
BundleLimitImageExpiredNumber int `gorm:"column:bundle_limit_image_expired_number;not null;comment:套餐权益限制类型会过期总数"`
|
||||||
|
IncreaseLimitImageExpiredNumber int `gorm:"column:increase_limit_image_expired_number;not null;comment:增值权益限制类型会过期总数"`
|
||||||
|
MonthlyInvalidBundleImageNumber int `gorm:"column:monthly_invalid_bundle_image_number;not null;comment:当月失效的套餐权益图片总数"`
|
||||||
|
InvalidBundleImageNumber int `gorm:"column:invalid_bundle_image_number;not null;comment:历史失效的套餐权益图片总数"`
|
||||||
|
MonthlyInvalidIncreaseImageNumber int `gorm:"column:monthly_invalid_increase_image_number;not null;comment:当月失效的增值权益图片总数"`
|
||||||
|
InvalidIncreaseImageNumber int `gorm:"column:invalid_increase_image_number;not null;comment:历史失效的增值权益图片总数"`
|
||||||
|
BundleImageConsumptionNumber int `gorm:"column:bundle_image_consumption_number;not null;comment:非限制类型套餐权益图片使用数"`
|
||||||
|
IncreaseImageConsumptionNumber int `gorm:"column:increase_image_consumption_number;not null;comment:非限制类型增值权益图片使用数"`
|
||||||
|
BundleLimitImageConsumptionNumber int `gorm:"column:bundle_limit_image_consumption_number;not null;comment:套餐权益限制类型非过期使用数"`
|
||||||
|
IncreaseLimitImageConsumptionNumber int `gorm:"column:increase_limit_image_consumption_number;not null;comment:增值权益限制类型非过期使用数"`
|
||||||
|
BundleLimitImageExpiredConsumptionNumber int `gorm:"column:bundle_limit_image_expired_consumption_number;not null;comment:套餐权益限制类型会过期使用数"`
|
||||||
|
IncreaseLimitImageExpiredConsumptionNumber int `gorm:"column:increase_limit_image_expired_consumption_number;not null;comment:增值权益限制类型会过期使用数"`
|
||||||
|
MonthlyLimitImageNumber int `gorm:"column:monthly_limit_image_number;not null;comment:当月限制类型图片可使用额度"`
|
||||||
|
MonthlyLimitImageConsumptionNumber int `gorm:"column:monthly_limit_image_consumption_number;not null;comment:当月限制类型图片已使用额度"`
|
||||||
|
MonthlyLimitImageExpireNumber int `gorm:"column:monthly_limit_image_expired_number;not null;comment:当月限制类型图片会过期可用数"`
|
||||||
|
MonthlyLimitImageExpireConsumptionNumber int `gorm:"column:monthly_limit_image_expired_consumption_number;not null;comment:当月限制类型图片会过期已使用额度"`
|
||||||
|
MonthlyBundleImageConsumptionNumber int `gorm:"column:monthly_bundle_image_consumption_number;not null;comment:当月套餐类型总使用数"`
|
||||||
|
MonthlyIncreaseImageConsumptionNumber int `gorm:"column:monthly_increase_image_consumption_number;not null;comment:当月增值类型总使用数"`
|
||||||
|
MonthlyLimitImageQuotaNumber int `gorm:"column:monthly_limit_image_quota_number;not null;comment:当月限制类型图片额度"`
|
||||||
|
ManualImageNumber int `gorm:"column:manual_image_number;comment:手动扩展图片总数"`
|
||||||
|
ManualImageConsumptionNumber int `gorm:"column:manual_image_consumption_number;comment:手动扩展图片使用数"`
|
||||||
|
MonthlyNewManualImageNumber int `gorm:"column:monthly_new_manual_image_number;comment:当月手动扩展图片新增数"`
|
||||||
|
MonthlyManualImageConsumptionNumber int `gorm:"column:monthly_manual_image_consumption_number;comment:当月手动扩展图片使用数"`
|
||||||
|
|
||||||
|
// ===== 数据分析类 =====
|
||||||
|
BundleDataAnalysisNumber int `gorm:"column:bundle_data_analysis_number;not null;comment:非限制类型套餐权益数据分析总数"`
|
||||||
|
IncreaseDataAnalysisNumber int `gorm:"column:increase_data_analysis_number;not null;comment:非限制类型增值权益数据分析总数"`
|
||||||
|
BundleLimitDataAnalysisNumber int `gorm:"column:bundle_limit_data_analysis_number;not null;comment:套餐权益限制类型非过期总数"`
|
||||||
|
IncreaseLimitDataAnalysisNumber int `gorm:"column:increase_limit_data_analysis_number;not null;comment:增值权益限制类型非过期总数"`
|
||||||
|
BundleLimitDataAnalysisExpiredNumber int `gorm:"column:bundle_limit_data_analysis_expired_number;not null;comment:套餐权益限制类型会过期总数"`
|
||||||
|
IncreaseLimitDataAnalysisExpiredNumber int `gorm:"column:increase_limit_data_analysis_expired_number;not null;comment:增值权益限制类型会过期总数"`
|
||||||
|
MonthlyInvalidBundleDataAnalysisNumber int `gorm:"column:monthly_invalid_bundle_data_analysis_number;not null;comment:当月失效的套餐权益数据分析总数"`
|
||||||
|
InvalidBundleDataAnalysisNumber int `gorm:"column:invalid_bundle_data_analysis_number;not null;comment:历史失效的套餐权益数据分析总数"`
|
||||||
|
MonthlyInvalidIncreaseDataAnalysisNumber int `gorm:"column:monthly_invalid_increase_data_analysis_number;not null;comment:当月失效的增值权益数据分析总数"`
|
||||||
|
InvalidIncreaseDataAnalysisNumber int `gorm:"column:invalid_increase_data_analysis_number;not null;comment:历史失效的增值权益数据分析总数"`
|
||||||
|
BundleDataAnalysisConsumptionNumber int `gorm:"column:bundle_data_analysis_consumption_number;not null;comment:非限制类型套餐权益数据分析使用数"`
|
||||||
|
IncreaseDataAnalysisConsumptionNumber int `gorm:"column:increase_data_analysis_consumption_number;not null;comment:非限制类型增值权益数据分析使用数"`
|
||||||
|
BundleLimitDataAnalysisConsumptionNumber int `gorm:"column:bundle_limit_data_analysis_consumption_number;not null;comment:套餐权益限制类型非过期使用数"`
|
||||||
|
IncreaseLimitDataAnalysisConsumptionNumber int `gorm:"column:increase_limit_data_analysis_consumption_number;not null;comment:增值权益限制类型非过期使用数"`
|
||||||
|
BundleLimitDataAnalysisExpiredConsumptionNumber int `gorm:"column:bundle_limit_data_analysis_expired_consumption_number;not null;comment:套餐权益限制类型会过期使用数"`
|
||||||
|
IncreaseLimitDataAnalysisExpiredConsumptionNumber int `gorm:"column:increase_limit_data_analysis_expired_consumption_number;not null;comment:增值权益限制类型会过期使用数"`
|
||||||
|
MonthlyLimitDataAnalysisNumber int `gorm:"column:monthly_limit_data_analysis_number;not null;comment:当月限制类型数据分析可使用额度"`
|
||||||
|
MonthlyLimitDataAnalysisConsumptionNumber int `gorm:"column:monthly_limit_data_analysis_consumption_number;not null;comment:当月限制类型数据分析已使用额度"`
|
||||||
|
MonthlyLimitDataAnalysisExpireNumber int `gorm:"column:monthly_limit_data_analysis_expired_number;not null;comment:当月限制类型数据分析会过期可用数"`
|
||||||
|
MonthlyLimitDataAnalysisExpireConsumptionNumber int `gorm:"column:monthly_limit_data_analysis_expired_consumption_number;not null;comment:当月限制类型数据分析会过期已使用额度"`
|
||||||
|
MonthlyBundleDataAnalysisConsumptionNumber int `gorm:"column:monthly_bundle_data_analysis_consumption_number;not null;comment:当月套餐类型总使用数"`
|
||||||
|
MonthlyIncreaseDataAnalysisConsumptionNumber int `gorm:"column:monthly_increase_data_analysis_consumption_number;not null;comment:当月增值类型总使用数"`
|
||||||
|
MonthlyLimitDataAnalysisQuotaNumber int `gorm:"column:monthly_limit_data_analysis_quota_number;not null;comment:当月限制类型数据分析额度"`
|
||||||
|
ManualDataAnalysisNumber int `gorm:"column:manual_data_analysis_number;comment:手动扩展数据分析总数"`
|
||||||
|
ManualDataAnalysisConsumptionNumber int `gorm:"column:manual_data_analysis_consumption_number;comment:手动扩展数据分析使用数"`
|
||||||
|
MonthlyNewManualDataAnalysisNumber int `gorm:"column:monthly_new_manual_data_analysis_number;comment:当月手动扩展数据分析新增数"`
|
||||||
|
MonthlyManualDataAnalysisConsumptionNumber int `gorm:"column:monthly_manual_data_analysis_consumption_number;comment:当月手动扩展数据分析使用数"`
|
||||||
|
|
||||||
|
MonthlyNewDurationNumber int `gorm:"column:monthly_new_duration_number;comment:当月新增手动扩展时长(天)"`
|
||||||
|
ExpansionPacksNumber int `gorm:"column:expansion_packs_number;not null;comment:扩展包数量"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName 表名称
|
// TableName 表名称
|
||||||
@ -208,11 +286,41 @@ func (*BundleBalance) TableName() string {
|
|||||||
|
|
||||||
type BundleActivate struct {
|
type BundleActivate struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UserId int `gorm:"column:user_id;not null;unique"`
|
UserId int `gorm:"column:user_id;not null;unique"`
|
||||||
Activate bool `gorm:"column:activate"`
|
Activate int `gorm:"column:activate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName 表名称
|
// TableName 表名称
|
||||||
func (*BundleActivate) TableName() string {
|
func (*BundleActivate) TableName() string {
|
||||||
return "bundle_activate"
|
return "bundle_activate"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BundleBalanceUsePo struct {
|
||||||
|
UserId int
|
||||||
|
AccountNumber int
|
||||||
|
VideoNumber int
|
||||||
|
ImageNumber int
|
||||||
|
DataAnalysisNumber int
|
||||||
|
}
|
||||||
|
type BundleBalanceExtendPo struct {
|
||||||
|
UserId int
|
||||||
|
AccountNumber int
|
||||||
|
VideoNumber int
|
||||||
|
ImageNumber int
|
||||||
|
DataAnalysisNumber int
|
||||||
|
DurationNumber int
|
||||||
|
}
|
||||||
|
|
||||||
|
type BundleUsedRecord struct {
|
||||||
|
gorm.Model
|
||||||
|
UserID uint64 `gorm:"column:user_id;not null"`
|
||||||
|
Type string `gorm:"column:type;size:100"`
|
||||||
|
OrderUUID string `gorm:"column:order_uuid;size:100"`
|
||||||
|
IsIncrement int `gorm:"column:is_increment"`
|
||||||
|
ConsumptionType int `gorm:"column:consumption_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName 设置表名
|
||||||
|
func (BundleUsedRecord) TableName() string {
|
||||||
|
return "bundle_used_record"
|
||||||
|
}
|
||||||
|
@ -43,12 +43,6 @@ func (m *CastWorkExtra) TableName() string {
|
|||||||
return "cast_work_extra"
|
return "cast_work_extra"
|
||||||
}
|
}
|
||||||
|
|
||||||
type CostLogPo struct {
|
|
||||||
CostLog
|
|
||||||
ArtistConfirmedTime int64 `gorm:"column:artist_confirmed_time;type:bigint(20);default:0;comment:艺人确认时间;NOT NULL" json:"artist_confirmed_time"`
|
|
||||||
CostType int `gorm:"column:cost_type;type:int(11)" json:"costType"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CastWorkImage struct {
|
type CastWorkImage struct {
|
||||||
Uuid string `json:"uuid" gorm:"uuid"`
|
Uuid string `json:"uuid" gorm:"uuid"`
|
||||||
WorkUuid string `json:"work_uuid" gorm:"work_uuid"` // 作品uuid
|
WorkUuid string `json:"work_uuid" gorm:"work_uuid"` // 作品uuid
|
||||||
|
107
pb/bundle.proto
107
pb/bundle.proto
@ -65,7 +65,7 @@ service Bundle {
|
|||||||
// 使用记录
|
// 使用记录
|
||||||
rpc GetUsedRecordList(GetUsedRecordListReq) returns (GetUsedRecordListResp) {} // 获取套餐使用记录列表
|
rpc GetUsedRecordList(GetUsedRecordListReq) returns (GetUsedRecordListResp) {} // 获取套餐使用记录列表
|
||||||
rpc GetImageWorkDetail(GetImageWorkDetailReq) returns (GetImageWorkDetailResp) {} // 获取图文作品详情
|
rpc GetImageWorkDetail(GetImageWorkDetailReq) returns (GetImageWorkDetailResp) {} // 获取图文作品详情
|
||||||
rpc GetVedioWorkDetail(GetVedioWorkDetailReq) returns (GetVedioeWorkDetailResp) {} // 获取视频作品详情
|
rpc GetVedioWorkDetail(GetVedioWorkDetailReq) returns (GetVedioeWorkDetailResp) {} // 获取数据分析作品详情
|
||||||
|
|
||||||
rpc ToBeComfirmedWorks(ToBeComfirmedWorksReq) returns (ToBeComfirmedWorksResp) {} // 待确认作品列表
|
rpc ToBeComfirmedWorks(ToBeComfirmedWorksReq) returns (ToBeComfirmedWorksResp) {} // 待确认作品列表
|
||||||
rpc ConfirmWork(ConfirmWorkReq) returns (ConfirmWorkResp) {} // 确认作品
|
rpc ConfirmWork(ConfirmWorkReq) returns (ConfirmWorkResp) {} // 确认作品
|
||||||
@ -553,7 +553,7 @@ message ValueAddService {
|
|||||||
message ValueAddServiceLang {
|
message ValueAddServiceLang {
|
||||||
string uuid = 1 [json_name = "uuid"];
|
string uuid = 1 [json_name = "uuid"];
|
||||||
string serviceName = 2 [json_name = "serviceName"]; //服务名称
|
string serviceName = 2 [json_name = "serviceName"]; //服务名称
|
||||||
int32 serviceType = 3 [json_name = "serviceType"]; //服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长
|
int32 serviceType = 3 [json_name = "serviceType"]; //服务类型 1:数据分析 2:图文 3:数据报表 4:账号数 5:可用时长
|
||||||
int32 priceMode = 4 [json_name = "priceMode"]; //套餐价格类型 1:单价 2:总价
|
int32 priceMode = 4 [json_name = "priceMode"]; //套餐价格类型 1:单价 2:总价
|
||||||
string originalPrice = 5 [json_name = "originalPrice"];//原单价
|
string originalPrice = 5 [json_name = "originalPrice"];//原单价
|
||||||
string unit = 6 [json_name = "unit"];//单位 1:个 2:条 3:天 4:月 5:年 6:自然月 7:自然季度 8:半年 9:自然年
|
string unit = 6 [json_name = "unit"];//单位 1:个 2:条 3:天 4:月 5:年 6:自然月 7:自然季度 8:半年 9:自然年
|
||||||
@ -678,6 +678,7 @@ message GetBundleBalanceListReq{
|
|||||||
int64 expiredTimeEnd = 6;
|
int64 expiredTimeEnd = 6;
|
||||||
int32 page = 7;
|
int32 page = 7;
|
||||||
int32 pageSize = 8;
|
int32 pageSize = 8;
|
||||||
|
string month = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetBundleBalanceReq{
|
message GetBundleBalanceReq{
|
||||||
@ -690,23 +691,69 @@ message GetBundleBalanceReq{
|
|||||||
int32 pageSize = 7;
|
int32 pageSize = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BundleBalanceItem{
|
message BundleBalanceItem {
|
||||||
int32 userId = 1;
|
int32 userId = 1;
|
||||||
string userName = 2;
|
string userName = 2;
|
||||||
string userPhoneNumber = 3;
|
string userPhoneNumber = 3;
|
||||||
int32 status = 4;
|
int32 status = 4;
|
||||||
string bundleName = 5;
|
string bundleName = 5;
|
||||||
int64 expiredTime = 6;
|
int64 expiredTime = 6;
|
||||||
int32 accountNumber = 7;
|
int32 bought = 7;
|
||||||
int32 accountConsumptionNumber = 8;
|
|
||||||
int32 videoNumber = 9;
|
// 账号类
|
||||||
int32 videoConsumptionNumber = 10;
|
int32 bundleAccountNumber = 8; // 套餐账号总数
|
||||||
int32 imageNumber = 11;
|
int32 increaseAccountNumber = 9; // 增值账号总数
|
||||||
int32 imageConsumptionNumber = 12;
|
int32 bundleAccountConsumptionNumber = 10; // 套餐账号使用数
|
||||||
int32 dataAnalysisNumber = 13;
|
int32 increaseAccountConsumptionNumber = 11; // 增值账号使用数
|
||||||
int32 dataAnalysisConsumptionNumber = 14;
|
|
||||||
int32 expansionPacksNumber = 15;
|
// 视频类
|
||||||
int32 bought = 16;
|
int32 bundleVideoNumber = 12; // 当前可用套餐视频数
|
||||||
|
int32 increaseVideoNumber = 13; // 当前可用增值视频数
|
||||||
|
int32 bundleVideoConsumptionNumber = 14; // 当前已用套餐视频数
|
||||||
|
int32 increaseVideoConsumptionNumber = 15; // 当前已用增值视频数
|
||||||
|
int32 invalidBundleVideoNumber = 16; // 当前作废套餐视频数
|
||||||
|
int32 invalidIncreaseVideoNumber = 17; // 当前作废增值视频数
|
||||||
|
int32 monthlyNewBundleVideoNumber = 18; // 当月新增套餐视频数
|
||||||
|
int32 monthlyNewIncreaseVideoNumber = 19; // 当月新增增值视频数
|
||||||
|
int32 monthlyInvalidBundleVideoNumber = 20; // 当月作废套餐视频数
|
||||||
|
int32 monthlyInvalidIncreaseVideoNumber = 21; // 当月作废增值视频数
|
||||||
|
|
||||||
|
// 图文类
|
||||||
|
int32 bundleImageNumber = 22; // 当前可用套餐图文数
|
||||||
|
int32 increaseImageNumber = 23; // 当前可用增值图文数
|
||||||
|
int32 bundleImageConsumptionNumber = 24; // 当前已用套餐图文数
|
||||||
|
int32 increaseImageConsumptionNumber = 25; // 当前已用增值图文数
|
||||||
|
int32 invalidBundleImageNumber = 26; // 当前作废套餐图文数
|
||||||
|
int32 invalidIncreaseImageNumber = 27; // 当前作废增值图文数
|
||||||
|
int32 monthlyNewBundleImageNumber = 28; // 当月新增套餐图文数
|
||||||
|
int32 monthlyNewIncreaseImageNumber = 29; // 当月新增增值图文数
|
||||||
|
int32 monthlyInvalidBundleImageNumber = 30; // 当月作废套餐图文数
|
||||||
|
int32 monthlyInvalidIncreaseImageNumber = 31; // 当月作废增值图文数
|
||||||
|
|
||||||
|
// 数据分析类
|
||||||
|
int32 bundleDataAnalysisNumber = 32; // 当前可用套餐数据分析数
|
||||||
|
int32 increaseDataAnalysisNumber = 33; // 当前可用增值数据分析数
|
||||||
|
int32 bundleDataAnalysisConsumptionNumber = 34; // 当前已用套餐数据分析数
|
||||||
|
int32 increaseDataAnalysisConsumptionNumber = 35; // 当前已用增值数据分析数
|
||||||
|
int32 invalidBundleDataAnalysisNumber = 36; // 当前作废套餐数据分析数
|
||||||
|
int32 invalidIncreaseDataAnalysisNumber = 37; // 当前作废增值数据分析数
|
||||||
|
int32 monthlyNewBundleDataAnalysisNumber = 38; // 当月新增套餐数据分析数
|
||||||
|
int32 monthlyNewIncreaseDataAnalysisNumber = 39; // 当月新增增值数据分析数
|
||||||
|
int32 monthlyInvalidBundleDataAnalysisNumber = 40; // 当月作废套餐数据分析数
|
||||||
|
int32 monthlyInvalidIncreaseDataAnalysisNumber = 41; // 当月作废增值数据分析数
|
||||||
|
|
||||||
|
// 手动扩展类
|
||||||
|
int32 monthlyNewManualAccountNumber = 42; // 当月手动扩展账号新增数
|
||||||
|
int32 monthlyNewManualVideoNumber = 43; // 当月手动扩展视频新增数
|
||||||
|
int32 monthlyNewManualImageNumber = 44; // 当月手动扩展图文新增数
|
||||||
|
int32 monthlyNewManualDataAnalysisNumber = 45; // 当月手动扩展数据分析新增数
|
||||||
|
int32 monthlyNewDurationNumber = 46; // 当月新增手动扩展时长(天)
|
||||||
|
int32 monthlyManualAccountConsumptionNumber = 47; // 当月手动扩展账号使用数
|
||||||
|
int32 monthlyManualVideoConsumptionNumber = 48; // 当月手动扩展视频使用数
|
||||||
|
int32 monthlyManualImageConsumptionNumber = 49; // 当月手动扩展图文使用数
|
||||||
|
int32 monthlyManualDataAnalysisConsumptionNumber = 50; // 当月手动扩展数据分析使用数
|
||||||
|
|
||||||
|
int32 activate = 51 ; // 激活状态
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetBundleBalanceListResp{
|
message GetBundleBalanceListResp{
|
||||||
@ -748,7 +795,7 @@ message AddBundleBalanceReq{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message AddBundleBalanceResp{
|
message AddBundleBalanceResp{
|
||||||
|
uint32 usedType = 1; // 0 套餐内 1 增值 2 手动
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUsedRecordListReq{
|
message GetUsedRecordListReq{
|
||||||
@ -775,7 +822,7 @@ message WorkCastItem{
|
|||||||
string artistName = 2; // 艺人名称
|
string artistName = 2; // 艺人名称
|
||||||
string artistPhone = 3; // 艺人手机号
|
string artistPhone = 3; // 艺人手机号
|
||||||
string workUuid = 4; // 作品uuid
|
string workUuid = 4; // 作品uuid
|
||||||
uint32 workCategory = 5; // 1 图文 2 视频
|
uint32 workCategory = 5; // 1 图文 2 数据分析
|
||||||
string bundleUuid = 6; // 套餐ID uuid
|
string bundleUuid = 6; // 套餐ID uuid
|
||||||
string bundleName = 7; // 套餐名称
|
string bundleName = 7; // 套餐名称
|
||||||
string platformIds = 8; // 发布平台ID集合 (json 格式字符串)
|
string platformIds = 8; // 发布平台ID集合 (json 格式字符串)
|
||||||
@ -786,8 +833,7 @@ message WorkCastItem{
|
|||||||
string operatorName = 13; // 操作人名称
|
string operatorName = 13; // 操作人名称
|
||||||
string operatorPhone = 14; // 操作人手机号
|
string operatorPhone = 14; // 操作人手机号
|
||||||
uint32 status = 15; // 1 有效 2 失效
|
uint32 status = 15; // 1 有效 2 失效
|
||||||
string artistConfirmedTime = 16; // 艺人确认时间
|
uint32 costType = 16;
|
||||||
uint32 costType = 17;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetImageWorkDetailReq {
|
message GetImageWorkDetailReq {
|
||||||
@ -933,6 +979,14 @@ message SoftDeleteUnfinishedInfoRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message BundleActivateReq{
|
||||||
|
repeated uint32 ids = 1; // 激活用户的id
|
||||||
|
}
|
||||||
|
|
||||||
|
message BundleActivateResp{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 任务管理台相关消息定义
|
// 任务管理台相关消息定义
|
||||||
|
|
||||||
// 查询待指派任务记录
|
// 查询待指派任务记录
|
||||||
@ -955,7 +1009,7 @@ message TaskManagementInfo {
|
|||||||
string subNum = 1 [json_name = "subNum"]; // 艺人编号
|
string subNum = 1 [json_name = "subNum"]; // 艺人编号
|
||||||
string telNum = 2 [json_name = "telNum"]; // 手机号
|
string telNum = 2 [json_name = "telNum"]; // 手机号
|
||||||
string artistName = 3 [json_name = "artistName"]; // 艺人姓名
|
string artistName = 3 [json_name = "artistName"]; // 艺人姓名
|
||||||
int32 pendingVideoCount = 4 [json_name = "pendingVideoCount"]; // 待发视频数量
|
int32 pendingVideoCount = 4 [json_name = "pendingVideoCount"]; // 待发数据分析数量
|
||||||
int32 pendingPostCount = 5 [json_name = "pendingPostCount"]; // 待发图文数量
|
int32 pendingPostCount = 5 [json_name = "pendingPostCount"]; // 待发图文数量
|
||||||
int32 pendingDataCount = 6 [json_name = "pendingDataCount"]; // 待发数据数量
|
int32 pendingDataCount = 6 [json_name = "pendingDataCount"]; // 待发数据数量
|
||||||
int32 progressTaskCount = 7 [json_name = "progressTaskCount"]; // 进行中任务数量
|
int32 progressTaskCount = 7 [json_name = "progressTaskCount"]; // 进行中任务数量
|
||||||
@ -973,7 +1027,7 @@ message TaskAssignRequest {
|
|||||||
string taskAssigneeNum = 5 [json_name = "taskAssigneeNum"]; // 任务指派人账号
|
string taskAssigneeNum = 5 [json_name = "taskAssigneeNum"]; // 任务指派人账号
|
||||||
string operator = 6 [json_name = "operator"]; // 操作人
|
string operator = 6 [json_name = "operator"]; // 操作人
|
||||||
string operatorNum = 7 [json_name = "operatorNum"]; // 操作人账号
|
string operatorNum = 7 [json_name = "operatorNum"]; // 操作人账号
|
||||||
int32 assignVideoCount = 8 [json_name = "assignVideoCount"]; // 指派视频数
|
int32 assignVideoCount = 8 [json_name = "assignVideoCount"]; // 指派数据分析数
|
||||||
int32 assignPostCount = 9 [json_name = "assignPostCount"]; // 指派图文数
|
int32 assignPostCount = 9 [json_name = "assignPostCount"]; // 指派图文数
|
||||||
int32 assignDataCount = 10 [json_name = "assignDataCount"]; // 指派数据数
|
int32 assignDataCount = 10 [json_name = "assignDataCount"]; // 指派数据数
|
||||||
}
|
}
|
||||||
@ -983,7 +1037,7 @@ message UpdatePendingCountRequest {
|
|||||||
string subNum = 1 [json_name = "subNum"]; // 艺人编号
|
string subNum = 1 [json_name = "subNum"]; // 艺人编号
|
||||||
string telNum = 2 [json_name = "telNum"]; // 艺人手机号
|
string telNum = 2 [json_name = "telNum"]; // 艺人手机号
|
||||||
string artistName = 3 [json_name = "artistName"]; // 艺人姓名
|
string artistName = 3 [json_name = "artistName"]; // 艺人姓名
|
||||||
int32 pendingVideoCount = 4 [json_name = "pendingVideoCount"]; // 待发视频数量
|
int32 pendingVideoCount = 4 [json_name = "pendingVideoCount"]; // 待发数据分析数量
|
||||||
int32 pendingPostCount = 5 [json_name = "pendingPostCount"]; // 待发图文数量
|
int32 pendingPostCount = 5 [json_name = "pendingPostCount"]; // 待发图文数量
|
||||||
int32 pendingDataCount = 6 [json_name = "pendingDataCount"]; // 待发数据数量
|
int32 pendingDataCount = 6 [json_name = "pendingDataCount"]; // 待发数据数量
|
||||||
string operator = 7 [json_name = "operator"]; // 操作人
|
string operator = 7 [json_name = "operator"]; // 操作人
|
||||||
@ -1036,7 +1090,7 @@ message TaskAssignRecordInfo {
|
|||||||
string operatorTime = 11 [json_name = "operatorTime"]; // 操作时间
|
string operatorTime = 11 [json_name = "operatorTime"]; // 操作时间
|
||||||
string taskAssignee = 12 [json_name = "taskAssignee"]; // 任务指派人
|
string taskAssignee = 12 [json_name = "taskAssignee"]; // 任务指派人
|
||||||
string taskAssigneeNum = 13 [json_name = "taskAssigneeNum"]; // 任务指派人账号
|
string taskAssigneeNum = 13 [json_name = "taskAssigneeNum"]; // 任务指派人账号
|
||||||
int32 pendingVideoCount = 14 [json_name = "pendingVideoCount"]; // 待发视频数量
|
int32 pendingVideoCount = 14 [json_name = "pendingVideoCount"]; // 待发数据分析数量
|
||||||
int32 pendingPostCount = 15 [json_name = "pendingPostCount"]; // 待发图文数量
|
int32 pendingPostCount = 15 [json_name = "pendingPostCount"]; // 待发图文数量
|
||||||
int32 pendingDataCount = 16 [json_name = "pendingDataCount"]; // 待发数据数量
|
int32 pendingDataCount = 16 [json_name = "pendingDataCount"]; // 待发数据数量
|
||||||
string updatedAt = 24 [json_name = "updatedAt"]; // 更新时间
|
string updatedAt = 24 [json_name = "updatedAt"]; // 更新时间
|
||||||
@ -1086,16 +1140,7 @@ message ArtistBundleBalanceRequest {
|
|||||||
|
|
||||||
// 艺人套餐剩余数量响应
|
// 艺人套餐剩余数量响应
|
||||||
message ArtistBundleBalanceResponse {
|
message ArtistBundleBalanceResponse {
|
||||||
int32 remainingVideoCount = 1 [json_name = "remainingVideoCount"]; // 剩余视频数量
|
int32 remainingVideoCount = 1 [json_name = "remainingVideoCount"]; // 剩余数据分析数量
|
||||||
int32 remainingImageCount = 2 [json_name = "remainingImageCount"]; // 剩余图片数量
|
int32 remainingImageCount = 2 [json_name = "remainingImageCount"]; // 剩余图片数量
|
||||||
int32 remainingDataAnalysisCount = 3 [json_name = "remainingDataAnalysisCount"]; // 剩余数据分析数量
|
int32 remainingDataAnalysisCount = 3 [json_name = "remainingDataAnalysisCount"]; // 剩余数据分析数量
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message BundleActivateReq{
|
|
||||||
repeated uint32 ids = 1; // 激活用户的id
|
|
||||||
}
|
|
||||||
|
|
||||||
message BundleActivateResp{
|
|
||||||
|
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -486,6 +486,12 @@ func (this *UnfinishedInfo) Validate() error {
|
|||||||
func (this *SoftDeleteUnfinishedInfoRequest) Validate() error {
|
func (this *SoftDeleteUnfinishedInfoRequest) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (this *BundleActivateReq) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *BundleActivateResp) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (this *TaskQueryRequest) Validate() error {
|
func (this *TaskQueryRequest) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -555,9 +561,3 @@ func (this *ArtistBundleBalanceRequest) Validate() error {
|
|||||||
func (this *ArtistBundleBalanceResponse) Validate() error {
|
func (this *ArtistBundleBalanceResponse) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *BundleActivateReq) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (this *BundleActivateResp) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
25
pkg/cron/cron.go
Normal file
25
pkg/cron/cron.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cron
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"micro-bundle/internal/logic"
|
||||||
|
|
||||||
|
"github.com/robfig/cron/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitCronJob() {
|
||||||
|
c := cron.New(cron.WithSeconds())
|
||||||
|
|
||||||
|
spec := "0 0 0 1 * *"
|
||||||
|
|
||||||
|
_, err := c.AddFunc(spec, func() {
|
||||||
|
log.Printf("执行余量每月数据更新")
|
||||||
|
logic.UpdateBundleBalance()
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Start()
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user