diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 2125fbef4..f2a88dd2b 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -1283,7 +1283,7 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng) order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat) } - storeList, err := common.GetStoreListByLocation(ctx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 5000, false, true) + storeList, err := common.GetStoreListByLocation(ctx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 5000, false, true, 0) if err != nil { globals.SugarLogger.Debugf("jds GetStoreListByLocation error: %v", err.Error()) continue diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index 37e823bc4..93ceb59f3 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -1144,3 +1144,15 @@ func RefreshUserMemberStatus(ctx *jxcontext.Context) (err error) { } return err } + +func UpdateUserLastInfo(ctx *jxcontext.Context, storeID, brandID int) (err error) { + var ( + db = dao.GetDB() + ) + if user, err := dao.GetUserByID(db, "user_id", ctx.GetUserID()); err == nil { + user.LastStoreID = storeID + user.LastBrandID = brandID + _, err = dao.UpdateEntity(db, user, "LastStoreID", "LastBrandID") + } + return err +} diff --git a/business/jxstore/common/common.go b/business/jxstore/common/common.go index 64633a911..91d827752 100644 --- a/business/jxstore/common/common.go +++ b/business/jxstore/common/common.go @@ -109,7 +109,7 @@ func GetNearSupplyGoodsStoreByStoreID(ctx *jxcontext.Context, storeID int) (stor return store, err } -func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius int, needWalkDistance, isJds bool) (storeList []*Store4User, err error) { +func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius int, needWalkDistance, isJds bool, brandID int) (storeList []*Store4User, err error) { const ( maxStoreCount4User = 5 ) @@ -134,14 +134,20 @@ func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius WHERE t1.deleted_at = ? AND t1.status <> ? AND t1.lng > ? AND t1.lng < ? AND t1.lat > ? AND t1.lat < ? AND sm.is_order <> ? AND t1.id <> ? + ` + if brandID != 0 { + sql += " AND t1.brand_id = ?" + sqlParams = append(sqlParams, brandID) + } + sql += ` ORDER BY t1.id ` - sqlParams = []interface{}{ + sqlParams = append(sqlParams, model.VendorIDJX, utils.DefaultTimeValue, model.StoreStatusDisabled, utils.DefaultTimeValue, model.StoreStatusDisabled, jxutils.StandardCoordinate2Int(lng1), jxutils.StandardCoordinate2Int(lng2), jxutils.StandardCoordinate2Int(lat1), jxutils.StandardCoordinate2Int(lat2), model.YES, model.MatterStoreID, - } + ) } else { sql = ` SELECT t1.*, diff --git a/business/partner/purchase/jdshop/callback.go b/business/partner/purchase/jdshop/callback.go index 33ce3c689..1d5073eef 100644 --- a/business/partner/purchase/jdshop/callback.go +++ b/business/partner/purchase/jdshop/callback.go @@ -184,7 +184,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit) order.Skus = append(order.Skus, sku) } - storeList, err := common.GetStoreListByLocation(jxcontext.AdminCtx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 3000, false, true) + storeList, err := common.GetStoreListByLocation(jxcontext.AdminCtx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 3000, false, true, 0) if err != nil { globals.SugarLogger.Debugf("jds GetStoreListByLocation error: %v", err.Error()) return order, err diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 3f5334ea3..1211d7732 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -547,12 +547,13 @@ func (c *StoreController) SyncStoresCourierInfo() { // @Param lng query float64 true "经度" // @Param lat query float64 true "纬度" // @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)" +// @Param brandID query int false "品牌ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetStoreListByLocation [get] func (c *StoreController) GetStoreListByLocation() { c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) { - retVal, err = common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false) + retVal, err = common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID) return retVal, "", err }) } diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index 249ffbce4..db960f0db 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -556,3 +556,18 @@ func (c *User2Controller) GetJxShopUsers() { return retVal, "", err }) } + +// @Title 更新用户上次浏览门店和品牌 +// @Description 更新用户上次浏览门店和品牌 +// @Param token header string true "认证token" +// @Param storeID formData int false "门店ID" +// @Param brandID formData int false "品牌ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /UpdateUserLastInfo [post] +func (c *User2Controller) UpdateUserLastInfo() { + c.callUpdateUserLastInfo(func(params *tUser2UpdateUserLastInfoParams) (retVal interface{}, errCode string, err error) { + err = cms.UpdateUserLastInfo(params.Ctx, params.StoreID, params.BrandID) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index ded41205a..e9603eecf 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -3240,6 +3240,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], + beego.ControllerComments{ + Method: "UpdateUserLastInfo", + Router: `/UpdateUserLastInfo`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ Method: "UpdateUserWxNoAndPercent",