Merge branch 'feat-hjj-Paylater' into dev
This commit is contained in:
commit
824ba26bbc
@ -22,7 +22,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
subQuery := app.ModuleClients.BundleDB.Model(&model.Reconciliation{}).
|
||||
Select("TRUNCATE(COALESCE(SUM(CAST(handling_fee AS DECIMAL(12,3))), 0), 3) as total_fee_payment_amount").
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no COLLATE utf8mb4_general_ci = reconciliation.bundle_order_on COLLATE utf8mb4_general_ci").
|
||||
Where("bor.deleted_at is null and bor.status=2")
|
||||
Where("bor.deleted_at is null and bor.status=2 and bor.order_type = 1")
|
||||
// if req.BundleUuid != "" {
|
||||
// subQuery = subQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
// }
|
||||
@ -33,7 +33,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
TRUNCATE(COALESCE(SUM(total_amount), 0) - COALESCE(SUM(amount), 0), 3) as total_increase_payment_amount,
|
||||
(?) as total_fee_payment_amount
|
||||
`, subQuery).
|
||||
Where("deleted_at IS NULL and status=2")
|
||||
Where("deleted_at IS NULL and status=2 and order_type = 1")
|
||||
// if req.BundleUuid != "" {
|
||||
// query = query.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
// }
|
||||
@ -76,7 +76,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no COLLATE utf8mb4_general_ci = reconciliation.bundle_order_on COLLATE utf8mb4_general_ci").
|
||||
Where("`reconciliation`.pay_time >= ?", req.Start+" 00:00:00").
|
||||
Where("`reconciliation`.pay_time <= ?", req.End+" 23:59:59").
|
||||
Where("`reconciliation`.deleted_at is null and reconciliation.pay_status = 2 and bor.status=2 and bor.deleted_at is null")
|
||||
Where("`reconciliation`.deleted_at is null and reconciliation.pay_status = 2 and bor.status=2 and bor.deleted_at is null and bor.order_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -95,7 +95,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
`).
|
||||
Where("`bundle_order_records`.pay_time >= ?", req.Start+" 00:00:00").
|
||||
Where("`bundle_order_records`.pay_time <= ?", req.End+" 23:59:59").
|
||||
Where("`bundle_order_records`.deleted_at is null and bundle_order_records.pay_time != ''")
|
||||
Where("`bundle_order_records`.deleted_at is null and bundle_order_records.pay_time != '' and bundle_order_records.order_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -119,7 +119,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
countQuery := app.ModuleClients.BundleDB.Model(&model.BundleOrderRecords{}).
|
||||
Where("pay_time >= ?", req.Start+" 00:00:00").
|
||||
Where("pay_time <= ?", req.End+" 23:59:59").
|
||||
Where("deleted_at is null and status = 2")
|
||||
Where("deleted_at is null and status = 2 and order_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
countQuery = countQuery.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -131,7 +131,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
// ---------- 重复购买套餐数 ----------
|
||||
subQuery = app.ModuleClients.BundleDB.Table("bundle_order_records AS bor2").
|
||||
Select("1").
|
||||
Where("bor.customer_id = bor2.customer_id and bor2.created_at < bor.pay_time and bor2.deleted_at is null and bor.status=2 and bor.uuid != bor2.uuid")
|
||||
Where("bor.customer_id = bor2.customer_id and bor2.created_at < bor.pay_time and bor2.deleted_at is null and bor2.order_type = 1 and bor.status=2 and bor.uuid != bor2.uuid")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -140,7 +140,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Where("EXISTS (?)", subQuery).
|
||||
Where("bor.pay_time >= ?", req.Start+" 00:00:00").
|
||||
Where("bor.pay_time <= ?", req.End+" 23:59:59").
|
||||
Where("bor.deleted_at is null and bor.status=2")
|
||||
Where("bor.deleted_at is null and bor.status=2 and bor.order_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
repoQuery = repoQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -156,6 +156,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
var newIncreaseCount int64
|
||||
incQuery := app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
|
||||
Where("bor.order_type = 1").
|
||||
Where("`bundle_order_value_add`.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("`bundle_order_value_add`.created_at <= ?", req.End+" 23:59:59").
|
||||
Where("`bundle_order_value_add`.deleted_at is null and `bundle_order_value_add`.payment_status = 2 and `bundle_order_value_add`.equity_type = 2 and bor.status=2 and bor.deleted_at is null")
|
||||
@ -171,6 +172,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
subQuery = app.ModuleClients.BundleDB.Table("bundle_order_value_add AS bova2").
|
||||
Select("1").
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
|
||||
Where("bor.order_type = 1").
|
||||
Where("bova.customer_id = bova2.customer_id and bova2.created_at < bova.created_at and bova2.deleted_at is null and bova2.payment_status = 2 and bova2.equity_type = 2 and bova2.order_uuid != bova.order_uuid and bor.status=2 and bor.deleted_at is null")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
@ -178,6 +180,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
|
||||
repoQuery = app.ModuleClients.BundleDB.Table("bundle_order_value_add AS bova").
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
|
||||
Where("bor.order_type = 1").
|
||||
Where("EXISTS (?)", subQuery).
|
||||
Where("bova.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("bova.created_at <= ?", req.End+" 23:59:59").
|
||||
@ -198,7 +201,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Joins("INNER JOIN cast_work_log cwl on cwl.work_uuid = cast_work.uuid and cwl.work_status = 9").
|
||||
Where("cwe.cost_type = 1").
|
||||
Where("cwe.cost_type = 1 and cwe.billing_type = 0").
|
||||
Where("cast_work.work_category = 2").
|
||||
Where("cwl.update_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cwl.update_time <= ?", req.End+" 23:59:59").
|
||||
@ -218,7 +221,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Joins("INNER JOIN cast_work_log cwl on cwl.work_uuid = cast_work.uuid and cwl.work_status = 9").
|
||||
Where("cwe.cost_type != 1").
|
||||
Where("cwe.cost_type != 1 and cwe.billing_type = 0").
|
||||
Where("cast_work.work_category = 2").
|
||||
Where("cwl.update_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cwl.update_time <= ?", req.End+" 23:59:59").
|
||||
@ -249,7 +252,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
`).
|
||||
Joins("left join cast_work_extra as cwe on cwe.work_uuid = cw.uuid").
|
||||
Joins("LEFT JOIN cast_work_log AS cwl ON cwl.work_uuid = cw.uuid and cwl.work_status = 9").
|
||||
Where("cwl.work_status = 9").
|
||||
Where("cwl.work_status = 9 and cwe.billing_type = 0").
|
||||
Where("cwe.cost_type in ?", []int{1, 2}).
|
||||
Where("cw.work_category = ?", 2).
|
||||
Where("cw.status in ?", []int{7, 6, 9}).
|
||||
@ -274,6 +277,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join (?) as nb on bb.user_id = nb.user_id", newMonthSubQuery).
|
||||
Joins("left join (?) as ws on ws.artist_uuid COLLATE utf8mb4_general_ci = CAST(bb.user_id AS CHAR) COLLATE utf8mb4_general_ci", workStatsSubQuery).
|
||||
Where("nb.new_month = bb.month").
|
||||
Where("bor.order_type = 1").
|
||||
Where("bb.deleted_at is null").
|
||||
Where("bor.deleted_at is null")
|
||||
|
||||
@ -315,7 +319,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
SUM(CASE WHEN ccl.uuid IS NULL THEN 1 ELSE 0 END) AS un_used_video
|
||||
`).
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.work_category = 2").
|
||||
Joins("left join cast_work_extra as cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.work_category = 2 and cwe.billing_type = 0").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
@ -336,7 +341,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
query = app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("LEFT JOIN cast_work_extra cwe ON cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join bundle_order_records bor ON bor.uuid COLLATE utf8mb4_general_ci = cwe.bundle_order_uuid COLLATE utf8mb4_general_ci").
|
||||
Where("cast_work.work_category = 2").
|
||||
Where("cast_work.work_category = 2 and cwe.billing_type = 0").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
@ -353,8 +358,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid AND ccl.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.work_category = 2"). // 视频类型
|
||||
Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("cast_work.work_category = 2"). // 视频类型
|
||||
Where("cwe.cost_type = 1 and cwe.billing_type = 0"). // 套餐类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
@ -371,8 +376,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid AND cwe.deleted_at = 0").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid AND ccl.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.work_category = 2"). // 视频类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("cast_work.work_category = 2 and cwe.billing_type = 0"). // 视频类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
@ -420,7 +425,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci = cma.artist_uuid COLLATE utf8mb4_general_ci ").
|
||||
Where("cma.created_at >= ?", timeParse(req.Start+" 00:00:00").Unix()).
|
||||
Where("cma.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cma.deleted_at = 0 and bor.deleted_at is null").
|
||||
Where("cma.deleted_at = 0 and bor.deleted_at is null and bor.order_type = 1").
|
||||
Group("cma.user_id")
|
||||
|
||||
if req.BundleUuid != "" {
|
||||
@ -434,7 +439,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
query = app.ModuleClients.BundleDB.Table("cast_media_account AS cma").
|
||||
Joins("left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci = cma.artist_uuid COLLATE utf8mb4_general_ci ").
|
||||
Where("cma.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cma.deleted_at = 0 and bor.deleted_at is null")
|
||||
Where("cma.deleted_at = 0 and bor.deleted_at is null and bor.order_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -455,7 +460,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
SUM(CASE WHEN ccl.uuid IS NULL THEN 1 ELSE 0 END) AS un_used_image
|
||||
`).
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.work_category = 1").
|
||||
Joins("left join cast_work_extra as cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.work_category = 1 and cwe.billing_type = 0").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
@ -475,7 +481,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
query = app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("LEFT JOIN cast_work_extra cwe ON cwe.work_uuid = cast_work.uuid ").
|
||||
Joins("left join bundle_order_records bor ON bor.uuid COLLATE utf8mb4_general_ci = cwe.bundle_order_uuid COLLATE utf8mb4_general_ci").
|
||||
Where("cast_work.work_category = 1").
|
||||
Where("cast_work.work_category = 1 and cwe.billing_type = 0").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
@ -492,8 +498,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid AND ccl.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.work_category = 1"). // 图文类型
|
||||
Where("cwe.cost_type = 1 "). // 套餐类型
|
||||
Where("cast_work.work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cwe.cost_type = 1 "). // 套餐类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
@ -510,8 +516,8 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid AND cwe.deleted_at = 0").
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid AND ccl.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("cast_work.work_category = 1"). // 图文类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("cast_work.work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
@ -742,10 +748,10 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
//====================视频=======================
|
||||
var newUploadedBundleVideoCount int64
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
// Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 2"). // 视频类型
|
||||
Where("work_category = 2 and cwe.billing_type = 0"). // 视频类型
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
// Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("deleted_at = 0").
|
||||
@ -764,9 +770,9 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
|
||||
var totalUploadedVideoCount int64
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
// Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 2"). // 视频类型
|
||||
Where("work_category = 2 and cwe.billing_type = 0"). // 视频类型
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
// Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("deleted_at = 0").
|
||||
@ -777,8 +783,8 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 2"). // 视频类型
|
||||
Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("work_category = 2 and cwe.billing_type = 0"). // 视频类型
|
||||
Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0 and cwe.deleted_at = 0").
|
||||
@ -788,8 +794,8 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid AND cwe.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 2"). // 视频类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型或扩展类型
|
||||
Where("work_category = 2 and cwe.billing_type = 0"). // 视频类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型或扩展类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0 and cwe.deleted_at = 0").
|
||||
@ -815,10 +821,10 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
//====================图文=======================
|
||||
var newUploadedBundleImageCount int64
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
// Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time >= ?", req.Start+" 00:00:00").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 1"). // 图文类型
|
||||
Where("work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
// Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("deleted_at = 0").
|
||||
@ -837,9 +843,9 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
|
||||
var totalUploadedImageCount int64
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
// Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 1"). // 图文类型
|
||||
Where("work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.status != 8").
|
||||
// Where("cwe.cost_type = 2"). // 套餐类型
|
||||
@ -851,8 +857,8 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 1"). // 图文类型
|
||||
Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cwe.cost_type = 1"). // 套餐类型
|
||||
Where("cast_work.status != 8").
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0 and cwe.deleted_at = 0").
|
||||
@ -862,8 +868,8 @@ func MetricsOperatingCreate(req *bundle.MetricsOperatingCreateReq) (result *bund
|
||||
app.ModuleClients.BundleDB.Model(&model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid AND cwe.deleted_at = 0").
|
||||
Where("cast_work.submit_time <= ?", req.End+" 23:59:59").
|
||||
Where("work_category = 1"). // 图文类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("work_category = 1 and cwe.billing_type = 0"). // 图文类型
|
||||
Where("cwe.cost_type in ?", []int{2, 3}). // 增值类型
|
||||
Where("cast_work.origin_uuid = ''").
|
||||
Where("cast_work.deleted_at = 0 and cwe.deleted_at = 0").
|
||||
Count(&totalUploadedIncreaseImageCount)
|
||||
@ -1041,7 +1047,8 @@ func balanceInfoWithShop(startMonth string, endMonth string, startTime string, e
|
||||
WHERE deleted_at IS NULL
|
||||
GROUP BY order_uuid
|
||||
) AS bb_min ON bb.order_uuid = bb_min.order_uuid AND bb.created_at = bb_min.min_created_at`).
|
||||
Where("bor.deleted_at is null and bor.status=2").
|
||||
Where("bor.deleted_at is null").
|
||||
Where("(bor.order_mode = 1 and bor.status=2) OR (bor.order_mode = 2)").
|
||||
Where("bb.month = DATE_FORMAT(bb.start_at, '%Y-%m')").
|
||||
Where("bor.order_type = ?", model.BundleTypeBasic).
|
||||
Where("bb.deleted_at IS NULL")
|
||||
@ -1103,7 +1110,9 @@ func IncreasealanceInfoWithShop(startMonth string, endMonth string, startTime st
|
||||
WHERE deleted_at IS NULL
|
||||
GROUP BY order_uuid
|
||||
) AS bb_min ON bb.order_uuid = bb_min.order_uuid AND bb.created_at = bb_min.min_created_at`).
|
||||
Where("bor.deleted_at is null and bor.status=2").
|
||||
Where("bor.deleted_at is null").
|
||||
Where("bor.order_type = ?", model.BundleTypeBasic).
|
||||
Where("(bor.order_mode = 1 and bor.status=2) OR (bor.order_mode = 2)").
|
||||
Where("bb.month = DATE_FORMAT(bb.start_at, '%Y-%m')").
|
||||
Where("bb.deleted_at IS NULL")
|
||||
if bundleUUID != "" {
|
||||
@ -1316,7 +1325,10 @@ func getIncreaseBalanceInfo(month string, bundleUUID string, endTime string) (da
|
||||
func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle.MetricsOperatingStatusResp, err error) {
|
||||
data = &bundle.MetricsOperatingStatusResp{}
|
||||
var statistic = func(status int8, workCategory int8) (i int64) {
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).Where(model.CastWork{Status: status, WorkCategory: workCategory}).Where("deleted_at = 0 and submit_time <= ?", req.Date+" 23:59:59").Count(&i)
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).Where(model.CastWork{Status: status, WorkCategory: workCategory}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cwe.billing_type = 0"). // 只统计套餐类型的作品
|
||||
Where("deleted_at = 0 and submit_time <= ?", req.Date+" 23:59:59").Count(&i)
|
||||
return
|
||||
}
|
||||
//视频
|
||||
@ -1333,10 +1345,12 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
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").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cw.billing_type = 0"). // 只统计套餐类型的作品
|
||||
Where("cwe.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("cw.billing_type = 0"). // 只统计套餐类型的作品
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 2 and cwe.confirm_type = 2").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
@ -1354,12 +1368,14 @@ func MetricsOperatingStatus(req *bundle.MetricsOperatingStatusReq) (data *bundle
|
||||
|
||||
app.ModuleClients.BundleDB.Model(model.CastWork{}).
|
||||
Joins("left join cast_work_extra cwe on cwe.work_uuid = cast_work.uuid").
|
||||
Where("cw.billing_type = 0"). // 只统计套餐类型的作品
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 1 and cwe.confirm_type = 1").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.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("cw.billing_type = 0"). // 只统计套餐类型的作品
|
||||
Where("cast_work.status in (9,6) and cast_work.work_category = 1 and cwe.confirm_type = 2").
|
||||
Where("cast_work.submit_time <= ?", req.Date+" 23:59:59").
|
||||
Where("cwe.deleted_at = 0 and cast_work.deleted_at = 0").
|
||||
@ -1462,7 +1478,7 @@ func MetricsBundlePurchaseExport(req *bundle.MetricsBundlePurchaseExportReq) (*b
|
||||
where a1.deleted_at is null and a1.status = 2 and a1.total_amount > 300 and a2.deleted_at is null
|
||||
group by a1.order_no
|
||||
) t4 on t1.order_no = t4.order_no
|
||||
where t1.deleted_at is null and t1.status = 2 and t1.total_amount > 300 and t1.order_type = 1
|
||||
where t1.deleted_at is null and t1.status = 2 and t1.total_amount > 300 and t1.order_type = 1 and t1.order_type = 1
|
||||
order by t2.sub_num asc`,
|
||||
"`micro-account`.`user`",
|
||||
"`micro-account`.`real_name`")
|
||||
@ -1568,6 +1584,7 @@ func MetricsArtistAccountExport(req *bundle.MetricsArtistAccountExportReq) (*bun
|
||||
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.order_type = ?", model.BundleTypeBasic).
|
||||
Where("bor.deleted_at is null")
|
||||
err = query.Find(&data.Data).Error
|
||||
if err != nil {
|
||||
@ -1591,6 +1608,7 @@ func MetricsVideoSubmitExport(req *bundle.MetricsVideoSubmitExportReq) (result *
|
||||
Joins("left join (select created_at,work_uuid from cast_work_platform_info cwi where cwi.platform_id = 4) dm on dm.work_uuid = cw.uuid").
|
||||
Joins("left join (select created_at,work_uuid from cast_work_platform_info cwi where cwi.platform_id = 3) ins on ins.work_uuid = cw.uuid").
|
||||
Joins("left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci = cw.artist_uuid COLLATE utf8mb4_general_ci").
|
||||
Where("bor.order_type = ?", model.BundleTypeBasic).
|
||||
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 {
|
||||
@ -1648,6 +1666,7 @@ func MetricsVideoSubmitExport(req *bundle.MetricsVideoSubmitExportReq) (result *
|
||||
}
|
||||
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)`).
|
||||
Where("bor.order_type = ?", model.BundleTypeBasic).
|
||||
Order("cw.artist_name")
|
||||
}
|
||||
err = query.Find(&result.Data).Error
|
||||
@ -1698,6 +1717,7 @@ func getMonthlyRelease(month string, bundleUuid string) (bundleBalanceInfo Balan
|
||||
query := app.ModuleClients.BundleDB.Table("bundle_balance as bb").
|
||||
Joins("left join bundle_order_records bor on bor.uuid = bb.order_uuid").
|
||||
Where("bb.`month` = ?", datetime.AddMonth(t, -1).Format("2006-01")).
|
||||
Where("bor.order_type = ?", model.BundleTypeBasic).
|
||||
Where("bor.deleted_at is null and bb.deleted_at is null")
|
||||
if bundleUuid != "" {
|
||||
query = query.Where("bor.bundle_uuid = ?", bundleUuid)
|
||||
@ -1759,6 +1779,7 @@ func qua(data model.BundleBalance, total, limit int, date time.Time) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// 临时接口,不在正逻辑中使用
|
||||
func ExportWorkCastInfo(req *bundle.ExportWorkCastInfoReq) (*bundle.ExportWorkCastInfoResp, error) {
|
||||
result := &bundle.ExportWorkCastInfoResp{}
|
||||
query := app.ModuleClients.BundleDB.Raw(`
|
||||
@ -1792,6 +1813,7 @@ func ExportWorkCastInfo(req *bundle.ExportWorkCastInfoReq) (*bundle.ExportWorkCa
|
||||
WHERE bb.deleted_at IS NULL
|
||||
AND bb.month = '2026-01'
|
||||
AND bor.deleted_at IS NULL
|
||||
AND bor.order_type = 1
|
||||
AND cw.title IS NOT NULL
|
||||
AND cw.submit_time < ?
|
||||
AND cw.submit_time > ?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user