门店价格
This commit is contained in:
@@ -2412,3 +2412,17 @@ func StoreStatus2Chinese(status int) (str string) {
|
||||
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
|
||||
}
|
||||
|
||||
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, snapDate string, offset, pageSize int) (storeTotalScoreEx *model.StoreTotalScoreEx, err error) {
|
||||
var snapDateParam time.Time
|
||||
func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||
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
|
||||
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -462,3 +462,40 @@ func GetStoreMapsListWithoutDisabled(db *DaoDB, vendorIDs []int, status int) (st
|
||||
err = GetRows(db, &storeMapList, sql, sqlParams...)
|
||||
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
|
||||
}
|
||||
|
||||
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 := `
|
||||
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
|
||||
UPDATE store_sku_bind a
|
||||
JOIN store d ON d.id = a.store_id
|
||||
JOIN price_refer_snapshot b ON a.sku_id = b.sku_id AND b.snapshot_at = ? AND d.city_code = b.city_code
|
||||
SET a.price = b.mid_price*100
|
||||
WHERE 1=1
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if !utils.IsTimeZero(snapDate) {
|
||||
sql += " AND a.snapshot_at = ?"
|
||||
sqlParams = append(sqlParams, snapDate)
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
sql += `
|
||||
GROUP BY c.store_id)t1
|
||||
ORDER BY t1.store_score
|
||||
LIMIT ? OFFSET ?
|
||||
AND a.price > b.mid_price*100
|
||||
AND a.deleted_at = ?
|
||||
AND a.status = ?
|
||||
`
|
||||
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
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SkuStatusNormal)
|
||||
return ExecuteSQL(db, sql, sqlParams)
|
||||
}
|
||||
|
||||
func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int) {
|
||||
|
||||
Reference in New Issue
Block a user