diff --git a/business/partner/purchase/jdshop/store.go b/business/partner/purchase/jdshop/store.go index 03c45c509..ea0f395ac 100644 --- a/business/partner/purchase/jdshop/store.go +++ b/business/partner/purchase/jdshop/store.go @@ -68,11 +68,141 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin updateEntityStoreParam.AddCode = store.JdCode } err = api.JdShopAPI.UpdateEntityStore(updateEntityStoreParam) + url, _ := getAPI("2").UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png") + ex := store.LicenceExpire + if ex == "" { + ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(20, 0, 0)) + } + if !strings.Contains(ex, "00:00:00") { + ex += " 00:00:00" + } + var url2 string + if store.Licence != "" { + data2, _, _ := jxutils.DownloadFileByURL(store.Licence) + fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)] + url2, _ = getAPI("2").UploadImageNew(data2, fileName) + } + storeName := store.Name + if strings.Contains(storeName, "(") { + storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)] + } + if strings.Contains(storeName, "(") { + storeName = storeName[0:strings.Index(storeName, "(")] + storeName[strings.Index(storeName, ")")+3:len(storeName)] + } + if strings.Contains(storeName, ".") { + storeName = strings.ReplaceAll(storeName, ".", "") + } + if strings.Contains(storeName, "-") { + storeName = strings.ReplaceAll(storeName, "-", "") + } + if strings.Contains(storeName, " ") { + storeName = strings.ReplaceAll(storeName, " ", "") + } + storeName = "京西菜市" + strings.ReplaceAll(storeName, "店", "") + "生鲜店" + if len(storeName) > 30 { + storeName = utils.LimitUTF8StringLen2(storeName, 30) + } if err == nil { - // if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 { - // mergeStatus := jxutils.MergeStoreStatus(store.Status, store.VendorStatus) - // err = api.JdShopAPI.UpdateStoreStatus(utils.Str2Int(store.VendorStoreID), jxStatus2JdsStatus(mergeStatus)) - // } + param := &jdshopapi.UpdateBasicParam{ + StoreName: storeName, + CategoryID2: 4, + 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: 3, + } + var ( + url3 string + idCode string + startTime string + ) + if store.IDCardFront != "" { + data2, _, _ := jxutils.DownloadFileByURL(store.IDCardFront) + fileName := store.IDCardFront[strings.LastIndex(store.IDCardFront, "/")+1 : len(store.IDCardFront)] + url3, _ = api.JdShopAPI.UploadImageNew(data2, fileName) + } else { + data2, _, _ := jxutils.DownloadFileByURL("http://image.jxc4.com/image/a9bfc170a950ab9a4c76bd10b48b222b.tem.jpg") + fileName := "a9bfc170a950ab9a4c76bd10b48b222b.tem.jpg" + url3, _ = api.JdShopAPI.UploadImageNew(data2, fileName) + } + if store.IDCode == "" { + idCode = "610126198012230014" + } else { + idCode = store.IDCode + } + if store.IDValid == "" { + startTime = "2013-01-25 00:00:00" + } else { + startTime = utils.Time2Str(utils.Str2Time(store.IDValid)) + } + ex2 := store.IDExpire + if ex2 == "" { + ex2 = utils.Time2Str(utils.Str2Time(store.IDValid).AddDate(20, 0, 0)) + } + if !strings.Contains(ex2, "00:00:00") { + ex2 += " 00:00:00" + } + if url2 != "" { + param.CategoryID1 = 34 + param.CategoryID2 = 62 + param.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}, + }, + &jdshopapi.QualificationRequests{ + QualificationID: 42, + QualificationName: "身份证件", + QualificationNo: idCode, + QualificationURL: url3, + StartTime: startTime, + EndingTime: ex2, + Time: []string{startTime, ex2}, + }, + } + } + if store.JdsStreetCode != 0 { + param.AddCode3 = store.JdsStreetCode + } + if updateEntityStoreParam.AddCode == 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 + } + } + } + } + } + } + } + } + } + _, err = getAPI("2").SubmitBasic(param) } return err }