Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark

This commit is contained in:
gazebo
2019-12-13 15:21:09 +08:00
8 changed files with 24 additions and 25 deletions

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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)) + ")"

View File

@@ -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)
}

View File

@@ -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{}{

View File

@@ -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
})
}