- 门店同步状态区分名称与配送相关的部分,分开同步
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ const (
|
||||
SyncFlagSaleMask = 8
|
||||
SyncFlagPriceMask = 16
|
||||
SyncFlagSpecMask = 32
|
||||
|
||||
SyncFlagStoreName = 8
|
||||
SyncFlagStoreAddress = 16
|
||||
)
|
||||
|
||||
// const (
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user