更改平台门店名称

This commit is contained in:
苏尹岚
2019-12-17 14:10:44 +08:00
parent 81ea19b80a
commit a02dbdeacc
6 changed files with 47 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"unicode/utf8"
"github.com/360EntSecGroup-Skylar/excelize" "github.com/360EntSecGroup-Skylar/excelize"
@@ -1149,6 +1150,13 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
if valid["status"] != nil { if valid["status"] != nil {
syncStatus |= model.SyncFlagStoreStatus syncStatus |= model.SyncFlagStoreStatus
} }
if valid["vendorStoreName"] != nil {
vendorStoreName := valid["vendorStoreName"].(string)
if utf8.RuneCountInString(vendorStoreName) > 13 && vendorID == model.VendorIDJD {
return 0, fmt.Errorf("门店名称不允许超过13位")
}
syncStatus |= model.SyncFlagStoreName
}
for _, v := range [][]string{ for _, v := range [][]string{
[]string{ []string{
"pricePercentagePack", "pricePercentagePack",
@@ -1189,7 +1197,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
panic(r) panic(r)
} }
}() }()
if valid["status"] != nil { // 对于store vendor map只有Status改变才需要同步到厂商 if valid["status"] != nil || valid["vendorStoreName"] != nil { // 对于store vendor map只有Status改变才需要同步到厂商
num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{ num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, storeMap, valid, userName, map[string]interface{}{
model.FieldStoreID: storeID, model.FieldStoreID: storeID,
model.FieldVendorID: vendorID, model.FieldVendorID: vendorID,
@@ -1222,7 +1230,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
} }
} }
dao.Commit(db) dao.Commit(db)
if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil) { if vendorID != model.VendorIDJX && (valid["status"] != nil || valid["freightDeductionPack"] != nil || valid["vendorStoreName"] != nil) {
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName) _, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
} }
} }

View File

@@ -14,10 +14,11 @@ type StoreDetail struct {
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
VendorStatus int `json:"vendor_status"` // 取值同Store.Status VendorStoreName string `json:"vendorStoreName"`
DeliveryFee int `json:"deliveryFee"` VendorStatus int `json:"vendor_status"` // 取值同Store.Status
SyncStatus int8 `orm:"default(2)" json:"syncStatus"` DeliveryFee int `json:"deliveryFee"`
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格 PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePackStr string `orm:"size(4096)" json:"-"` // PricePercentagePackStr string `orm:"size(4096)" json:"-"` //
@@ -81,7 +82,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
sql := ` sql := `
SELECT t1.*, SELECT t1.*,
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status, t2.vendor_org_code, t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status, t2.vendor_org_code,
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name,
t3.value price_percentage_pack_str, t3.value price_percentage_pack_str,
t4.value freight_deduction_pack_str, t4.value freight_deduction_pack_str,
district.name district_name, district.name district_name,

View File

@@ -388,9 +388,10 @@ type StoreMap struct {
VendorID int `orm:"column(vendor_id)" json:"vendorID"` VendorID int `orm:"column(vendor_id)" json:"vendorID"`
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空 VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"` VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
Status int `json:"status"` // 取值同Store.Status Status int `json:"status"` // 取值同Store.Status
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字 StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字,由平台到京西
VendorStoreName string `orm:"size(255)" json:"vendorStoreName"` //平台门店名,由京西到平台
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格 PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` // PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //

View File

@@ -30,9 +30,10 @@ type tEbaiStoreInfo struct {
EbaiStoreStatus int EbaiStoreStatus int
SyncStatus int SyncStatus int
ProvinceID int `orm:"column(province_id)"` ProvinceID int `orm:"column(province_id)"`
CityID int `orm:"column(city_id)"` CityID int `orm:"column(city_id)"`
DistrictID int `orm:"column(district_id)"` DistrictID int `orm:"column(district_id)"`
VendorStoreName string
} }
func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) { func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName string) (vendorStoreID string, err error) {
@@ -156,7 +157,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
SELECT SELECT
t1.*, t1.*,
t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code, t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code,
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status, t2.vendor_store_name
FROM store t1 FROM store t1
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
WHERE t1.id = ? WHERE t1.id = ?
@@ -392,8 +393,12 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
if store.VendorStoreID != "" { if store.VendorStoreID != "" {
params["baidu_shop_id"] = store.VendorStoreID params["baidu_shop_id"] = store.VendorStoreID
} }
if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreName*/) != 0 { if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) if store.VendorStoreName != "" {
params["name"] = store.VendorStoreName
} else {
params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI)
}
} }
params["address"] = store.Address params["address"] = store.Address
// todo 饿百 开店审核通过后不允许修改商户信息 // todo 饿百 开店审核通过后不允许修改商户信息

View File

@@ -36,6 +36,7 @@ type tJdStoreInfo struct {
VendorStoreID string `orm:"column(vendor_store_id)"` VendorStoreID string `orm:"column(vendor_store_id)"`
RealLastOperator string RealLastOperator string
SyncStatus int SyncStatus int
VendorStoreName string
} }
var ( var (
@@ -123,7 +124,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, 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.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.last_operator) real_last_operator,
t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code t2.sync_status, t2.freight_deduction_pack, t2.vendor_org_code, t2.vendor_store_name
FROM store t1 FROM store t1
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?) JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
LEFT JOIN place city ON t1.city_code = city.code LEFT JOIN place city ON t1.city_code = city.code
@@ -146,7 +147,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
storeParams.OutSystemID = store.VendorStoreID storeParams.OutSystemID = store.VendorStoreID
} }
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 { if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD) if store.VendorStoreName != "" {
storeParams.StationName = store.VendorStoreName
} else {
storeParams.StationName = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
}
} }
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 {
storeParams.StationAddress = store.Address storeParams.StationAddress = store.Address

View File

@@ -101,6 +101,7 @@ func (p *PurchaseHandler) CreateStore(db *dao.DaoDB, storeID int, userName strin
} }
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) { func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
var name string
if db == nil { if db == nil {
db = dao.GetDB() db = dao.GetDB()
} }
@@ -115,10 +116,16 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
return err return err
} }
mergedStoreStatus := jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus) mergedStoreStatus := jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)
name = remoteStoreInfo.Name
if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
if storeDetail.VendorStoreName != "" {
name = storeDetail.VendorStoreName
}
}
// openLevel, isOnline := bizStatusJX2Mtwm(mergedStoreStatus) // openLevel, isOnline := bizStatusJX2Mtwm(mergedStoreStatus)
params := map[string]interface{}{ params := map[string]interface{}{
"name": remoteStoreInfo.Name, //jxutils.ComposeStoreName(storeDetail.Store.Name, model.VendorIDMTWM), "name": name, //jxutils.ComposeStoreName(storeDetail.Store.Name, model.VendorIDMTWM),
"address": storeDetail.Address, // 美团好像地址也不能改的? "address": storeDetail.Address, // 美团好像地址也不能改的?
"longitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Longitude)), "longitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Longitude)),
"latitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Latitude)), "latitude": jxutils.IntCoordinate2Standard(int(remoteStoreInfo.Latitude)),
"phone": storeDetail.Tel1, "phone": storeDetail.Tel1,