- 适应快递API接口变更

This commit is contained in:
gazebo
2019-07-23 09:24:17 +08:00
parent 06c0929122
commit 3d4d539ab1
5 changed files with 120 additions and 35 deletions

View File

@@ -24,6 +24,7 @@ import (
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/delivery/dada"
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
@@ -997,7 +998,7 @@ func AddStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
if vendorID == model.VendorIDDada {
storeList, err2 := dao.GetMissingDadaStores(db, storeID, false)
if err = err2; err == nil && len(storeList) > 0 {
storeList[0].DadaStoreID = storeCourierMap.VendorStoreID
storeList[0].VendorStoreID = storeCourierMap.VendorStoreID
err = updateOrCreateDadaStore(storeList[0])
} else {
globals.SugarLogger.Debugf("AddStoreCourierMap GetMissingDadaStores error:%v, len(storeList):%d", err, len(storeList))
@@ -1069,7 +1070,7 @@ func RefreshMissingDadaStores(ctx *jxcontext.Context, storeID int, isAsync, isCo
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
storeDetail := batchItemList[0].(*dao.StoreDetail2)
var resultList []interface{}
if storeDetail.DadaStoreID == "" {
if storeDetail.VendorStoreID == "" {
if storeDetail.DistrictName == "" || storeDetail.CityName == "" {
return nil, fmt.Errorf("门店:%s的城市码或区码有错误", storeDetail.Name)
}
@@ -1102,36 +1103,16 @@ func updateOrCreateDadaStore(storeDetail *dao.StoreDetail2) (err error) {
if storeDetail.CityName == "" {
return fmt.Errorf("门店的城市码有问题,请检查")
}
if dadaDistrictMap[storeDetail.DistrictName] != "" {
if dadaDistrictMap[storeDetail.DistrictName] == "1" { // 区镇信息
storeDetail.CityName = storeDetail.DistrictName
storeDetail.DistrictName, _ = api.AutonaviAPI.GetCoordinateTownInfo(jxutils.IntCoordinate2Standard(storeDetail.Lng), jxutils.IntCoordinate2Standard(storeDetail.Lat))
}
if dadaDistrictMap[storeDetail.DistrictName] != "" {
storeDetail.DistrictName = dadaDistrictMap[storeDetail.DistrictName]
}
}
storeDetail.CourierStoreName = composeDadaStoreName(storeDetail)
if globals.EnableStoreWrite {
_, err = api.DadaAPI.ShopDetail(storeDetail.DadaStoreID)
_, err = api.DadaAPI.ShopDetail(storeDetail.VendorStoreID)
if err != nil {
if codeErr, ok := err.(*utils.ErrorWithCode); ok && codeErr.IntCode() == dadaapi.ResponseCodeShopNotExist {
_, err = api.DadaAPI.ShopAdd(storeDetail.DadaStoreID, composeDadaStoreName(storeDetail), dadaapi.BusinessTypeConvStore, storeDetail.CityName,
storeDetail.DistrictName, storeDetail.Address, jxutils.IntCoordinate2Standard(storeDetail.Lng), jxutils.IntCoordinate2Standard(storeDetail.Lat),
storeDetail.Tel1, storeDetail.Tel1, nil)
_, err = api.DadaAPI.ShopAdd(dada.StoreDetail2ShopInfo(storeDetail))
}
} else {
params := map[string]interface{}{
"station_name": composeDadaStoreName(storeDetail),
"business": dadaapi.BusinessTypeConvStore,
"city_name": storeDetail.CityName,
"area_name": storeDetail.DistrictName,
"station_address": storeDetail.Address,
"lng": jxutils.IntCoordinate2Standard(storeDetail.Lng),
"lat": jxutils.IntCoordinate2Standard(storeDetail.Lat),
"contact_name": storeDetail.Tel1,
"phone": storeDetail.Tel1,
}
err = api.DadaAPI.ShopUpdate(storeDetail.DadaStoreID, params)
err = api.DadaAPI.ShopUpdate(dada.StoreDetail2ShopInfo(storeDetail))
}
}
if err != nil {
@@ -1142,7 +1123,7 @@ func updateOrCreateDadaStore(storeDetail *dao.StoreDetail2) (err error) {
}
func composeDadaStoreName(storeDetail *dao.StoreDetail2) (storeName string) {
return storeDetail.Name + "-" + storeDetail.DadaStoreID
return storeDetail.Name + "-" + storeDetail.VendorStoreID
}
func ExportShopsHealthInfo(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {