- 整理partner.ReadStore
This commit is contained in:
@@ -32,17 +32,19 @@ type tJdStoreInfo struct {
|
||||
SyncStatus int
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
|
||||
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID)
|
||||
if err == nil {
|
||||
retVal := &model.Store{
|
||||
Address: utils.Interface2String(result["stationAddress"]),
|
||||
OpenTime1: JdOperationTime2JxOperationTime(result["serviceTimeStart1"]),
|
||||
CloseTime1: JdOperationTime2JxOperationTime(result["serviceTimeEnd1"]),
|
||||
OpenTime2: JdOperationTime2JxOperationTime(result["serviceTimeStart2"]),
|
||||
CloseTime2: JdOperationTime2JxOperationTime(result["serviceTimeEnd2"]),
|
||||
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
||||
Tel1: utils.Interface2String(result["phone"]),
|
||||
retVal := &dao.StoreDetail{
|
||||
Store: model.Store{
|
||||
Address: utils.Interface2String(result["stationAddress"]),
|
||||
OpenTime1: JdOperationTime2JxOperationTime(result["serviceTimeStart1"]),
|
||||
CloseTime1: JdOperationTime2JxOperationTime(result["serviceTimeEnd1"]),
|
||||
OpenTime2: JdOperationTime2JxOperationTime(result["serviceTimeStart2"]),
|
||||
CloseTime2: JdOperationTime2JxOperationTime(result["serviceTimeEnd2"]),
|
||||
Status: JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]),
|
||||
Tel1: utils.Interface2String(result["phone"]),
|
||||
},
|
||||
}
|
||||
retVal.OriginalName = utils.Interface2String(result["stationName"])
|
||||
_, retVal.Name = jxutils.SplitStoreName(retVal.OriginalName, partner.StoreNameSeparator, VendorStorePrefix)
|
||||
@@ -118,7 +120,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
"phone": store.Tel1,
|
||||
"mobile": store.Tel2,
|
||||
}
|
||||
fillOpTimeParams(params, []int16{store.OpenTime1, store.CloseTime1, store.OpenTime2, store.CloseTime2})
|
||||
fillOpTimeParams(params, store.GetOpTimeList())
|
||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0 {
|
||||
params["stationName"] = jxutils.ComposeStoreName(store.Name, model.VendorIDJD)
|
||||
}
|
||||
@@ -192,9 +194,9 @@ func (p *PurchaseHandler) GetAllStoresFromRemote() ([]*model.Store, error) {
|
||||
if err == nil {
|
||||
retVal := make([]*model.Store, len(ids))
|
||||
for index, id := range ids {
|
||||
store, err2 := p.ReadStore(id)
|
||||
store, err2 := p.ReadStore(jxcontext.AdminCtx, id)
|
||||
if err2 == nil {
|
||||
retVal[index] = store
|
||||
retVal[index] = &store.Store
|
||||
} else {
|
||||
return nil, err2
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
@@ -14,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
func TestReadStore(t *testing.T) {
|
||||
result, err := new(PurchaseHandler).ReadStore(TestJdStoreNo)
|
||||
result, err := new(PurchaseHandler).ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -23,7 +25,7 @@ func TestReadStore(t *testing.T) {
|
||||
|
||||
func TestUpdateStore(t *testing.T) {
|
||||
handler := new(PurchaseHandler)
|
||||
result, err := handler.ReadStore(TestJdStoreNo)
|
||||
result, err := handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||
|
||||
// result := &model.Store{}
|
||||
// result.ID = 100164
|
||||
@@ -40,7 +42,7 @@ func TestUpdateStore(t *testing.T) {
|
||||
}
|
||||
|
||||
// same
|
||||
result, err = handler.ReadStore(TestJdStoreNo)
|
||||
result, err = handler.ReadStore(jxcontext.AdminCtx, TestJdStoreNo)
|
||||
if result.Name != newName {
|
||||
t.Fatalf("result is not same, desired newName:%s, newName:%s", newName, result.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user