去除getAPI("")调用,没有vendorOrgCode时报警
This commit is contained in:
@@ -325,7 +325,7 @@ func (c *PurchaseHandler) onActMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.C
|
||||
if _, ok := actMap.Load(intPromotionID); !ok {
|
||||
utils.CallFuncAsync(func() {
|
||||
if !partner.CurActManager.IsVendorActExist(jxcontext.AdminCtx, promotionID, model.VendorIDJD) {
|
||||
act, actStoreSkuList, err := getActFromJD(appKey2OrgCode(msg.AppKey), promotionID)
|
||||
act, actStoreSkuList, err := getActFromJD(AppKey2OrgCode(msg.AppKey), promotionID)
|
||||
if err == nil && len(actStoreSkuList) > 0 {
|
||||
_, err = partner.CurActManager.CreateActFromVendor(jxcontext.AdminCtx, act, actStoreSkuList)
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ import (
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
retVal = CurPurchaseHandler.OnOrderMsg(appKey2OrgCode(msg.AppKey), msg)
|
||||
retVal = CurPurchaseHandler.OnOrderMsg(AppKey2OrgCode(msg.AppKey), msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
retVal = CurPurchaseHandler.OnWaybillMsg(appKey2OrgCode(msg.AppKey), msg)
|
||||
retVal = CurPurchaseHandler.OnWaybillMsg(AppKey2OrgCode(msg.AppKey), msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if CurPurchaseHandler != nil {
|
||||
retVal = CurPurchaseHandler.OnStoreMsg(appKey2OrgCode(msg.AppKey), msg)
|
||||
retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func (p *PurchaseHandler) OnFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *j
|
||||
// 京东正向/退款订单类型处理--存储
|
||||
func (p *PurchaseHandler) onFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
var err error
|
||||
a := GetAPIByAppKey(msg.AppKey)
|
||||
a := getAPI(AppKey2OrgCode(msg.AppKey))
|
||||
// if msg.StatusID == jdapi.OrderStatusPayFinishedSettle || msg.StatusID == jdapi.OrderStatusTipChanged || msg.StatusID == jdapi.OrderStatusSwitch2SelfSettle { // 如果是正向单
|
||||
if msg.StatusID == jdapi.OrderStatusPayFinishedSettle || msg.StatusID == jdapi.OrderStatusTipChanged || msg.StatusID == jdapi.OrderStatusAdjustSettle || msg.StatusID == jdapi.OrderStatusSwitch2SelfSettle { // 如果是正向单
|
||||
order, err2 := partner.CurOrderManager.LoadOrder(msg.BillID, model.VendorIDJD)
|
||||
|
||||
@@ -23,6 +23,9 @@ func init() {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -30,7 +33,7 @@ func GetAPI(appOrgCode string) (apiObj *jdapi.API) {
|
||||
return getAPI(appOrgCode)
|
||||
}
|
||||
|
||||
func appKey2OrgCode(appKey string) (vendorOrgCode string) {
|
||||
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)
|
||||
@@ -42,22 +45,6 @@ func appKey2OrgCode(appKey string) (vendorOrgCode string) {
|
||||
return vendorOrgCode
|
||||
}
|
||||
|
||||
func GetAPIByAppKey(appKey string) (apiObj *jdapi.API) {
|
||||
if appKey == "" {
|
||||
apiObj = getAPI("")
|
||||
} else {
|
||||
apiList := partner.CurAPIManager.GetAppOrgCodeList(model.VendorIDJD)
|
||||
for _, v := range apiList {
|
||||
jdAPI := partner.CurAPIManager.GetAPI(model.VendorIDJD, v).(*jdapi.API)
|
||||
if jdAPI.GetAppKey() == appKey {
|
||||
apiObj = jdAPI
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return apiObj
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
return model.VendorIDJD
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -113,7 +114,7 @@ func (p *PurchaseHandler) ReorderCategories2(ctx *jxcontext.Context, vendorOrgCo
|
||||
|
||||
func (p *PurchaseHandler) getVendorCategories(level int, pid int64) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
// 得到平台的分类,不需要指定分账号
|
||||
cats, err := getAPI("").QueryChildCategoriesForOP(pid)
|
||||
cats, err := api.Jd2API.QueryChildCategoriesForOP(pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (c *PurchaseHandler) callbackMsg2Waybill(msg *jdapi.CallbackDeliveryStatusM
|
||||
StatusTime: utils.Str2Time(msg.DeliveryStatusTime),
|
||||
Remark: msg.Remark,
|
||||
|
||||
VendorOrgCode: appKey2OrgCode(msg.AppKey),
|
||||
VendorOrgCode: AppKey2OrgCode(msg.AppKey),
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (c *DjswController) handleMsg(isNeedDecode bool, handler func(*jdapi.API, i
|
||||
callbackMsg, mapData, callbackResponse := jdapi.GetCallbackMsg2(getUsefulRequest(c.Ctx))
|
||||
globals.SugarLogger.Debug(utils.Format4Output(callbackMsg, true))
|
||||
if callbackResponse == nil {
|
||||
if jdAPI := jd.GetAPIByAppKey(callbackMsg.AppKey); jdAPI != nil {
|
||||
if jdAPI := jd.GetAPI(jd.AppKey2OrgCode(callbackMsg.AppKey)); jdAPI != nil {
|
||||
if callbackResponse = jdAPI.CheckCallbackValidation2(mapData, callbackMsg.Sign); callbackResponse == nil {
|
||||
callbackResponse = handler(jdAPI, callbackMsg.Param)
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
OutputDebugMsgLevel = 1
|
||||
|
||||
logs.SetLogFuncCallDepth(3)
|
||||
beego.BConfig.Log.AccessLogs = true
|
||||
|
||||
@@ -71,6 +69,10 @@ func init() {
|
||||
}
|
||||
|
||||
func Init() {
|
||||
if IsProductEnv(){
|
||||
OutputDebugMsgLevel = 1
|
||||
}
|
||||
|
||||
SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode)
|
||||
ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test")
|
||||
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
|
||||
|
||||
Reference in New Issue
Block a user