From f2e52b14b40be0a7fd891b74ee59429d9e4099bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 3 Dec 2020 11:14:19 +0800 Subject: [PATCH] aa --- business/jxstore/tempop/tempop.go | 296 +++++++++++++----------------- 1 file changed, 125 insertions(+), 171 deletions(-) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 8fbd29d5c..2e2446166 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -14,6 +14,7 @@ import ( "github.com/qiniu/api.v7/storage" "git.rosy.net.cn/baseapi/platformapi/jdapi" + "git.rosy.net.cn/baseapi/platformapi/jdshopapi" "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils/errlist" @@ -1592,150 +1593,103 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // }, []int{0}) // tasksch.HandleTask(task, nil, true).Run() // _, err = task.GetResult(0) - // var ( - // storeMaps []*model.StoreMap - // db = dao.GetDB() - // ) - // sql := ` - // SELECT * from store_map where vendor_id = 5 and deleted_at = '1970-01-01 00:00:00' and vendor_org_code = 2 and vendor_store_id = '' - // ` - // err = dao.GetRows(db, &storeMaps, sql, nil) - // for _, v := range storeMaps { - // store, _ := dao.GetStoreDetail(db, v.StoreID, model.VendorIDJDShop, "") - // data, _, _ := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg) - // timeMap := map[string]string{ - // "businessBeginTime": int2TimeStr(int(store.OpenTime1)), - // "businessEndTime": int2TimeStr(int(store.CloseTime1)), - // } - // timeJSON, _ := json.Marshal(timeMap) - // createEntityStoreParam := &jdshopapi.CreateEntityStoreParam{ - // Name: "京西菜市" + strings.ReplaceAll(store.Name, "店", "") + "生鲜店", - // AddCode: store.JdsCode, - // AddCodeName: store.DistrictName, - // AddName: store.ProvinceName + store.CityName + store.DistrictName + "@!" + store.Address, - // Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)), - // Phone: store.Tel1, - // ExtendJSON: string(timeJSON), - // ImageFile: base64.StdEncoding.EncodeToString(data), - // CategoryName: "生鲜店", - // CustomerID: utils.Int2Str(store.ID), - // } - // if store.JdsStreetCode != 0 { - // createEntityStoreParam.AddCode = store.JdsStreetCode - // } - // if createEntityStoreParam.AddCode == 0 { - // createEntityStoreParam.AddCode = store.JdCode - // } - // //证明这个店可能隶属直辖市或者东莞 - // if model.ZXCityCodeMap[store.CityCode] != "" { - // result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat)) - // if result["regeocode"] != nil { - // street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string) - // if street != "" { - // result1, _ := api.JdShopAPI.GetProvince() - // for _, v := range result1 { - // if strings.Contains(store.CityName, v.AreaName) { - // result2, _ := api.JdShopAPI.GetCity(v.AreaID) - // for _, vv := range result2 { - // if strings.Contains(store.DistrictName, vv.AreaName) { - // result3, _ := api.JdShopAPI.GetCounty(vv.AreaID) - // for _, vvv := range result3 { - // if street == vvv.AreaName { - // createEntityStoreParam.AddCode = vvv.AreaID - // break - // } - // } - // } - // } - // } - // } - // } - // } - // } - // vendorStoreID, _ := api.JdShop2API.CreateEntityStore(createEntityStoreParam) - - // storeMap := &model.StoreMap{ - // StoreID: v.StoreID, - // VendorStoreID: vendorStoreID, - // VendorID: model.VendorIDJDShop, - // Status: 1, - // PricePercentage: 100, - // AutoPickup: 1, - // DeliveryType: 2, - // DeliveryCompetition: 1, - // IsSync: 1, - // PricePercentagePack: "京西100-100", - // VendorOrgCode: "2", - // JdsStreetCode: v.JdsStreetCode, - // JdsStreetName: v.JdsStreetName, - // } - // dao.WrapAddIDCULDEntity(storeMap, "jxadmin") - // if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil { - // api.JdShop2API.SetCookieWithStr(configs[0].Value) - // } - // for i := 1; i < 6; i++ { - // shopListResult, _ := api.JdShop2API.ShopList(i) - // for _, v := range shopListResult.List { - // var store *model.Store - // sql := ` - // SELECT a.* - // FROM store a - // JOIN store_map b ON a.id = b.store_id - // WHERE b.deleted_at = '1970-01-01 00:00:00' - // AND b.vendor_id = 5 - // AND b.vendor_store_id = ? - // AND b.vendor_org_code = 2 - // ` - // sqlParams := []interface{}{v.StoreID} - // err = dao.GetRow(dao.GetDB(), &store, sql, sqlParams) - // if strings.Contains(v.StoreName, "(") { - // v.StoreName = v.StoreName[0:strings.Index(v.StoreName, "(")] + v.StoreName[strings.Index(v.StoreName, ")")+3:len(v.StoreName)] - // } - // if strings.Contains(v.StoreName, ".") { - // v.StoreName = v.StoreName[0:strings.Index(v.StoreName, ".")] + v.StoreName[strings.Index(v.StoreName, ".")+1:len(v.StoreName)] - // } - // if shopDetailResult, err := api.JdShop2API.ShopDetail(v.StoreID); err == nil { - // if store.Licence != "" { - // data, _, _ := jxutils.DownloadFileByURL(store.Licence) - // fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)] - // url, _ := api.JdShop2API.UploadImageNew(data, fileName) - // ex := store.LicenceExpire - // if ex == "" { - // ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0)) - // } - // if !strings.Contains(ex, "00:00:00") { - // ex += " 00:00:00" - // } - // err = api.JdShop2API.UpdateBasic(&jdshopapi.UpdateBasicParam{ - // StoreID: v.StoreID, - // StoreName: v.StoreName, - // CategoryID2: 62, - // Coordinate: shopDetailResult.Coordinate, - // BussinessBeginTime: shopDetailResult.BussinessBeginTime, - // BussinessEndTime: shopDetailResult.BussinessEndTime, - // ImgURL: shopDetailResult.ImgURL, - // StorePhone: shopDetailResult.StorePhone, - // AddName: shopDetailResult.AddName, - // AddCode1: shopDetailResult.AddCode1, - // AddCode2: shopDetailResult.AddCode2, - // AddCode3: shopDetailResult.AddCode3, - // CategoryID1: 34, - // QualificationRequests: []*jdshopapi.QualificationRequests{ - // &jdshopapi.QualificationRequests{ - // QualificationID: 41, - // QualificationName: "营业执照", - // QualificationNo: store.LicenceCode, - // QualificationURL: url, - // StartTime: utils.Time2Str(utils.Str2Time(store.LicenceValid)), - // EndingTime: ex, - // Time: []string{utils.Time2Str(utils.Str2Time(store.LicenceValid)), ex}, - // }, - // }, - // }) - // } - // } - // } - // } + var ( + storeMaps []*model.StoreMap + db = dao.GetDB() + ) + if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil { + api.JdShop2API.SetCookieWithStr(configs[0].Value) + } + sql := ` + SELECT * from store_map where vendor_id = 5 and deleted_at = '1970-01-01 00:00:00' and vendor_org_code = 2 and store_id <> 667281 + AND store_id = 103075 + ` + err = dao.GetRows(db, &storeMaps, sql, nil) + for _, v := range storeMaps { + store, _ := dao.GetStoreDetail(db, v.StoreID, model.VendorIDJDShop, "2") + err = api.JdShop2API.DeleteStoresByID(utils.Str2Int64(store.VendorStoreID)) + data, _, _ := jxutils.DownloadFileByURL(jdshopapi.JdsStoreImg) + url, _ := api.JdShop2API.UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png") + ex := store.LicenceExpire + if ex == "" { + ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0)) + } + if !strings.Contains(ex, "00:00:00") { + ex += " 00:00:00" + } + data2, _, _ := jxutils.DownloadFileByURL(store.Licence) + fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)] + url2, _ := api.JdShop2API.UploadImageNew(data2, fileName) + if strings.Contains(v.StoreName, "(") { + v.StoreName = v.StoreName[0:strings.Index(v.StoreName, "(")] + v.StoreName[strings.Index(v.StoreName, ")")+3:len(v.StoreName)] + } + if strings.Contains(v.StoreName, ".") { + v.StoreName = v.StoreName[0:strings.Index(v.StoreName, ".")] + v.StoreName[strings.Index(v.StoreName, ".")+1:len(v.StoreName)] + } + if strings.Contains(v.StoreName, "-") { + v.StoreName = v.StoreName[0:strings.Index(v.StoreName, "-")] + v.StoreName[strings.Index(v.StoreName, "-")+1:len(v.StoreName)] + } + param := &jdshopapi.UpdateBasicParam{ + StoreName: "京西菜市" + strings.ReplaceAll(v.StoreName, "店", "") + "生鲜店", + CategoryID2: 62, + Coordinate: utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lat)) + "," + utils.Float64ToStr(jxutils.IntCoordinate2Standard(store.Lng)), + BussinessBeginTime: int2TimeStr(int(store.OpenTime1)), + BussinessEndTime: int2TimeStr(int(store.CloseTime1)), + ImgURL: url, + StorePhone: store.Tel1, + AddName: store.Address, + AddCode3: store.JdsCode, + CategoryID1: 34, + QualificationRequests: []*jdshopapi.QualificationRequests{ + &jdshopapi.QualificationRequests{ + QualificationID: 41, + QualificationName: "营业执照", + QualificationNo: store.LicenceCode, + QualificationURL: url2, + StartTime: utils.Time2Str(utils.Str2Time(store.LicenceValid)), + EndingTime: ex, + Time: []string{utils.Time2Str(utils.Str2Time(store.LicenceValid)), ex}, + }, + }, + } + if store.JdsStreetCode != 0 { + param.AddCode3 = store.JdsStreetCode + } + if param.AddCode3 == 0 { + param.AddCode3 = store.JdCode + } + //证明这个店可能隶属直辖市或者东莞 + if model.ZXCityCodeMap[store.CityCode] != "" { + result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat)) + if result["regeocode"] != nil { + street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string) + if street != "" { + result1, _ := api.JdShopAPI.GetProvince() + for _, v := range result1 { + if strings.Contains(store.CityName, v.AreaName) { + result2, _ := api.JdShopAPI.GetCity(v.AreaID) + for _, vv := range result2 { + if strings.Contains(store.DistrictName, vv.AreaName) { + result3, _ := api.JdShopAPI.GetCounty(vv.AreaID) + for _, vvv := range result3 { + if street == vvv.AreaName { + param.AddCode3 = vvv.AreaID + break + } + } + } + } + } + } + } + } + } + if vendorStroeID, err := api.JdShop2API.SubmitBasic(param); err == nil { + v.VendorStoreID = utils.Int64ToStr(vendorStroeID) + dao.UpdateEntity(db, v, "VendorStoreID") + err = api.JdShop2API.UpdateExpand(int(vendorStroeID)) + } + } // var ( // db = dao.GetDB() // ) @@ -1768,33 +1722,33 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // } // } // } - var ( - db = dao.GetDB() - ) - storeSkus, _ := dao.GetStoresSkusInfo(db, []int{model.JdShopMainStoreID2}, nil) - for _, v := range storeSkus { - if v.JdsID != 0 { - // if err = api.JdShop2API.StoreSkuBindStore(false, []string{utils.Int64ToStr(v.JdsID)}, []string{"1000063128"}); err == nil { - storeSkus2, _ := dao.GetStoresSkusInfo(db, []int{667281}, []int{v.SkuID}) - if len(storeSkus2) > 0 { - // status := storeSkus2[0].Status - // stock := storeSkus2[0].Stock - price := storeSkus2[0].Price - // if status == model.StoreSkuBindStatusNormal { - // api.JdShop2API.StoreWareDoUpdate(status, v.JdsID, "1000063128") - // } - // if stock != 0 { - // api.JdShop2API.StoreUpdateStock(stock, v.JdsID, "1000063128") - // } - api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), v.JdsID, "1000063128") - } else { - continue - } - // } - } else { - continue - } - } + // var ( + // db = dao.GetDB() + // ) + // storeSkus, _ := dao.GetStoresSkusInfo(db, []int{model.JdShopMainStoreID2}, nil) + // for _, v := range storeSkus { + // if v.JdsID != 0 { + // if err = api.JdShop2API.StoreSkuBindStore(false, []string{utils.Int64ToStr(v.JdsID)}, []string{"1000063128"}); err == nil { + // storeSkus2, _ := dao.GetStoresSkusInfo(db, []int{667281}, []int{v.SkuID}) + // if len(storeSkus2) > 0 { + // status := storeSkus2[0].Status + // stock := storeSkus2[0].Stock + // price := storeSkus2[0].Price + // if status == model.StoreSkuBindStatusNormal { + // api.JdShop2API.StoreWareDoUpdate(status, v.JdsID, "1000063128") + // } + // if stock != 0 { + // api.JdShop2API.StoreUpdateStock(stock, v.JdsID, "1000063128") + // } + // api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), v.JdsID, "1000063128") + // } else { + // continue + // } + // } + // } else { + // continue + // } + // } return err }