- avoid dada store name duplicated.

This commit is contained in:
gazebo
2019-02-18 21:42:09 +08:00
parent f8071859a3
commit 4740a057ff

View File

@@ -714,13 +714,13 @@ func RefreshMissingDadaStores(ctx *jxcontext.Context, storeID int, isAsync, isCo
_, err = api.DadaAPI.ShopDetail(utils.Int2Str(storeDetail.ID)) _, err = api.DadaAPI.ShopDetail(utils.Int2Str(storeDetail.ID))
if err != nil { if err != nil {
if codeErr, ok := err.(*utils.ErrorWithCode); ok && codeErr.IntCode() == dadaapi.ResponseCodeShopNotExist { if codeErr, ok := err.(*utils.ErrorWithCode); ok && codeErr.IntCode() == dadaapi.ResponseCodeShopNotExist {
_, err = api.DadaAPI.ShopAdd(utils.Int2Str(storeDetail.ID), storeDetail.Name, dadaapi.BusinessTypeConvStore, storeDetail.CityName, _, err = api.DadaAPI.ShopAdd(utils.Int2Str(storeDetail.ID), composeDadaStoreName(storeDetail), dadaapi.BusinessTypeConvStore, storeDetail.CityName,
storeDetail.DistrictName, storeDetail.Address, jxutils.IntCoordinate2Standard(storeDetail.Lng), jxutils.IntCoordinate2Standard(storeDetail.Lat), storeDetail.DistrictName, storeDetail.Address, jxutils.IntCoordinate2Standard(storeDetail.Lng), jxutils.IntCoordinate2Standard(storeDetail.Lat),
storeDetail.Tel1, storeDetail.Tel1, nil) storeDetail.Tel1, storeDetail.Tel1, nil)
} }
} else { } else {
params := map[string]interface{}{ params := map[string]interface{}{
"station_name": storeDetail.Name, "station_name": composeDadaStoreName(storeDetail),
"business": dadaapi.BusinessTypeConvStore, "business": dadaapi.BusinessTypeConvStore,
"city_name": storeDetail.CityName, "city_name": storeDetail.CityName,
"area_name": storeDetail.DistrictName, "area_name": storeDetail.DistrictName,
@@ -749,3 +749,7 @@ func RefreshMissingDadaStores(ctx *jxcontext.Context, storeID int, isAsync, isCo
} }
return hint, err return hint, err
} }
func composeDadaStoreName(store *dao.StoreDetail2) (storeName string) {
return storeDetail.Name + "-" + utils.Int2Str(store.ID)
}