aa
This commit is contained in:
@@ -452,6 +452,7 @@ func (c *OrderManager) ExportOrders(ctx *jxcontext.Context, fromDateStr, toDateS
|
||||
"status2",
|
||||
"skuInfo",
|
||||
"waybillTipMoney",
|
||||
"orderPayPercentage",
|
||||
// "skuInfo2",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -242,6 +242,18 @@ func UpdateVendorOrgCode(ctx *jxcontext.Context, ID int, payload map[string]inte
|
||||
)
|
||||
vendorOrgCode.ID = ID
|
||||
err = dao.GetEntity(db, vendorOrgCode)
|
||||
if payload["key"] != nil {
|
||||
payload["vendorOrgCode"] = payload["key"]
|
||||
delete(payload, "key")
|
||||
}
|
||||
if payload["code"] != nil {
|
||||
payload["vendorID"] = payload["code"]
|
||||
delete(payload, "code")
|
||||
}
|
||||
if payload["name"] != nil {
|
||||
payload["comment"] = payload["name"]
|
||||
delete(payload, "name")
|
||||
}
|
||||
valid := dao.StrictMakeMapByStructObject(payload, vendorOrgCode, ctx.GetUserName())
|
||||
if len(valid) > 0 {
|
||||
dao.Begin(db)
|
||||
|
||||
@@ -348,9 +348,9 @@ func Init() {
|
||||
jdsCookie = configs[0].Value
|
||||
api.JdShopAPI.SetCookieWithStr(jdsCookie)
|
||||
}
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||
}
|
||||
// if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
// api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||
// }
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||
yinbaoCookie := configs[0].Value
|
||||
api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie)
|
||||
|
||||
@@ -18,4 +18,7 @@ type VendorOrgCode struct {
|
||||
IsOpen int `json:"isOpen"` //主要三方配送用,是否配送,默认0表示打开,1表示关
|
||||
EmpowerURL string `orm:"column(empower_url)" json:"empowerURL"` //授权地址
|
||||
StoreBrandName string `json:"storeBrandName"` //建店品牌名(和饿百供应商不同,美团是根据平台账号划分)
|
||||
Token string `json:"token"`
|
||||
AppKey string `json:"appKey"`
|
||||
AppSecret string `json:"appSecret"`
|
||||
}
|
||||
|
||||
@@ -22,8 +22,32 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
ComplaintReasonsFn150 = 150 //:未保持餐品完整,
|
||||
ComplaintReasonsFn220 = 220 //:少餐错餐,
|
||||
ComplaintReasonsFn160 = 160 //:服务态度恶劣,
|
||||
ComplaintReasonsFn190 = 190 //:额外索取费用,
|
||||
ComplaintReasonsFn170 = 170 //:诱导收货人或商户退单,
|
||||
ComplaintReasonsFn140 = 140 //:提前点击送达,
|
||||
ComplaintReasonsFn210 = 210 //:虚假标记异常,
|
||||
ComplaintReasonsFn200 = 200 //:虚假点击配送成功,
|
||||
ComplaintReasonsFn130 = 130 //:未进行配送,导致订单失败或取消,
|
||||
ComplaintReasonsFn120 = 120 //:配送超时
|
||||
)
|
||||
|
||||
var (
|
||||
curDeliveryHandler *DeliveryHandler
|
||||
complaintReson2FnResonMap = map[int]int{
|
||||
model.ComplaintReasons1: ComplaintReasonsFn160,
|
||||
model.ComplaintReasons2: ComplaintReasonsFn130,
|
||||
model.ComplaintReasons3: ComplaintReasonsFn130,
|
||||
model.ComplaintReasons4: ComplaintReasonsFn120,
|
||||
model.ComplaintReasons5: ComplaintReasonsFn130,
|
||||
model.ComplaintReasons6: ComplaintReasonsFn150,
|
||||
model.ComplaintReasons7: ComplaintReasonsFn190,
|
||||
model.ComplaintReasons69: ComplaintReasonsFn170,
|
||||
model.ComplaintReasons71: ComplaintReasonsFn140,
|
||||
}
|
||||
)
|
||||
|
||||
type DeliveryHandler struct {
|
||||
@@ -59,7 +83,7 @@ func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int,
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||
|
||||
err = api.FnAPI.ComplaintRider(bill.VendorOrderID, complaintReson2FnResonMap[resonID])
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ func (c *PurchaseHandler) SyncQualify(ctx *jxcontext.Context, storeDetail *dao.S
|
||||
}
|
||||
var qualifyList []*jdapi.QualifyItem
|
||||
licenceDetail, err := api.JdPageAPI.GetCorporationInfo(storeDetail.VendorStoreID, storeDetail.LicenceCode)
|
||||
if err != nil {
|
||||
if err != nil && !strings.Contains(err.Error(), "degrade") {
|
||||
return addStoreInfo2Err(err, storeDetail.ID)
|
||||
}
|
||||
licenceURL, err := c.storeUploadImgByURL(storeDetail.VendorOrgCode, storeDetail.Licence)
|
||||
|
||||
@@ -264,7 +264,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
}
|
||||
}
|
||||
order.PickDeadline = order.ExpectedDeliveredTime.Add(-time.Hour)
|
||||
} else if msg.OrderState == jdshopapi.OrderStatusWait {
|
||||
} else if msg.OrderState == jdshopapi.OrderStatusWait || msg.OrderState == "WAIT_GOODS_RECEIVE_CONFIRM" || msg.OrderState == "FINISHED_L" {
|
||||
order.ExpectedDeliveredTime = order.OrderCreatedAt.Add(time.Hour)
|
||||
order.BusinessType = model.BusinessTypeImmediate
|
||||
} else if msg.OrderState == "UN_KNOWN" {
|
||||
|
||||
@@ -5,6 +5,7 @@ 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/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
@@ -37,7 +38,13 @@ func getAPI(appOrgCode string) (apiObj *jdshopapi.API) {
|
||||
if appOrgCode == "" {
|
||||
globals.SugarLogger.Warnf("getAPI appOrgCode is empty")
|
||||
}
|
||||
return partner.CurAPIManager.GetAPI(model.VendorIDJDShop, appOrgCode).(*jdshopapi.API)
|
||||
apiObj = partner.CurAPIManager.GetAPI(model.VendorIDJDShop, appOrgCode).(*jdshopapi.API)
|
||||
if appOrgCode == "2" {
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
apiObj.SetCookieWithStr(configs[0].Value)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetVendorID() int {
|
||||
@@ -47,7 +54,7 @@ func (p *PurchaseHandler) GetVendorID() int {
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
||||
if globals.EnableJdShopWrite {
|
||||
if imgType > model.ImgTypeLocal {
|
||||
result, err := api.JdShopAPI.UploadPicture(imgData, 0, imgName)
|
||||
result, err := getAPI(vendorOrgCode).UploadPicture(imgData, 0, imgName)
|
||||
if err == nil {
|
||||
imgHint = result.PictureURL
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
status = model.OrderStatusAccepted
|
||||
//京东商城第二个号要自动接单
|
||||
if order.VendorOrgCode == "2" {
|
||||
err = api.JdShop2API.SetOrderStateToWait(utils.Str2Int64(order.VendorOrderID2))
|
||||
err = getAPI(order.VendorOrgCode).SetOrderStateToWait(utils.Str2Int64(order.VendorOrderID2))
|
||||
}
|
||||
} else {
|
||||
status = model.OrderStatusCanceled
|
||||
@@ -106,7 +106,7 @@ func (p *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
func (p *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
ChangeOrderStatus(order.VendorOrderID, model.OrderStatusFinished, "")
|
||||
if order.VendorOrgCode == "2" {
|
||||
api.JdShop2API.SetOrderStateToFinish(utils.Str2Int64(order.VendorOrderID2))
|
||||
getAPI(order.VendorOrgCode).SetOrderStateToFinish(utils.Str2Int64(order.VendorOrderID2))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
CategoryName: jdshopapi.JdsStoreCategoryName,
|
||||
CustomerID: utils.Int2Str(store.ID),
|
||||
}
|
||||
url, _ := api.JdShop2API.UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
||||
url, _ := getAPI("2").UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
||||
ex := store.LicenceExpire
|
||||
if ex == "" {
|
||||
ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0))
|
||||
@@ -112,7 +112,7 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
if store.Licence != "" {
|
||||
data2, _, _ := jxutils.DownloadFileByURL(store.Licence)
|
||||
fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)]
|
||||
url2, _ = api.JdShop2API.UploadImageNew(data2, fileName)
|
||||
url2, _ = getAPI("2").UploadImageNew(data2, fileName)
|
||||
}
|
||||
storeName := store.Name
|
||||
if strings.Contains(storeName, "(") {
|
||||
@@ -197,9 +197,9 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
}
|
||||
}
|
||||
vendorStoreID, err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
|
||||
if vendorStroeID2, err := api.JdShop2API.SubmitBasic(param); err == nil {
|
||||
if vendorStroeID2, err := getAPI("2").SubmitBasic(param); err == nil {
|
||||
time.Sleep(time.Second)
|
||||
err = api.JdShop2API.UpdateExpand(int(vendorStroeID2))
|
||||
err = getAPI("2").UpdateExpand(int(vendorStroeID2))
|
||||
var storeMap *model.StoreMap
|
||||
sql := `
|
||||
SELECT * FROM store_map WHERE deletad_at = ? AND store_id = ? AND vendor_id = ? AND vendor_org_code = ?
|
||||
|
||||
@@ -58,7 +58,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
if v.VendorOrgCode == "2" && flag2 {
|
||||
err = api.JdShop2API.WareDoUpdate("op", utils.Int64ToStr(v.JdsWareID))
|
||||
err = getAPI(v.VendorOrgCode).WareDoUpdate("op", utils.Int64ToStr(v.JdsWareID))
|
||||
} else {
|
||||
if result.TotalItem > 0 && len(result.Data) > 0 && flag {
|
||||
//jds2
|
||||
@@ -82,7 +82,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
var wareSaveSkus []*jdshopapi.WareSaveSkus
|
||||
//先把已有的规格放进去
|
||||
if v.VendorOrgCode == "2" {
|
||||
wareResult, _ := api.JdShop2API.FindWareById(wareSaveParam.WareID)
|
||||
wareResult, _ := getAPI(v.VendorOrgCode).FindWareById(wareSaveParam.WareID)
|
||||
if wareResult != nil {
|
||||
for _, v := range wareResult.Images {
|
||||
wareSaveParam.ImageMap.Num0000000000 = append(wareSaveParam.ImageMap.Num0000000000, &jdshopapi.CreateSkuParamImages{
|
||||
@@ -92,7 +92,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
})
|
||||
}
|
||||
}
|
||||
skus, _, _ := api.JdShop2API.SearchSkuList2([]int{int(wareSaveParam.WareID)})
|
||||
skus, _, _ := getAPI(v.VendorOrgCode).SearchSkuList2([]int{int(wareSaveParam.WareID)})
|
||||
if len(skus) > 0 {
|
||||
for _, vv := range skus {
|
||||
sku := &jdshopapi.WareSaveSkus{
|
||||
@@ -138,8 +138,8 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
//创建商品后要上架,改价,库存,门店关注商品等
|
||||
if err = api.JdShop2API.WareDoUpdate("up", utils.Int64ToStr(wareSaveParam.WareID)); err == nil {
|
||||
err = api.JdShop2API.StoreSkuBindStore(true, []string{vv.VendorSkuID}, nil)
|
||||
if err = getAPI(v.VendorOrgCode).WareDoUpdate("up", utils.Int64ToStr(wareSaveParam.WareID)); err == nil {
|
||||
err = getAPI(v.VendorOrgCode).StoreSkuBindStore(true, []string{vv.VendorSkuID}, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
} else {
|
||||
var createSkuResult []*jdshopapi.WareSaveResult
|
||||
for i := 0; i < 10; i++ {
|
||||
createSkuResult, err = api.JdShop2API.WareSave(wareSaveParam)
|
||||
createSkuResult, err = getAPI(v.VendorOrgCode).WareSave(wareSaveParam)
|
||||
if len(createSkuResult) > 0 {
|
||||
break
|
||||
}
|
||||
@@ -209,10 +209,10 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
//创建商品后要上架,改价,库存,门店关注商品等
|
||||
if err = api.JdShop2API.WareDoUpdate("up", utils.Int64ToStr(wareID)); err == nil {
|
||||
if err = getAPI(v.VendorOrgCode).WareDoUpdate("up", utils.Int64ToStr(wareID)); err == nil {
|
||||
for _, vv2 := range v.StoreSkuSyncInfoJds {
|
||||
if resultAttrs[utils.Int2Str(vv2.SkuID)] != 0 {
|
||||
err = api.JdShop2API.StoreSkuBindStore(true, []string{utils.Int64ToStr(resultAttrs[utils.Int2Str(vv2.SkuID)])}, nil)
|
||||
err = getAPI(v.VendorOrgCode).StoreSkuBindStore(true, []string{utils.Int64ToStr(resultAttrs[utils.Int2Str(vv2.SkuID)])}, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,20 +259,20 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
stock := vv.Stock
|
||||
price := vv.VendorPrice
|
||||
if status == model.StoreSkuBindStatusNormal {
|
||||
err = api.JdShop2API.StoreWareDoUpdate(status, storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(vv.VendorOrgCode).StoreWareDoUpdate(status, storeSku.JdsID, vendorStoreID)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
if stock != 0 {
|
||||
err = api.JdShop2API.StoreUpdateStock(stock, storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(vv.VendorOrgCode).StoreUpdateStock(stock, storeSku.JdsID, vendorStoreID)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
err = api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), storeSku.JdsID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -440,7 +440,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
wareSaveSku.SkuID = utils.Str2Int64(vv.VendorSkuID)
|
||||
wareSaveSkus = append(wareSaveSkus, wareSaveSku)
|
||||
}
|
||||
api.JdShop2API.WareSave(wareSaveParam)
|
||||
getAPI("2").WareSave(wareSaveParam)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -462,7 +462,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
err = getAPI(v.VendorOrgCode).DeleteWare(utils.Str2Int(v.VendorSkuID2))
|
||||
}
|
||||
} else {
|
||||
err = api.JdShop2API.WareDoUpdate("down", v.VendorSkuID2)
|
||||
err = getAPI(v.VendorOrgCode).WareDoUpdate("down", v.VendorSkuID2)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -531,7 +531,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
||||
}
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreWareDoUpdate(status, vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreWareDoUpdate(status, vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
// null
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(v.VendorPrice)), vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(v.VendorPrice)), vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
|
||||
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreUpdateStock(v.Stock, vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdateStock(v.Stock, vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,6 +577,7 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
err = nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -164,8 +164,9 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
},
|
||||
MultiPoiShippingInfo: &mtwmapi.MultiPoiShippingInfo{
|
||||
ShippingType: 5, //1:商家自配 5:美团专送,101:美团快送
|
||||
MinPrice: params["minPrice"].(float64),
|
||||
ShippingFee: params["shippingFee"].(float64),
|
||||
//美团专送不需要输下面这俩
|
||||
// MinPrice: params["minPrice"].(float64),
|
||||
// ShippingFee: params["shippingFee"].(float64),
|
||||
},
|
||||
//资质
|
||||
},
|
||||
@@ -213,7 +214,8 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
cert.LicensePic, cert.LicenseSocialCreditCode, cert.LicenseNumber, cert.LicenseLegalPerson, cert.LicenseAddress, cert.LicenseValidStartDate, cert.LicenseValidity, cert.IsLongTime = switchCertType(v)
|
||||
certs = append(certs, cert)
|
||||
}
|
||||
mtapi := getAPIWithoutToken(storeDetail.VendorOrgCode)
|
||||
poiSettleSaveParam.ApplyInfos[0].MultiPoiCertInfos = certs
|
||||
mtapi := getAPIWithoutToken(vendorOrgCode)
|
||||
if vendorStoreID, err = mtapi.PoiSettleSave(poiSettleSaveParam); err == nil {
|
||||
err = mtapi.PoiSettleAuditSubmit([]string{vendorStoreID})
|
||||
}
|
||||
|
||||
@@ -112,29 +112,32 @@ func init() {
|
||||
// 这样写的原因是在测试时,可以重新读取配置文件
|
||||
func Init() {
|
||||
if !beego.AppConfig.DefaultBool("disableJd", false) {
|
||||
JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
||||
// cookieValue := beego.AppConfig.DefaultString("jdStorePageCookie", "")
|
||||
// JdAPI.SetJdCookie(cookieValue)
|
||||
//初始化京东api
|
||||
// JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
||||
JdAPI = jdapi.New("", "", "")
|
||||
|
||||
conf := platformapi.NewDefAPIConfig()
|
||||
conf.MaxSleepSecondWhenExceedLimit = 60 * 30 // 最大重试间隙30分钟
|
||||
JdPageAPI = jdapi.NewPageOnly("", conf)
|
||||
|
||||
if globals.Jd2OrgCode != "" {
|
||||
Jd2API = jdapi.New(beego.AppConfig.String("jd2Token"), beego.AppConfig.String("jd2AppKey"), beego.AppConfig.String("jd2Secret"))
|
||||
// Jd2API.SetJdCookie(beego.AppConfig.DefaultString("jd2StorePageCookie", ""))
|
||||
// Jd2API = jdapi.New(beego.AppConfig.String("jd2Token"), beego.AppConfig.String("jd2AppKey"), beego.AppConfig.String("jd2Secret"))
|
||||
Jd2API = jdapi.New("", "", "")
|
||||
}
|
||||
|
||||
if globals.Jd3OrgCode != "" {
|
||||
Jd3API = jdapi.New(beego.AppConfig.String("jd3Token"), beego.AppConfig.String("jd3AppKey"), beego.AppConfig.String("jd3Secret"))
|
||||
// Jd3API = jdapi.New(beego.AppConfig.String("jd3Token"), beego.AppConfig.String("jd3AppKey"), beego.AppConfig.String("jd3Secret"))
|
||||
Jd3API = jdapi.New("", "", "")
|
||||
}
|
||||
|
||||
if globals.JdcsOrgCode != "" {
|
||||
JdcsAPI = jdapi.New(beego.AppConfig.String("jdcsToken"), beego.AppConfig.String("jdcsAppKey"), beego.AppConfig.String("jdcsSecret"))
|
||||
// JdcsAPI = jdapi.New(beego.AppConfig.String("jdcsToken"), beego.AppConfig.String("jdcsAppKey"), beego.AppConfig.String("jdcsSecret"))
|
||||
JdAPI = jdapi.New("", "", "")
|
||||
}
|
||||
|
||||
if globals.JdydOrgCode != "" {
|
||||
JdydAPI = jdapi.New(beego.AppConfig.String("jdydToken"), beego.AppConfig.String("jdydAppKey"), beego.AppConfig.String("jdydSecret"))
|
||||
// JdydAPI = jdapi.New(beego.AppConfig.String("jdydToken"), beego.AppConfig.String("jdydAppKey"), beego.AppConfig.String("jdydSecret"))
|
||||
JdAPI = jdapi.New("", "", "")
|
||||
}
|
||||
|
||||
fakeJdToken := beego.AppConfig.DefaultString("fakeJdToken", "")
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package apimanager
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
@@ -32,19 +34,22 @@ func init() {
|
||||
}
|
||||
|
||||
func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{}) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
switch vendorID {
|
||||
case model.VendorIDJD:
|
||||
pfAPI = api.JdAPI
|
||||
if appOrgCode == FakeJdOrgCode {
|
||||
pfAPI = api.FakeJdAPI
|
||||
} else if appOrgCode != "" && appOrgCode == globals.Jd2OrgCode {
|
||||
pfAPI = api.Jd2API
|
||||
} else if appOrgCode != "" && appOrgCode == globals.Jd3OrgCode {
|
||||
pfAPI = api.Jd3API
|
||||
} else if appOrgCode != "" && appOrgCode == globals.JdcsOrgCode {
|
||||
pfAPI = api.JdcsAPI
|
||||
} else if appOrgCode != "" && appOrgCode == globals.JdydOrgCode {
|
||||
pfAPI = api.JdydAPI
|
||||
} else {
|
||||
codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform")
|
||||
code := codes[0]
|
||||
api.JdAPI = jdapi.New(code.Token, code.AppKey, code.AppSecret)
|
||||
pfAPI = api.JdAPI
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||
JdStorePageCookie := configs[0].Value
|
||||
api.JdAPI.SetJdCookie(JdStorePageCookie)
|
||||
}
|
||||
}
|
||||
case model.VendorIDMTWM:
|
||||
pfAPI = api.MtwmAPI
|
||||
|
||||
Reference in New Issue
Block a user