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

This commit is contained in:
gazebo
2019-12-09 09:39:17 +08:00
4 changed files with 35 additions and 15 deletions

View File

@@ -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
db := dao.GetDB()
if snapDate != "" {
snapDateParam = utils.Str2Time(snapDate)
}
storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, fromScore, toScore, sort, snapDateParam, offset, pageSize)
storePriceScoreEx = &dao.StorePriceScoreEx{
StorePriceScoreList: storePriceScore,
TotalCount: totalCount,
pagedInfo = &model.PagedInfo{
Data: storePriceScore,
TotalCount: totalCount,
}
return storePriceScoreEx, err
return pagedInfo, err
}
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {

View File

@@ -36,9 +36,18 @@ func GetStatisticsReportForAfsOrders(ctx *jxcontext.Context, storeIDs []int, fro
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()
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) {

View File

@@ -234,12 +234,12 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
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 := `
SELECT *
SELECT SQL_CALC_FOUND_ROWS *
FROM price_refer_snapshot
WHERE 1=1
AND delete_at = ?
AND deleted_at = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
@@ -252,8 +252,16 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapsh
sql += " AND city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
sqlParams = append(sqlParams, cityCodes)
}
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
return priceReferSnapshot, nil
if !utils.IsTimeZero(snapDate) {
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
}

View File

@@ -53,7 +53,10 @@ func (c *ReportController) StatisticsReportForAfsOrders() {
// @Description 查询京西门店商品价格统计相关信息
// @Param token header string true "认证token"
// @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
// @Failure 200 {object} controllers.CallResult
// @router /StatisticsReportForStoreSkusPrice [post]
@@ -61,7 +64,7 @@ func (c *ReportController) StatisticsReportForStoreSkusPrice() {
c.callStatisticsReportForStoreSkusPrice(func(params *tReportStatisticsReportForStoreSkusPriceParams) (retVal interface{}, errCode string, err error) {
var cityCodeList, skuIDList []int
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
})