- continue refactoring...
This commit is contained in:
60
business/partner/purchase/jd/jd.go
Normal file
60
business/partner/purchase/jd/jd.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
var (
|
||||
curPurchaseHandler *PurchaseHandler
|
||||
)
|
||||
|
||||
type PurchaseHandler struct {
|
||||
scheduler.BasePurchasePlatform
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
scheduler.CurrentScheduler.RegisterPurchasePlatform(model.VendorIDJD, curPurchaseHandler)
|
||||
}
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
return curPurchaseHandler.OnOrderMsg(msg)
|
||||
}
|
||||
|
||||
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
|
||||
return curPurchaseHandler.OnWaybillMsg(msg)
|
||||
}
|
||||
|
||||
func JdOperationTime2JxOperationTime(value1 interface{}) int {
|
||||
value := int(utils.Interface2Int64WithDefault(value1, 0))
|
||||
return (value/2)*100 + (value%2)*30
|
||||
}
|
||||
|
||||
func JxOperationTime2JdOperationTime(value int) int {
|
||||
return (value/100)*2 + (value % 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, 0
|
||||
case model.StoreStatusClosed:
|
||||
return 0, 1
|
||||
default:
|
||||
return 0, 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user