价格统计
This commit is contained in:
@@ -2595,7 +2595,7 @@ func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
priceReferSnapshotDeleteHis := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
|
priceReferSnapshotDeleteHis := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt.AddDate(0, 0, -7)}
|
||||||
priceReferSnapshotDelete := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt}
|
priceReferSnapshotDelete := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt}
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
||||||
|
|||||||
@@ -66,9 +66,8 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
priceReferSnapshotDeleteHis := &model.PriceReferSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
|
dao.DeletePriceReferHistory(db, utils.Time2Date(snapshotAt.AddDate(0, 0, -7)))
|
||||||
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
|
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
||||||
task := tasksch.NewParallelTask("生成价格统计", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("生成价格统计", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
@@ -82,26 +81,5 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
|||||||
_, err = task.GetResult(0)
|
_, err = task.GetResult(0)
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
}
|
}
|
||||||
priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, nil, nil, nil, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
|
||||||
if len(priceReferList) > 0 {
|
|
||||||
dao.Begin(db)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil || err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
if r != nil {
|
|
||||||
panic(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
for _, v := range priceReferList {
|
|
||||||
priceRefer, _ := dao.GetPriceReferUnitPrice(db, v.CityCode, v.NameID, v.SnapshotAt)
|
|
||||||
v.MidUnitPrice = priceRefer.MidUnitPrice
|
|
||||||
v.MaxUnitPrice = priceRefer.MaxUnitPrice
|
|
||||||
v.MinUnitPrice = priceRefer.MinUnitPrice
|
|
||||||
v.AvgUnitPrice = priceRefer.AvgUnitPrice
|
|
||||||
_, err = dao.UpdateEntity(db, v, "MidUnitPrice", "MaxUnitPrice", "AvgUnitPrice", "MinUnitPrice")
|
|
||||||
}
|
|
||||||
dao.Commit(db)
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
ROUND(MIN(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) min_price,
|
ROUND(MIN(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) min_price,
|
||||||
ROUND(AVG(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) avg_price,
|
ROUND(AVG(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) avg_price,
|
||||||
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
|
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
|
||||||
|
ROUND(MAX(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) max_unit_price,
|
||||||
|
ROUND(MIN(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) min_unit_price,
|
||||||
|
ROUND(AVG(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) avg_unit_price,
|
||||||
|
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100 ORDER BY (a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_unit_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,
|
||||||
@@ -322,3 +326,14 @@ func GetPriceReferSnapshotNoPage(db *DaoDB, cityCodes, skuIDs, skuNameIDs []int,
|
|||||||
err = GetRows(db, &priceReferSnapshot, sql, sqlParams...)
|
err = GetRows(db, &priceReferSnapshot, sql, sqlParams...)
|
||||||
return priceReferSnapshot, err
|
return priceReferSnapshot, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeletePriceReferHistory(db *DaoDB, snapDate time.Time) (num int64, err error) {
|
||||||
|
sql := `
|
||||||
|
DELETE FROM price_refer_snapshot
|
||||||
|
WHERE snapshot_at <= ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
snapDate,
|
||||||
|
}
|
||||||
|
return ExecuteSQL(db, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore
|
|||||||
FROM store_price_score_snapshot a
|
FROM store_price_score_snapshot a
|
||||||
JOIN store b ON b.id = a.store_id
|
JOIN store b ON b.id = a.store_id
|
||||||
JOIN place e ON e.code = b.city_code
|
JOIN place e ON e.code = b.city_code
|
||||||
JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
|
LEFT JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
|
||||||
FROM store_sku_bind a
|
FROM store_sku_bind a
|
||||||
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
|
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
|
||||||
LEFT JOIN act_map c ON c.act_id = b.act_id
|
LEFT JOIN act_map c ON c.act_id = b.act_id
|
||||||
|
|||||||
@@ -84,19 +84,6 @@ func (c *ReportController) PriceRefer() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title 生成价格参考数据单价
|
|
||||||
// @Description 生成价格参考数据单价
|
|
||||||
// @Param token header string true "认证token"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
|
||||||
// @Failure 200 {object} controllers.CallResult
|
|
||||||
// @router /PriceReferUnitPrice [post]
|
|
||||||
func (c *ReportController) PriceReferUnitPrice() {
|
|
||||||
// c.callPriceReferUnitPrice(func(params *tReportPriceReferUnitPriceParams) (retVal interface{}, errCode string, err error) {
|
|
||||||
// report.UpdatePriceReferUnitPrice(params.Ctx)
|
|
||||||
// return retVal, "", err
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Title 自动关注商品(针对后加的商品规格未关注)
|
// @Title 自动关注商品(针对后加的商品规格未关注)
|
||||||
// @Description 自动关注商品(针对后加的商品规格未关注)
|
// @Description 自动关注商品(针对后加的商品规格未关注)
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user