用户统计
This commit is contained in:
@@ -2,7 +2,6 @@ package localjx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
@@ -13,37 +12,45 @@ import (
|
|||||||
|
|
||||||
type GetJxShopUsersResult struct {
|
type GetJxShopUsersResult struct {
|
||||||
model.User
|
model.User
|
||||||
BuyCount int `json:"buyCount"`
|
BuyCount int `json:"buyCount"`
|
||||||
ActualPayPrice int `json:"actualPayPrice"`
|
ActualPayPrice int `json:"actualPayPrice"`
|
||||||
|
// VendorUserID int `orm:"column(vendor_user_id)" json:"vendorUserID"`
|
||||||
GoodCommentCount int `json:"goodCommentCount"`
|
GoodCommentCount int `json:"goodCommentCount"`
|
||||||
BadCommentCount int `json:"badCommentCount"`
|
BadCommentCount int `json:"badCommentCount"`
|
||||||
UserMembers []*model.UserMember `json:"userMembers"`
|
UserMembers []*model.UserMember `json:"userMembers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetJxShopUsers(ctx *jxcontext.Context, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
func GetJxShopUsers(ctx *jxcontext.Context, keyword, fromTime, toTime string, vendorIDs []int, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
var (
|
var (
|
||||||
requestList []*GetJxShopUsersResult
|
requestList []*GetJxShopUsersResult
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
|
fromTimeP = utils.Str2Time(fromTime)
|
||||||
|
toTimeP = utils.Str2Time(toTime)
|
||||||
|
sqlParams = []interface{}{}
|
||||||
)
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, b.buy_count, b.actual_pay_price
|
SELECT a.*, b.name, b.created_at, b.last_login_at
|
||||||
FROM user a,
|
FROM (
|
||||||
(SELECT a.user_id, COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price
|
SELECT c.vendor_user_id, IF(c.consignee_mobile2 <> '',c.consignee_mobile2,c.consignee_mobile) mobile,
|
||||||
FROM user a
|
c.vendor_id,COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price, COUNT(d.score > 3) good_comment_count,
|
||||||
JOIN auth_bind b ON b.user_id = a.user_id AND b.deleted_at = ? AND b.type_id = ?
|
COUNT(d.score < 3) bad_comment_count
|
||||||
JOIN goods_order c ON c.user_id = a.user_id AND c.status <> ? AND c.store_id <> ?
|
FROM goods_order c
|
||||||
WHERE a.deleted_at = ?
|
LEFT JOIN jx_bad_comments d ON d.order_id = c.vendor_order_id
|
||||||
GROUP BY 1) b
|
`
|
||||||
WHERE a.user_id = b.user_id
|
if fromTimeP != utils.ZeroTimeValue && toTimeP != utils.ZeroTimeValue {
|
||||||
`
|
sql += ` WHERE c.order_created_at >= ? AND c.order_created_at <= ?`
|
||||||
sqlParams := []interface{}{
|
sqlParams = append(sqlParams, fromTimeP, toTimeP)
|
||||||
utils.DefaultTimeValue, api.WeixinMiniAppID2,
|
|
||||||
model.OrderStatusCanceled, model.MatterStoreID,
|
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
}
|
||||||
|
sql += `
|
||||||
|
AND c.status <> ?
|
||||||
|
GROUP BY 1,2,3)a
|
||||||
|
LEFT JOIN user b ON b.user_id = a.vendor_user_id
|
||||||
|
WHERE (b.deleted_at = ? OR b.deleted_at is null)
|
||||||
|
`
|
||||||
|
sqlParams = append(sqlParams, model.OrderStatusCanceled, utils.DefaultTimeValue)
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
sql += " AND (a.user_id LIKE ? OR a.name LIKE ? OR a.mobile LIKE ? OR a.user_id2 LIKE ?)"
|
sql += " AND (a.user_id LIKE ? OR b.name LIKE ? OR a.mobile LIKE ?)"
|
||||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
||||||
}
|
}
|
||||||
sql += "LIMIT ? OFFSET ?"
|
sql += "LIMIT ? OFFSET ?"
|
||||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||||
|
|||||||
@@ -539,6 +539,9 @@ func (c *User2Controller) GetUserAgreement() {
|
|||||||
// @Description 查询京西商城用户信息
|
// @Description 查询京西商城用户信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param keyword query string false "关键字"
|
// @Param keyword query string false "关键字"
|
||||||
|
// @Param fromTime query string false "开始时间"
|
||||||
|
// @Param toTime query string false "结束时间"
|
||||||
|
// @Param vendorIDs query string false "平台号"
|
||||||
// @Param offset query int false "结果起始序号(以0开始,缺省为0)"
|
// @Param offset query int false "结果起始序号(以0开始,缺省为0)"
|
||||||
// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)"
|
// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -546,7 +549,10 @@ func (c *User2Controller) GetUserAgreement() {
|
|||||||
// @router /GetJxShopUsers [get]
|
// @router /GetJxShopUsers [get]
|
||||||
func (c *User2Controller) GetJxShopUsers() {
|
func (c *User2Controller) GetJxShopUsers() {
|
||||||
c.callGetJxShopUsers(func(params *tUser2GetJxShopUsersParams) (retVal interface{}, errCode string, err error) {
|
c.callGetJxShopUsers(func(params *tUser2GetJxShopUsersParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = localjx.GetJxShopUsers(params.Ctx, params.Keyword, params.Offset, params.PageSize)
|
var vendorIDs []int
|
||||||
|
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs); err == nil {
|
||||||
|
retVal, err = localjx.GetJxShopUsers(params.Ctx, params.Keyword, params.FromTime, params.ToTime, vendorIDs, params.Offset, params.PageSize)
|
||||||
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user