Compare commits
No commits in common. "1106a19dafeeb44f615543cd67baa88697272433" and "7beeb39d9002cc63c9c3c1450869fd7105a6509a" have entirely different histories.
1106a19daf
...
7beeb39d90
@ -17,8 +17,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
// ---------- 总金额统计 ----------
|
||||
subQuery := app.ModuleClients.BundleDB.Model(&model.Reconciliation{}).
|
||||
Select("SUM(handling_fee)").
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no = bundle_order_on").
|
||||
Where("bor.deleted_at is null and bor.pay_time != ''")
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no = bundle_order_on")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -29,7 +28,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
(SUM(total_amount) - SUM(amount)) as total_increase_payment_amount,
|
||||
(?) as total_fee_payment_amount
|
||||
`, subQuery).
|
||||
Where("deleted_at IS NULL and pay_time != ''")
|
||||
Where("deleted_at IS NULL")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -44,8 +43,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Select("SUM(handling_fee)").
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.order_no = bundle_order_on").
|
||||
Where("`reconciliation`.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("`reconciliation`.created_at <= ?", req.End+" 23:59:59").
|
||||
Where("`reconciliation`.deleted_at is null and bor.pay_time != ''")
|
||||
Where("`reconciliation`.created_at <= ?", req.End+" 23:59:59")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -58,8 +56,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
(?) as new_fee_payment_amount
|
||||
`, subQuery).
|
||||
Where("`bundle_order_records`.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("`bundle_order_records`.created_at <= ?", req.End+" 23:59:59").
|
||||
Where("`bundle_order_records`.deleted_at is null and bundle_order_records.pay_time != ''")
|
||||
Where("`bundle_order_records`.created_at <= ?", req.End+" 23:59:59")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -74,8 +71,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
var newBundleCount int64
|
||||
countQuery := app.ModuleClients.BundleDB.Model(&model.BundleOrderRecords{}).
|
||||
Where("created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("created_at <= ?", req.End+" 23:59:59").
|
||||
Where("deleted_at is null")
|
||||
Where("created_at <= ?", req.End+" 23:59:59")
|
||||
if req.BundleUuid != "" {
|
||||
countQuery = countQuery.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -88,7 +84,6 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
subQuery = app.ModuleClients.BundleDB.Model(&model.BundleOrderRecords{}).
|
||||
Select("customer_id").
|
||||
Where("created_at <= ?", req.Start+" 00:00:00").
|
||||
Where("deleted_at is null").
|
||||
Group("customer_id")
|
||||
if req.BundleUuid != "" {
|
||||
subQuery = subQuery.Where("bundle_uuid = ?", req.BundleUuid)
|
||||
@ -97,8 +92,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
repoQuery := app.ModuleClients.BundleDB.Table("bundle_order_records AS bor").
|
||||
Joins("INNER JOIN (?) AS bor1 ON bor1.customer_id = bor.customer_id", subQuery).
|
||||
Where("bor.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("bor.created_at <= ?", req.End+" 23:59:59").
|
||||
Where("bor.deleted_at is null and bor.pay_time != ''")
|
||||
Where("bor.created_at <= ?", req.End+" 23:59:59")
|
||||
if req.BundleUuid != "" {
|
||||
repoQuery = repoQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -115,8 +109,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
incQuery := app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
|
||||
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")
|
||||
Where("`bundle_order_value_add`.created_at <= ?", req.End+" 23:59:59")
|
||||
if req.BundleUuid != "" {
|
||||
incQuery = incQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -137,7 +130,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
|
||||
Where("bova.created_at >= ?", req.Start+" 00:00:00").
|
||||
Where("bova.created_at <= ?", req.End+" 23:59:59").
|
||||
Where("bova.deleted_at is null and bova.payment_status = 2")
|
||||
Where("bova.deleted_at is null")
|
||||
if req.BundleUuid != "" {
|
||||
repoQuery = repoQuery.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -154,8 +147,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").
|
||||
Where("cast_work.status = 9").
|
||||
Where("cwe.cost_type = 1").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
Where("cwe.cost_type = 1")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("ccl.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -170,8 +162,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").
|
||||
Where("cast_work.status = 9").
|
||||
Where("cwe.cost_type != 1").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
Where("cwe.cost_type != 1")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("ccl.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -192,7 +183,6 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Where("cw.created_at >= ?", timeParse(req.Start+" 00:00:00").Unix()).
|
||||
Where("cw.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cwe.cost_type = ?", 1).
|
||||
Where("cw.deleted_at = 0").
|
||||
Group("cw.artist_uuid")
|
||||
|
||||
if req.BundleUuid != "" {
|
||||
@ -210,8 +200,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid COLLATE utf8mb4_general_ci").
|
||||
Joins("LEFT JOIN (?) wn ON wn.artist_uuid = bor.customer_id COLLATE utf8mb4_general_ci", subWorkCount).
|
||||
Joins("left join (select max(bb.`month`) as new_month , user_id from bundle_balance bb group by bb.user_id) nb on bb.user_id = nb.user_id").
|
||||
Where("nb.new_month = bb.`month`").
|
||||
Where("bb.deleted_at is null and bor.deleted_at is null")
|
||||
Where("nb.new_month = bb.`month`")
|
||||
err = app.ModuleClients.BundleDB.
|
||||
Table("(?) as statistic", subStatistic).
|
||||
Select("COALESCE(SUM(statistic.bundle_add_price), 0)").
|
||||
@ -231,7 +220,6 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Where("cw.created_at >= ?", timeParse(req.Start+" 00:00:00").Unix()).
|
||||
Where("cw.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cwe.cost_type != ?", 1).
|
||||
Where("cw.deleted_at = 0").
|
||||
Group("cw.artist_uuid")
|
||||
|
||||
if req.BundleUuid != "" {
|
||||
@ -249,8 +237,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid COLLATE utf8mb4_general_ci").
|
||||
Joins("LEFT JOIN (?) wn ON wn.artist_uuid = bor.customer_id COLLATE utf8mb4_general_ci", subWorkCount).
|
||||
Joins("left join (select max(bb.`month`) as new_month , user_id from bundle_balance bb group by bb.user_id) nb on bb.user_id = nb.user_id").
|
||||
Where("nb.new_month = bb.`month`").
|
||||
Where("bb.deleted_at is null and bor.deleted_at is null")
|
||||
Where("nb.new_month = bb.`month`")
|
||||
err = app.ModuleClients.BundleDB.
|
||||
Table("(?) as statistic", subStatistic).
|
||||
Select("COALESCE(SUM(statistic.bundle_add_price), 0)").
|
||||
@ -278,8 +265,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Where("cwe.cost_type != 1").
|
||||
Where("cast_work.work_category = 2").
|
||||
Where("cast_work.created_at >= ?", timeParse(req.Start+" 00:00:00").Unix()).
|
||||
Where("cast_work.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cast_work.deleted_at = 0")
|
||||
Where("cast_work.created_at <= ?", timeParse(req.End+" 23:59:59").Unix())
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("ccl.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -292,8 +278,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
Joins("left join cast_cost_log ccl on ccl.work_uuid = cast_work.uuid").
|
||||
// Where("cast_work.status = 9").
|
||||
Where("cwe.cost_type != 1").
|
||||
Where("cast_work.work_category = 2").
|
||||
Where("cast_work.deleted_at = 0")
|
||||
Where("cast_work.work_category = 2")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("ccl.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -305,8 +290,7 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
|
||||
var totalAccountUsed int64
|
||||
var newAccountUsed int64
|
||||
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.deleted_at is null")
|
||||
Joins("left join bundle_order_records bor on bor.customer_id COLLATE utf8mb4_general_ci = cma.artist_uuid COLLATE utf8mb4_general_ci")
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -317,8 +301,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.Start+" 00:00:00").Unix()).
|
||||
Where("cma.created_at <= ?", timeParse(req.End+" 23:59:59").Unix()).
|
||||
Where("cma.deleted_at is null")
|
||||
Where("cma.created_at <= ?", timeParse(req.End+" 23:59:59").Unix())
|
||||
if req.BundleUuid != "" {
|
||||
query = query.Where("bor.bundle_uuid = ?", req.BundleUuid)
|
||||
}
|
||||
@ -602,7 +585,7 @@ left join(
|
||||
) fee on
|
||||
fee.bundle_order_on = bor.order_no
|
||||
where
|
||||
bor.deleted_at is null and bor.pay_time != ''
|
||||
bor.deleted_at is null
|
||||
`
|
||||
if req.Month != "" {
|
||||
t, err := time.Parse("2006-01", req.Month)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user