- 适应快递API接口变更
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -29,6 +30,17 @@ var (
|
||||
|
||||
var (
|
||||
CurDeliveryHandler *DeliveryHandler
|
||||
|
||||
dadaDistrictMap = map[string]string{
|
||||
"苏州工业园区": "工业园区",
|
||||
"郫都区": "郫县",
|
||||
"管城回族区": "管城区",
|
||||
"昆山市": "1",
|
||||
"常熟市": "1",
|
||||
"太仓市": "1",
|
||||
"虞山街道": "虞山镇",
|
||||
"常福街道": "虞山镇",
|
||||
}
|
||||
)
|
||||
|
||||
type DeliveryHandler struct {
|
||||
@@ -103,6 +115,51 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal
|
||||
return retVal
|
||||
}
|
||||
|
||||
func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) {
|
||||
lng := jxutils.IntCoordinate2Standard(storeDetail.Lng)
|
||||
lat := jxutils.IntCoordinate2Standard(storeDetail.Lat)
|
||||
cityName := storeDetail.CityName
|
||||
districtName := storeDetail.DistrictName
|
||||
if dadaDistrictMap[districtName] != "" {
|
||||
if dadaDistrictMap[districtName] == "1" { // 区镇信息
|
||||
cityName = districtName
|
||||
districtName, _ = api.AutonaviAPI.GetCoordinateTownInfo(lng, lat)
|
||||
}
|
||||
if dadaDistrictMap[storeDetail.DistrictName] != "" {
|
||||
storeDetail.DistrictName = dadaDistrictMap[storeDetail.DistrictName]
|
||||
}
|
||||
}
|
||||
shopInfo = &dadaapi.ShopInfo{
|
||||
OriginShopID: utils.Int2Str(storeDetail.ID),
|
||||
StationName: storeDetail.Name,
|
||||
CityName: cityName,
|
||||
AreaName: districtName,
|
||||
StationAddress: storeDetail.Address,
|
||||
Lng: lng,
|
||||
Lat: lat,
|
||||
ContactName: storeDetail.PayeeName,
|
||||
Phone: storeDetail.Tel1,
|
||||
}
|
||||
return shopInfo
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
_, err = api.DadaAPI.ShopAdd(StoreDetail2ShopInfo(storeDetail))
|
||||
}
|
||||
if err == nil {
|
||||
status = model.StoreAuditStatusOnline
|
||||
}
|
||||
return "", status, err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.DadaAPI.ShopUpdate(StoreDetail2ShopInfo(storeDetail))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||
db := dao.GetDB()
|
||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||
|
||||
Reference in New Issue
Block a user