From 7feac44223a8732a73cbcc86caead61ad48b77f4 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 14 Mar 2023 10:01:05 +0800 Subject: [PATCH] update --- consume/canal_guide_order_consume.go | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/consume/canal_guide_order_consume.go b/consume/canal_guide_order_consume.go index 79c9f8e..e3388d3 100644 --- a/consume/canal_guide_order_consume.go +++ b/consume/canal_guide_order_consume.go @@ -147,23 +147,25 @@ func getUserAddress(Db *xorm.Engine, uid string, geoIp2db *geoip2.DBReader) (pro if err != nil { return } - utils.FilePutContents("getUserAddress", utils.SerializeStr(userLoginIpList)) - record, _ := geoIp2db.City(net.ParseIP(userLoginIpList.NowIp)) - if record.Country.Names != nil && record.Subdivisions != nil && record.City.Names != nil { - province, err := db.ProvinceGetOneByName(record.Subdivisions[0].Names["zh-CN"]) - if err != nil { - return - } - provinceId = province.Id - provinceName = province.Name + if userLoginIpList != nil { + utils.FilePutContents("getUserAddress", utils.SerializeStr(userLoginIpList)) + record, _ := geoIp2db.City(net.ParseIP(userLoginIpList.NowIp)) + if record.Country.Names != nil && record.Subdivisions != nil && record.City.Names != nil { + province, err := db.ProvinceGetOneByName(record.Subdivisions[0].Names["zh-CN"]) + if err != nil { + return + } + provinceId = province.Id + provinceName = province.Name - city, err := db.CityGetOneByName(record.City.Names["zh-CN"]) - if err != nil { + city, err := db.CityGetOneByName(record.City.Names["zh-CN"]) + if err != nil { + return + } + cityId = city.Id + cityName = city.Name return } - cityId = city.Id - cityName = city.Name - return } //TODO::没开区域代理的,默认归属到广东 provinceName = "广东省"