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