修改微盟回调的bug

This commit is contained in:
gazebo
2019-10-31 14:06:14 +08:00
parent 5dc67bcd9e
commit ae58b41ac6
2 changed files with 8 additions and 2 deletions

View File

@@ -26,11 +26,14 @@ func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResp
} }
func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) {
globals.SugarLogger.Debugf("onOrderMsg:%s", utils.Format4Output(msg, true))
if msg.Event == weimobapi.MsgEventOrderStatusChange { if msg.Event == weimobapi.MsgEventOrderStatusChange {
if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil {
if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment {
changeStoreSkusByOrder(orderDetail) changeStoreSkusByOrder(orderDetail)
} }
} else {
response = weimobapi.Err2CallbackResponse(err, "")
} }
} }
return response return response
@@ -43,6 +46,7 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) {
if len(storeList) == 1 { if len(storeList) == 1 {
var skuBindInfos []*cms.StoreSkuBindInfo var skuBindInfos []*cms.StoreSkuBindInfo
storeID := storeList[0].ID storeID := storeList[0].ID
globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID)
for _, v := range order.ItemList { for _, v := range order.ItemList {
nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0)) nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0))
unitPrice := v.OriginalPrice unitPrice := v.OriginalPrice

View File

@@ -2,8 +2,8 @@ package controllers
import ( import (
"git.rosy.net.cn/baseapi/platformapi/weimobapi" "git.rosy.net.cn/baseapi/platformapi/weimobapi"
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
"git.rosy.net.cn/jx-callback/business/cs" "git.rosy.net.cn/jx-callback/business/cs"
"git.rosy.net.cn/jx-callback/business/jxutils/tasks"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego" "github.com/astaxie/beego"
@@ -15,12 +15,14 @@ type WeimobController struct {
func (c *WeimobController) onCallbackMsg() { func (c *WeimobController) onCallbackMsg() {
if true { //c.Ctx.Input.Method() == http.MethodPost { if true { //c.Ctx.Input.Method() == http.MethodPost {
callbackResponse := weimobapi.SuccessResponse
msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody)
if callbackResponse == nil { if callbackResponse == nil {
// callbackResponse = wsc.OnCallbackMsg(msg) // callbackResponse = wsc.OnCallbackMsg(msg)
callbackResponse = cs.OnCallbackMsg(msg) callbackResponse = cs.OnCallbackMsg(msg)
} }
if callbackResponse == nil {
callbackResponse = weimobapi.SuccessResponse
}
c.Data["json"] = callbackResponse c.Data["json"] = callbackResponse
c.ServeJSON() c.ServeJSON()
} else { } else {