- 平台多账号相关
This commit is contained in:
@@ -70,6 +70,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
|||||||
"storeDeliveryType": model.DeliveryTypeName,
|
"storeDeliveryType": model.DeliveryTypeName,
|
||||||
"storeStatus": model.StoreStatusName,
|
"storeStatus": model.StoreStatusName,
|
||||||
"categoryType": model.CategoryTypeName,
|
"categoryType": model.CategoryTypeName,
|
||||||
|
"vendorTypeName": model.VendorTypeName,
|
||||||
"vendorName": model.VendorChineseNames,
|
"vendorName": model.VendorChineseNames,
|
||||||
"orderStatus": model.OrderStatusName,
|
"orderStatus": model.OrderStatusName,
|
||||||
"waybillStatus": model.WaybillStatusName,
|
"waybillStatus": model.WaybillStatusName,
|
||||||
|
|||||||
@@ -1,15 +1,169 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
// VendorIDJD, VendorIDMTWM与VendorIDELM的定义和老系统是兼容的
|
||||||
|
const (
|
||||||
|
VendorTypeUnknown = 0 // 未知
|
||||||
|
VendorTypePurchase = 1 // 购物平台
|
||||||
|
VendorTypeDelivery = 2 // 快递平台
|
||||||
|
VendorTypeOthers = 9 // 其它
|
||||||
|
|
||||||
|
VendorIDUnknown = -1
|
||||||
|
VendorIDPurchaseBegin = 0
|
||||||
|
VendorIDJD = 0
|
||||||
|
VendorIDMTWM = 1
|
||||||
|
VendorIDELM = 2
|
||||||
|
VendorIDEBAI = 3
|
||||||
|
VendorIDWSC = 11 // 微盟微商城
|
||||||
|
VendorIDPurchaseEnd = 11
|
||||||
|
VendorIDJX = 9 // 这是一个假的京西VendorID
|
||||||
|
|
||||||
|
VendorIDDeliveryBegin = 101
|
||||||
|
VendorIDDada = 101
|
||||||
|
VendorIDMTPS = 102
|
||||||
|
VendorIDFengNiao = 103
|
||||||
|
VendorIDDeliveryEnd = 200
|
||||||
|
|
||||||
|
VendorIDPrinterBegin = 201
|
||||||
|
VendorIDFeiE = 201 // 飞鹅打印机
|
||||||
|
VendorIDXiaoWM = 202 // 外卖管家打印机
|
||||||
|
VendorIDYiLianYun = 203 // 易联云
|
||||||
|
VendorIDZhongWu = 204 // 中午云打印
|
||||||
|
VendorIDPrinterEnd = 300
|
||||||
|
|
||||||
|
VendorIDOthersBegin = 301
|
||||||
|
|
||||||
|
VendorIDWXMP = 301 // 微信公众号
|
||||||
|
VendorIDWXQRCode = 302 // 微信扫码
|
||||||
|
VendorIDWXMini = 303 // 微信小程序
|
||||||
|
|
||||||
|
VendorIDDDH5MicroApp = 311 // 钉钉H5微应用
|
||||||
|
VendorIDDDMobileQRCode = 312 // 钉钉移动接入应用(登录)
|
||||||
|
|
||||||
|
VendorIDAutonavi = 321 // 高德导航
|
||||||
|
VendorIDQiNiuCloud = 323 // 七牛云
|
||||||
|
VendorIDShowAPI = 325 // 万维易源
|
||||||
|
)
|
||||||
|
|
||||||
|
type VendorInfo struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
OrgCodeName string `json:"orgCodeName"`
|
||||||
|
Value1Name string `json:"value1Name,omitempty"`
|
||||||
|
Value2Name string `json:"value2Name,omitempty"`
|
||||||
|
Value3Name string `json:"value3Name,omitempty"`
|
||||||
|
Value4Name string `json:"value4Name,omitempty"`
|
||||||
|
Value5Name string `json:"value5Name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
VendorNames = map[int]string{
|
||||||
|
VendorIDJD: "Jd",
|
||||||
|
VendorIDMTWM: "Mtwm",
|
||||||
|
VendorIDELM: "Elm",
|
||||||
|
VendorIDEBAI: "Ebai",
|
||||||
|
VendorIDWSC: "Wsc",
|
||||||
|
|
||||||
|
VendorIDDada: "Dada",
|
||||||
|
VendorIDMTPS: "Mtps",
|
||||||
|
|
||||||
|
VendorIDFeiE: "Feie",
|
||||||
|
VendorIDXiaoWM: "XiaoWM",
|
||||||
|
VendorIDYiLianYun: "Yilianyun",
|
||||||
|
VendorIDZhongWu: "ZhongWu",
|
||||||
|
}
|
||||||
|
|
||||||
|
VendorTypeName = map[int]string{
|
||||||
|
VendorTypeUnknown: "未知",
|
||||||
|
VendorTypePurchase: "购物平台",
|
||||||
|
VendorTypeDelivery: "快递平台",
|
||||||
|
VendorTypeOthers: "其它",
|
||||||
|
}
|
||||||
|
|
||||||
|
VendorChineseNames = map[int]string{
|
||||||
|
VendorIDJD: "京东到家",
|
||||||
|
VendorIDMTWM: "美团外卖",
|
||||||
|
VendorIDELM: "饿了么",
|
||||||
|
VendorIDEBAI: "饿百新零售",
|
||||||
|
VendorIDWSC: "微盟微商城",
|
||||||
|
|
||||||
|
VendorIDDada: "达达众包",
|
||||||
|
VendorIDMTPS: "美团配送",
|
||||||
|
|
||||||
|
VendorIDFeiE: "飞鹅",
|
||||||
|
VendorIDXiaoWM: "外卖管家",
|
||||||
|
VendorIDYiLianYun: "易联云",
|
||||||
|
VendorIDZhongWu: "中午云",
|
||||||
|
|
||||||
|
VendorIDWXMP: "微信公众号",
|
||||||
|
VendorIDWXQRCode: "微信扫码",
|
||||||
|
VendorIDWXMini: "微信小程序",
|
||||||
|
|
||||||
|
VendorIDDDH5MicroApp: "钉钉H5微应用",
|
||||||
|
VendorIDDDMobileQRCode: "钉钉移动接入应用(登录)",
|
||||||
|
|
||||||
|
VendorIDAutonavi: "高德导航",
|
||||||
|
VendorIDQiNiuCloud: "七牛云",
|
||||||
|
VendorIDShowAPI: "万维易源",
|
||||||
|
}
|
||||||
|
|
||||||
|
VendorInfoMap = map[int]*VendorInfo{
|
||||||
|
VendorIDJD: &VendorInfo{
|
||||||
|
Name: "京东到家",
|
||||||
|
OrgCodeName: "商户代码",
|
||||||
|
Value1Name: "AppKey",
|
||||||
|
Value2Name: "AppSecret",
|
||||||
|
Value3Name: "Token",
|
||||||
|
Value4Name: "管理后台Cookie",
|
||||||
|
},
|
||||||
|
VendorIDMTWM: &VendorInfo{
|
||||||
|
Name: "美团外卖",
|
||||||
|
OrgCodeName: "AppID",
|
||||||
|
Value1Name: "Secret",
|
||||||
|
Value2Name: "回调URL",
|
||||||
|
},
|
||||||
|
VendorIDEBAI: &VendorInfo{
|
||||||
|
Name: "饿百联盟",
|
||||||
|
OrgCodeName: "商户代码",
|
||||||
|
Value1Name: "Source",
|
||||||
|
Value2Name: "Secret",
|
||||||
|
Value3Name: "管理后台Cookie",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetVendorMask(vendorIDs ...int) (vendorMask int) {
|
||||||
|
for _, vendorID := range vendorIDs {
|
||||||
|
vendorMask |= 1 << uint(vendorID)
|
||||||
|
}
|
||||||
|
return vendorMask
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetVendorType(vendorID int) (vendorType int) {
|
||||||
|
if vendorID >= VendorIDPurchaseBegin && VendorIDPurchaseBegin <= VendorIDPurchaseEnd {
|
||||||
|
return VendorTypePurchase
|
||||||
|
} else if vendorID >= VendorIDPurchaseBegin && VendorIDPurchaseBegin <= VendorIDPurchaseEnd {
|
||||||
|
return VendorTypeDelivery
|
||||||
|
} else if vendorID >= VendorIDOthersBegin {
|
||||||
|
return VendorTypeOthers
|
||||||
|
}
|
||||||
|
return VendorTypeUnknown
|
||||||
|
}
|
||||||
|
|
||||||
type AppKeyConfig struct {
|
type AppKeyConfig struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
VendorID int
|
VendorID int `json:"vendorID"`
|
||||||
AppCode string // 同一平台下不同的商户代码
|
OrgCode string `orm:"size(32)" json:"orgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
AppName string
|
Name string `orm:"size(32)" json:"name"`
|
||||||
AppType int
|
Value1 string `orm:"size(1024)" json:"value1"`
|
||||||
Value1 string
|
Value2 string `orm:"size(1024)" json:"value2"`
|
||||||
Value2 string
|
Value3 string `orm:"size(1024)" json:"value3"`
|
||||||
Value3 string
|
Value4 string `orm:"size(1024)" json:"value4"`
|
||||||
Value4 string
|
Value5 string `orm:"size(1024)" json:"value5"`
|
||||||
Value5 string
|
}
|
||||||
|
|
||||||
|
func (a *AppKeyConfig) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"VendorID", "OrgCode", "DeletedAt"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,65 +6,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VendorIDJD, VendorIDMTWM与VendorIDELM的定义和老系统是兼容的
|
|
||||||
const (
|
|
||||||
VendorIDUnknown = -1
|
|
||||||
VendorIDPurchaseBegin = 0
|
|
||||||
VendorIDJD = 0
|
|
||||||
VendorIDMTWM = 1
|
|
||||||
VendorIDELM = 2
|
|
||||||
VendorIDEBAI = 3
|
|
||||||
VendorIDWSC = 11 // 微盟微商城
|
|
||||||
VendorIDPurchaseEnd = 11
|
|
||||||
VendorIDJX = 9 // 这是一个假的京西VendorID
|
|
||||||
|
|
||||||
VendorIDDeliveryBegin = 101
|
|
||||||
VendorIDDada = 101
|
|
||||||
VendorIDMTPS = 102
|
|
||||||
VendorIDFengNiao = 103
|
|
||||||
VendorIDDeliveryEnd = VendorIDFengNiao
|
|
||||||
|
|
||||||
VendorIDPrinterBegin = 201
|
|
||||||
VendorIDFeiE = 201 // 飞鹅打印机
|
|
||||||
VendorIDXiaoWM = 202 // 外卖管家打印机
|
|
||||||
VendorIDYiLianYun = 203 // 易联云
|
|
||||||
VendorIDZhongWu = 204 // 中午云打印
|
|
||||||
VendorIDPrinterEnd = 204
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
VendorNames = map[int]string{
|
|
||||||
VendorIDJD: "Jd",
|
|
||||||
VendorIDMTWM: "Mtwm",
|
|
||||||
VendorIDELM: "Elm",
|
|
||||||
VendorIDEBAI: "Ebai",
|
|
||||||
VendorIDWSC: "Wsc",
|
|
||||||
|
|
||||||
VendorIDDada: "Dada",
|
|
||||||
VendorIDMTPS: "Mtps",
|
|
||||||
|
|
||||||
VendorIDFeiE: "Feie",
|
|
||||||
VendorIDXiaoWM: "XiaoWM",
|
|
||||||
VendorIDYiLianYun: "Yilianyun",
|
|
||||||
VendorIDZhongWu: "ZhongWu",
|
|
||||||
}
|
|
||||||
|
|
||||||
VendorChineseNames = map[int]string{
|
|
||||||
VendorIDJD: "京东到家",
|
|
||||||
VendorIDMTWM: "美团外卖",
|
|
||||||
VendorIDELM: "饿了么",
|
|
||||||
VendorIDEBAI: "饿百新零售",
|
|
||||||
VendorIDWSC: "微盟微商城",
|
|
||||||
|
|
||||||
VendorIDDada: "达达众包",
|
|
||||||
VendorIDMTPS: "美团配送",
|
|
||||||
|
|
||||||
VendorIDFeiE: "飞鹅",
|
|
||||||
VendorIDXiaoWM: "外卖管家",
|
|
||||||
VendorIDYiLianYun: "易联云",
|
|
||||||
VendorIDZhongWu: "中午云",
|
|
||||||
}
|
|
||||||
|
|
||||||
PurchaseVendorInfo = map[int]map[string]interface{}{
|
PurchaseVendorInfo = map[int]map[string]interface{}{
|
||||||
VendorIDJD: map[string]interface{}{
|
VendorIDJD: map[string]interface{}{
|
||||||
"chineseName": VendorChineseNames[VendorIDJD],
|
"chineseName": VendorChineseNames[VendorIDJD],
|
||||||
@@ -412,10 +354,3 @@ func IsAfsOrderFinalStatus(status int) bool {
|
|||||||
const (
|
const (
|
||||||
DefaultEarningPricePercentage = 70 // 门店缺省结算百分比
|
DefaultEarningPricePercentage = 70 // 门店缺省结算百分比
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetVendorMask(vendorIDs ...int) (vendorMask int) {
|
|
||||||
for _, vendorID := range vendorIDs {
|
|
||||||
vendorMask |= 1 << uint(vendorID)
|
|
||||||
}
|
|
||||||
return vendorMask
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package jd
|
package jd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -8,14 +9,14 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
curPurchaseHandler *PurchaseHandler
|
|
||||||
)
|
|
||||||
|
|
||||||
type PurchaseHandler struct {
|
type PurchaseHandler struct {
|
||||||
partner.BasePurchasePlatform
|
partner.BasePurchasePlatform
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
curPurchaseHandler *PurchaseHandler
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if api.JdAPI != nil {
|
if api.JdAPI != nil {
|
||||||
curPurchaseHandler = new(PurchaseHandler)
|
curPurchaseHandler = new(PurchaseHandler)
|
||||||
@@ -23,6 +24,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getAPI(orgCode string) (apiObj *jdapi.API) {
|
||||||
|
return partner.CurAPIManager.GetAPI(model.VendorIDJD, orgCode).(*jdapi.API)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *PurchaseHandler) GetVendorID() int {
|
func (c *PurchaseHandler) GetVendorID() int {
|
||||||
return model.VendorIDJD
|
return model.VendorIDJD
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,19 +22,25 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/zhongwuapi"
|
"git.rosy.net.cn/baseapi/platformapi/zhongwuapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/qiniu/api.v7/auth/qbox"
|
"github.com/qiniu/api.v7/auth/qbox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type APIManager struct {
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
curAPIManager *APIManager
|
||||||
|
|
||||||
JdAPI *jdapi.API
|
JdAPI *jdapi.API
|
||||||
JdPageAPI *jdapi.API
|
JdPageAPI *jdapi.API
|
||||||
ElmAPI *elmapi.API
|
ElmAPI *elmapi.API
|
||||||
EbaiAPI *ebaiapi.API
|
EbaiAPI *ebaiapi.API
|
||||||
|
MtwmAPI *mtwmapi.API
|
||||||
MtpsAPI *mtpsapi.API
|
MtpsAPI *mtpsapi.API
|
||||||
DadaAPI *dadaapi.API
|
DadaAPI *dadaapi.API
|
||||||
MtwmAPI *mtwmapi.API
|
|
||||||
WeixinAPI *weixinapi.API // 微信公众号
|
WeixinAPI *weixinapi.API // 微信公众号
|
||||||
WeixinMiniAPI *weixinapi.API // 小程序
|
WeixinMiniAPI *weixinapi.API // 小程序
|
||||||
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
WeixinMiniAPI2 *weixinapi.API // 小程序2
|
||||||
@@ -59,12 +65,22 @@ var (
|
|||||||
Cacher cache.ICacher
|
Cacher cache.ICacher
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
||||||
|
if vendorID == model.VendorIDJD {
|
||||||
|
pfAPI = JdAPI
|
||||||
|
}
|
||||||
|
return pfAPI
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Init() // 这里必须要调用
|
Init() // 这里必须要调用
|
||||||
}
|
}
|
||||||
|
|
||||||
// 这样写的原因是在测试时,可以重新读取配置文件
|
// 这样写的原因是在测试时,可以重新读取配置文件
|
||||||
func Init() {
|
func Init() {
|
||||||
|
curAPIManager = &APIManager{}
|
||||||
|
// partner.InitAPIManager(curAPIManager)
|
||||||
|
|
||||||
if !beego.AppConfig.DefaultBool("disableJd", false) {
|
if !beego.AppConfig.DefaultBool("disableJd", false) {
|
||||||
JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
||||||
cookieValue := beego.AppConfig.DefaultString("jdStorePageCookie", "")
|
cookieValue := beego.AppConfig.DefaultString("jdStorePageCookie", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user