From e17afbd4b921ac73db2845ddd73cef4873f871c0 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 29 Mar 2019 11:37:15 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E9=97=A8=E5=BA=97=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8C=BA=E5=88=86=E5=90=8D=E7=A7=B0=E4=B8=8E?= =?UTF-8?q?=E9=85=8D=E9=80=81=E7=9B=B8=E5=85=B3=E7=9A=84=E9=83=A8=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E5=88=86=E5=BC=80=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 20 +++++++++++--- business/model/model.go | 3 +++ business/model/store.go | 2 +- business/partner/purchase/ebai/store.go | 34 +++++++++++++----------- business/partner/purchase/jd/store.go | 35 ++++++++++++++----------- business/partner/purchase/mtwm/store.go | 8 +++--- 6 files changed, 64 insertions(+), 38 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 0fd84ac3b..fae859109 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -364,11 +364,25 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa if valid["originalName"] != nil { delete(valid, "originalName") } + syncStatus := model.SyncFlagModifiedMask if valid["name"] != nil { valid["name"] = jxutils.FormalizeName(valid["name"].(string)) + syncStatus |= model.SyncFlagStoreName + } + for _, v := range []string{ + "lng", + "lat", + "cityCode", + "address", + "deliveryRange", + } { + if payload[v] != nil { + syncStatus |= model.SyncFlagStoreAddress + break + } } var lng, lat float64 - if payload["lng"] != nil { + if payload["lng"] != nil || payload["lat"] != nil { lng = utils.Interface2FloatWithDefault(payload["lng"], 0.0) lat = utils.Interface2FloatWithDefault(payload["lat"], 0.0) valid["lng"] = jxutils.StandardCoordinate2Int(lng) @@ -397,7 +411,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa dummy := &model.StoreMap{} _, err2 := dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, dummy, nil, userName, map[string]interface{}{ model.FieldStoreID: store.ID, - }, model.FieldSyncStatus, model.SyncFlagModifiedMask) + }, model.FieldSyncStatus, syncStatus) if err = err2; err == nil { dao.Commit(db) _, err = CurVendorSync.SyncStore(ctx, db, -1, store.ID, false, userName) @@ -454,7 +468,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID storeMap.Status = store.Status } err = nil - storeMap.SyncStatus = model.SyncFlagModifiedMask // 新增绑定门店是修改的概念 + storeMap.SyncStatus = model.SyncFlagModifiedMask | model.SyncFlagStoreName | model.SyncFlagStoreAddress // 新增绑定门店是修改的概念 if db == nil { db = dao.GetDB() } diff --git a/business/model/model.go b/business/model/model.go index 0852b120a..c21b271ef 100644 --- a/business/model/model.go +++ b/business/model/model.go @@ -72,6 +72,9 @@ const ( SyncFlagSaleMask = 8 SyncFlagPriceMask = 16 SyncFlagSpecMask = 32 + + SyncFlagStoreName = 8 + SyncFlagStoreAddress = 16 ) // const ( diff --git a/business/model/store.go b/business/model/store.go index a0912bfd0..22b230dd6 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -128,7 +128,7 @@ type Store struct { DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义 DeliveryRange string `orm:"type(text)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米 Status int `json:"status"` - ChangePriceType int8 `json:"changePriceType"` + ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"` IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"` diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index ebed102b5..a3e27e345 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -359,31 +359,35 @@ func JxBusinessTime2Ebai(store *model.Store) interface{} { func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} { params := map[string]interface{}{ - // "name": jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI), "phone": store.Tel1, - "longitude": jxutils.IntCoordinate2Standard(store.Lng), - "latitude": jxutils.IntCoordinate2Standard(store.Lat), - "address": store.Address, - "coord_type": ebaiapi.CoordTypeAutonavi, // 一直用高德 "business_time": JxBusinessTime2Ebai(&store.Store), } - if deliveryRegion := JxDeliveryRegion2Ebai(&store.Store); deliveryRegion != nil { - params["delivery_region"] = deliveryRegion - } if store.VendorStoreID != "" { params["baidu_shop_id"] = store.VendorStoreID } if store.Tel2 != "" { params["ivr_phone"] = store.Tel2 } - if store.ProvinceID != 0 { - params["province"] = store.ProvinceID + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 { + // params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) } - if store.CityID != 0 { - params["city"] = store.CityID - } - if store.DistrictID != 0 { - params["county"] = store.DistrictID + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { + params["longitude"] = jxutils.IntCoordinate2Standard(store.Lng) + params["latitude"] = jxutils.IntCoordinate2Standard(store.Lat) + params["address"] = store.Address + params["coord_type"] = ebaiapi.CoordTypeAutonavi + if deliveryRegion := JxDeliveryRegion2Ebai(&store.Store); deliveryRegion != nil { + params["delivery_region"] = deliveryRegion + } + if store.ProvinceID != 0 { + params["province"] = store.ProvinceID + } + if store.CityID != 0 { + params["city"] = store.CityID + } + if store.DistrictID != 0 { + params["county"] = store.DistrictID + } } return params } diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index a50aea9a2..713d4df62 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -113,29 +113,32 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin } params := map[string]interface{}{ "outSystemId": outSystemID, // todo 直接修改这个字段可能会有问题 - "stationName": jxutils.ComposeStoreName(store.Name, model.VendorIDJD), - "stationAddress": store.Address, "serviceTimeStart1": JxOperationTime2JdOperationTime(store.OpenTime1), "serviceTimeEnd1": JxOperationTime2JdOperationTime(store.CloseTime1), - "deliveryRangeType": store.DeliveryRangeType, - "coordinateType": 3, // 一直用高德 - "lng": jxutils.IntCoordinate2Standard(store.Lng), - "lat": jxutils.IntCoordinate2Standard(store.Lat), "phone": store.Tel1, "mobile": store.Tel2, } - if store.JdCityCode != 0 { - params["city"] = store.JdCityCode + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 { + params["stationName"] = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) } - if store.JdDistrictCode != 0 { - params["county"] = store.JdDistrictCode + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { + params["stationAddress"] = store.Address + params["deliveryRangeType"] = store.DeliveryRangeType + params["coordinateType"] = 3 // 一直用高德 + params["lng"] = jxutils.IntCoordinate2Standard(store.Lng) + params["lat"] = jxutils.IntCoordinate2Standard(store.Lat) + if store.JdCityCode != 0 { + params["city"] = store.JdCityCode + } + if store.JdDistrictCode != 0 { + params["county"] = store.JdDistrictCode + } + if store.DeliveryRangeType == model.DeliveryRangeTypePolygon { + params["coordinatePoints"] = store.DeliveryRange + } else { + params["deliveryRangeRadius"] = utils.Str2Int64(store.DeliveryRange) + } } - if store.DeliveryRangeType == model.DeliveryRangeTypePolygon { - params["coordinatePoints"] = store.DeliveryRange - } else { - params["deliveryRangeRadius"] = utils.Str2Int64(store.DeliveryRange) - } - openTime2 := JxOperationTime2JdOperationTime(store.OpenTime2) if openTime2 != 0 { params["serviceTimeStart2"] = openTime2 diff --git a/business/partner/purchase/mtwm/store.go b/business/partner/purchase/mtwm/store.go index 938dc9e5f..b0afbc4ae 100644 --- a/business/partner/purchase/mtwm/store.go +++ b/business/partner/purchase/mtwm/store.go @@ -113,14 +113,16 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin } params := map[string]interface{}{ "name": utils.Interface2String(remoteStoreInfo["name"]), //jxutils.ComposeStoreName(storeDetail.Store.Name, model.VendorIDMTWM), - "address": storeDetail.Address, - "longitude": jxutils.IntCoordinate2Standard(storeDetail.Lng), - "latitude": jxutils.IntCoordinate2Standard(storeDetail.Lat), "phone": storeDetail.Tel1, "shipping_fee": jxutils.IntPrice2Standard(int64(storeDetail.DeliveryFee)), "shipping_time": openTimeJX2Mtwm(openTime), "third_tag_name": "蔬菜", } + if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { + params["address"] = storeDetail.Address + params["longitude"] = jxutils.IntCoordinate2Standard(storeDetail.Lng) + params["latitude"] = jxutils.IntCoordinate2Standard(storeDetail.Lat) + } params["open_level"], params["is_online"] = bizStatusJX2Mtwm(jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)) globals.SugarLogger.Debug(utils.Format4Output(params, false)) if globals.EnableStoreWrite && globals.EnableMtwmStoreWrite {