parent
8f5e5c782a
commit
720ea2640e
@ -0,0 +1,36 @@
|
||||
package jyy
|
||||
|
||||
import (
|
||||
"recook/internal/back"
|
||||
"recook/internal/libs/bean"
|
||||
"recook/internal/v2/logic/manage/jyy"
|
||||
"recook/tools"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (o Proxy) VipList(c *gin.Context) {
|
||||
var args jyy.ArgsVipList
|
||||
if err := tools.Params(&args, c); err != nil {
|
||||
back.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
data, total := jyy.Logic.VipList(args)
|
||||
back.Suc(c, "ok", bean.ResultLists{
|
||||
Total: int(total),
|
||||
List: data,
|
||||
})
|
||||
}
|
||||
|
||||
func (o Proxy) VipSummay(c *gin.Context) {
|
||||
var args jyy.VipSummary
|
||||
if err := tools.Params(&args, c); err != nil {
|
||||
back.Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
data, total := jyy.Logic.VipSummay(args)
|
||||
back.Suc(c, "ok", bean.ResultLists{
|
||||
Total: int(total),
|
||||
List: data,
|
||||
})
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
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 != 0 {
|
||||
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")
|
||||
query.Count(&total)
|
||||
query.Limit(args.GetLimit()).Offset(args.GetStart()).Find(&data)
|
||||
return
|
||||
}
|
Loading…
Reference in new issue