diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 516420ae9..c5f9f6746 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -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) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index d7e4771ab..df0a1dd2b 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -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 } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 62923b4b9..ae1becc34 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -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) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index f3120c702..016bf0679 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -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 } diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 125b42a21..deb057438 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -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)) + ")" diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 08ac3f9ae..9dd0d194f 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -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) } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index e2c7c908f..163efd27e 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -924,7 +924,7 @@ func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (storeSkuNameExt []*StoreSk JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id AND a.vendor_id = b.vendor_id JOIN sku c ON b.sku_id = c.id AND c.deleted_at = ? JOIN sku_name t1 ON t1.id = c.name_id AND t1.deleted_at = ? - STRAIGHT_JOIN store_sku_bind t4 ON t4.store_id = IF(a.store_id = 0,a.jx_store_id,a.store_id) AND t4.sku_id = b.sku_id AND t4.status = ? AND t4.deleted_at = ? + STRAIGHT_JOIN store_sku_bind t4 ON t4.store_id = IF(a.jx_store_id = 0,a.store_id,a.jx_store_id) AND t4.sku_id = b.sku_id AND t4.status = ? AND t4.deleted_at = ? JOIN store d ON d.id = a.store_id WHERE 1=1 AND a.order_created_at BETWEEN ? and NOW() @@ -993,10 +993,10 @@ func GetTopCategorysByStoreIDs(db *DaoDB, storeIDs []int) (skuCategory []*model. FROM( SELECT SUM(b.count) count,d.category_id FROM goods_order a - JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id + JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id AND a.vendor_id = b.vendor_id JOIN sku c ON b.sku_id = c.id AND c.deleted_at = ? JOIN sku_name d ON d.id = c.name_id AND d.deleted_at = ? - JOIN store e ON e.id = a.store_id + JOIN store e ON e.id = IF(a.jx_store_id = 0,a.store_id,a.jx_store_id) AND e.status != -2 JOIN (SELECT city_code FROM store WHERE 1=1 ` sqlParams := []interface{}{ diff --git a/controllers/cms_store.go b/controllers/cms_store.go index b9b340768..40d69f25d 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -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 }) }