Files
jx-callback/business/partner/purchase/jd/jd.go
gazebo d87483cff6 - 平台门店没有临时休息的概念,ReadStore不会返回临时休息
- 得到平台门店快照后,会刷新本地storeMap中的状态(但store的状态暂时没有更新)
2019-06-28 09:47:14 +08:00

64 lines
1.5 KiB
Go

package jd
import (
"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/api"
)
var (
curPurchaseHandler *PurchaseHandler
)
type PurchaseHandler struct {
partner.BasePurchasePlatform
}
func init() {
if api.JdAPI != nil {
curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler)
}
}
func (c *PurchaseHandler) GetVendorID() int {
return model.VendorIDJD
}
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.StoreStatusHaveRest, model.StoreStatusClosed:
return 0, 1
default:
return 0, 0
}
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
return imgHint, err
}