- bare store name.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -14,6 +15,10 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
VendorStorePrefix = "京西菜市"
|
||||
)
|
||||
|
||||
type tJdStoreInfo struct {
|
||||
model.Store
|
||||
JdCityCode int
|
||||
@@ -27,7 +32,6 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
|
||||
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID)
|
||||
if err == nil {
|
||||
retVal := &model.Store{
|
||||
Name: utils.Interface2String(result["stationName"]),
|
||||
Address: utils.Interface2String(result["stationAddress"]),
|
||||
OpenTime1: JdOperationTime2JxOperationTime(result["serviceTimeStart1"]),
|
||||
CloseTime1: JdOperationTime2JxOperationTime(result["serviceTimeEnd1"]),
|
||||
@@ -36,6 +40,7 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
|
||||
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
||||
Tel1: utils.Interface2String(result["phone"]),
|
||||
}
|
||||
_, retVal.Name = SplitStoreName(utils.Interface2String(result["stationName"]))
|
||||
retVal.DeliveryType = JdDeliveryType2Jx(int(utils.MustInterface2Int64(result["carrierNo"])))
|
||||
|
||||
tel2 := utils.Interface2String(result["mobile"])
|
||||
@@ -86,7 +91,7 @@ func (p *PurchaseHandler) UpdateStore(storeID int, userName string) (err error)
|
||||
if err = dao.GetRow(db, &store, sql, model.VendorIDJD, storeID); err == nil {
|
||||
params := map[string]interface{}{
|
||||
"outSystemId": utils.Int2Str(int(store.ID)), // todo 直接修改这个字段可能会有问题
|
||||
"stationName": store.Name,
|
||||
"stationName": ComposeStoreName(store.Name),
|
||||
"stationAddress": store.Address,
|
||||
"serviceTimeStart1": JxOperationTime2JdOperationTime(store.OpenTime1),
|
||||
"serviceTimeEnd1": JxOperationTime2JdOperationTime(store.CloseTime1),
|
||||
@@ -203,3 +208,20 @@ func JdDeliveryType2Jx(deliveryType int) int8 {
|
||||
}
|
||||
return scheduler.StoreDeliveryTypeByPlatform
|
||||
}
|
||||
|
||||
func SplitStoreName(fullName string) (prefix, bareName string) {
|
||||
names := strings.Split(fullName, partner.StoreNameSeparator)
|
||||
if len(names) == 2 {
|
||||
prefix = names[0]
|
||||
bareName = names[1]
|
||||
} else {
|
||||
prefix = VendorStorePrefix
|
||||
bareName = strings.Trim(strings.Trim(fullName, VendorStorePrefix), partner.StoreNameSeparator)
|
||||
|
||||
}
|
||||
return utils.TrimBlanChar(prefix), utils.TrimBlanChar(bareName)
|
||||
}
|
||||
|
||||
func ComposeStoreName(bareName string) (fullName string) {
|
||||
return VendorStorePrefix + partner.StoreNameSeparator + utils.TrimBlanChar(strings.Trim(bareName, partner.StoreNameSeparator))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user