diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index f838bfffc..949f35afd 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -161,7 +161,6 @@ func getFixedTokenName(token string) *AuthInfo { func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) { token, tokenType := createToken(user, authBindInfo) //user为空 tokenType=2 - globals.SugarLogger.Debug("token,tokenType,user============", token, tokenType, user) expireDuration := DefTokenDuration authInfo = &AuthInfo{ AuthBindInfo: authBindInfo, @@ -249,7 +248,6 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string } realAuthID = user.GetID() } - globals.SugarLogger.Debug("打印realAuthID检测是否为空==================", realAuthID) if authBindEx, err = handler.VerifySecret(realAuthID, authSecret); err == nil { globals.SugarLogger.Debugf("Login authBindEx", utils.Format4Output(authBindEx, false)) if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体) @@ -383,7 +381,6 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) { } else { if handler := authers[newAuthInfo.AuthBindInfo.Type]; handler != nil { newAuthInfo.AuthBindInfo.UserID = user.GetID() - globals.SugarLogger.Debug("进入AddAuthBind获取userID", newAuthInfo.AuthBindInfo.UserID) handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), newAuthInfo.GetAuthTypeID(), user.GetName()) err = handler.AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName()) } else { diff --git a/business/auth2/authprovider/douyin/tiktop_mini.go b/business/auth2/authprovider/douyin/tiktop_mini.go index 41c3ec5cf..4de2ea799 100644 --- a/business/auth2/authprovider/douyin/tiktop_mini.go +++ b/business/auth2/authprovider/douyin/tiktop_mini.go @@ -96,10 +96,8 @@ func getWxApp(appID string) (miniApi *weixinapi.API) { func getTikTokApp(appID string) (TikTokMini *tiktok.API) { TikTokMini = api.TiktokApi if len(appID) > 0 && appID == api.TiktokJXDJApiID { - globals.SugarLogger.Debug("我进入这里了") TikTokMini = api.TiktokJXDJApi } - globals.SugarLogger.Debug("输出一下TikTokMini", TikTokMini) return TikTokMini } func splitCode(code string) (appID, realCode string) { diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index cb86159f8..a07288289 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1041,6 +1041,7 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf if retryCount > 0 { utils.AfterFuncWithRecover(duration, func() { jxutils.CallMsgHandlerAsync(func() { + s.SelfDeliverDelivering(order, "非专送、快送、混合送订单,转自送失败,调用deriving转自送") s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, retryCount-1, duration) }, jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID)) }) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 7d0d64200..2da8f76aa 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "git.rosy.net.cn/jx-callback/business/jxstore/common" "git.rosy.net.cn/jx-callback/business/jxstore/event" "io" "math" @@ -120,6 +121,32 @@ type VendorStoreExcel struct { OperatorName3 string `json:"运营负责人3"` } +//首页展示信息 +type HomePageInfos struct { + StoreID int `json:"storeID"` //门店ID + StoreName string `json:"storeName"` //门店名字 + OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 + CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 + OpenTime2 int16 `json:"openTime2"` // 营业时间2 + CloseTime2 int16 `json:"closeTime2"` + Status int `json:"status"` //门店是否营业 + Distance int `json:"distance"` //店铺与定位 直线距离 + BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID + BrandName string `json:"brandName"` //品牌名字 + BrandLogo string `json:"brandLogo"` //品牌logo + //热销商品信息 + SkuID int `json:"skuID"` //商品ID + SkuName string `json:"skuName"` //商品名字 + SkuStatus int `json:"skuStatus"` //商品是否可售状态 1可售 0不可售 + BestSeller int `json:"bestSeller"` //畅销品 0不是 1是 + Img string `json:"img"` //商品第一张图片 + Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量 + Unit string `json:"unit"` //商品售卖单位 份/kg等 + //减运策略 + DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额 + DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额 +} + type JdStoreLevelExt struct { Level string `json:"level` PageNo int `json:"pageNo"` @@ -518,6 +545,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa var storeIDs []int if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err == nil { for _, v := range storeIDs { + globals.SugarLogger.Debug("storeIDs===============", v) if storeIDsMap[v] != 0 { storeIDs2 = append(storeIDs2, v) } @@ -5626,3 +5654,69 @@ func UpdateStoreTemplate(ctx *jxcontext.Context, storeID int, content, sound str _, err = dao.UpdateEntity(db, store, "PrinterTemplate", "PrinterSound") return err } + +//条件过滤 B2B、物料店 +func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*common.Store4User, errCode string, err error) { + userAuth, err := auth2.GetTokenInfo(token) + if err != nil { + return nil, "", err + } + user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1) + if err != nil { + return nil, "", err + } + // 获取位置附近门店列表 + storeIDs := make([]int, 0, len(locationList)) + for _, v := range locationList { + storeIDs = append(storeIDs, v.ID) + } + // 判断门店是不是b2b门店,如果是,用户必须为系统管理员(门店老板和运营人员) + store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "") + if err != nil { + return nil, "", err + } + + isMatterStore := false + for _, v := range storeIDs { + if v == model.MatterStoreID { + isMatterStore = true + } + } + + result := make([]*common.Store4User, 0, 0) + for _, v := range store { + for _, s := range locationList { + if v.ID == s.ID { + if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店 + continue + } else { + result = append(result, s) + } + } + } + } + + if total != model.YES { + return result, "", errors.New("") + } + if user[0].Type != model.YES { + return locationList, "", nil + } else { + return result, "", err + } +} + +//首页信息展示 +//func GetHomePageByLocation(ctx *jxcontext.Context, params map[string]interface{}) (interface{}, string, error) { +// //获取门店信息 +// timeList, err := jxutils.BatchStr2Time("1970-01-01 00:00:00 +0800 CST", "1970-01-01 00:00:00 +0800 CST") +// if err != nil { +// return nil, "", err +// } +// store, err := GetStores(ctx, "", params, 0, 0, timeList[0], timeList[1], 0, 0) +// //获取热销商品 +// +// //获取满减策略 +// +// return nil, "", nil +//} diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index 633033604..5ba93357d 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -3,7 +3,6 @@ package localjx import ( "errors" "fmt" - "git.rosy.net.cn/baseapi/platformapi/tiktok" "math" "regexp" "strings" @@ -326,15 +325,15 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType err = dao.CreateEntity(dao.GetDB(), orderPay) } case model.PayTypeTL: - if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID { - subAppID = model.JXC4AppId // 京西商城 - } + //if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID { + // subAppID = model.JXC4AppId // 京西商城 + //} if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil { dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName()) err = dao.CreateEntity(dao.GetDB(), orderPay) } case model.PayTypeTicTok: - if orderPay, err = pay4OrderByTT(ctx, order, vendorPayType); err == nil && orderPay != nil { + if orderPay, err = pay4OrderByTT(ctx, order, vendorPayType, subAppID); err == nil && orderPay != nil { dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName()) err = dao.CreateEntity(dao.GetDB(), orderPay) } @@ -1017,7 +1016,11 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64 // 订单超过一千配送费优惠(门店运费) discountPrice, err := cms.GetStoreVendorMaps(ctx, nil, jxOrder.StoreID, -1) if len(discountPrice) == 1 && outJxOrder.OrderPrice >= int64(discountPrice[0].DeliveryFeeDeductionSill) { - outJxOrder.FreightPrice = outJxOrder.FreightPrice - int64(discountPrice[0].DeliveryFeeDeductionFee) + if outJxOrder.FreightPrice-int64(discountPrice[0].DeliveryFeeDeductionFee) >= 0 { + outJxOrder.FreightPrice = outJxOrder.FreightPrice - int64(discountPrice[0].DeliveryFeeDeductionFee) + } else { + outJxOrder.FreightPrice = 0 + } } // ?????????????????????? 测试 if storeDetail.ID == 668470 || storeDetail.ID == 668469 { @@ -1553,6 +1556,7 @@ func changeOrderStatus(vendorOrderID string, status int, remark string) (err err StatusTime: time.Now(), Remark: remark, } + globals.SugarLogger.Debug("检测数据orderStatus.Status", status, orderStatus.Status) jxutils.CallMsgHandlerAsync(func() { err = partner.CurOrderManager.OnOrderStatusChanged("", orderStatus) }, jxutils.ComposeUniversalOrderID(vendorOrderID, model.VendorIDJX)) diff --git a/business/partner/purchase/jx/localjx/order_test.go b/business/partner/purchase/jx/localjx/order_test.go index d3eea832a..2d1070fc6 100644 --- a/business/partner/purchase/jx/localjx/order_test.go +++ b/business/partner/purchase/jx/localjx/order_test.go @@ -17,8 +17,8 @@ func init() { func TestGenOrderNo(t *testing.T) { loc, _ := time.LoadLocation("Local") - t1, _ := time.ParseInLocation("20060102150405", time.Unix(1654510539,0).Format("20060102150405"), loc) - fmt.Println("t1",t1) + t1, _ := time.ParseInLocation("20060102150405", time.Unix(1654510539, 0).Format("20060102150405"), loc) + fmt.Println("t1", t1) } func TestGetAvailableDeliverTime(t *testing.T) { @@ -28,3 +28,7 @@ func TestGetAvailableDeliverTime(t *testing.T) { } t.Log(utils.Format4Output(timeInfo, false)) } +func TestChangeStatus(t *testing.T) { + err := changeOrderStatus("88398619646640", 115, "") + fmt.Println(err) +} diff --git a/business/partner/purchase/jx/localjx/tiktokPay.go b/business/partner/purchase/jx/localjx/tiktokPay.go index 592506384..ebac7bfc9 100644 --- a/business/partner/purchase/jx/localjx/tiktokPay.go +++ b/business/partner/purchase/jx/localjx/tiktokPay.go @@ -18,9 +18,9 @@ func getOrderBriefTt(order *model.GoodsOrder) string { return fmt.Sprintf("%s等共%d件商品", order.Skus[0].SkuName, order.GoodsCount) } -func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayType string) (orderPay *model.OrderPay, err error) { +func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) { param := &tiktok.TickTokCreateOrder{ - AppID: api.TiktokApi.GetAppID(), + //AppID: api.TiktokApi.GetAppID(), OutOrderNo: utils.Int64ToStr(GenPayOrderID(order)), TotalAmount: int(order.ActualPayPrice), Subject: "蔬菜水果日用品", @@ -29,14 +29,18 @@ func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp CpExtra: "msg", NotifyURL: globals.TictokpayNotifyURL, } - - ttOrderId, orderToken, err := api.TiktokApi.CreateOrderByTicktock(param) + if subAppID == tiktok.TiktokJXDJAppID { + param.AppID = api.TiktokJXDJApi.GetAppID() + } else { + param.AppID = api.TiktokApi.GetAppID() + } + globals.SugarLogger.Debug("打印param", param) + ttOrderId, orderToken, err := getTikTok(subAppID).CreateOrderByTicktock(param) if err == nil { orderPay = &model.OrderPay{ PayOrderID: ttOrderId, // 抖音订单id PayType: model.PayTypeTicTok, VendorPayType: vendorPayType, - VendorOrderID: order.VendorOrderID, VendorID: order.VendorID, Status: 0, @@ -48,7 +52,14 @@ func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp } return orderPay, err } - +func getTikTok(appID string) (TikTokMini *tiktok.API) { + TikTokMini = api.TiktokApi + if len(appID) > 0 && appID == api.TiktokJXDJApiID { + TikTokMini = api.TiktokJXDJApi + } + globals.SugarLogger.Debug("输出TikTokMini", TikTokMini) + return TikTokMini +} func OnTTPayCallback(msg *tiktok.DetailCallBackMessage, refund *tiktok.DetailCallBackMessage2Refund, payType string) (err error) { globals.SugarLogger.Debugf("OnTTPayCallback msg:%s", utils.Format4Output(msg, true)) switch payType { diff --git a/controllers/auth2.go b/controllers/auth2.go index 27ac53507..dcf855b97 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -116,6 +116,7 @@ func (c *Auth2Controller) TiktokDecrypt() { // @router /Login [post] func (c *Auth2Controller) Login() { c.callLogin(func(params *tAuth2LoginParams) (retVal interface{}, errCode string, err error) { + globals.SugarLogger.Debug("params.AuthType==============", params.AuthType) if params.AuthType == auth2.AuthTypeMobile { params.AuthIDType = auth2.UserIDMobile } else if params.AuthType == auth2.AuthTypeEmail { @@ -133,14 +134,18 @@ func (c *Auth2Controller) Login() { params.AuthSecret = GetComposedCode2(&c.Controller, params.AuthSecret) } ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request) + globals.SugarLogger.Debug("params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret==============", params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret) authInfo, err := auth2.Login(ctx, params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret) + globals.SugarLogger.Debug("authInfo==============", authInfo) // TODO 兼容没有取到authid2的错误 if err == nil && authInfo.AuthBindInfo != nil { if authInfo.AuthBindInfo.AuthID2 == "" { + globals.SugarLogger.Debug("fgfggggggg") authInfo.AuthBindInfo.AuthID2 = authInfo.AuthBindInfo.AuthID } retVal = authInfo } + globals.SugarLogger.Debug("retVal==============", retVal) return retVal, "", err }) } @@ -343,6 +348,7 @@ func (c *Auth2Controller) AddAuthBindWithMobile() { if err != nil { return retVal, "", err } + globals.SugarLogger.Debug("打印newAuthInfo==============", newAuthInfo) err = auth2.AddAuthBindWithMobile(newAuthInfo, params.Mobile) return retVal, "", err }) diff --git a/controllers/cms_store.go b/controllers/cms_store.go index dd1413b75..834498c03 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -1,9 +1,7 @@ package controllers import ( - "errors" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxstore/common" "git.rosy.net.cn/jx-callback/business/jxstore/misc" @@ -11,8 +9,6 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" ) @@ -595,57 +591,10 @@ func (c *StoreController) SyncStoresCourierInfo() { func (c *StoreController) GetStoreListByLocation() { c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) { locationList, err := common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID) - //if params.Token == "tempToken" { - // return locationList, "", nil - //} if params.Token != "" { - // 获取用户权限,如果是普通用户不展示b2b相关目录,如果是门店老板或者管理则展示全部 - userAuth, err := auth2.GetTokenInfo(params.Token) + result, _, err := cms.FilterByB2B(locationList, params.Token) if err != nil { return nil, "", err - } - user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1) - if err != nil { - return nil, "", err - } - globals.SugarLogger.Debug("检测数据userAuth,user,total==============", userAuth, user, total) - // 获取位置附近门店列表 - storeIDs := make([]int, 0, len(locationList)) - for _, v := range locationList { - storeIDs = append(storeIDs, v.ID) - } - globals.SugarLogger.Debug("检测数据locationList,storeIDs==============", locationList, storeIDs) - // 判断门店是不是b2b门店,如果是,用户必须为系统管理员(门店老板和运营人员) - store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "") - if err != nil { - return nil, "", err - } - - isMatterStore := false - for _, v := range storeIDs { - if v == model.MatterStoreID { - isMatterStore = true - } - } - - result := make([]*common.Store4User, 0, 0) - for _, v := range store { - for _, s := range locationList { - if v.ID == s.ID { - if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店 - continue - } else { - result = append(result, s) - } - } - } - } - - if total != model.YES { - return result, "", errors.New("") - } - if user[0].Type != model.YES { - return locationList, "", nil } else { return result, "", err } @@ -654,6 +603,34 @@ func (c *StoreController) GetStoreListByLocation() { }) } +// @Title 根据位置得到首页商店详细信息 +// @Description 根据位置得到首页商店详细信息 +// @Param token header string false "认证token" +// @Param lng query float64 true "经度" +// @Param lat query float64 true "纬度" +//@Param storeID query string false "门店ID" +// @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)" +// @Param brandID query int false "品牌ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetHomePageByLocation [get] +//func (c *StoreController) GetHomePageByLocation() { +// c.callGetHomePageByLocation(func(params *tStoreGetHomePageByLocationParams) (interface{}, string, error) { +// details, _, err := cms.GetHomePageByLocation(params.Ctx, params.MapData) +// if err != nil { +// return nil, "根据经纬度获取门店详细信息失败", err +// } +// if params.Token != "" { +// utils.Str2Int() +// //获取店铺基本信息 +// //storeDetail := cms.GetStores(params.Ctx, params.Keyword, params.MapData, params.Offset, params.PageSize, timeList[0], timeList[1], params.OrderCountFrom, params.OrderCountTo) +// //retVal, err = cms.GetStoreVendorMaps(params.Ctx, nil, utils.Interface2String(), params.VendorID) +// } +// //return locationList, "", err +// return nil, "", err +// }) +//} + // @Title 老格恢复拓店进度 // @Description 老格恢复拓店进度 // @Param token header string true "认证token" diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 344499a4a..b70369015 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -1,11 +1,10 @@ package controllers import ( + "git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/baseapi/platformapi/jdapi" - "errors" "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxutils"