Compare commits
10 Commits
feat-hjj-U
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0bfd322a8 | ||
|
|
e9bef82968 | ||
|
|
aae7aa077b | ||
|
|
61e5a69484 | ||
|
|
0524d503f3 | ||
|
|
36a751b8ac | ||
|
|
7f5384c935 | ||
|
|
137e752c1b | ||
| 8b85aeee28 | |||
| bbe0c0390c |
@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"micro-bundle/internal/logic"
|
||||
"micro-bundle/pb/bundle"
|
||||
)
|
||||
@ -85,13 +84,3 @@ func (b *BundleProvider) GetBundleBalanceLayout(_ context.Context, req *bundle.G
|
||||
func (b *BundleProvider) SetBundleBalanceLayout(_ context.Context, req *bundle.SetBundleBalanceLayoutReq) (*bundle.SetBundleBalanceLayoutResp, error) {
|
||||
return logic.SetBundleBalanceLayout(req)
|
||||
}
|
||||
|
||||
// 更新余量表数据
|
||||
func (b *BundleProvider) UpdateBundleBalance(_ context.Context, req *bundle.UpdateBundleBalanceReq) (*bundle.UpdateBundleBalanceResp, error) {
|
||||
var resp bundle.UpdateBundleBalanceResp
|
||||
err := logic.UpdateBundleBalance()
|
||||
if err != nil {
|
||||
return nil, errors.New("更新余量表数据失败")
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
@ -135,11 +135,11 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun
|
||||
}
|
||||
}
|
||||
}
|
||||
if req.Month == "" {
|
||||
if len(req.Month) == 0 {
|
||||
newestMonthQuery := app.ModuleClients.BundleDB.Model(&model.BundleBalance{}).Select("max(month) as month,user_id").Group("user_id")
|
||||
session.Joins("LEFT JOIN (?) as newest_month on newest_month.user_id = bb.user_id", newestMonthQuery).Where("")
|
||||
} else {
|
||||
session = session.Where("bb.month = ?", req.Month)
|
||||
session = session.Where("bb.month in (?)", req.Month)
|
||||
}
|
||||
err = session.Count(&total).Error
|
||||
if err != nil {
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"micro-bundle/internal/model"
|
||||
"micro-bundle/pb/bundle"
|
||||
"micro-bundle/pkg/app"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/duke-git/lancet/v2/datetime"
|
||||
@ -1316,22 +1317,38 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
||||
var start time.Time
|
||||
var end time.Time
|
||||
var err error
|
||||
if req.Month != "" {
|
||||
t, err := time.Parse("2006-01", req.Month)
|
||||
|
||||
subQuery := app.ModuleClients.BundleDB.Table("cast_media_account").
|
||||
Select("artist_uuid,any_value(artist_name) as artist_name,any_value(created_at) as created_at").
|
||||
Group("artist_uuid").
|
||||
Where("deleted_at = 0 and expired != 2")
|
||||
//如果选择了月份
|
||||
if len(req.Month) > 0 {
|
||||
// 构建多个月份的时间范围条件(使用 OR 连接)
|
||||
var conditions []string
|
||||
var args []interface{}
|
||||
for _, month := range req.Month {
|
||||
t, err := time.Parse("2006-01", month)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
start = datetime.BeginOfMonth(t)
|
||||
end = datetime.EndOfMonth(t)
|
||||
// 为每个月添加时间范围条件
|
||||
conditions = append(conditions, "(created_at >= ? AND created_at <= ?)")
|
||||
args = append(args, start.Unix(), end.Unix())
|
||||
}
|
||||
// 使用 OR 连接所有月份条件
|
||||
if len(conditions) > 0 {
|
||||
subQuery = subQuery.Where(strings.Join(conditions, " OR "), args...)
|
||||
}
|
||||
} else {
|
||||
start = time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC) // Unix 时间戳起始时间
|
||||
end = time.Date(2099, 12, 31, 23, 59, 59, 0, time.UTC) // 设置一个很远的未来日期
|
||||
subQuery = subQuery.Where("created_at >= ?", start.Unix()).
|
||||
Where("created_at <= ?", end.Unix())
|
||||
}
|
||||
subQuery := app.ModuleClients.BundleDB.Table("cast_media_account").
|
||||
Select("artist_uuid,any_value(artist_name) as artist_name,any_value(created_at) as created_at").
|
||||
Group("artist_uuid").
|
||||
Where("created_at >= ?", start.Unix()).Where("created_at <= ?", end.Unix()).
|
||||
Where("deleted_at = 0")
|
||||
|
||||
query := app.ModuleClients.BundleDB.Table("( ? ) cma", subQuery).
|
||||
Select(`tiktok.platform_user_id as tiktok_account,
|
||||
tiktok.platform_user_name as tiktok_nickname,
|
||||
@ -1351,21 +1368,18 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
||||
cma.artist_name,
|
||||
bor.customer_num as user_num
|
||||
`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 1 and deleted_at = 0) tiktok on tiktok.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 1 and deleted_at = 0 and expired != 2) tiktok on tiktok.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_auth where platform_id = 1 and deleted_at = 0 ) tiktok_auth on tiktok_auth.user_id = tiktok.user_id`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 4 and deleted_at = 0) dm on dm.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 4 and deleted_at = 0 and expired != 2) dm on dm.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_auth where platform_id = 4 and deleted_at = 0) dm_auth on dm_auth.user_id = dm.user_id`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 3 and deleted_at = 0) ins on ins.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (SELECT * FROM cast_media_account where platform_id = 3 and deleted_at = 0 and expired != 2) ins on ins.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_auth where platform_id = 3 and deleted_at = 0) ins_auth on ins_auth.user_id = ins.user_id`).
|
||||
Joins(`left join (Select * from cast_media_account where platform_id = 2 and deleted_at = 0) youtube on youtube.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_account where platform_id = 2 and deleted_at = 0 and expired != 2) youtube on youtube.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_auth where platform_id = 2 and deleted_at = 0) youtube_auth on youtube_auth.user_id = youtube.user_id`).
|
||||
Joins(`left join (Select * from cast_media_account where platform_id = 5 and deleted_at = 0) bluesky on bluesky.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_account where platform_id = 5 and deleted_at = 0 and expired != 2) bluesky on bluesky.artist_uuid = cma.artist_uuid`).
|
||||
Joins(`left join (Select * from cast_media_auth where platform_id = 5 and deleted_at = 0) bluesky_auth on bluesky_auth.user_id = bluesky.user_id`).
|
||||
Joins(`left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci= cma.artist_uuid COLLATE utf8mb4_general_ci`).
|
||||
Where("bor.deleted_at is null")
|
||||
if req.Month != "" {
|
||||
query = query.Where("cma.created_at >= ?", start.Unix()).Where("cma.created_at <= ?", end.Unix())
|
||||
}
|
||||
err = query.Find(&data.Data).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1376,7 +1390,7 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
||||
func MetricsVideoSubmitExport(req *bundle.MetricsVideoSubmitExportReq) (result *bundle.MetricsVideoSubmitExportResp, err error) {
|
||||
result = &bundle.MetricsVideoSubmitExportResp{}
|
||||
var query *gorm.DB
|
||||
if req.Month == "" {
|
||||
if len(req.Month) == 0 {
|
||||
query = app.ModuleClients.BundleDB.Table("cast_work AS cw").
|
||||
Select(`cw.artist_name ,
|
||||
cw.title as video_title,
|
||||
@ -1391,22 +1405,61 @@ func MetricsVideoSubmitExport(req *bundle.MetricsVideoSubmitExportReq) (result *
|
||||
Where("(tiktok.created_at is not null or dm.created_at is not null or ins.created_at is not null) and cw.deleted_at = 0 and bor.deleted_at is null and cw.origin_uuid = ''").
|
||||
Order("cw.artist_name")
|
||||
} else {
|
||||
// 构建多个月份的时间范围参数
|
||||
var timeRanges []struct {
|
||||
Start int64
|
||||
End int64
|
||||
}
|
||||
|
||||
t, err := time.Parse("2006-01", req.Month)
|
||||
for _, month := range req.Month {
|
||||
t, err := time.Parse("2006-01", month)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
start := datetime.BeginOfMonth(t)
|
||||
end := datetime.EndOfMonth(t)
|
||||
timeRanges = append(timeRanges, struct {
|
||||
Start int64
|
||||
End int64
|
||||
}{Start: start.Unix(), End: end.Unix()})
|
||||
}
|
||||
// 构建时间筛选 SQL 条件的辅助函数
|
||||
buildTimeFilterSQL := func(tableAlias string) (string, []interface{}) {
|
||||
if len(timeRanges) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
var conditions []string
|
||||
var args []interface{}
|
||||
for _, tr := range timeRanges {
|
||||
// 明确指定表别名,避免字段歧义
|
||||
conditions = append(conditions, fmt.Sprintf("(%s.created_at >= ? AND %s.created_at <= ?)", tableAlias, tableAlias))
|
||||
args = append(args, tr.Start, tr.End)
|
||||
}
|
||||
return "(" + strings.Join(conditions, " OR ") + ")", args
|
||||
}
|
||||
query = app.ModuleClients.BundleDB.Table("cast_work AS cw").
|
||||
Select(`cw.artist_name, cw.title AS video_title, tiktok.created_at AS tiktok_upload_time, dm.created_at AS dm_upload_time, ins.created_at AS instagram_upload_time, bor.customer_num AS user_num`).
|
||||
Joins(`LEFT JOIN cast_work_platform_info tiktok ON tiktok.work_uuid = cw.uuid AND tiktok.platform_id = 1 AND tiktok.created_at >= ? AND tiktok.created_at <= ?`, start.Unix(), end.Unix()).
|
||||
Joins(`LEFT JOIN cast_work_platform_info dm ON dm.work_uuid = cw.uuid AND dm.platform_id = 4 AND dm.created_at >= ? AND dm.created_at <= ?`, start.Unix(), end.Unix()).
|
||||
Joins(`LEFT JOIN cast_work_platform_info ins ON ins.work_uuid = cw.uuid AND ins.platform_id = 3 AND ins.created_at >= ? AND ins.created_at <= ?`, start.Unix(), end.Unix()).
|
||||
Joins(`LEFT JOIN bundle_order_records bor ON bor.customer_id COLLATE utf8mb4_general_ci = cw.artist_uuid COLLATE utf8mb4_general_ci AND bor.deleted_at IS NULL`).
|
||||
Where(`cw.origin_uuid = '' and cw.deleted_at = 0 AND (tiktok.created_at IS NOT NULL OR dm.created_at IS NOT NULL OR ins.created_at IS NOT NULL)`).
|
||||
Order("cw.artist_name")
|
||||
Select(`cw.artist_name, cw.title AS video_title, tiktok.created_at AS tiktok_upload_time, dm.created_at AS dm_upload_time, ins.created_at AS instagram_upload_time, bor.customer_num AS user_num`)
|
||||
|
||||
// 为每个平台添加时间筛选条件
|
||||
if len(timeRanges) > 0 {
|
||||
// TikTok JOIN
|
||||
tiktokTimeSQL, tiktokArgs := buildTimeFilterSQL("tiktok")
|
||||
joinSQL := `LEFT JOIN cast_work_platform_info tiktok ON tiktok.work_uuid = cw.uuid AND tiktok.platform_id = 1 AND ` + tiktokTimeSQL
|
||||
query = query.Joins(joinSQL, tiktokArgs...)
|
||||
|
||||
// DM JOIN
|
||||
dmTimeSQL, dmArgs := buildTimeFilterSQL("dm")
|
||||
joinSQL = `LEFT JOIN cast_work_platform_info dm ON dm.work_uuid = cw.uuid AND dm.platform_id = 4 AND ` + dmTimeSQL
|
||||
query = query.Joins(joinSQL, dmArgs...)
|
||||
|
||||
// Instagram JOIN
|
||||
insTimeSQL, insArgs := buildTimeFilterSQL("ins")
|
||||
joinSQL = `LEFT JOIN cast_work_platform_info ins ON ins.work_uuid = cw.uuid AND ins.platform_id = 3 AND ` + insTimeSQL
|
||||
query = query.Joins(joinSQL, insArgs...)
|
||||
}
|
||||
query = query.Joins(`LEFT JOIN bundle_order_records bor ON bor.customer_id COLLATE utf8mb4_general_ci = cw.artist_uuid COLLATE utf8mb4_general_ci AND bor.deleted_at IS NULL`).
|
||||
Where(`cw.deleted_at = 0 AND (tiktok.created_at IS NOT NULL OR dm.created_at IS NOT NULL OR ins.created_at IS NOT NULL)`).
|
||||
Order("cw.artist_name")
|
||||
}
|
||||
err = query.Find(&result.Data).Error
|
||||
return
|
||||
|
||||
@ -539,6 +539,7 @@ func OrderRecordsListV2(req *bundle.OrderRecordsRequestV2) (res *bundle.OrderRec
|
||||
Amount: record.Amount,
|
||||
CustomerId: customerID,
|
||||
PayTime: record.PayTime,
|
||||
InviterId: record.InviterID,
|
||||
}
|
||||
|
||||
// 聚合子订单
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"dubbo.apache.org/dubbo-go/v3/common/logger"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
func BundleExtend(req *bundle.BundleExtendRequest) (*bundle.BundleExtendResponse, error) {
|
||||
@ -485,12 +486,8 @@ func BundleActivate(req *bundle.BundleActivateReq) error {
|
||||
return dao.BundleActivate(req.Ids)
|
||||
}
|
||||
|
||||
func UpdateBundleBalance() error {
|
||||
err := dao.UpdateBundleBalance()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
func UpdateBundleBalance() {
|
||||
dao.UpdateBundleBalance()
|
||||
}
|
||||
|
||||
func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBalanceExportResp, error) {
|
||||
@ -548,6 +545,14 @@ func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBala
|
||||
} else {
|
||||
item.IncreaseVideoUnitPrice = float32(math.Round(float64(item.IncreaseAmount/float32(v.IncreaseVideoNumber))*100) / 100)
|
||||
}
|
||||
bundleUnitPrice := decimal.NewFromFloat32(item.BundleVideoUnitPrice)
|
||||
increaseUnitPrice := decimal.NewFromFloat32(item.IncreaseVideoUnitPrice)
|
||||
|
||||
bundlePriceTotal := bundleUnitPrice.Mul(decimal.NewFromInt32(v.MonthBundleVideoConsumptionNumber))
|
||||
increasePriceTotal := increaseUnitPrice.Mul(decimal.NewFromInt32(v.MonthIncreaseVideoConsumptionNumber))
|
||||
|
||||
item.MonthlyBundleVideoConsumptionPrice = bundlePriceTotal.StringFixed(2)
|
||||
item.MonthlyIncreaseVideoConsumptionPrice = increasePriceTotal.StringFixed(2)
|
||||
items = append(items, item)
|
||||
}
|
||||
return &bundle.BundleBalanceExportResp{Total: int64(len(items)), Data: items}, nil
|
||||
|
||||
@ -69,6 +69,7 @@ func CreateOrderRecord(req *bundle.OrderCreateRecord) (res *bundle.CommonRespons
|
||||
Language: req.Language,
|
||||
BundleOrderValueAdd: addRecords,
|
||||
PlatformIds: req.PlatformIds,
|
||||
InviterID: req.InviterId,
|
||||
}
|
||||
res, err = dao.CreateOrderRecord(orderRecord)
|
||||
return
|
||||
|
||||
@ -45,6 +45,7 @@ type BundleOrderRecords struct {
|
||||
BundleOrderValueAdd []BundleOrderValueAdd `gorm:"foreignKey:OrderUUID;references:UUID" json:"bundleOrderValueAdd"`
|
||||
ReSignature int `json:"reSignature" gorm:"column:re_signature;default:2;type:int;comment:是否重新签 1:是 2:否"`
|
||||
PlatformIds PlatformIDs `gorm:"column:platform_ids;type:json;NOT NULL;comment:发布平台ID集合 TIKTOK= 1, YOUTUBE = 2, INS = 3 , DM = 4, BL = 5;" json:"platformIDs"`
|
||||
InviterID uint64 `gorm:"column:inviter_id;type:bigint;comment:邀请人ID" json:"inviterID"`
|
||||
}
|
||||
type BundleOrderValueAdd struct {
|
||||
gorm.Model
|
||||
|
||||
@ -55,7 +55,6 @@ service Bundle {
|
||||
|
||||
|
||||
// 余量管理
|
||||
rpc UpdateBundleBalance(UpdateBundleBalanceReq) returns (UpdateBundleBalanceResp) {} // 更新余量表数据(用于每月定时任务,谨慎调用)
|
||||
rpc BundleExtend(BundleExtendRequest) returns (BundleExtendResponse) {} // 套餐扩展
|
||||
rpc BundleExtendRecordsList(BundleExtendRecordsListRequest) returns (BundleExtendRecordsListResponse) {} // 套餐扩展记录查询
|
||||
rpc GetBundleBalanceList(GetBundleBalanceListReq) returns (GetBundleBalanceListResp) {} // 余量信息
|
||||
@ -219,6 +218,7 @@ message OrderCreateRecord{
|
||||
repeated OrderCreateAddRecord addRecords = 20 [json_name = "addRecords"]; //增值服务
|
||||
string orderNo = 21 [json_name = "orderNo"];
|
||||
repeated uint32 platformIds = 22; // 发布平台ID集合 (json 格式字符串)
|
||||
uint64 inviterId = 23; // 邀请人ID
|
||||
}
|
||||
message OrderCreateAddRecord{
|
||||
int32 serviceType = 1 [json_name = "serviceType"];
|
||||
@ -271,6 +271,9 @@ message OrderBundleRecordInfo{
|
||||
int64 customerId = 9;
|
||||
string payTime = 10;
|
||||
string subNum = 11;
|
||||
uint64 inviterId = 12;
|
||||
string inviterCode = 13;
|
||||
string inviterName = 14;
|
||||
}
|
||||
message OrderAddBundleRecordInfo{
|
||||
string orderAddNo = 1;
|
||||
@ -665,12 +668,6 @@ message BatchGetValueAddServiceLangResponse{
|
||||
}
|
||||
//*********************************新增值服务-over******************************************
|
||||
|
||||
message UpdateBundleBalanceReq{
|
||||
}
|
||||
|
||||
message UpdateBundleBalanceResp{
|
||||
}
|
||||
|
||||
message BundleExtendRequest{
|
||||
int64 userId = 1;
|
||||
uint32 accountAdditional = 2;
|
||||
@ -734,7 +731,7 @@ message GetBundleBalanceListReq{
|
||||
int64 expiredTimeEnd = 8;
|
||||
int32 page = 9;
|
||||
int32 pageSize = 10;
|
||||
string month = 11;
|
||||
repeated string month = 11;
|
||||
int32 statusType = 12;
|
||||
}
|
||||
|
||||
@ -918,11 +915,15 @@ message BundleBalanceExportItem {
|
||||
int32 monthlyManualVideoConsumptionNumber = 65; // 当月手动扩展视频使用数
|
||||
int32 monthlyManualImageConsumptionNumber = 66; // 当月手动扩展图文使用数
|
||||
int32 monthlyManualDataAnalysisConsumptionNumber = 67; // 当月手动扩展数据分析使用数
|
||||
|
||||
//视频当月消耗金额
|
||||
string monthlyBundleVideoConsumptionPrice = 68;//当月套餐消耗总金额
|
||||
string monthlyIncreaseVideoConsumptionPrice = 69;//当月增值消耗总金额
|
||||
}
|
||||
|
||||
|
||||
message BundleBalanceExportReq{
|
||||
string month = 1;
|
||||
repeated string month = 1;
|
||||
string userName = 2;
|
||||
uint64 expiredTimeStart = 3;
|
||||
uint64 expiredTimeEnd = 4;
|
||||
@ -1769,7 +1770,7 @@ message MetricsBundlePurchaseItem{
|
||||
}
|
||||
|
||||
message MetricsArtistAccountExportReq{
|
||||
string month = 1;
|
||||
repeated string month = 1;
|
||||
}
|
||||
|
||||
message MetricsArtistAccountExportResp{
|
||||
@ -1799,7 +1800,7 @@ message MetricsArtistAccountExportItem{
|
||||
|
||||
|
||||
message MetricsVideoSubmitExportReq{
|
||||
string month = 1;
|
||||
repeated string month = 1;
|
||||
}
|
||||
|
||||
message MetricsVideoSubmitExportResp{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -365,12 +365,6 @@ func (this *BatchGetValueAddServiceLangResponse) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *UpdateBundleBalanceReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *UpdateBundleBalanceResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BundleExtendRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -64,7 +64,6 @@ type BundleClient interface {
|
||||
BatchGetValueAddServiceLang(ctx context.Context, in *BatchGetValueAddServiceLangRequest, opts ...grpc_go.CallOption) (*BatchGetValueAddServiceLangResponse, common.ErrorWithAttachment)
|
||||
DeleteValueAddService(ctx context.Context, in *DeleteValueAddServiceRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
|
||||
// 余量管理
|
||||
UpdateBundleBalance(ctx context.Context, in *UpdateBundleBalanceReq, opts ...grpc_go.CallOption) (*UpdateBundleBalanceResp, common.ErrorWithAttachment)
|
||||
BundleExtend(ctx context.Context, in *BundleExtendRequest, opts ...grpc_go.CallOption) (*BundleExtendResponse, common.ErrorWithAttachment)
|
||||
BundleExtendRecordsList(ctx context.Context, in *BundleExtendRecordsListRequest, opts ...grpc_go.CallOption) (*BundleExtendRecordsListResponse, common.ErrorWithAttachment)
|
||||
GetBundleBalanceList(ctx context.Context, in *GetBundleBalanceListReq, opts ...grpc_go.CallOption) (*GetBundleBalanceListResp, common.ErrorWithAttachment)
|
||||
@ -160,7 +159,6 @@ type BundleClientImpl struct {
|
||||
CalculatePrice func(ctx context.Context, in *CalculatePriceRequest) (*CalculatePriceResponse, error)
|
||||
BatchGetValueAddServiceLang func(ctx context.Context, in *BatchGetValueAddServiceLangRequest) (*BatchGetValueAddServiceLangResponse, error)
|
||||
DeleteValueAddService func(ctx context.Context, in *DeleteValueAddServiceRequest) (*CommonResponse, error)
|
||||
UpdateBundleBalance func(ctx context.Context, in *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error)
|
||||
BundleExtend func(ctx context.Context, in *BundleExtendRequest) (*BundleExtendResponse, error)
|
||||
BundleExtendRecordsList func(ctx context.Context, in *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
|
||||
GetBundleBalanceList func(ctx context.Context, in *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
|
||||
@ -423,12 +421,6 @@ func (c *bundleClient) DeleteValueAddService(ctx context.Context, in *DeleteValu
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteValueAddService", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) UpdateBundleBalance(ctx context.Context, in *UpdateBundleBalanceReq, opts ...grpc_go.CallOption) (*UpdateBundleBalanceResp, common.ErrorWithAttachment) {
|
||||
out := new(UpdateBundleBalanceResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateBundleBalance", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) BundleExtend(ctx context.Context, in *BundleExtendRequest, opts ...grpc_go.CallOption) (*BundleExtendResponse, common.ErrorWithAttachment) {
|
||||
out := new(BundleExtendResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -769,7 +761,6 @@ type BundleServer interface {
|
||||
BatchGetValueAddServiceLang(context.Context, *BatchGetValueAddServiceLangRequest) (*BatchGetValueAddServiceLangResponse, error)
|
||||
DeleteValueAddService(context.Context, *DeleteValueAddServiceRequest) (*CommonResponse, error)
|
||||
// 余量管理
|
||||
UpdateBundleBalance(context.Context, *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error)
|
||||
BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error)
|
||||
BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
|
||||
GetBundleBalanceList(context.Context, *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
|
||||
@ -932,9 +923,6 @@ func (UnimplementedBundleServer) BatchGetValueAddServiceLang(context.Context, *B
|
||||
func (UnimplementedBundleServer) DeleteValueAddService(context.Context, *DeleteValueAddServiceRequest) (*CommonResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteValueAddService not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) UpdateBundleBalance(context.Context, *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateBundleBalance not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BundleExtend not implemented")
|
||||
}
|
||||
@ -2070,35 +2058,6 @@ func _Bundle_DeleteValueAddService_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_UpdateBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateBundleBalanceReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("UpdateBundleBalance", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_BundleExtend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(BundleExtendRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -3688,10 +3647,6 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "DeleteValueAddService",
|
||||
Handler: _Bundle_DeleteValueAddService_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateBundleBalance",
|
||||
Handler: _Bundle_UpdateBundleBalance_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "BundleExtend",
|
||||
Handler: _Bundle_BundleExtend_Handler,
|
||||
|
||||
@ -11,9 +11,19 @@ import (
|
||||
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)
|
||||
}
|
||||
|
||||
// 避免冲突,任务余额每月更新定时任务 - 每月1号1点执行
|
||||
taskBalanceSpec := "0 0 1 1 * *"
|
||||
_, err := c.AddFunc(taskBalanceSpec, func() {
|
||||
_, err = c.AddFunc(taskBalanceSpec, func() {
|
||||
log.Printf("执行任务余额每月数据更新")
|
||||
logic.UpdateTaskBalanceEveryMonLogic()
|
||||
})
|
||||
|
||||
@ -68,6 +68,11 @@ func loadMysqlConn(conn string) *gorm.DB {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
if db.Migrator().HasColumn(&model.BundleOrderRecords{}, "inviter_id") == false {
|
||||
if err := db.Migrator().AddColumn(&model.BundleOrderRecords{}, "inviter_id"); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
// return nil
|
||||
panic(err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user