Merge branch 'dev-lzh' into dev
This commit is contained in:
commit
f4841ed772
@ -99,25 +99,22 @@ func GetBundleExtendRecordList(req *bundle.BundleExtendRecordsListRequest) (data
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.BundleBalancePo, total int64, err error) {
|
func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.BundleBalancePo, total int64, err error) {
|
||||||
subQuery := app.ModuleClients.BundleDB.Table("bundle_order_records").
|
subQuery := app.ModuleClients.BundleDB.Table("bundle_order_records as bor1").
|
||||||
Select("customer_id, MAX(created_at) AS max_created_time").
|
Select("bor1.*").
|
||||||
Group("customer_id")
|
Joins(`INNER JOIN (
|
||||||
|
SELECT customer_id, MAX(created_at) AS max_created_time
|
||||||
|
FROM bundle_order_records
|
||||||
|
GROUP BY customer_id
|
||||||
|
) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`)
|
||||||
session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").
|
session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").
|
||||||
Select(`
|
Select(`bb.*, bor.expiration_time as expired_time, bor.bundle_name, bor.status,
|
||||||
bb.*,
|
bor.uuid as order_uuid, rn.name as user_name,
|
||||||
bor.expiration_time as expired_time,
|
u.tel_num as user_phone_number, u.id as user_id`).
|
||||||
bor.bundle_name,
|
Joins("LEFT JOIN `micro-account`.real_name rn ON u.real_name_id = rn.id").
|
||||||
bor.status,
|
Joins("LEFT JOIN (?) as bor ON bor.customer_id = u.id", subQuery).
|
||||||
bor.uuid as order_uuid,
|
Joins("LEFT JOIN fiee_bundle.bundle_balance bb ON u.id = bb.user_id AND bb.order_uuid = bor.uuid").
|
||||||
rn.name as user_name,
|
Where("rn.name IS NOT NULL").
|
||||||
u.tel_num as user_phone_number,
|
Where("u.deleted_at = 0")
|
||||||
u.id as user_id
|
|
||||||
`).
|
|
||||||
Joins("LEFT JOIN fiee_bundle.bundle_balance AS bb on u.id = bb.user_id").
|
|
||||||
Joins("LEFT JOIN `micro-account`.`real_name` rn on u.real_name_id = rn.id").
|
|
||||||
Joins("LEFT JOIN bundle_order_records bor on bor.uuid = bb.order_uuid").
|
|
||||||
Joins("LEFT JOIN (?) AS t ON bor.customer_id = t.customer_id AND bor.created_at = t.max_created_time", subQuery).
|
|
||||||
Where("rn.name IS NOT NULL and u.deleted_at = 0").Group("u.id")
|
|
||||||
if req.UserName != "" {
|
if req.UserName != "" {
|
||||||
if utils.IsPhoneNumber(req.UserName) {
|
if utils.IsPhoneNumber(req.UserName) {
|
||||||
session = session.Where("u.tel_num = ?", req.UserName)
|
session = session.Where("u.tel_num = ?", req.UserName)
|
||||||
|
Loading…
Reference in New Issue
Block a user