1
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -196,7 +197,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{})
|
||||
orderStatus.RefVendorOrderID = refundData.OutOrderId
|
||||
orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusApplyAfs, "用户申请取消")
|
||||
orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusApplyAfs)
|
||||
orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp)
|
||||
orderStatus.StatusTime = time.Now()
|
||||
orderStatus.Remark = refundData.Remarks
|
||||
orderStatus.VendorOrderID = refundData.BizRefundId
|
||||
case tao_vegetable.OrderStatusCancelAfs:
|
||||
@@ -204,7 +205,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{})
|
||||
orderStatus.RefVendorOrderID = refundData.OutOrderId
|
||||
orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusCancelAfs, "用户取消售后申请")
|
||||
orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusCancelAfs)
|
||||
orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp)
|
||||
orderStatus.StatusTime = time.Now()
|
||||
orderStatus.VendorOrderID = refundData.BizRefundId
|
||||
//case tao_vegetable.OrderStatusOnSaleCancel:
|
||||
// refundData := msg.(*tao_vegetable.OnSaleCancel)
|
||||
@@ -218,7 +219,7 @@ func (c *PurchaseHandler) callbackAfsMsg2Status(status string, msg interface{})
|
||||
orderStatus.RefVendorOrderID = refundData.OutMainRefundId
|
||||
orderStatus.VendorStatus = fmt.Sprintf("%s:%s", tao_vegetable.OrderStatusRefundSuccess, "用户售后退款成功")
|
||||
orderStatus.Status = c.GetAfsStatusFromVendorStatus(tao_vegetable.OrderStatusRefundSuccess)
|
||||
orderStatus.StatusTime = utils.Str2Time(refundData.Timestamp)
|
||||
orderStatus.StatusTime = time.Now()
|
||||
orderStatus.VendorOrderID = refundData.BizSubRefundId
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,179 @@ func (c *TaoBaoVegetableController) GetCode() {
|
||||
return
|
||||
}
|
||||
|
||||
// OrderStatus 订单状态变化 [post]
|
||||
func (c *TaoBaoVegetableController) OrderStatus() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
|
||||
// 获取url参数
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 获取body参数
|
||||
order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyCancelOrder 用户发起售后申请
|
||||
func (c *TaoBaoVegetableController) ApplyCancelOrder() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
|
||||
// 获取url参数
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户发起售后:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// UserCancelRefund 用户取消售后
|
||||
func (c *TaoBaoVegetableController) UserCancelRefund() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
|
||||
// 获取url参数
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户取消售后:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// CancelOnSaleRefundOrder 用户售中取消(走订单取消流程)
|
||||
func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
|
||||
// 获取url参数
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户售中取消:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(afsOrder, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.BizOrderId), afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知)
|
||||
func (c *TaoBaoVegetableController) RefundOrderSuccess() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
|
||||
// 获取url参数
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
if err != nil {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户售后成功消息通知:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
// 验签
|
||||
sign := Sign(values, utils.Format4Output(refundSuccess, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
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 {
|
||||
var publicParam = make([]string, 0, 0)
|
||||
for k, v := range param {
|
||||
@@ -87,113 +260,3 @@ func Sign(param url.Values, data, secret string) string {
|
||||
cc := secret + strings.Join(publicParam, "") + strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(data, "\n", ""), "\t", ""), " ", "") + secret
|
||||
return fmt.Sprintf("%X", md5.Sum([]byte(cc)))
|
||||
}
|
||||
|
||||
// OrderStatus 订单状态变化 [post]
|
||||
func (c *TaoBaoVegetableController) OrderStatus() {
|
||||
urlParam := c.Ctx.Request.URL.RawQuery
|
||||
values, err := url.ParseQuery(urlParam)
|
||||
order, err := api.TaoVegetableApi.ReaderOrderInfo(c.Ctx.Request)
|
||||
sign := Sign(values, utils.Format4Output(order, false), api.TaoVegetableApi.GetAppSecret())
|
||||
if sign != values.Get("sign") { // 49C8CEEDC523CA387A677D08C8861ABC
|
||||
c.Data["json"] = tao_vegetable.CallBackResultSign(fmt.Errorf("非法签名"))
|
||||
c.ServeJSON()
|
||||
return
|
||||
} else {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("OrderStatus := %s", utils.Format4Output(order, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("订单状态变化:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusChange, utils.Int64ToStr(order.BizOrderId), order)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyCancelOrder 用户发起售后申请
|
||||
func (c *TaoBaoVegetableController) ApplyCancelOrder() {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserApplyRefund(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("ApplyCancelOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户发起售后:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusApplyAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// UserCancelRefund 用户取消售后
|
||||
func (c *TaoBaoVegetableController) UserCancelRefund() {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.UserCancelRefundApply(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("UserCancelRefund := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户取消售后:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusCancelAfs, afsOrder.OutOrderId, afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// CancelOnSaleRefundOrder 用户售中取消(走订单取消流程)
|
||||
func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
|
||||
afsOrder, err := api.TaoVegetableApi.OnSaleRefundOrder(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("CancelOnSaleRefundOrder := %s", utils.Format4Output(afsOrder, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户售中取消:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusOnSaleCancel, utils.Int64ToStr(afsOrder.BizOrderId), afsOrder)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
// RefundOrderSuccess 用户售后成功通知,只有退款成功了才会通知(商户拒绝退款,不会通知)
|
||||
func (c *TaoBaoVegetableController) RefundOrderSuccess() {
|
||||
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(nil)
|
||||
c.ServeJSON()
|
||||
return
|
||||
refundSuccess, err := api.TaoVegetableApi.RefundOrderFinish(c.Ctx.Request)
|
||||
globals.SugarLogger.Debugf("RefundOrderSuccess := %s", utils.Format4Output(refundSuccess, false))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("用户售后成功消息通知:%s", err.Error())
|
||||
c.Data["json"] = tao_vegetable.CallBackResultInfo(err)
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
callbackResponse := taoVegetable.OnCallbackMsg(tao_vegetable.OrderStatusRefundSuccess, refundSuccess.OutSubOrderId, refundSuccess)
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user