“京东商城直辖市门店更新

This commit is contained in:
苏尹岚
2020-05-25 09:43:59 +08:00
parent 6047bf15aa
commit 2f465df551
2 changed files with 58 additions and 32 deletions

View File

@@ -18,7 +18,6 @@ import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/baseapi/utils/errlist"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
@@ -1523,37 +1522,63 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
// }
// }
// }
beginTime := utils.Str2Time("2020-05-18")
endTime := utils.Str2Time("2020-05-24")
result, _ := misc.GetStoreTotalScoreList(nil, 0, "", beginTime, endTime, true, 50, 100, 1, 700)
for _, v := range result.StoreTotalScoreList {
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJX}, []int{v.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "")
if len(storeMaps) == 0 {
stores, _ := dao.GetStoreList(db, []int{v.StoreID}, nil, nil, nil, "")
store := stores[0]
if store.Status != model.StoreStatusDisabled && !strings.Contains(store.Name, "不做") {
pricePercentagePack := ""
if store.PayPercentage >= 90 {
pricePercentagePack = "京西100"
} else if store.PayPercentage >= 80 {
pricePercentagePack = "京西80"
} else {
pricePercentagePack = "京西70"
}
storeMap := &model.StoreMap{
Status: 1,
VendorID: model.VendorIDJX,
AutoPickup: 1,
DeliveryCompetition: 1,
PricePercentage: 100,
IsSync: 1,
VendorStoreID: utils.Int2Str(v.StoreID),
PricePercentagePack: pricePercentagePack,
}
_, err = cms.AddStoreVendorMap(ctx, db, model.VendorIDJX, "", v.StoreID, storeMap)
if err != nil {
continue
}
///建店
// beginTime := utils.Str2Time("2020-05-18")
// endTime := utils.Str2Time("2020-05-24")
// result, _ := misc.GetStoreTotalScoreList(nil, 0, "", beginTime, endTime, true, 50, 100, 1, 700)
// for _, v := range result.StoreTotalScoreList {
// storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJX}, []int{v.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "")
// if len(storeMaps) == 0 {
// stores, _ := dao.GetStoreList(db, []int{v.StoreID}, nil, nil, nil, "")
// store := stores[0]
// if store.Status != model.StoreStatusDisabled && !strings.Contains(store.Name, "不做") {
// pricePercentagePack := ""
// if store.PayPercentage >= 90 {
// pricePercentagePack = "京西100"
// } else if store.PayPercentage >= 80 {
// pricePercentagePack = "京西80"
// } else {
// pricePercentagePack = "京西70"
// }
// storeMap := &model.StoreMap{
// Status: 1,
// VendorID: model.VendorIDJX,
// AutoPickup: 1,
// DeliveryCompetition: 1,
// PricePercentage: 100,
// IsSync: 1,
// VendorStoreID: utils.Int2Str(v.StoreID),
// PricePercentagePack: pricePercentagePack,
// }
// _, err = cms.AddStoreVendorMap(ctx, db, model.VendorIDJX, "", v.StoreID, storeMap)
// if err != nil {
// continue
// }
// }
// }
// }
//京东商城街道code
var stores []*model.Store
sql := `
SELECT b.*
FROM store_map a, store b
WHERE a.store_id = b.id
AND a.vendor_store_id = '' AND a.vendor_id = 5 AND a.deleted_at = ?
AND b.deleted_at = ?
`
sqlParams := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
err = dao.GetRows(db, &stores, sql, sqlParams)
for _, v := range stores {
result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat))
if result["regeocode"] != nil {
street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string)
if street != "" {
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJDShop}, []int{v.ID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "")
storeMap := storeMaps[0]
storeMap.JdsStreetName = street
dao.UpdateEntity(db, storeMap, "JdsStreetName")
}
}
}

View File

@@ -428,6 +428,7 @@ type StoreMap struct {
FakeOpenStop int16 `orm:"default(0)" json:"fakeOpenStop"` // 假开店结束
JdStoreLevel string `orm:"size(32)" json:"jdStoreLevel"` //京东门店等级
JdsStreetCode int `orm:"default(0)" json:"jdsStreetCode"` //京东商城直辖市街道code
JdsStreetName string `orm:"size(32)" json:"jdsStreetName"` //京东商城直辖市街道
IsOrder int `orm:"default(0)" json:"isOrder"` //是否是下预订单门店