同步京东门店
This commit is contained in:
@@ -2762,73 +2762,80 @@ type tJdStoreInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) {
|
func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) {
|
||||||
|
storeMap := map[int]int{
|
||||||
|
100653: 100653,
|
||||||
|
100037: 100037,
|
||||||
|
100968: 100968,
|
||||||
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
var stores []*tJdStoreInfo
|
for _, v := range storeMap {
|
||||||
sql := `
|
var stores []*tJdStoreInfo
|
||||||
SELECT
|
sql := `
|
||||||
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
|
SELECT
|
||||||
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
|
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code,
|
||||||
t2.last_operator) real_last_operator,
|
t2.status jd_store_status, t2.vendor_store_id, IF(t1.updated_at > t2.updated_at, t1.last_operator,
|
||||||
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name
|
t2.last_operator) real_last_operator,
|
||||||
FROM store t1
|
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name
|
||||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ?
|
FROM store t1
|
||||||
LEFT JOIN place city ON t1.city_code = city.code
|
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ?
|
||||||
LEFT JOIN place district ON t1.district_code = district.code
|
LEFT JOIN place city ON t1.city_code = city.code
|
||||||
WHERE t1.id = ?
|
LEFT JOIN place district ON t1.district_code = district.code
|
||||||
ORDER BY t2.updated_at
|
WHERE t1.id = ?
|
||||||
`
|
ORDER BY t2.updated_at
|
||||||
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, 102108); err == nil {
|
`
|
||||||
for _, store := range stores {
|
if err = dao.GetRows(db, &stores, sql, model.VendorIDJD, v); err == nil {
|
||||||
a := jd.GetAPI(store.VendorOrgCode)
|
for _, store := range stores {
|
||||||
storeParams := &jdapi.OpStoreParams{
|
a := jd.GetAPI(store.VendorOrgCode)
|
||||||
StationNo: store.VendorStoreID,
|
storeParams := &jdapi.OpStoreParams{
|
||||||
Operator: userName,
|
StationNo: store.VendorStoreID,
|
||||||
Phone: store.Tel1,
|
Operator: userName,
|
||||||
Mobile: store.Tel2,
|
Phone: store.Tel1,
|
||||||
}
|
Mobile: store.Tel2,
|
||||||
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
}
|
||||||
storeParams.OutSystemID = utils.Int2Str(int(store.ID))
|
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
||||||
} else {
|
storeParams.OutSystemID = utils.Int2Str(int(store.ID))
|
||||||
storeParams.OutSystemID = store.VendorStoreID
|
|
||||||
}
|
|
||||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
|
||||||
if store.VendorStoreName != "" {
|
|
||||||
storeParams.StationName = store.VendorStoreName
|
|
||||||
} else {
|
} 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.SyncFlagStoreName) != 0 {
|
||||||
}
|
if store.VendorStoreName != "" {
|
||||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 {
|
storeParams.StationName = store.VendorStoreName
|
||||||
storeParams.StationAddress = store.Address
|
} else {
|
||||||
storeParams.CoordinateType = jdapi.CoordinateTypeAutonavi // 一直用高德
|
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||||
storeParams.Lng = jxutils.IntCoordinate2Standard(store.Lng)
|
}
|
||||||
storeParams.Lat = jxutils.IntCoordinate2Standard(store.Lat)
|
storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen)
|
||||||
if store.JdCityCode != 0 {
|
|
||||||
storeParams.City = store.JdCityCode
|
|
||||||
}
|
}
|
||||||
if store.JdDistrictCode != 0 {
|
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 {
|
||||||
storeParams.County = store.JdDistrictCode
|
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
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user