Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark
This commit is contained in:
@@ -2413,18 +2413,18 @@ func StoreStatus2Chinese(status int) (str string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toScore, sort int, snapDate string, offset, pageSize int) (storePriceScoreEx *dao.StorePriceScoreEx, err error) {
|
func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toScore, sort int, snapDate string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
var snapDateParam time.Time
|
var snapDateParam time.Time
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if snapDate != "" {
|
if snapDate != "" {
|
||||||
snapDateParam = utils.Str2Time(snapDate)
|
snapDateParam = utils.Str2Time(snapDate)
|
||||||
}
|
}
|
||||||
storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, fromScore, toScore, sort, snapDateParam, offset, pageSize)
|
storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, fromScore, toScore, sort, snapDateParam, offset, pageSize)
|
||||||
storePriceScoreEx = &dao.StorePriceScoreEx{
|
pagedInfo = &model.PagedInfo{
|
||||||
StorePriceScoreList: storePriceScore,
|
Data: storePriceScore,
|
||||||
TotalCount: totalCount,
|
TotalCount: totalCount,
|
||||||
}
|
}
|
||||||
return storePriceScoreEx, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
||||||
|
|||||||
@@ -36,9 +36,18 @@ func GetStatisticsReportForAfsOrders(ctx *jxcontext.Context, storeIDs []int, fro
|
|||||||
return statisticsReportForOrdersList, err
|
return statisticsReportForOrdersList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs []int) (priceRefer []*model.PriceReferSnapshot, err error) {
|
func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs []int, snapDate string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||||
|
var snapDateParam time.Time
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
return dao.GetPriceReferSnapshot(db, cityCodes, skuIDs)
|
if snapDate != "" {
|
||||||
|
snapDateParam = utils.Str2Time(snapDate)
|
||||||
|
}
|
||||||
|
priceReferSnapshot, totalCount, err := dao.GetPriceReferSnapshot(db, cityCodes, skuIDs, snapDateParam, offset, pageSize)
|
||||||
|
pagedInfo = &model.PagedInfo{
|
||||||
|
Data: priceReferSnapshot,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
||||||
|
|||||||
@@ -234,12 +234,12 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*model.PriceReferSnapshot, totalCount int, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT SQL_CALC_FOUND_ROWS *
|
||||||
FROM price_refer_snapshot
|
FROM price_refer_snapshot
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
AND delete_at = ?
|
AND deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
@@ -252,8 +252,16 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapsh
|
|||||||
sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
||||||
sqlParams = append(sqlParams, cityCodes)
|
sqlParams = append(sqlParams, cityCodes)
|
||||||
}
|
}
|
||||||
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
|
if !utils.IsTimeZero(snapDate) {
|
||||||
return priceReferSnapshot, nil
|
sql += " AND snapshot_at = ?"
|
||||||
|
sqlParams = append(sqlParams, snapDate)
|
||||||
}
|
}
|
||||||
return nil, err
|
sql += " LIMIT ? OFFSET ?"
|
||||||
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
Begin(db)
|
||||||
|
defer Commit(db)
|
||||||
|
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
|
||||||
|
totalCount = GetLastTotalRowCount(db)
|
||||||
|
}
|
||||||
|
return priceReferSnapshot, totalCount, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ func (c *ReportController) StatisticsReportForAfsOrders() {
|
|||||||
// @Description 查询京西门店商品价格统计相关信息
|
// @Description 查询京西门店商品价格统计相关信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param cityCodes formData string true "城市ID列表[1,2,3]"
|
// @Param cityCodes formData string true "城市ID列表[1,2,3]"
|
||||||
// @Param skuIDs formData string true "skuID列表[1,2,3]"
|
// @Param skuIDs formData string false "skuID列表[1,2,3]"
|
||||||
|
// @Param snapDate formData string true "某天的参考价格 格式:2006-01-02,默认前一天"
|
||||||
|
// @Param offset formData int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
|
// @Param pageSize formData int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /StatisticsReportForStoreSkusPrice [post]
|
// @router /StatisticsReportForStoreSkusPrice [post]
|
||||||
@@ -61,7 +64,7 @@ func (c *ReportController) StatisticsReportForStoreSkusPrice() {
|
|||||||
c.callStatisticsReportForStoreSkusPrice(func(params *tReportStatisticsReportForStoreSkusPriceParams) (retVal interface{}, errCode string, err error) {
|
c.callStatisticsReportForStoreSkusPrice(func(params *tReportStatisticsReportForStoreSkusPriceParams) (retVal interface{}, errCode string, err error) {
|
||||||
var cityCodeList, skuIDList []int
|
var cityCodeList, skuIDList []int
|
||||||
if err = jxutils.Strings2Objs(params.CityCodes, &cityCodeList, params.SkuIDs, &skuIDList); err == nil {
|
if err = jxutils.Strings2Objs(params.CityCodes, &cityCodeList, params.SkuIDs, &skuIDList); err == nil {
|
||||||
retVal, err = report.StatisticsReportForStoreSkusPrice(params.Ctx, cityCodeList, skuIDList)
|
retVal, err = report.StatisticsReportForStoreSkusPrice(params.Ctx, cityCodeList, skuIDList, params.SnapDate, params.Offset, params.PageSize)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user