This commit is contained in:
gazebo
2019-07-24 20:10:54 +08:00
parent 94510ff2af
commit 987d205985
4 changed files with 45 additions and 25 deletions

View File

@@ -146,12 +146,15 @@ func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.Shop
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
if globals.EnableStoreWrite {
_, err = api.DadaAPI.ShopAdd(StoreDetail2ShopInfo(storeDetail))
}
if err == nil {
vendorStoreID, err = api.DadaAPI.ShopAdd(StoreDetail2ShopInfo(storeDetail))
if err == nil {
status = model.StoreAuditStatusOnline
}
} else {
vendorStoreID = utils.Int64ToStr(jxutils.GenFakeID())
status = model.StoreAuditStatusOnline
}
return "", status, err
return vendorStoreID, status, err
}
func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) {
@@ -161,6 +164,13 @@ func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.S
return err
}
func dadaStatus2Jx(dadaStatus int) int {
if dadaStatus == dadaapi.ShopStatusOnline {
return model.StoreStatusOpened
}
return model.StoreStatusDisabled
}
func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
shopInfo, err := api.DadaAPI.ShopDetail(vendorStoreID)
if err == nil {
@@ -175,6 +185,8 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
},
VendorID: model.VendorIDDada,
VendorStoreID: shopInfo.OriginShopID,
CourierStatus: dadaStatus2Jx(shopInfo.Status),
AuditStatus: model.StoreAuditStatusOnline,
CityName: shopInfo.CityName,
DistrictName: shopInfo.AreaName,
}

View File

@@ -3,6 +3,7 @@ package mtps
import (
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
@@ -13,10 +14,10 @@ import (
var (
auditStatusMap = map[int]int{
mtpsapi.ShopStatusCreateSuccess: model.StoreAuditStatusCreated,
mtpsapi.ShopStatusAuditCreated: model.StoreAuditStatusCreated,
mtpsapi.ShopStatusAuditRejected: model.StoreAuditStatusRejected,
mtpsapi.ShopStatusAuditPassed: model.StoreAuditStatusCreated,
mtpsapi.ShopStatusOnline: model.StoreAuditStatusOnline,
mtpsapi.ShopStatusAuditOnline: model.StoreAuditStatusOnline,
}
)
@@ -58,14 +59,18 @@ func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.S
CoordinateType: mtpsapi.CoordinateTypeMars,
BusinessHours: string(utils.MustMarshal(businessHours)),
}
shopStatus := mtpsapi.ShopStatusCreateSuccess
shopStatus := mtpsapi.ShopStatusAuditCreated
if globals.EnableStoreWrite {
shopStatus, err = api.MtpsAPI.ShopCreate(shopInfo)
if err == nil {
vendorStoreID = shopInfo.ShopID
status = getAuditStatus(shopStatus)
}
} else {
vendorStoreID = utils.Int64ToStr(jxutils.GenFakeID())
status = model.StoreAuditStatusOnline
}
if err == nil {
status = getAuditStatus(shopStatus)
}
return "", status, err
return vendorStoreID, status, err
}
func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
@@ -83,6 +88,8 @@ func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorSt
},
VendorID: model.VendorIDMTPS,
VendorStoreID: shopInfo.ShopID,
CourierStatus: model.StoreStatusOpened,
AuditStatus: model.StoreAuditStatusOnline,
}
}
return storeDetail, err