门店促销指数
This commit is contained in:
@@ -2548,13 +2548,13 @@ func StoreStatus2Chinese(status int) (str string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toScore, sort int, snapDate string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs, vendorIDs []int, fromScore, toScore, sort, directSort, secKillSort int, snapDate string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var snapDateParam time.Time
|
||||
db := dao.GetDB()
|
||||
if snapDate != "" {
|
||||
snapDateParam = utils.Str2Time(snapDate)
|
||||
}
|
||||
storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, fromScore, toScore, sort, snapDateParam, offset, pageSize)
|
||||
storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, vendorIDs, fromScore, toScore, sort, directSort, secKillSort, snapDateParam, offset, pageSize)
|
||||
pagedInfo = &model.PagedInfo{
|
||||
Data: storePriceScore,
|
||||
TotalCount: totalCount,
|
||||
|
||||
@@ -63,10 +63,12 @@ type CityBrankBranch struct {
|
||||
}
|
||||
|
||||
type StorePriceScore struct {
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
StoreName string `json:"storeName"`
|
||||
StoreScore float64 `json:"storeScore"`
|
||||
CityName string `json:"cityName"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
StoreName string `json:"storeName"`
|
||||
StoreScore float64 `json:"storeScore"`
|
||||
CityName string `json:"cityName"`
|
||||
DirectDownCount int `json:"directDownCount"`
|
||||
SecKillCount int `json:"secKillCount"`
|
||||
}
|
||||
|
||||
type StorePriceScoreEx struct {
|
||||
@@ -487,15 +489,38 @@ func GetStoreMapsListWithoutDisabled(db *DaoDB, vendorIDs []int, status int) (st
|
||||
return storeMapList, err
|
||||
}
|
||||
|
||||
func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int, snapDate time.Time, offset, pageSize int) (StorePriceScore []*StorePriceScore, totalCount int, err error) {
|
||||
func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore, sort, directSort, secKillSort int, snapDate time.Time, offset, pageSize int) (StorePriceScore []*StorePriceScore, totalCount int, err error) {
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.store_id,score store_score,e.name city_name,b.name store_name
|
||||
FROM store_price_score_snapshot a
|
||||
JOIN store b ON b.id = a.store_id
|
||||
JOIN place e ON e.code = b.city_code
|
||||
JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
|
||||
FROM store_sku_bind a
|
||||
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
|
||||
LEFT JOIN act_map c ON c.act_id = b.act_id
|
||||
LEFT JOIN act d ON d.id = c.act_id
|
||||
WHERE 1=1
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.ActSkuDirectDown, model.ActSkuSecKill,
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND a.store_id IN(" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
sql += " AND c.vendor_id IN(" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||
sqlParams = append(sqlParams, vendorIDs)
|
||||
}
|
||||
sql += `
|
||||
AND NOW() BETWEEN d.begin_at AND d.end_at
|
||||
AND a.status = ?
|
||||
AND a.deleted_at = ?
|
||||
GROUP BY a.store_id)t1 ON t1.store_id = a.store_id
|
||||
WHERE 1=1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
sqlParams = append(sqlParams, model.StoreSkuBindStatusNormal, utils.DefaultTimeValue)
|
||||
if fromScore != 0 || toScore != 0 {
|
||||
sql += " AND a.score BETWEEN ? AND ?"
|
||||
sqlParams = append(sqlParams, fromScore, toScore)
|
||||
@@ -510,9 +535,19 @@ func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int,
|
||||
}
|
||||
if sort == 0 {
|
||||
sql += " ORDER BY a.score"
|
||||
} else {
|
||||
} else if sort == 1 {
|
||||
sql += " ORDER BY a.score DESC"
|
||||
}
|
||||
if directSort == 0 {
|
||||
sql += " ORDER BY t1.direct_down_count"
|
||||
} else if directSort == 1 {
|
||||
sql += " ORDER BY t1.direct_down_count DESC"
|
||||
}
|
||||
if secKillSort == 0 {
|
||||
sql += " ORDER BY t1.sec_kill_count"
|
||||
} else if secKillSort == 1 {
|
||||
sql += " ORDER BY t1.sec_kill_count DESC"
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
Begin(db)
|
||||
|
||||
@@ -589,20 +589,23 @@ func (c *StoreController) GetVendorStoreInfo() {
|
||||
// @Description 查询门店价格评分
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string false "门店列表"
|
||||
// @Param vendorIDs formData string false "厂商列表"
|
||||
// @Param snapDate formData string true "时间,默认前一天(格式2006-01-02"
|
||||
// @Param fromScore formData int false "分数范围开始 默认0"
|
||||
// @Param toScore formData int false "分数范围结束 默认100"
|
||||
// @Param sort formData int false "排序,默认降序,0为降序,1为升序"
|
||||
// @Param sort formData int false "分数排序,默认降序,0为降序,1为升序,-1为忽略"
|
||||
// @Param directSort formData int false "直降排序,默认降序,0为降序,1为升序,-1为忽略"
|
||||
// @Param secKillSort formData int false "秒杀排序,默认降序,0为降序,1为升序,-1为忽略"
|
||||
// @Param offset formData int false "门店列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize formData int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetStorePriceScore [post]
|
||||
func (c *StoreController) GetStorePriceScore() {
|
||||
var storeIDList []int
|
||||
var storeIDList, vendorIDList []int
|
||||
c.callGetStorePriceScore(func(params *tStoreGetStorePriceScoreParams) (retVal interface{}, errCode string, err error) {
|
||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||
retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, params.FromScore, params.ToScore, params.Sort, params.SnapDate, params.Offset, params.PageSize)
|
||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.VendorIDs, &vendorIDList); err == nil {
|
||||
retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, vendorIDList, params.FromScore, params.ToScore, params.Sort, params.DirectSort, params.SecKillSort, params.SnapDate, params.Offset, params.PageSize)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user