门店价格
This commit is contained in:
@@ -2412,3 +2412,17 @@ func StoreStatus2Chinese(status int) (str string) {
|
|||||||
return "未知的营业状态"
|
return "未知的营业状态"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, snapDate string, offset, pageSize int) (storeTotalScoreEx *model.StoreTotalScoreEx, err error) {
|
||||||
|
var snapDateParam time.Time
|
||||||
|
db := dao.GetDB()
|
||||||
|
if snapDate != "" {
|
||||||
|
snapDateParam = utils.Str2Time(snapDate)
|
||||||
|
}
|
||||||
|
storeTotalScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, snapDateParam, offset, pageSize)
|
||||||
|
storeTotalScoreEx = &model.StoreTotalScoreEx{
|
||||||
|
StoreTotalScoreList: storeTotalScore,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
}
|
||||||
|
return storeTotalScoreEx, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -2185,16 +2185,8 @@ func GetTopCategorysByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCateg
|
|||||||
return skuCategory, err
|
return skuCategory, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, snapDate string, offset, pageSize int) (storeTotalScoreEx *model.StoreTotalScoreEx, err error) {
|
func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||||
var snapDateParam time.Time
|
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if snapDate != "" {
|
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
||||||
snapDateParam = utils.Str2Time(snapDate)
|
return err
|
||||||
}
|
|
||||||
storeTotalScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, snapDateParam, offset, pageSize)
|
|
||||||
storeTotalScoreEx = &model.StoreTotalScoreEx{
|
|
||||||
StoreTotalScoreList: storeTotalScore,
|
|
||||||
TotalCount: totalCount,
|
|
||||||
}
|
|
||||||
return storeTotalScoreEx, err
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -462,3 +462,40 @@ func GetStoreMapsListWithoutDisabled(db *DaoDB, vendorIDs []int, status int) (st
|
|||||||
err = GetRows(db, &storeMapList, sql, sqlParams...)
|
err = GetRows(db, &storeMapList, sql, sqlParams...)
|
||||||
return storeMapList, err
|
return storeMapList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStorePriceScore(db *DaoDB, storeIDs []int, snapDate time.Time, offset, pageSize int) (storeTotalScore []*model.StoreTotalScore, totalCount int, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT SQL_CALC_FOUND_ROWS
|
||||||
|
t1.* FROM(
|
||||||
|
SELECT c.store_id,d.name store_name,e.name city_name,ROUND(count(c.price/100 <= a.mid_price or NULL)/count(*)*100,2) store_score
|
||||||
|
FROM price_refer_snapshot a
|
||||||
|
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = 1 AND c.deleted_at = ?
|
||||||
|
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status !=-2
|
||||||
|
JOIN place e ON e.code = d.city_code
|
||||||
|
WHERE 1=1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if len(storeIDs) > 0 {
|
||||||
|
sql += " AND c.store_id IN(" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(snapDate) {
|
||||||
|
sql += " AND a.snapshot_at = ?"
|
||||||
|
sqlParams = append(sqlParams, snapDate)
|
||||||
|
}
|
||||||
|
sql += `
|
||||||
|
GROUP BY c.store_id)t1
|
||||||
|
ORDER BY t1.store_score
|
||||||
|
LIMIT ? OFFSET ?
|
||||||
|
`
|
||||||
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
Begin(db)
|
||||||
|
defer Commit(db)
|
||||||
|
if err = GetRows(db, &storeTotalScore, sql, sqlParams...); err == nil {
|
||||||
|
totalCount = GetLastTotalRowCount(db)
|
||||||
|
}
|
||||||
|
return storeTotalScore, totalCount, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -737,37 +737,28 @@ func GetTopCategorysByStoreIDs(db *DaoDB, storeIDs []int) (skuCategory []*model.
|
|||||||
return skuCategory, err
|
return skuCategory, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStorePriceScore(db *DaoDB, storeIDs []int, snapDate time.Time, offset, pageSize int) (storeTotalScore []*model.StoreTotalScore, totalCount int, err error) {
|
func RefershStoreSkusMidPrice(db *DaoDB, storeIDs []int) (count int64, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS
|
UPDATE store_sku_bind a
|
||||||
t1.* FROM(
|
JOIN store d ON d.id = a.store_id
|
||||||
SELECT c.store_id,d.name store_name,e.name city_name,ROUND(count(c.price/100 <= a.mid_price or NULL)/count(*)*100,2) store_score
|
JOIN price_refer_snapshot b ON a.sku_id = b.sku_id AND b.snapshot_at = ? AND d.city_code = b.city_code
|
||||||
FROM price_refer_snapshot a
|
SET a.price = b.mid_price*100
|
||||||
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = 1 AND c.deleted_at = ?
|
|
||||||
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status !=-2
|
|
||||||
JOIN place e ON e.code = d.city_code
|
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
}
|
||||||
if !utils.IsTimeZero(snapDate) {
|
if len(storeIDs) > 0 {
|
||||||
sql += " AND a.snapshot_at = ?"
|
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, snapDate)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
GROUP BY c.store_id)t1
|
AND a.price > b.mid_price*100
|
||||||
ORDER BY t1.store_score
|
AND a.deleted_at = ?
|
||||||
LIMIT ? OFFSET ?
|
AND a.status = ?
|
||||||
`
|
`
|
||||||
sqlParams = append(sqlParams, pageSize, offset)
|
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SkuStatusNormal)
|
||||||
Begin(db)
|
return ExecuteSQL(db, sql, sqlParams)
|
||||||
defer Commit(db)
|
|
||||||
if err = GetRows(db, &storeTotalScore, sql, sqlParams...); err == nil {
|
|
||||||
totalCount = GetLastTotalRowCount(db)
|
|
||||||
}
|
|
||||||
return storeTotalScore, totalCount, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int) {
|
func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int) {
|
||||||
|
|||||||
@@ -583,3 +583,23 @@ func (c *StoreController) GetVendorStoreInfo() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 查询门店价格评分
|
||||||
|
// @Description 查询门店价格评分
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs query string false "门店列表"
|
||||||
|
// @Param snapDate query string true "时间,默认当天(格式2006-01-02"
|
||||||
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
|
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetStorePriceScore [post]
|
||||||
|
func (c *StoreController) GetStorePriceScore() {
|
||||||
|
var storeIDList []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.SnapDate, params.Offset, params.PageSize)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ func (c *StoreSkuController) GetTopCategorysByStoreIDs() {
|
|||||||
|
|
||||||
// @Title 根据门店刷新中位价
|
// @Title 根据门店刷新中位价
|
||||||
// @Description 根据门店刷新中位价
|
// @Description 根据门店刷新中位价
|
||||||
// @Param token header string false "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeIDs query string true "门店列表"
|
// @Param storeIDs query string true "门店列表"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
@@ -493,27 +493,7 @@ func (c *StoreSkuController) RefershStoreSkusMidPrice() {
|
|||||||
var storeIDList []int
|
var storeIDList []int
|
||||||
c.callRefershStoreSkusMidPrice(func(params *tStoreSkuRefershStoreSkusMidPriceParams) (retVal interface{}, errCode string, err error) {
|
c.callRefershStoreSkusMidPrice(func(params *tStoreSkuRefershStoreSkusMidPriceParams) (retVal interface{}, errCode string, err error) {
|
||||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||||
// cms.RefershStoreSkusMidPrice()
|
err = cms.RefershStoreSkusMidPrice(params.Ctx, storeIDList)
|
||||||
}
|
|
||||||
return retVal, "", err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 查询门店价格评分
|
|
||||||
// @Description 查询门店价格评分
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Param storeIDs query string false "门店列表"
|
|
||||||
// @Param snapDate query string true "时间,默认当天(格式2006-01-02"
|
|
||||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
|
||||||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /GetStorePriceScore [post]
|
|
||||||
func (c *StoreSkuController) GetStorePriceScore() {
|
|
||||||
var storeIDList []int
|
|
||||||
c.callGetStorePriceScore(func(params *tStoreSkuGetStorePriceScoreParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
|
||||||
retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, params.SnapDate,params.Offset, params.PageSize)
|
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1386,6 +1386,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetStorePriceScore",
|
||||||
|
Router: `/GetStorePriceScore`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoreTotalScoreList",
|
Method: "GetStoreTotalScoreList",
|
||||||
@@ -1566,15 +1575,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "GetStorePriceScore",
|
|
||||||
Router: `/GetStorePriceScore`,
|
|
||||||
AllowHTTPMethods: []string{"post"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoreSkus",
|
Method: "GetStoreSkus",
|
||||||
|
|||||||
Reference in New Issue
Block a user