Compare commits

..

No commits in common. "4ee25c05bf1e5ce73681015a99d1da56f45e5d6f" and "b1a047f67fbcd4e28ea960fed08e82c79f896da5" have entirely different histories.

View File

@ -85,15 +85,17 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
result.NewBundleCount = newBundleCount
// ---------- 重复购买套餐数 ----------
subQuery = app.ModuleClients.BundleDB.Table("bundle_order_records AS bor2").
Select("1").
Where("bor.customer_id = bor2.customer_id and bor2.created_at < bor.created_at and bor2.deleted_at is null and bor.pay_time != ''")
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)
}
repoQuery := app.ModuleClients.BundleDB.Table("bundle_order_records AS bor").
Where("EXISTS (?)", subQuery).
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 != ''")
@ -129,17 +131,10 @@ func MetricsBusiness(req *bundle.MetricsBusinessReq) (result *bundle.MetricsBusi
Where("created_at <= ?", req.Start+" 00:00:00").
Where("deleted_at is null").
Group("customer_id")
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("bova.customer_id = bova2.customer_id and bova2.created_at < bova.created_at and bova2.deleted_at is null and bova2.payment_status = 2")
if req.BundleUuid != "" {
subQuery = subQuery.Where("bundle_uuid = ?", req.BundleUuid)
}
repoQuery = app.ModuleClients.BundleDB.Table("bundle_order_value_add AS bova").
Joins("INNER JOIN (?) AS bova1 ON bova1.customer_id = bova.customer_id", subQuery).
Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = order_uuid").
Where("EXISTS (?)", subQuery).
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")