门店价格修改
This commit is contained in:
@@ -2544,14 +2544,10 @@ func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toSco
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func CreateStorePriceScore(ctx *jxcontext.Context, forRefresh bool) (err error) {
|
||||
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
||||
db := dao.GetDB()
|
||||
var snapshotAt time.Time
|
||||
if forRefresh {
|
||||
snapshotAt = utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||
} else {
|
||||
snapshotAt = utils.Time2Date(time.Now())
|
||||
}
|
||||
snapshotAt = utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||
storePriceScoreSnapshot, err := dao.GetStorePriceScoreSnapshot(db, snapshotAt)
|
||||
if len(storePriceScoreSnapshot) > 0 {
|
||||
dao.Begin(db)
|
||||
|
||||
@@ -2155,7 +2155,7 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error
|
||||
db := dao.GetDB()
|
||||
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
||||
if err == nil {
|
||||
CreateStorePriceScore(ctx, true)
|
||||
CreateStorePriceScore(ctx)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -34,8 +34,11 @@ var (
|
||||
dailyWorkTimeList = []string{
|
||||
"20:30:00",
|
||||
}
|
||||
priceReferTimeList = []string{
|
||||
"01:00:00",
|
||||
}
|
||||
createStorePriceTimeList = []string{
|
||||
"23:00:00",
|
||||
"02:00:00",
|
||||
}
|
||||
refreshPageActTimeList = []string{
|
||||
"7:00:00",
|
||||
@@ -138,10 +141,10 @@ func Init() {
|
||||
}, ChangeStoreSkuSaleStatusList)
|
||||
ScheduleTimerFunc("BeginSavePriceRefer", func() {
|
||||
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil)
|
||||
}, createStorePriceTimeList)
|
||||
}, priceReferTimeList)
|
||||
ScheduleTimerFunc("CreateStorePriceScore", func() {
|
||||
cms.CreateStorePriceScore(jxcontext.AdminCtx, false)
|
||||
}, openRemoteStoreTimeList)
|
||||
cms.CreateStorePriceScore(jxcontext.AdminCtx)
|
||||
}, createStorePriceTimeList)
|
||||
}
|
||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||
|
||||
@@ -52,7 +52,7 @@ func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs
|
||||
|
||||
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
||||
db := dao.GetDB()
|
||||
snapshotAt := utils.Time2Date(time.Now())
|
||||
snapshotAt := utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
||||
if len(priceReferSnapshot) > 0 {
|
||||
dao.Begin(db)
|
||||
@@ -71,7 +71,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
||||
for _, v := range priceReferSnapshot {
|
||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||
v.SnapshotAt = snapshotAt
|
||||
fmt.Println(v)
|
||||
if err = dao.CreateEntity(db, v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -188,10 +188,10 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
||||
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
||||
sql := `
|
||||
SELECT b.city_code,a.sku_id,
|
||||
MAX(a.price) max_price,
|
||||
MIN(a.price) min_price,
|
||||
ROUND(AVG(a.price)) avg_price,
|
||||
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100),',',Count(1)/2),',',-1),2) mid_price,
|
||||
ROUND(MAX(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) max_price,
|
||||
ROUND(MIN(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) min_price,
|
||||
ROUND(AVG(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) avg_price,
|
||||
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
|
||||
MAX(a.jd_price) max_jd_price,
|
||||
MIN(a.jd_price) min_jd_price,
|
||||
ROUND(AVG(a.jd_price)) avg_jd_price,
|
||||
@@ -211,8 +211,7 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
||||
t1.min_vendor_price,
|
||||
t1.avg_vendor_price
|
||||
FROM store_sku_bind a
|
||||
JOIN store b ON a.store_id = b.id AND b.deleted_at = ?
|
||||
JOIN sku d ON a.sku_id = d.id AND d.deleted_at = ?
|
||||
JOIN store b ON a.store_id = b.id AND b.deleted_at = ? AND b.status != ?
|
||||
LEFT JOIN (
|
||||
SELECT SUM(t1.count),t1.sku_id,MAX(t1.sale_price) max_sale_price,MIN(t1.sale_price) min_sale_price,ROUND(AVG(t1.sale_price)) avg_sale_price,MAX(t1.vendor_price) max_vendor_price,MIN(t1.vendor_price) min_vendor_price,ROUND(AVG(t1.vendor_price)) avg_vendor_price
|
||||
FROM order_sku t1
|
||||
@@ -220,12 +219,14 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
||||
GROUP BY 2
|
||||
)t1 ON t1.sku_id = a.sku_id
|
||||
WHERE a.deleted_at = ?
|
||||
AND a.status = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
model.StoreStatusDisabled,
|
||||
time.Now().AddDate(0, -1, 0),
|
||||
utils.DefaultTimeValue,
|
||||
model.SkuStatusNormal,
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
|
||||
@@ -493,7 +493,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int,
|
||||
WHERE 1=1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if fromScore != 0 && toScore != 0 {
|
||||
if fromScore != 0 || toScore != 0 {
|
||||
sql += " AND a.score BETWEEN ? AND ?"
|
||||
sqlParams = append(sqlParams, fromScore, toScore)
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ func (c *StoreController) GetStorePriceScore() {
|
||||
// @router /CreateStorePriceScore [post]
|
||||
func (c *StoreController) CreateStorePriceScore() {
|
||||
c.callCreateStorePriceScore(func(params *tStoreCreateStorePriceScoreParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.CreateStorePriceScore(params.Ctx, params.ForRefresh)
|
||||
err = cms.CreateStorePriceScore(params.Ctx)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user