Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -699,7 +699,7 @@ func (c *OrderController) ConfirmReceiveGoods() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 同意或拒绝用户取消订单申请
|
||||
// @Title 同意或拒绝用户取消订单申请 (饿百)
|
||||
// @Description 同意或拒绝用户取消订单申请
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorOrderID formData string true "订单ID"
|
||||
|
||||
@@ -89,7 +89,7 @@ func (c *TaoBaoVegetableController) OrderStatus() {
|
||||
}
|
||||
|
||||
// 获取body参数
|
||||
order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
||||
order, body, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("order_status ReaderOrderInfo:= %s", utils.Format4Output(order, false))
|
||||
globals.SugarLogger.Debugf("order_status ReaderOrderInfo:= %s", utils.Format4Output(order, false))
|
||||
if err != nil {
|
||||
@@ -99,21 +99,24 @@ func (c *TaoBaoVegetableController) OrderStatus() {
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret())
|
||||
switch order.MerchantCode {
|
||||
case "CSSJ": // 淘宝回调地址检测
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
default:
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
} /*else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}*/
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyCancelOrder 用户发起售后申请
|
||||
@@ -130,7 +133,7 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() {
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request)
|
||||
afsOrder, body, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
globals.SugarLogger.Debugf("ApplyCancelOrder err := %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
@@ -141,21 +144,25 @@ func (c *TaoBaoVegetableController) ApplyCancelOrder() {
|
||||
}
|
||||
|
||||
// 验签 FFF779F16365992BD721C9C1A027F03C
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") { // 76626F983F0F7E4A159AD64F9B13B332
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret())
|
||||
switch afsOrder.MerchantCode {
|
||||
case "CSSJ":
|
||||
if sign != values.Get("sign") { // E8C3B7D19ECCB6618CB0F2C30BB086EC
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
default:
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder)
|
||||
globals.SugarLogger.Debugf("callbackResponse response : %s", utils.Format4Output(callbackResponse, false))
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// UserCancelRefund 用户取消售后
|
||||
@@ -172,7 +179,7 @@ func (c *TaoBaoVegetableController) UserCancelRefund() {
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request)
|
||||
afsOrder, body, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false))
|
||||
globals.SugarLogger.Debugf("UserCancelRefund err := %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
@@ -183,21 +190,25 @@ func (c *TaoBaoVegetableController) UserCancelRefund() {
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret())
|
||||
switch afsOrder.MerchantCode {
|
||||
case "CSSJ":
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
default:
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
} /*else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}*/
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// CancelOnSaleRefundOrder 用户售中取消(走订单取消流程)
|
||||
@@ -214,7 +225,7 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request)
|
||||
afsOrder, body, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
globals.SugarLogger.Debugf("CancelOnSaleRefundOrder err := %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
@@ -225,21 +236,24 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret())
|
||||
switch afsOrder.PartCancelRequest.MerchantCode {
|
||||
case "CSSJ":
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
default:
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.PartCancelRequest.BizOrderId), afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
} /*else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}*/
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.PartCancelRequest.BizOrderId), afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知)
|
||||
@@ -256,7 +270,7 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() {
|
||||
return
|
||||
}
|
||||
|
||||
refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request)
|
||||
refundSuccess, body, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false))
|
||||
globals.SugarLogger.Debugf("RefundOrderSuccess err := %s", utils.Format4Output(err, false))
|
||||
if err != nil {
|
||||
@@ -266,21 +280,24 @@ func (c *TaoBaoVegetableController) RefundOrderSuccess() {
|
||||
return
|
||||
}
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(refundSuccess, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
sign := Sign(values, body, api.TaoVegetableApi.GetAppSecret())
|
||||
switch refundSuccess.MerchantCode {
|
||||
case "CSSJ":
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
default:
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutMainRefundId, refundSuccess)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
} /*else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}*/
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func Sign(param url.Values, data, secret string) string {
|
||||
@@ -293,10 +310,11 @@ func Sign(param url.Values, data, secret string) string {
|
||||
}
|
||||
|
||||
sort.Strings(publicParam)
|
||||
resultParam := strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "")
|
||||
resultParam := strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", ""), "\r", "")
|
||||
if strings.Contains(resultParam, `\u0026`) {
|
||||
resultParam = strings.ReplaceAll(resultParam, `\u0026`, "&")
|
||||
}
|
||||
cc := secret + strings.Join(publicParam, "") + resultParam + secret
|
||||
|
||||
return fmt.Sprintf("%X", md5.Sum([]byte(cc)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user