You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.6 KiB
95 lines
2.6 KiB
package jyy
|
|
|
|
import (
|
|
"fmt"
|
|
"recook/internal/libs/bean"
|
|
"recook/internal/model/user"
|
|
"time"
|
|
|
|
"git.oa00.com/go/mysql"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type ArgsVipList struct {
|
|
bean.Page
|
|
Mobile string `json:"mobile"`
|
|
Level *int `json:"level"`
|
|
Kind int `json:"kind"`
|
|
Start *time.Time `json:"start"`
|
|
End *time.Time `json:"end"`
|
|
ExpireStart *time.Time `json:"expire_start"`
|
|
ExpireEnd *time.Time `json:"expire_end"`
|
|
NickName string `json:"nickname"`
|
|
ShareID int `json:"share_id"`
|
|
}
|
|
|
|
func (o logic) VipList(args ArgsVipList) (data []user.VipHistory, total int64) {
|
|
query := mysql.Db.Model(&user.VipHistory{})
|
|
{
|
|
if args.Mobile != "" {
|
|
query = query.Where("mobile=?", args.Mobile)
|
|
}
|
|
if args.Level != nil {
|
|
query = query.Where("level = ?", args.Level)
|
|
}
|
|
if args.Kind != 0 {
|
|
query = query.Where("kind = ?", args.Kind)
|
|
}
|
|
if args.Start != nil {
|
|
query = query.Where("start > ?", args.Start)
|
|
}
|
|
if args.End != nil {
|
|
query = query.Where("start < ?", args.End)
|
|
}
|
|
if args.ExpireStart != nil {
|
|
query = query.Where("end > ?", args.ExpireStart)
|
|
}
|
|
if args.ExpireEnd != nil {
|
|
query = query.Where("end < ?", args.ExpireEnd)
|
|
}
|
|
if args.NickName != "" {
|
|
query = query.Where("nickname like ?", fmt.Sprintf("%%%s%%", args.NickName))
|
|
}
|
|
if args.ShareID != 0 {
|
|
query = query.Where("share_id = ?", args.ShareID)
|
|
}
|
|
}
|
|
query.Count(&total)
|
|
query.Limit(args.GetLimit()).Offset(args.GetStart()).Find(&data)
|
|
return
|
|
}
|
|
|
|
type VipSummary struct {
|
|
bean.Page
|
|
Mobile string `json:"mobile"`
|
|
NickName string `json:"nickName"`
|
|
}
|
|
|
|
type Summary struct {
|
|
UserID int `json:"user_id"`
|
|
Mobile string `json:"mobile"`
|
|
NickName string `json:"name"`
|
|
Count int `json:"count"`
|
|
Amount decimal.Decimal `json:"amount"`
|
|
}
|
|
|
|
func (o logic) VipSummay(args VipSummary) (data []Summary, total int64) {
|
|
query := mysql.Db.Table("recook_order_info as a").
|
|
Select("a.sharer_id as user_id, SUM(a.actual_total_amount) as amount, count(1) as count, b.nickname, b.mobile").
|
|
Where("a.sharer_id <> a.user_id").
|
|
Where("a.is_split = 1").
|
|
Where("a.jcook_order_id = 0").
|
|
Where("a.shama_order_id = 0").
|
|
Group("a.sharer_id").
|
|
Joins("JOIN recook_user_info as b on b.id = a.sharer_id")
|
|
if args.NickName != "" {
|
|
query = query.Where("b.nickname like ?", fmt.Sprintf("%%%s%%", args.NickName))
|
|
}
|
|
if args.NickName != "" {
|
|
query = query.Where("b.mobile = ?", args.Mobile)
|
|
}
|
|
query.Count(&total)
|
|
query.Limit(args.GetLimit()).Offset(args.GetStart()).Find(&data)
|
|
return
|
|
}
|