diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 5e5c92780..49a71f3d4 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -224,9 +224,6 @@ func init() { }, TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) { order := savedOrderInfo.order - if order != nil && order.TotalShopMoney == 0 { - globals.SugarLogger.Debugf("init() TotalShopMoney=0 orderID:%s", order.VendorOrderID) - } mobile := order.ConsigneeMobile if order.ConsigneeMobile2 != "" { mobile = order.ConsigneeMobile2 @@ -356,9 +353,6 @@ func Init() { // 以下是订单 func (s *DefScheduler) OnOrderNew(order *model.GoodsOrder, isPending bool) (err error) { globals.SugarLogger.Debugf("OnOrderNew orderID:%s", order.VendorOrderID) - if order != nil && order.TotalShopMoney == 0 { - globals.SugarLogger.Debugf("OnOrderNew TotalShopMoney=0 orderID:%s", order.VendorOrderID) - } savedOrderInfo := s.loadSavedOrderFromMap(model.Order2Status(order), false) savedOrderInfo.SetOrder(order) if order.Status >= model.OrderStatusNew { @@ -1357,7 +1351,7 @@ func OrderProfitWarning(order *model.GoodsOrder) { operatorName = storeDetail.OperatorName2 operatorPhone = storeDetail.OperatorPhone2 } - noticeMsg = fmt.Sprintf("利润 :[%v],运营负责人:[%v],门店ID:[%v],平台门店ID[%v],门店名:[%v],订单号(点击进入详情):%v", profit, operatorName, order.StoreID, order.VendorStoreID, order.StoreName, "http://www.jxc4.com/#/ordermanager/"+order.VendorOrderID) + noticeMsg = fmt.Sprintf("利润 :[%v],运营负责人:[%v],门店ID:[%v],平台门店ID[%v],门店名:[%v],订单号(点击进入详情):%v", profit, operatorName, order.StoreID, order.VendorStoreID, order.StoreName, globals.BackstageHost+"/#/ordermanager/"+order.VendorOrderID) user, err := dao.GetUserByID(db, "mobile", operatorPhone) if user != nil && err == nil { ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index ec780e523..713226b5f 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -2548,13 +2548,13 @@ func StoreStatus2Chinese(status int) (str string) { } } -func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toScore, sort int, snapDate string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) { +func GetStorePriceScore(ctx *jxcontext.Context, storeIDs, vendorIDs []int, fromScore, toScore, sort, directSort, secKillSort 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) + storePriceScore, totalCount, err := dao.GetStorePriceScore(db, storeIDs, vendorIDs, fromScore, toScore, sort, directSort, secKillSort, snapDateParam, offset, pageSize) pagedInfo = &model.PagedInfo{ Data: storePriceScore, TotalCount: totalCount, diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 40c35c240..96ee15a7c 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -63,10 +63,12 @@ type CityBrankBranch struct { } type StorePriceScore struct { - StoreID int `orm:"column(store_id)" json:"storeID"` - StoreName string `json:"storeName"` - StoreScore float64 `json:"storeScore"` - CityName string `json:"cityName"` + StoreID int `orm:"column(store_id)" json:"storeID"` + StoreName string `json:"storeName"` + StoreScore float64 `json:"storeScore"` + CityName string `json:"cityName"` + DirectDownCount int `json:"directDownCount"` + SecKillCount int `json:"secKillCount"` } type StorePriceScoreEx struct { @@ -487,15 +489,38 @@ func GetStoreMapsListWithoutDisabled(db *DaoDB, vendorIDs []int, status int) (st return storeMapList, err } -func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int, snapDate time.Time, offset, pageSize int) (StorePriceScore []*StorePriceScore, totalCount int, err error) { +func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore, sort, directSort, secKillSort int, snapDate time.Time, offset, pageSize int) (StorePriceScore []*StorePriceScore, totalCount int, err error) { sql := ` SELECT SQL_CALC_FOUND_ROWS a.store_id,score store_score,e.name city_name,b.name store_name FROM store_price_score_snapshot a JOIN store b ON b.id = a.store_id 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 + 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_map c ON c.act_id = b.act_id + LEFT JOIN act d ON d.id = c.act_id + WHERE 1=1 + ` + sqlParams := []interface{}{ + model.ActSkuDirectDown, model.ActSkuSecKill, + } + if len(storeIDs) > 0 { + sql += " AND a.store_id IN(" + GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } + if len(vendorIDs) > 0 { + sql += " AND c.vendor_id IN(" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, vendorIDs) + } + sql += ` + AND NOW() BETWEEN d.begin_at AND d.end_at + AND a.status = ? + AND a.deleted_at = ? + GROUP BY a.store_id)t1 ON t1.store_id = a.store_id WHERE 1=1 ` - sqlParams := []interface{}{} + sqlParams = append(sqlParams, model.StoreSkuBindStatusNormal, utils.DefaultTimeValue) if fromScore != 0 || toScore != 0 { sql += " AND a.score BETWEEN ? AND ?" sqlParams = append(sqlParams, fromScore, toScore) @@ -510,9 +535,19 @@ func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int, } if sort == 0 { sql += " ORDER BY a.score" - } else { + } else if sort == 1 { sql += " ORDER BY a.score DESC" } + if directSort == 0 { + sql += " ORDER BY t1.direct_down_count" + } else if directSort == 1 { + sql += " ORDER BY t1.direct_down_count DESC" + } + if secKillSort == 0 { + sql += " ORDER BY t1.sec_kill_count" + } else if secKillSort == 1 { + sql += " ORDER BY t1.sec_kill_count DESC" + } sql += " LIMIT ? OFFSET ?" sqlParams = append(sqlParams, pageSize, offset) Begin(db) diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 9a29cda4f..29d2b36df 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -589,20 +589,23 @@ func (c *StoreController) GetVendorStoreInfo() { // @Description 查询门店价格评分 // @Param token header string true "认证token" // @Param storeIDs formData string false "门店列表" +// @Param vendorIDs formData string false "厂商列表" // @Param snapDate formData string true "时间,默认前一天(格式2006-01-02" // @Param fromScore formData int false "分数范围开始 默认0" // @Param toScore formData int false "分数范围结束 默认100" -// @Param sort formData int false "排序,默认降序,0为降序,1为升序" +// @Param sort formData int false "分数排序,默认降序,0为降序,1为升序,-1为忽略" +// @Param directSort formData int false "直降排序,默认降序,0为降序,1为升序,-1为忽略" +// @Param secKillSort formData int false "秒杀排序,默认降序,0为降序,1为升序,-1为忽略" // @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 /GetStorePriceScore [post] func (c *StoreController) GetStorePriceScore() { - var storeIDList []int + var storeIDList, vendorIDList []int c.callGetStorePriceScore(func(params *tStoreGetStorePriceScoreParams) (retVal interface{}, errCode string, err error) { - if jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { - retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, params.FromScore, params.ToScore, params.Sort, params.SnapDate, params.Offset, params.PageSize) + if jxutils.Strings2Objs(params.StoreIDs, &storeIDList, params.VendorIDs, &vendorIDList); err == nil { + retVal, err = cms.GetStorePriceScore(params.Ctx, storeIDList, vendorIDList, params.FromScore, params.ToScore, params.Sort, params.DirectSort, params.SecKillSort, params.SnapDate, params.Offset, params.PageSize) } return retVal, "", err })