87 lines
2.1 KiB
Go
87 lines
2.1 KiB
Go
package jd
|
|
|
|
import (
|
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
|
"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"
|
|
)
|
|
|
|
type PurchaseHandler struct {
|
|
partner.BasePurchasePlatform
|
|
}
|
|
|
|
var (
|
|
CurPurchaseHandler *PurchaseHandler
|
|
)
|
|
|
|
func init() {
|
|
globals.SugarLogger.Debug("init jd")
|
|
CurPurchaseHandler = new(PurchaseHandler)
|
|
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
|
}
|
|
|
|
func getAPI(appOrgCode string) (apiObj *jdapi.API) {
|
|
if appOrgCode == "" {
|
|
globals.SugarLogger.Warnf("getAPI appOrgCode is empty")
|
|
}
|
|
return partner.CurAPIManager.GetAPI(model.VendorIDJD, appOrgCode).(*jdapi.API)
|
|
}
|
|
|
|
func GetAPI(appOrgCode string) (apiObj *jdapi.API) {
|
|
return getAPI(appOrgCode)
|
|
}
|
|
|
|
func AppKey2OrgCode(appKey string) (vendorOrgCode string) {
|
|
apiList := partner.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD)
|
|
for _, v := range apiList {
|
|
jdAPI := partner.CurAPIManager.GetAPI(model.VendorIDJD, v).(*jdapi.API)
|
|
if jdAPI.GetAppKey() == appKey {
|
|
vendorOrgCode = v
|
|
break
|
|
}
|
|
}
|
|
if vendorOrgCode == "" {
|
|
globals.SugarLogger.Warnf("AppKey2OrgCode appKey:%s get empty vendorOrgCode", appKey)
|
|
}
|
|
return vendorOrgCode
|
|
}
|
|
|
|
func (c *PurchaseHandler) GetVendorID() int {
|
|
return model.VendorIDJD
|
|
}
|
|
|
|
func JdOperationTime2JxOperationTime(value1 int) int16 {
|
|
value := int16(value1)
|
|
return (value/2)*100 + (value%2)*30
|
|
}
|
|
|
|
func JxOperationTime2JdOperationTime(value int16) int16 {
|
|
return (value/100)*2 + (value%100)/30
|
|
}
|
|
|
|
func JdStoreStatus2JxStatus(yn, closeStatus int) int {
|
|
if yn == 1 {
|
|
return model.StoreStatusDisabled
|
|
} else if closeStatus == 1 {
|
|
return model.StoreStatusClosed
|
|
}
|
|
return model.StoreStatusOpened
|
|
}
|
|
|
|
func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) {
|
|
switch status {
|
|
case model.StoreStatusDisabled:
|
|
return 1, 1
|
|
case model.StoreStatusHaveRest, model.StoreStatusClosed:
|
|
return 0, 1
|
|
default:
|
|
return 0, 0
|
|
}
|
|
}
|
|
|
|
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
|
return imgHint, err
|
|
}
|