From e10becd5eb1f544b1f8f036be50453742ee8c9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 17 Feb 2020 15:01:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BA=AC=E4=B8=9C=E9=97=A8?= =?UTF-8?q?=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 127 ++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 219983f22..19d2e0d64 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -2762,73 +2762,80 @@ type tJdStoreInfo struct { } func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) { + storeMap := map[int]int{ + 100653: 100653, + 100037: 100037, + 100968: 100968, + } db := dao.GetDB() userName := ctx.GetUserName() - var stores []*tJdStoreInfo - sql := ` - SELECT - t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, - t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, - t2.last_operator) real_last_operator, - t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name - FROM store t1 - JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? - LEFT JOIN place city ON t1.city_code = city.code - LEFT JOIN place district ON t1.district_code = district.code - WHERE t1.id = ? - ORDER BY t2.updated_at - ` - if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, 102108); err == nil { - for _, store := range stores { - a := jd.GetAPI(store.VendorOrgCode) - storeParams := &jdapi.OpStoreParams{ - StationNo: store.VendorStoreID, - Operator: userName, - Phone: store.Tel1, - Mobile: store.Tel2, - } - if store.SyncStatus&model.SyncFlagDeletedMask == 0 { - storeParams.OutSystemID = utils.Int2Str(int(store.ID)) - } else { - storeParams.OutSystemID = store.VendorStoreID - } - if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 { - if store.VendorStoreName != "" { - storeParams.StationName = store.VendorStoreName + for _, v := range storeMap { + var stores []*tJdStoreInfo + sql := ` + SELECT + t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, + t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator, + t2.last_operator) real_last_operator, + t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name + FROM store t1 + JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? + LEFT JOIN place city ON t1.city_code = city.code + LEFT JOIN place district ON t1.district_code = district.code + WHERE t1.id = ? + ORDER BY t2.updated_at + ` + if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, v); err == nil { + for _, store := range stores { + a := jd.GetAPI(store.VendorOrgCode) + storeParams := &jdapi.OpStoreParams{ + StationNo: store.VendorStoreID, + Operator: userName, + Phone: store.Tel1, + Mobile: store.Tel2, + } + if store.SyncStatus&model.SyncFlagDeletedMask == 0 { + storeParams.OutSystemID = utils.Int2Str(int(store.ID)) } else { - storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) + storeParams.OutSystemID = store.VendorStoreID } - storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen) - } - if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { - storeParams.StationAddress = store.Address - storeParams.CoordinateType = jdapi.CoordinateTypeAutonavi // 一直用高德 - storeParams.Lng = jxutils.IntCoordinate2Standard(store.Lng) - storeParams.Lat = jxutils.IntCoordinate2Standard(store.Lat) - if store.JdCityCode != 0 { - storeParams.City = store.JdCityCode + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 { + if store.VendorStoreName != "" { + storeParams.StationName = store.VendorStoreName + } else { + storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) + } + storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen) } - if store.JdDistrictCode != 0 { - storeParams.County = store.JdDistrictCode + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { + storeParams.StationAddress = store.Address + storeParams.CoordinateType = jdapi.CoordinateTypeAutonavi // 一直用高德 + storeParams.Lng = jxutils.IntCoordinate2Standard(store.Lng) + storeParams.Lat = jxutils.IntCoordinate2Standard(store.Lat) + if store.JdCityCode != 0 { + storeParams.City = store.JdCityCode + } + if store.JdDistrictCode != 0 { + storeParams.County = store.JdDistrictCode + } } + // if specialDistrictMap[storeParams.County] != 0 { + // storeParams.City = storeParams.County + // storeParams.County = specialDistrictMap[storeParams.County] + // } + storeParams.StoreNotice = store.PromoteInfo + modifyCloseStatus := false + if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagDeletedMask|model.SyncFlagStoreStatus) != 0 { + modifyCloseStatus = true + _, storeParams.CloseStatus = jd.JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus)) + } + // fillOpTimeParams(storeParams, store.GetOpTimeList()) + // globals.SugarLogger.Debug(utils.Format4Output(storeParams, false)) + errList := errlist.New() + if globals.EnableJdStoreWrite { + errList.AddErr(a.UpdateStoreInfo4Open2(storeParams, modifyCloseStatus)) + } + err = errList.GetErrListAsOne() } - // if specialDistrictMap[storeParams.County] != 0 { - // storeParams.City = storeParams.County - // storeParams.County = specialDistrictMap[storeParams.County] - // } - storeParams.StoreNotice = store.PromoteInfo - modifyCloseStatus := false - if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagDeletedMask|model.SyncFlagStoreStatus) != 0 { - modifyCloseStatus = true - _, storeParams.CloseStatus = jd.JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus)) - } - // fillOpTimeParams(storeParams, store.GetOpTimeList()) - // globals.SugarLogger.Debug(utils.Format4Output(storeParams, false)) - errList := errlist.New() - if globals.EnableJdStoreWrite { - errList.AddErr(a.UpdateStoreInfo4Open2(storeParams, modifyCloseStatus)) - } - err = errList.GetErrListAsOne() } } return err