+ OpenRemoteStoreByJxStatus
This commit is contained in:
9
business/partner/partner_store.go
Normal file
9
business/partner/partner_store.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package partner
|
||||
|
||||
import "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
type IStoreHandler interface {
|
||||
UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error)
|
||||
// opTime格式为整数1130代表11:30
|
||||
// ChangeStoreOptime(ctx *jxcontext.Context, opTimeList []int) (err error)
|
||||
}
|
||||
@@ -181,27 +181,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
}
|
||||
if err == nil {
|
||||
mergeStatus := jxutils.MergeStoreStatus(store.Status, store.EbaiStoreStatus)
|
||||
if !isStoreStatusSame(store2.Status, mergeStatus) {
|
||||
if mergeStatus == model.StoreStatusOpened {
|
||||
err = api.EbaiAPI.ShopOpen("", utils.Str2Int64(store.VendorStoreID))
|
||||
} else if mergeStatus == model.StoreStatusHaveRest || mergeStatus == model.StoreStatusClosed {
|
||||
err = api.EbaiAPI.ShopClose("", utils.Str2Int64(store.VendorStoreID))
|
||||
} else if mergeStatus == model.StoreStatusDisabled {
|
||||
err = api.EbaiAPI.ShopOffline("", utils.Str2Int64(store.VendorStoreID))
|
||||
}
|
||||
if intErr, ok := err.(*utils.ErrorWithCode); ok && intErr.IntCode() == 201100 {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
// todo
|
||||
if intErr, ok := err.(*utils.ErrorWithCode); ok {
|
||||
if intErr.IntCode() == 201101 {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err = p.updateStoreStatus(userName, storeID, store.VendorStoreID, mergeStatus, store2.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
params := genStoreMapFromStore(store)
|
||||
@@ -441,3 +421,29 @@ func (c *PurchaseHandler) GetShopHealthInfo(vendorShopID string) (shopHealthInfo
|
||||
}
|
||||
return shopHealthInfo, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||
store, err := c.ReadStore(vendorStoreID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.updateStoreStatus(ctx.GetUserName(), storeID, vendorStoreID, status, store.Status)
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) updateStoreStatus(userName string, storeID int, vendorStoreID string, status, currentStatus int) (err error) {
|
||||
if !isStoreStatusSame(currentStatus, status) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if status == model.StoreStatusOpened {
|
||||
err = api.EbaiAPI.ShopOpen("", utils.Str2Int64(vendorStoreID))
|
||||
} else if status == model.StoreStatusHaveRest || status == model.StoreStatusClosed {
|
||||
err = api.EbaiAPI.ShopClose("", utils.Str2Int64(vendorStoreID))
|
||||
} else if status == model.StoreStatusDisabled {
|
||||
err = api.EbaiAPI.ShopOffline("", utils.Str2Int64(vendorStoreID))
|
||||
}
|
||||
}
|
||||
if intErr, ok := err.(*utils.ErrorWithCode); ok && intErr.IntCode() == 201100 {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -318,3 +318,13 @@ func (c *PurchaseHandler) OnStoreMsg(msg *jdapi.CallbackOrderMsg) (response *jda
|
||||
// }
|
||||
return jdapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||
_, closeStatus := JxStoreStatus2JdStatus(status)
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), map[string]interface{}{
|
||||
"closeStatus": closeStatus,
|
||||
})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
if storeDetail.OpenTime2 > 0 {
|
||||
openTime = append(openTime, [2]int16{storeDetail.OpenTime2, storeDetail.CloseTime2})
|
||||
}
|
||||
openLevel, isOnline := bizStatusJX2Mtwm(jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus))
|
||||
// remoteStoreInfo, err := api.MtwmAPI.PoiGet(storeDetail.VendorStoreID)
|
||||
// if err != nil {
|
||||
// return err
|
||||
@@ -130,29 +129,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
// if globals.EnableMtwmStoreWrite {
|
||||
// err = api.MtwmAPI.PoiSave(storeDetail.VendorStoreID, params)
|
||||
// }
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if isOnline != mtwmapi.PoiStatusOnline {
|
||||
err = api.MtwmAPI.PoiOffline(storeDetail.VendorStoreID)
|
||||
} else {
|
||||
if err = api.MtwmAPI.PoiOnline(storeDetail.VendorStoreID); err == nil {
|
||||
// 这个函数成功返回也并不表示上线成功。。。
|
||||
remoteStoreInfo, err2 := api.MtwmAPI.PoiGet(storeDetail.VendorStoreID)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
if remoteStoreInfo.IsOnline == mtwmapi.PoiStatusOnline {
|
||||
if openLevel == mtwmapi.PoiOpenLevelHaveRest {
|
||||
err = api.MtwmAPI.PoiClose(storeDetail.VendorStoreID)
|
||||
} else {
|
||||
err = api.MtwmAPI.PoiOpen(storeDetail.VendorStoreID)
|
||||
}
|
||||
if err == nil {
|
||||
err = api.MtwmAPI.PoiShipTimeUpdate(storeDetail.VendorStoreID, openTimeJX2Mtwm(openTime))
|
||||
}
|
||||
} else {
|
||||
err = errors.New("门店还未上线,不能修改营业状态")
|
||||
}
|
||||
}
|
||||
if err = p.UpdateStoreStatus(jxcontext.AdminCtx, storeID, storeDetail.VendorStoreID, jxutils.MergeStoreStatus(storeDetail.Status, storeDetail.VendorStatus)); err == nil {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.PoiShipTimeUpdate(storeDetail.VendorStoreID, openTimeJX2Mtwm(openTime))
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -190,3 +169,29 @@ func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorStoreID s
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||
openLevel, isOnline := bizStatusJX2Mtwm(status)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if isOnline != mtwmapi.PoiStatusOnline {
|
||||
err = api.MtwmAPI.PoiOffline(vendorStoreID)
|
||||
} else {
|
||||
if err = api.MtwmAPI.PoiOnline(vendorStoreID); err == nil { // 这个函数成功返回也并不表示上线成功。。。
|
||||
remoteStoreInfo, err2 := api.MtwmAPI.PoiGet(vendorStoreID)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
if remoteStoreInfo.IsOnline == mtwmapi.PoiStatusOnline {
|
||||
if openLevel == mtwmapi.PoiOpenLevelHaveRest {
|
||||
err = api.MtwmAPI.PoiClose(vendorStoreID)
|
||||
} else {
|
||||
err = api.MtwmAPI.PoiOpen(vendorStoreID)
|
||||
}
|
||||
} else {
|
||||
err = errors.New("门店还未上线,不能修改营业状态")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user