用户统计
This commit is contained in:
@@ -2,7 +2,6 @@ package localjx
|
||||
|
||||
import (
|
||||
"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/jx-callback/business/jxutils"
|
||||
@@ -13,37 +12,45 @@ import (
|
||||
|
||||
type GetJxShopUsersResult struct {
|
||||
model.User
|
||||
BuyCount int `json:"buyCount"`
|
||||
ActualPayPrice int `json:"actualPayPrice"`
|
||||
BuyCount int `json:"buyCount"`
|
||||
ActualPayPrice int `json:"actualPayPrice"`
|
||||
// VendorUserID int `orm:"column(vendor_user_id)" json:"vendorUserID"`
|
||||
GoodCommentCount int `json:"goodCommentCount"`
|
||||
BadCommentCount int `json:"badCommentCount"`
|
||||
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 (
|
||||
requestList []*GetJxShopUsersResult
|
||||
db = dao.GetDB()
|
||||
fromTimeP = utils.Str2Time(fromTime)
|
||||
toTimeP = utils.Str2Time(toTime)
|
||||
sqlParams = []interface{}{}
|
||||
)
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, b.buy_count, b.actual_pay_price
|
||||
FROM user a,
|
||||
(SELECT a.user_id, COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price
|
||||
FROM user a
|
||||
JOIN auth_bind b ON b.user_id = a.user_id AND b.deleted_at = ? AND b.type_id = ?
|
||||
JOIN goods_order c ON c.user_id = a.user_id AND c.status <> ? AND c.store_id <> ?
|
||||
WHERE a.deleted_at = ?
|
||||
GROUP BY 1) b
|
||||
WHERE a.user_id = b.user_id
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue, api.WeixinMiniAppID2,
|
||||
model.OrderStatusCanceled, model.MatterStoreID,
|
||||
utils.DefaultTimeValue,
|
||||
sql := `
|
||||
SELECT a.*, b.name, b.created_at, b.last_login_at
|
||||
FROM (
|
||||
SELECT c.vendor_user_id, IF(c.consignee_mobile2 <> '',c.consignee_mobile2,c.consignee_mobile) mobile,
|
||||
c.vendor_id,COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price, COUNT(d.score > 3) good_comment_count,
|
||||
COUNT(d.score < 3) bad_comment_count
|
||||
FROM goods_order c
|
||||
LEFT JOIN jx_bad_comments d ON d.order_id = c.vendor_order_id
|
||||
`
|
||||
if fromTimeP != utils.ZeroTimeValue && toTimeP != utils.ZeroTimeValue {
|
||||
sql += ` WHERE c.order_created_at >= ? AND c.order_created_at <= ?`
|
||||
sqlParams = append(sqlParams, fromTimeP, toTimeP)
|
||||
}
|
||||
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 != "" {
|
||||
sql += " AND (a.user_id LIKE ? OR a.name LIKE ? OR a.mobile LIKE ? OR a.user_id2 LIKE ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
||||
sql += " AND (a.user_id LIKE ? OR b.name LIKE ? OR a.mobile LIKE ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
sql += "LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
|
||||
@@ -539,6 +539,9 @@ func (c *User2Controller) GetUserAgreement() {
|
||||
// @Description 查询京西商城用户信息
|
||||
// @Param token header string true "认证token"
|
||||
// @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 pageSize query int false "结果页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -546,7 +549,10 @@ func (c *User2Controller) GetUserAgreement() {
|
||||
// @router /GetJxShopUsers [get]
|
||||
func (c *User2Controller) GetJxShopUsers() {
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user