- 接收门店状态消息,本地同步状态,京东暂时无效
This commit is contained in:
33
business/partner/purchase/jd/callback.go
Normal file
33
business/partner/purchase/jd/callback.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
return curPurchaseHandler.onStoreMsg(msg)
|
||||
}
|
||||
|
||||
func OnAfterSaleMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
return retVal
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,20 +24,6 @@ func (c *PurchaseHandler) GetVendorID() int {
|
||||
return model.VendorIDJD
|
||||
}
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func JdOperationTime2JxOperationTime(value1 interface{}) int16 {
|
||||
value := int16(utils.Interface2Int64WithDefault(value1, 0))
|
||||
return (value/2)*100 + (value%2)*30
|
||||
@@ -73,18 +55,6 @@ func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) {
|
||||
}
|
||||
}
|
||||
|
||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("OnStoreMsg, msg:%s", utils.Format4Output(msg, false))
|
||||
return jdapi.Err2CallbackResponse(nil, "")
|
||||
}
|
||||
|
||||
func OnAfterSaleMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
|
||||
return imgHint, err
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
@@ -291,3 +292,23 @@ func JdDeliveryType2Jx(deliveryType int) int8 {
|
||||
}
|
||||
return scheduler.StoreDeliveryTypeByPlatform
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorStoreID string) (storeStatus int, err error) {
|
||||
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID)
|
||||
if err == nil {
|
||||
storeStatus = JdStoreStatus2JxStatus(result["yn"], result["closeStatus"])
|
||||
}
|
||||
return storeStatus, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onStoreMsg(msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) {
|
||||
var err error
|
||||
if msg.StatusID == jdapi.StatusIDUpdateStore {
|
||||
var storeStatus int
|
||||
vendorStoreID := msg.BillID
|
||||
if storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, vendorStoreID); err == nil {
|
||||
err = partner.CurStoreManager.OnStoreStatusChanged(vendorStoreID, model.VendorIDJD, storeStatus)
|
||||
}
|
||||
}
|
||||
return jdapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user