This commit is contained in:
邹宗楠
2025-12-22 17:40:50 +08:00
parent 1ad75133e5
commit 37d7e9edd8
8 changed files with 61610 additions and 61255 deletions

View File

@@ -566,6 +566,64 @@ func (c *OrderController) StaleIndexInfo() {
})
}
// @Title 门店订单排行统计
// @Description 门店订单排行统计
// @Param token header string true "认证token"
// @Param start query string true "起始时间"
// @Param end query string true "结束时间"
// @Param storeID query string false "门店id,[1,2,3]"
// @Param rank query string true "排序方式,订单中粮,[DESC,ASC]"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /StoreOrderRank [get]
func (c *OrderController) StoreOrderRank() {
c.callStoreOrderRank(func(params *tOrderStoreOrderRankParams) (retVal interface{}, code string, err error) {
var (
storeList []*dao.StoreWithCityName
dataList = make([]int, 0, len(storeList))
mapDataList = make(map[int]int, len(storeList))
)
timeList, err := jxutils.BatchStr2Time(params.Start, params.End)
if err != nil {
return nil, "", err
}
var storeIdList []int
if err = jxutils.Strings2Objs(params.StoreID, &storeIdList); err == nil {
return nil, "", err
}
ctx := params.Ctx
if !auth2.IsV2Token(ctx.GetToken()) {
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
}
mobile, userID := ctx.GetMobileAndUserID()
if mobile == "" || userID == "" || userID == "null" || userID == "NULL" {
return nil, "", fmt.Errorf("不能得到用户手机号,%s,%s", userID, mobile)
}
if permission.IsRoled(ctx) {
if storeList, err = cms.GetStoreList4User(ctx, mobile, userID); err == nil && len(storeList) > 0 {
for _, v := range storeList {
dataList = append(dataList, v.Store.ID)
mapDataList[v.Store.ID] = model.YES
}
}
if len(storeIdList) != model.NO {
for _, sl := range storeIdList {
if mapDataList[sl] != model.YES {
return retVal, "", fmt.Errorf("此门店%d,不归属于该用户%s", sl, ctx.GetUserName())
}
}
}
}
if len(storeIdList) == model.NO {
storeIdList = dataList
}
retVal, err = dao.StaticStoreOrderChange(dao.GetDB(), storeIdList, timeList[0], timeList[1], params.Rank)
return retVal, "", err
})
}
// @Title 刷新订单真实手机号
// @Description 刷新订单真实手机号
// @Param token header string true "认证token"