京东商城直辖市问题解决

This commit is contained in:
苏尹岚
2020-06-30 09:20:51 +08:00
parent 31cc598455
commit b8e330dd1a
2 changed files with 33 additions and 0 deletions

View File

@@ -151,6 +151,14 @@ var (
VendorIDEBAI: 0,
}
ZXCityCodeMap = map[int]string{
310100: "上海市",
110100: "北京市",
120100: "天津市",
440300: "深圳市",
500100: "重庆市",
}
PrinterVendorInfo = map[int][]string{
VendorIDFeiE: []string{
VendorChineseNames[VendorIDFeiE],

View File

@@ -105,6 +105,31 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
if createEntityStoreParam.AddCode == 0 {
createEntityStoreParam.AddCode = store.JdCode
}
//证明这个店可能隶属直辖市
if model.ZXCityCodeMap[store.CityCode] != "" {
result1, _ := api.JdShopAPI.GetProvince()
for _, v := range result1 {
if v.AreaName == model.ZXCityCodeMap[store.CityCode] {
result2, _ := api.JdShopAPI.GetCity(v.AreaID)
for _, vv := range result2 {
if vv.AreaName == store.DistrictName {
result3, _ := api.JdShopAPI.GetCounty(vv.AreaID)
for _, vvv := range result3 {
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 != "" {
if street == vvv.AreaName {
createEntityStoreParam.AddCode = vvv.AreaID
}
}
}
}
}
}
}
}
}
vendorStoreID, err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
return vendorStoreID, err
}