Accept Merge Request #82: (yonghui -> mark)
Merge Request: 推荐商品分类sql修改,门店价格统计等修改 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/82
This commit is contained in:
@@ -2544,14 +2544,10 @@ func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toSco
|
|||||||
return pagedInfo, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateStorePriceScore(ctx *jxcontext.Context, forRefresh bool) (err error) {
|
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
var snapshotAt time.Time
|
var snapshotAt time.Time
|
||||||
if forRefresh {
|
snapshotAt = utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||||
snapshotAt = utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
|
||||||
} else {
|
|
||||||
snapshotAt = utils.Time2Date(time.Now())
|
|
||||||
}
|
|
||||||
storePriceScoreSnapshot, err := dao.GetStorePriceScoreSnapshot(db, snapshotAt)
|
storePriceScoreSnapshot, err := dao.GetStorePriceScoreSnapshot(db, snapshotAt)
|
||||||
if len(storePriceScoreSnapshot) > 0 {
|
if len(storePriceScoreSnapshot) > 0 {
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
|
|||||||
@@ -2155,7 +2155,7 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error
|
|||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
CreateStorePriceScore(ctx, true)
|
CreateStorePriceScore(ctx)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,11 @@ var (
|
|||||||
dailyWorkTimeList = []string{
|
dailyWorkTimeList = []string{
|
||||||
"20:30:00",
|
"20:30:00",
|
||||||
}
|
}
|
||||||
|
priceReferTimeList = []string{
|
||||||
|
"01:00:00",
|
||||||
|
}
|
||||||
createStorePriceTimeList = []string{
|
createStorePriceTimeList = []string{
|
||||||
"23:00:00",
|
"02:00:00",
|
||||||
}
|
}
|
||||||
refreshPageActTimeList = []string{
|
refreshPageActTimeList = []string{
|
||||||
"7:00:00",
|
"7:00:00",
|
||||||
@@ -138,10 +141,10 @@ func Init() {
|
|||||||
}, ChangeStoreSkuSaleStatusList)
|
}, ChangeStoreSkuSaleStatusList)
|
||||||
ScheduleTimerFunc("BeginSavePriceRefer", func() {
|
ScheduleTimerFunc("BeginSavePriceRefer", func() {
|
||||||
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil)
|
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil)
|
||||||
}, createStorePriceTimeList)
|
}, priceReferTimeList)
|
||||||
ScheduleTimerFunc("CreateStorePriceScore", func() {
|
ScheduleTimerFunc("CreateStorePriceScore", func() {
|
||||||
cms.CreateStorePriceScore(jxcontext.AdminCtx, false)
|
cms.CreateStorePriceScore(jxcontext.AdminCtx)
|
||||||
}, openRemoteStoreTimeList)
|
}, createStorePriceTimeList)
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
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) {
|
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
snapshotAt := utils.Time2Date(time.Now())
|
snapshotAt := utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||||
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
||||||
if len(priceReferSnapshot) > 0 {
|
if len(priceReferSnapshot) > 0 {
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
@@ -71,7 +71,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
|||||||
for _, v := range priceReferSnapshot {
|
for _, v := range priceReferSnapshot {
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
v.SnapshotAt = snapshotAt
|
v.SnapshotAt = snapshotAt
|
||||||
fmt.Println(v)
|
|
||||||
if err = dao.CreateEntity(db, v); err != nil {
|
if err = dao.CreateEntity(db, v); err != nil {
|
||||||
return err
|
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) {
|
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT b.city_code,a.sku_id,
|
SELECT b.city_code,a.sku_id,
|
||||||
MAX(a.price) max_price,
|
ROUND(MAX(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) max_price,
|
||||||
MIN(a.price) min_price,
|
ROUND(MIN(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) min_price,
|
||||||
ROUND(AVG(a.price)) avg_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),2) mid_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,
|
MAX(a.jd_price) max_jd_price,
|
||||||
MIN(a.jd_price) min_jd_price,
|
MIN(a.jd_price) min_jd_price,
|
||||||
ROUND(AVG(a.jd_price)) avg_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.min_vendor_price,
|
||||||
t1.avg_vendor_price
|
t1.avg_vendor_price
|
||||||
FROM store_sku_bind a
|
FROM store_sku_bind a
|
||||||
JOIN store b ON a.store_id = b.id AND b.deleted_at = ?
|
JOIN store b ON a.store_id = b.id AND b.deleted_at = ? AND b.status != ?
|
||||||
JOIN sku d ON a.sku_id = d.id AND d.deleted_at = ?
|
|
||||||
LEFT JOIN (
|
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
|
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
|
FROM order_sku t1
|
||||||
@@ -220,12 +219,14 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
GROUP BY 2
|
GROUP BY 2
|
||||||
)t1 ON t1.sku_id = a.sku_id
|
)t1 ON t1.sku_id = a.sku_id
|
||||||
WHERE a.deleted_at = ?
|
WHERE a.deleted_at = ?
|
||||||
|
AND a.status = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
model.StoreStatusDisabled,
|
||||||
time.Now().AddDate(0, -1, 0),
|
time.Now().AddDate(0, -1, 0),
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
|
model.SkuStatusNormal,
|
||||||
}
|
}
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
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
|
WHERE 1=1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{}
|
sqlParams := []interface{}{}
|
||||||
if fromScore != 0 && toScore != 0 {
|
if fromScore != 0 || toScore != 0 {
|
||||||
sql += " AND a.score BETWEEN ? AND ?"
|
sql += " AND a.score BETWEEN ? AND ?"
|
||||||
sqlParams = append(sqlParams, fromScore, toScore)
|
sqlParams = append(sqlParams, fromScore, toScore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 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 = ?
|
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
|
JOIN store d ON d.id = a.store_id
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
AND a.order_created_at BETWEEN ? and NOW()
|
AND a.order_created_at BETWEEN ? and NOW()
|
||||||
@@ -993,10 +993,10 @@ func GetTopCategorysByStoreIDs(db *DaoDB, storeIDs []int) (skuCategory []*model.
|
|||||||
FROM(
|
FROM(
|
||||||
SELECT SUM(b.count) count,d.category_id
|
SELECT SUM(b.count) count,d.category_id
|
||||||
FROM goods_order a
|
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 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 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
|
JOIN (SELECT city_code FROM store WHERE 1=1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ func (c *StoreController) GetStorePriceScore() {
|
|||||||
// @router /CreateStorePriceScore [post]
|
// @router /CreateStorePriceScore [post]
|
||||||
func (c *StoreController) CreateStorePriceScore() {
|
func (c *StoreController) CreateStorePriceScore() {
|
||||||
c.callCreateStorePriceScore(func(params *tStoreCreateStorePriceScoreParams) (retVal interface{}, errCode string, err error) {
|
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
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user