86 lines
2.1 KiB
Go
86 lines
2.1 KiB
Go
package jd
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"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/business/partner"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
)
|
|
|
|
var (
|
|
curPurchaseHandler *PurchaseHandler
|
|
)
|
|
|
|
type PurchaseHandler struct {
|
|
partner.BasePurchasePlatform
|
|
}
|
|
|
|
func init() {
|
|
curPurchaseHandler = new(PurchaseHandler)
|
|
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
func JxOperationTime2JdOperationTime(value int16) int16 {
|
|
return (value/100)*2 + (value%100)/30
|
|
}
|
|
|
|
func JdStoreStatus2JxStatus(yn, closeStatus interface{}) int {
|
|
yn2 := utils.Interface2Int64WithDefault(yn, 0)
|
|
closeStatus2 := utils.Interface2Int64WithDefault(closeStatus, 0)
|
|
if yn2 == 1 {
|
|
return model.StoreStatusDisabled
|
|
} else if closeStatus2 == 1 {
|
|
return model.StoreStatusClosed
|
|
}
|
|
return model.StoreStatusOpened
|
|
}
|
|
|
|
func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) {
|
|
switch status {
|
|
case model.StoreStatusDisabled:
|
|
return 1, 1
|
|
case model.StoreStatusClosed:
|
|
return 0, 1
|
|
default:
|
|
return 0, 0
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|