diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index f49997f1d..a0ce88a6d 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -3455,3 +3455,82 @@ func UpdateStorePricePack(ctx *jxcontext.Context, storeID, vendorID int, pricePa } return err } + +func GetJdDeliveryArea(ctx *jxcontext.Context, storeIDs []int) (err error) { + type tmp struct { + JdID string `json:"jdID"` + S int `json:"s"` + } + type SpecialtyStoreSkus struct { + StoreID int `json:"门店ID"` + StoreName string `json:"门店名"` + City string `json:"城市"` + Area int `json:"面积"` + } + var ( + ss []*tmp + excelTitle = []string{ + "门店ID", + "门店名", + "城市", + "面积", + } + sheetList []*excel.Obj2ExcelSheetConfig + specialtyStoreSkus []*SpecialtyStoreSkus + downloadURL, fileName string + ) + storeMaps, _ := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDJD}, storeIDs, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "") + for _, v := range storeMaps { + time.Sleep(time.Second / 3) + station, err := jd.GetAPI("320406").GetDeliveryRangeByStationNo2(v.VendorStoreID) + if err != nil { + continue + } + if station.DeliveryRangeType == 2 { + strs := strings.Split(station.DeliveryRange, ";") + ss = append(ss, &tmp{ + JdID: v.VendorStoreID, + S: utils.Float64TwoInt(math.Ceil((jxutils.ComputeSignedArea(strs[:len(strs)-1])))), + }) + } + } + for i := 0; i < len(ss)-1; i++ { + for j := 0; j < len(ss)-1-i; j++ { + if ss[j].S > ss[j+1].S { + temp := ss[j] + ss[j] = ss[j+1] + ss[j+1] = temp + } + } + } + for _, v := range ss { + storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), v.JdID, model.VendorIDJD) + place, _ := dao.GetPlaceByCode(dao.GetDB(), storeDetail.CityCode) + specialtyStoreSku := &SpecialtyStoreSkus{ + StoreID: storeDetail.ID, + StoreName: storeDetail.Name, + City: place.Name, + Area: v.S, + } + specialtyStoreSkus = append(specialtyStoreSkus, specialtyStoreSku) + } + excelConf := &excel.Obj2ExcelSheetConfig{ + Title: "sheet1", + Data: specialtyStoreSkus, + CaptionList: excelTitle, + } + sheetList = append(sheetList, excelConf) + if excelConf != nil { + downloadURL, fileName, err = jxutils.UploadExeclAndPushMsg(sheetList, "面积") + } else { + baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess is nil!") + } + if err != nil { + baseapi.SugarLogger.Errorf("WriteToExcel:upload %s , %s failed error:%v", fileName, err) + } else { + noticeMsg := fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL) + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, ctx.GetUserID(), "异步任务完成", noticeMsg) + baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess downloadURL: [%v]", downloadURL) + } + return err +} diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 175c81f03..f4df58aee 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -9,7 +9,6 @@ import ( "time" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" - "git.rosy.net.cn/jx-callback/business/jxcallback/orderman" "git.rosy.net.cn/jx-callback/business/partner/delivery" "github.com/360EntSecGroup-Skylar/excelize" "github.com/qiniu/api.v7/storage" @@ -1585,82 +1584,7 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // fmt.Println("updateList2", utils.Format4Output(updateList, false)) // fmt.Println("deleteList2", deleteList) // cms.DeletedDuplicateWaitAuditData(ctx, dao.GetDB()) - // type tmp struct { - // JdID string `json:"jdID"` - // S int `json:"s"` - // } - // type SpecialtyStoreSkus struct { - // StoreID int `json:"门店ID"` - // StoreName string `json:"门店名"` - // City string `json:"城市"` - // Area int `json:"面积"` - // } - // var ( - // ss []*tmp - // excelTitle = []string{ - // "门店ID", - // "门店名", - // "城市", - // "面积", - // } - // sheetList []*excel.Obj2ExcelSheetConfig - // specialtyStoreSkus []*SpecialtyStoreSkus - // downloadURL, fileName string - // ) - // storeMaps, _ := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDJD}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "") - // for _, v := range storeMaps { - // time.Sleep(time.Second / 3) - // station, err := jd.GetAPI("320406").GetDeliveryRangeByStationNo2(v.VendorStoreID) - // if err != nil { - // continue - // } - // if station.DeliveryRangeType == 2 { - // strs := strings.Split(station.DeliveryRange, ";") - // ss = append(ss, &tmp{ - // JdID: v.VendorStoreID, - // S: utils.Float64TwoInt(math.Ceil((jxutils.ComputeSignedArea(strs[:len(strs)-1])))), - // }) - // } - // } - // for i := 0; i < len(ss)-1; i++ { - // for j := 0; j < len(ss)-1-i; j++ { - // if ss[j].S > ss[j+1].S { - // temp := ss[j] - // ss[j] = ss[j+1] - // ss[j+1] = temp - // } - // } - // } - // for _, v := range ss { - // storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), v.JdID, model.VendorIDJD) - // place, _ := dao.GetPlaceByCode(dao.GetDB(), storeDetail.CityCode) - // specialtyStoreSku := &SpecialtyStoreSkus{ - // StoreID: storeDetail.ID, - // StoreName: storeDetail.Name, - // City: place.Name, - // Area: v.S, - // } - // specialtyStoreSkus = append(specialtyStoreSkus, specialtyStoreSku) - // } - // excelConf := &excel.Obj2ExcelSheetConfig{ - // Title: "sheet1", - // Data: specialtyStoreSkus, - // CaptionList: excelTitle, - // } - // sheetList = append(sheetList, excelConf) - // if excelConf != nil { - // downloadURL, fileName, err = jxutils.UploadExeclAndPushMsg(sheetList, "面积") - // } else { - // baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess is nil!") - // } - // if err != nil { - // baseapi.SugarLogger.Errorf("WriteToExcel:upload %s , %s failed error:%v", fileName, err) - // } else { - // noticeMsg := fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL) - // ddmsg.SendUserMessage(dingdingapi.MsgTyeText, ctx.GetUserID(), "异步任务完成", noticeMsg) - // baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess downloadURL: [%v]", downloadURL) - // } - orderman.RefreshJdShopOrdersEarningPrice(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -2).Format("20060102"), time.Now().Format("20060102")) + // orderman.RefreshJdShopOrdersEarningPrice(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -2).Format("20060102"), time.Now().Format("20060102")) return err } diff --git a/controllers/cms_store.go b/controllers/cms_store.go index eb65996a1..58d4a15ef 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -808,3 +808,20 @@ func (c *StoreController) GetNearSupplyGoodsStoreByStoreID() { return retVal, "", err }) } + +// @Title 获取京东门店手动划的配送范围面积 +// @Description 获取京东门店手动划的配送范围面积 +// @Param token header string true "认证token" +// @Param storeIDs query int true "门店IDs" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetJdDeliveryArea [get] +func (c *StoreController) GetJdDeliveryArea() { + var storeIDs []int + c.callGetJdDeliveryArea(func(params *tStoreGetJdDeliveryAreaParams) (retVal interface{}, errCode string, err error) { + if jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { + err = cms.GetJdDeliveryArea(params.Ctx, storeIDs) + } + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index cc4663135..20f774aea 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1836,6 +1836,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"], + beego.ControllerComments{ + Method: "GetJdDeliveryArea", + Router: `/GetJdDeliveryArea`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"], beego.ControllerComments{ Method: "GetNearSupplyGoodsStoreByStoreID",