Compare commits
No commits in common. "main" and "feat-hjj-QuestionnaireSurvey" have entirely different histories.
main
...
feat-hjj-Q
@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"micro-bundle/internal/logic"
|
||||
"micro-bundle/pb/bundle"
|
||||
)
|
||||
@ -96,13 +95,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
|
||||
}
|
||||
|
||||
@ -1326,16 +1326,18 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
data.PendingUploadVideoCount = statistic(9, 2)
|
||||
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 2 and cwe.confirm_type = 1").
|
||||
Joins("left join cast_work_log cwl on cwl.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status = 9 and cwl.work_category = 2 and cwl.work_status = 9 and ccl.operator_name != '系统自动确定'").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Where("cwl.deleted_at = 0 and ccl.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Count(&data.ArtistConfirmVideoCount)
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 2 and cwe.confirm_type = 2").
|
||||
Joins("left join cast_work_log cwl on cwl.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status = 9 and cwl.work_category = 2 and cwl.work_status = 9 and ccl.operator_name = '系统自动确定'").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Where("cwl.deleted_at = 0 and ccl.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Count(&data.AutoConfirmVideoCount)
|
||||
|
||||
//图文
|
||||
@ -1349,16 +1351,18 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
data.PendingUploadImageCount = statistic(9, 1)
|
||||
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 1 and cwe.confirm_type = 1").
|
||||
Joins("left join cast_work_log cwl on cwl.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status = 9 and cwl.work_category = 1 and cwl.work_status = 9 and ccl.operator_name != '系统自动确定'").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Where("cwl.deleted_at = 0 and ccl.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Count(&data.ArtistConfirmImageCount)
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 1 and cwe.confirm_type = 2").
|
||||
Joins("left join cast_work_log cwl on cwl.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.status = 9 and cwl.work_category = 1 and cwl.work_status = 9 and ccl.operator_name = '系统自动确定'").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Where("cwl.deleted_at = 0 and ccl.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
Count(&data.AutoConfirmImageCount)
|
||||
//======================数据分析======================
|
||||
var analysisStatistic = func(status int8) (i int64) {
|
||||
@ -1373,15 +1377,17 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
data.UploadFailedDataAnalysisCount = analysisStatistic(5)
|
||||
|
||||
app.ModuleClients.BundleDB.Table("cast_work_analysis").
|
||||
Joins("left join cast_cost_analysis_log ccal on ccal.analysis_uuid = cast_work_analysis.uuid AND ccal.deleted_at = 0").
|
||||
Where("cast_work_analysis.work_analysis_status in ?", []int{6, 7}).
|
||||
Where("cast_work_analysis.deleted_at = 0").
|
||||
Where("cast_work_analysis.comfirm_type = 1").
|
||||
Where("ccal.operator_name != '系统自动确定'").
|
||||
Where("cast_work_analysis.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Count(&data.ArtistConfirmDataAnalysisCount)
|
||||
app.ModuleClients.BundleDB.Table("cast_work_analysis").
|
||||
Joins("left join cast_cost_analysis_log ccal on ccal.analysis_uuid = cast_work_analysis.uuid AND ccal.deleted_at = 0").
|
||||
Where("cast_work_analysis.work_analysis_status in ?", []int{6, 7}).
|
||||
Where("cast_work_analysis.deleted_at = 0").
|
||||
Where("cast_work_analysis.comfirm_type = 2").
|
||||
Where("ccal.operator_name = '系统自动确定'").
|
||||
Where("cast_work_analysis.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Count(&data.AutoConfirmDataAnalysisCount)
|
||||
//================竞品数==================
|
||||
@ -1397,15 +1403,17 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
data.UploadFailedCompetitiveCount = competitiveStatistic(5)
|
||||
|
||||
app.ModuleClients.BundleDB.Table("cast_competitive_report as ccr").
|
||||
Joins("left join cast_cost_competitive_report_log cccrl on cccrl.report_uuid = ccr.uuid AND cccrl.deleted_at = 0").
|
||||
Where("ccr.work_report_status in ?", []int{6, 7}).
|
||||
Where("ccr.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("ccr.comfirm_type = 1").
|
||||
Where("cccrl.operator_name != '系统自动确定'").
|
||||
Where("ccr.deleted_at = 0").
|
||||
Count(&data.ArtistConfirmCompetitiveCount)
|
||||
app.ModuleClients.BundleDB.Table("cast_competitive_report as ccr").
|
||||
Joins("left join cast_cost_competitive_report_log cccrl on cccrl.report_uuid = ccr.uuid AND cccrl.deleted_at = 0").
|
||||
Where("ccr.work_report_status in ?", []int{6, 7}).
|
||||
Where("ccr.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("ccr.comfirm_type = 2").
|
||||
Where("cccrl.operator_name = '系统自动确定'").
|
||||
Where("ccr.deleted_at = 0").
|
||||
Count(&data.AutoConfirmCompetitiveCount)
|
||||
return
|
||||
|
||||
@ -692,9 +692,6 @@ func GetReconciliationList(req *bundle.GetReconciliationListReq) (*bundle.GetRec
|
||||
if req.SerialNumber != "" {
|
||||
modelObj = modelObj.Where("serial_number like ?", "%"+req.SerialNumber+"%")
|
||||
}
|
||||
if req.AntomNum != "" {
|
||||
modelObj = modelObj.Where("antom_num like ?", "%"+req.AntomNum+"%")
|
||||
}
|
||||
if err := modelObj.Count(&res.Total).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询总数失败: %v", err)
|
||||
}
|
||||
@ -717,16 +714,9 @@ func CreateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonRes
|
||||
if req.SerialNumber != "" {
|
||||
var existing model.Reconciliation
|
||||
err = app.ModuleClients.BundleDB.Where("serial_number = ?", req.SerialNumber).First(&existing).Error
|
||||
switch {
|
||||
case err == nil:
|
||||
if err = app.ModuleClients.BundleDB.Model(&model.Reconciliation{}).
|
||||
Where("serial_number = ?", req.SerialNumber).
|
||||
Update("antom_num", req.AntomNum).Error; err != nil {
|
||||
return nil, fmt.Errorf("更新对账单失败: %v", err)
|
||||
}
|
||||
if err == nil {
|
||||
// 说明这笔流水存在对账单
|
||||
return &bundle.CommonResponse{Msg: "创建对账单成功"}, nil
|
||||
case !errors.Is(err, gorm.ErrRecordNotFound):
|
||||
return nil, fmt.Errorf("查询对账单失败: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,13 +735,14 @@ func CreateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonRes
|
||||
SerialNumber: req.SerialNumber,
|
||||
CreationTime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
HandlingFee: req.HandlingFee,
|
||||
AntomNum: req.AntomNum,
|
||||
}
|
||||
|
||||
// 创建记录
|
||||
if err := app.ModuleClients.BundleDB.Create(record).Error; err != nil {
|
||||
return nil, fmt.Errorf("创建对账单失败: %v", err)
|
||||
}
|
||||
|
||||
// 返回成功响应
|
||||
return &bundle.CommonResponse{Msg: "创建对账单成功"}, nil
|
||||
}
|
||||
func UpdateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonResponse, err error) {
|
||||
@ -775,7 +766,6 @@ func UpdateReconciliation(req *bundle.ReconciliationInfo) (res *bundle.CommonRes
|
||||
PayStatus: int(req.PayStatus),
|
||||
SerialNumber: req.SerialNumber,
|
||||
HandlingFee: req.HandlingFee,
|
||||
AntomNum: req.AntomNum,
|
||||
}
|
||||
if err := app.ModuleClients.BundleDB.Model(&existing).Updates(updates).Error; err != nil {
|
||||
return nil, fmt.Errorf("更新对账单失败: %v", err)
|
||||
|
||||
@ -89,9 +89,9 @@ newest_month AS (
|
||||
active_windows AS (
|
||||
SELECT
|
||||
u.id AS user_id,
|
||||
u.tel_num COLLATE utf8mb4_0900_ai_ci AS phone,
|
||||
u.tel_num AS phone,
|
||||
bor.uuid AS order_uuid,
|
||||
bor.customer_num COLLATE utf8mb4_0900_ai_ci AS customer_num,
|
||||
bor.customer_num,
|
||||
bb.start_at,
|
||||
bb.expired_at,
|
||||
bb.bundle_video_number, bb.bundle_limit_video_number, bb.bundle_limit_video_expired_number,
|
||||
@ -106,7 +106,7 @@ active_windows AS (
|
||||
bb.bundle_competitive_number, bb.bundle_limit_competitive_number, bb.bundle_limit_competitive_expired_number,
|
||||
bb.increase_competitive_number, bb.increase_limit_competitive_number, bb.increase_limit_competitive_expired_number,
|
||||
bb.manual_competitive_number, bb.manual_competitive_consumption_number,
|
||||
rn.name COLLATE utf8mb4_0900_ai_ci AS user_name
|
||||
rn.name AS user_name
|
||||
FROM ` + "`micro-account`.`user`" + ` u
|
||||
INNER JOIN ` + "`micro-account`.real_name" + ` rn ON rn.id = u.real_name_id AND rn.name IS NOT NULL AND rn.deleted_at = 0
|
||||
INNER JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2
|
||||
@ -188,7 +188,7 @@ cw_agg AS (
|
||||
COUNT(CASE WHEN cw.work_category = 2 AND cw.cost = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_video_consumed,
|
||||
COUNT(CASE WHEN cw.work_category = 1 AND cw.cost = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_post_consumed
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_work cw ON cw.artist_phone = aw.phone
|
||||
LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -196,10 +196,10 @@ cw_agg AS (
|
||||
cwa_agg AS (
|
||||
SELECT
|
||||
aw.user_id,
|
||||
COUNT(CASE WHEN cwa.deleted_at = 0 AND cwa.work_analysis_status != 1 AND cwa.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_data_count,
|
||||
COUNT(CASE WHEN cwa.cost = 1 AND cwa.deleted_at = 0 AND cwa.work_analysis_status != 1 AND cwa.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_data_consumed
|
||||
COUNT(CASE WHEN cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS uploaded_data_count,
|
||||
COUNT(CASE WHEN cwa.cost = 1 AND cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS released_data_consumed
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone = aw.phone
|
||||
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -210,7 +210,7 @@ ccr_agg AS (
|
||||
COUNT(CASE WHEN ccr.deleted_at = 0 AND ccr.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_report_count,
|
||||
COUNT(CASE WHEN ccr.cost = 1 AND ccr.deleted_at = 0 AND ccr.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS released_report_consumed
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_competitive_report ccr ON ccr.artist_phone = aw.phone
|
||||
LEFT JOIN cast_competitive_report ccr ON ccr.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -220,7 +220,7 @@ cvs_agg AS (
|
||||
aw.user_id,
|
||||
COUNT(cvs.artist_uuid) AS uploaded_video_script_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_video_script cvs ON CAST(aw.user_id AS CHAR) = cvs.artist_uuid
|
||||
LEFT JOIN cast_video_script cvs ON CAST(aw.user_id AS CHAR) COLLATE utf8mb4_general_ci = cvs.artist_uuid COLLATE utf8mb4_general_ci
|
||||
AND cvs.deleted_at = 0
|
||||
AND cvs.created_at BETWEEN UNIX_TIMESTAMP(CONVERT_TZ(aw.start_at, '+00:00', '+00:00'))
|
||||
AND UNIX_TIMESTAMP(CONVERT_TZ(aw.expired_at, '+00:00', '+00:00'))
|
||||
@ -234,7 +234,7 @@ tar_agg AS (
|
||||
COUNT(CASE WHEN tar.status = 1 AND tar.deleted_at = 0 AND tar.created_at BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS progress_task_count,
|
||||
COUNT(CASE WHEN tar.status = 2 AND tar.deleted_at = 0 AND tar.created_at BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS complete_task_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num = aw.customer_num
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num COLLATE utf8mb4_general_ci = aw.customer_num COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -273,7 +273,7 @@ assigned_pending_agg AS (
|
||||
END
|
||||
), 0) AS assigned_report_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num = aw.customer_num
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num COLLATE utf8mb4_general_ci = aw.customer_num COLLATE utf8mb4_general_ci
|
||||
AND tar.actual_status IN (1, 3)
|
||||
AND tar.deleted_at = 0
|
||||
AND tar.created_at BETWEEN aw.start_at AND aw.expired_at
|
||||
@ -325,16 +325,9 @@ LEFT JOIN assigned_pending_agg apa ON apa.user_id = aw.user_id`
|
||||
whereClause = " WHERE " + strings.Join(whereParts, " AND ")
|
||||
}
|
||||
|
||||
// 使用事务固定同一连接,仅对本次查询的 session 设置 collation,不影响其他接口
|
||||
tx := app.ModuleClients.BundleDB.Begin()
|
||||
defer tx.Rollback()
|
||||
if err := tx.Exec("SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci").Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "设置字符集失败", "设置字符集失败: ")
|
||||
}
|
||||
|
||||
countSQL := cte + " SELECT COUNT(DISTINCT aw.customer_num) " + fromClause + whereClause
|
||||
var total int64
|
||||
if err := tx.Raw(countSQL, args...).Scan(&total).Error; err != nil {
|
||||
if err := app.ModuleClients.BundleDB.Raw(countSQL, args...).Scan(&total).Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "查询总数失败", "查询艺人上传统计总数失败: ")
|
||||
}
|
||||
|
||||
@ -433,7 +426,7 @@ LEFT JOIN assigned_pending_agg apa ON apa.user_id = aw.user_id`
|
||||
}
|
||||
|
||||
items := make([]dto.ArtistUploadStatsItem, 0)
|
||||
if err := tx.Raw(selectSQL, listArgs...).Scan(&items).Error; err != nil {
|
||||
if err := app.ModuleClients.BundleDB.Raw(selectSQL, listArgs...).Scan(&items).Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "查询艺人余额与上传数据失败", "查询艺人余额与上传数据失败: ")
|
||||
}
|
||||
|
||||
@ -481,20 +474,20 @@ newest_month AS (
|
||||
active_windows AS (
|
||||
SELECT
|
||||
u.id AS user_id,
|
||||
u.tel_num COLLATE utf8mb4_0900_ai_ci AS phone,
|
||||
u.tel_num AS phone,
|
||||
bor.uuid AS order_uuid,
|
||||
bor.customer_num COLLATE utf8mb4_0900_ai_ci AS customer_num,
|
||||
bor.customer_num,
|
||||
bb.start_at,
|
||||
bb.expired_at,
|
||||
bb.manual_video_number, bb.manual_video_consumption_number,
|
||||
bb.manual_image_number, bb.manual_image_consumption_number,
|
||||
bb.manual_data_analysis_number, bb.manual_data_analysis_consumption_number,
|
||||
bb.manual_competitive_number, bb.manual_competitive_consumption_number,
|
||||
rn.name COLLATE utf8mb4_0900_ai_ci AS user_name
|
||||
rn.name AS user_name
|
||||
FROM ` + "`micro-account`.`user`" + ` u
|
||||
INNER JOIN ` + "`micro-account`.real_name" + ` rn ON rn.id = u.real_name_id AND rn.name IS NOT NULL AND rn.deleted_at = 0
|
||||
INNER JOIN ` + "`micro-account`.real_name" + ` rn ON rn.id = u.real_name_id AND rn.name IS NOT NULL
|
||||
INNER JOIN bundle_activate bc ON bc.user_id = u.id AND bc.activate = 2
|
||||
INNER JOIN latest_bor bor ON bor.customer_id = u.id AND u.deleted_at = 0
|
||||
INNER JOIN latest_bor bor ON bor.customer_id = u.id
|
||||
INNER JOIN newest_month nm ON nm.user_id = u.id
|
||||
INNER JOIN bundle_balance bb ON bb.user_id = u.id AND bb.order_uuid = bor.uuid AND bb.month = nm.month AND bb.deleted_at IS NULL
|
||||
WHERE u.deleted_at = 0
|
||||
@ -563,14 +556,14 @@ balance_sum AS (
|
||||
GROUP BY bb2.user_id
|
||||
),
|
||||
|
||||
-- 6. 作品统计(只统计 origin_uuid 为空的作品)
|
||||
-- 6. 作品统计
|
||||
cw_agg AS (
|
||||
SELECT
|
||||
aw.user_id,
|
||||
COUNT(CASE WHEN cw.work_category = 2 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_video_count,
|
||||
COUNT(CASE WHEN cw.work_category = 1 AND cw.deleted_at = 0 AND (cw.origin_uuid = '' OR cw.origin_uuid IS NULL) AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_post_count
|
||||
COUNT(CASE WHEN cw.work_category = 2 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_video_count,
|
||||
COUNT(CASE WHEN cw.work_category = 1 AND cw.deleted_at = 0 AND cw.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_post_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_work cw ON cw.artist_phone = aw.phone
|
||||
LEFT JOIN cast_work cw ON cw.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -578,9 +571,9 @@ cw_agg AS (
|
||||
cwa_agg AS (
|
||||
SELECT
|
||||
aw.user_id,
|
||||
COUNT(CASE WHEN cwa.deleted_at = 0 AND cwa.work_analysis_status != 1 AND cwa.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_data_count
|
||||
COUNT(CASE WHEN cwa.deleted_at = 0 AND (cwa.work_analysis_status IS NULL OR cwa.work_analysis_status != 1) AND cwa.submit_time BETWEEN UNIX_TIMESTAMP(aw.start_at) AND UNIX_TIMESTAMP(aw.expired_at) THEN 1 END) AS uploaded_data_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone = aw.phone
|
||||
LEFT JOIN cast_work_analysis cwa ON cwa.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -590,7 +583,7 @@ ccr_agg AS (
|
||||
aw.user_id,
|
||||
COUNT(CASE WHEN ccr.deleted_at = 0 AND ccr.submit_time BETWEEN aw.start_at AND aw.expired_at THEN 1 END) AS uploaded_report_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_competitive_report ccr ON ccr.artist_phone = aw.phone
|
||||
LEFT JOIN cast_competitive_report ccr ON ccr.artist_phone COLLATE utf8mb4_general_ci = aw.phone COLLATE utf8mb4_general_ci
|
||||
GROUP BY aw.user_id
|
||||
),
|
||||
|
||||
@ -600,7 +593,7 @@ cvs_agg AS (
|
||||
aw.user_id,
|
||||
COUNT(cvs.artist_uuid) AS uploaded_video_script_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN cast_video_script cvs ON CAST(aw.user_id AS CHAR) = cvs.artist_uuid
|
||||
LEFT JOIN cast_video_script cvs ON CAST(aw.user_id AS CHAR) COLLATE utf8mb4_general_ci = cvs.artist_uuid COLLATE utf8mb4_general_ci
|
||||
AND cvs.deleted_at = 0
|
||||
AND cvs.created_at BETWEEN UNIX_TIMESTAMP(CONVERT_TZ(aw.start_at, '+00:00', '+00:00'))
|
||||
AND UNIX_TIMESTAMP(CONVERT_TZ(aw.expired_at, '+00:00', '+00:00'))
|
||||
@ -642,7 +635,7 @@ assigned_pending_agg AS (
|
||||
END
|
||||
), 0) AS assigned_report_count
|
||||
FROM active_windows aw
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num = aw.customer_num
|
||||
LEFT JOIN ` + "`" + taskSchema + "`" + `.task_assign_records tar ON tar.sub_num COLLATE utf8mb4_general_ci = aw.customer_num COLLATE utf8mb4_general_ci
|
||||
AND tar.actual_status IN (1, 3)
|
||||
AND tar.deleted_at = 0
|
||||
AND tar.created_at BETWEEN aw.start_at AND aw.expired_at
|
||||
@ -661,16 +654,9 @@ LEFT JOIN assigned_pending_agg apa ON apa.user_id = aw.user_id`
|
||||
args = append(args, subNums)
|
||||
args = append(args, nowMonth)
|
||||
|
||||
// 使用事务固定同一连接,仅对本次查询的 session 设置 collation,不影响其他接口
|
||||
tx2 := app.ModuleClients.BundleDB.Begin()
|
||||
defer tx2.Rollback()
|
||||
if err := tx2.Exec("SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci").Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "设置字符集失败", "设置字符集失败: ")
|
||||
}
|
||||
|
||||
countSQL := cte + " SELECT COUNT(DISTINCT aw.customer_num) " + fromClause
|
||||
var total int64
|
||||
if err := tx2.Raw(countSQL, args...).Scan(&total).Error; err != nil {
|
||||
if err := app.ModuleClients.BundleDB.Raw(countSQL, args...).Scan(&total).Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "查询可指派数量总数失败", "查询可指派数量总数失败: ")
|
||||
}
|
||||
|
||||
@ -694,7 +680,7 @@ LEFT JOIN assigned_pending_agg apa ON apa.user_id = aw.user_id`
|
||||
}
|
||||
|
||||
items := make([]dto.ArtistPendingAssignItem, 0)
|
||||
if err := tx2.Raw(selectSQL, listArgs...).Scan(&items).Error; err != nil {
|
||||
if err := app.ModuleClients.BundleDB.Raw(selectSQL, listArgs...).Scan(&items).Error; err != nil {
|
||||
return nil, 0, commonErr.ReturnError(err, "查询可指派数量失败", "查询可指派数量失败: ")
|
||||
}
|
||||
|
||||
|
||||
@ -632,12 +632,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) {
|
||||
|
||||
@ -18,5 +18,4 @@ type Reconciliation struct {
|
||||
SerialNumber string `gorm:"column:serial_number;comment:流水号" json:"serialNumber"`
|
||||
CreationTime string `gorm:"column:creation_time;comment:创建时间" json:"creationTime"`
|
||||
HandlingFee string `gorm:"column:handling_fee;comment:手续费" json:"handlingFee"`
|
||||
AntomNum string `gorm:"column:antom_num;comment:安通流水号" json:"antomNum"`
|
||||
}
|
||||
|
||||
@ -52,7 +52,6 @@ service Bundle {
|
||||
|
||||
|
||||
// 余量管理
|
||||
rpc UpdateBundleBalance(UpdateBundleBalanceReq) returns (UpdateBundleBalanceResp) {} // 更新余量表数据(用于每月定时任务,谨慎调用)
|
||||
rpc BundleExtend(BundleExtendRequest) returns (BundleExtendResponse) {} // 套餐扩展
|
||||
rpc BundleExtendRecordsList(BundleExtendRecordsListRequest) returns (BundleExtendRecordsListResponse) {} // 套餐扩展记录查询
|
||||
rpc GetBundleBalanceList(GetBundleBalanceListReq) returns (GetBundleBalanceListResp) {} // 余量信息
|
||||
@ -195,7 +194,6 @@ message GetReconciliationListReq{
|
||||
int32 pageSize = 12;
|
||||
repeated uint64 userIDS = 13;
|
||||
string bundleAddOrderOn = 14;
|
||||
string antomNum = 15;
|
||||
}
|
||||
message GetReconciliationListResp{
|
||||
repeated ReconciliationInfo list = 1;
|
||||
@ -220,7 +218,6 @@ message ReconciliationInfo{
|
||||
uint64 userID = 14;
|
||||
string handlingFee = 15;
|
||||
string subNum = 16;
|
||||
string antomNum = 17;
|
||||
}
|
||||
message OrderInfoByOrderNoRequest{
|
||||
string orderNo = 1;
|
||||
@ -722,12 +719,6 @@ message BatchGetValueAddServiceLangResponse{
|
||||
}
|
||||
//*********************************新增值服务-over******************************************
|
||||
|
||||
message UpdateBundleBalanceReq{
|
||||
}
|
||||
|
||||
message UpdateBundleBalanceResp{
|
||||
}
|
||||
|
||||
message BundleExtendRequest{
|
||||
int64 userId = 1;
|
||||
uint32 accountAdditional = 2;
|
||||
|
||||
11767
pb/bundle/bundle.pb.go
11767
pb/bundle/bundle.pb.go
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,8 @@ import (
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
_ "github.com/mwitkow/go-proto-validators"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||
)
|
||||
|
||||
@ -368,12 +368,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
|
||||
}
|
||||
|
||||
@ -65,7 +65,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)
|
||||
@ -194,7 +193,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)
|
||||
@ -490,12 +488,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)
|
||||
@ -999,7 +991,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)
|
||||
@ -1197,9 +1188,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")
|
||||
}
|
||||
@ -2445,35 +2433,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 {
|
||||
@ -4850,10 +4809,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,
|
||||
|
||||
@ -1,10 +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()
|
||||
|
||||
}
|
||||
|
||||
@ -90,11 +90,6 @@ func loadMysqlConn(conn string) *gorm.DB {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
if db.Migrator().HasColumn(&model.Reconciliation{}, "antom_num") == false {
|
||||
if err := db.Migrator().AddColumn(&model.Reconciliation{}, "antom_num"); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
// return nil
|
||||
panic(err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user