<feat>退款
This commit is contained in:
parent
7ed9cb048d
commit
bb9ff190c3
|
@ -58,14 +58,17 @@ const (
|
||||||
PayChannelExtJsonError = 1302
|
PayChannelExtJsonError = 1302
|
||||||
|
|
||||||
//订单
|
//订单
|
||||||
OrdersNotFound = 1401
|
OrdersNotFound = 1401
|
||||||
OrdersExist = 1402
|
OrdersExist = 1402
|
||||||
OrderTypeNotFount = 1403
|
OrderTypeNotFount = 1403
|
||||||
OrderIsDelete = 1405
|
OrderIsDelete = 1405
|
||||||
OrderStatusErr = 1406
|
OrderStatusErr = 1406
|
||||||
OrderClosed = 1407
|
OrderClosed = 1407
|
||||||
OrderFailed = 1408
|
OrderFailed = 1408
|
||||||
OrderPayed = 1409
|
OrderPayed = 1409
|
||||||
|
RefundOrderNotFound = 1410
|
||||||
|
OrderStatusRefundNotSupport = 1411
|
||||||
|
|
||||||
//请求日志
|
//请求日志
|
||||||
RequestLogErrors = 1500
|
RequestLogErrors = 1500
|
||||||
RequestLogNotFound = 1501
|
RequestLogNotFound = 1501
|
||||||
|
@ -132,17 +135,18 @@ var MsgZH = map[int]string{
|
||||||
RequestLogNotFound: "未找到日志信息",
|
RequestLogNotFound: "未找到日志信息",
|
||||||
RequestResponseValid: "上游返回格式无效",
|
RequestResponseValid: "上游返回格式无效",
|
||||||
|
|
||||||
OrdersNotFound: "未找到订单",
|
OrdersNotFound: "未找到订单",
|
||||||
OrdersExist: "订单已存在",
|
OrdersExist: "订单已存在",
|
||||||
OrderTypeNotFount: "未知的支付方式",
|
OrderTypeNotFount: "未知的支付方式",
|
||||||
OrderIsDelete: "订单已删除",
|
OrderIsDelete: "订单已删除",
|
||||||
OrderStatusErr: "订单状态错误",
|
OrderStatusErr: "订单状态错误",
|
||||||
OrderClosed: "订单已关闭,无法继续支付",
|
OrderClosed: "订单已关闭,无法继续支付",
|
||||||
OrderFailed: "订单支付失败,请重新发起",
|
OrderFailed: "订单支付失败,请重新发起",
|
||||||
OrderPayed: "订单已支付成功,请勿重复支付",
|
OrderPayed: "订单已支付成功,请勿重复支付",
|
||||||
NotifySendFail: "回调发送失败",
|
NotifySendFail: "回调发送失败",
|
||||||
|
RefundOrderNotFound: "退款订单未找到",
|
||||||
PrePayFail: "预支付失败",
|
OrderStatusRefundNotSupport: "订单状态不支持退款",
|
||||||
|
PrePayFail: "预支付失败",
|
||||||
}
|
}
|
||||||
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
|
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (w *Pay) CreateOrder(order_type int) {
|
||||||
w.PayCode = errorcode.PayChannelNotFound
|
w.PayCode = errorcode.PayChannelNotFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Order, w.PayCode = services.OrderCreate(&ordersmodel.Orders{
|
order := &ordersmodel.Orders{
|
||||||
MerchantId: w.PayParam.Merchant.Id,
|
MerchantId: w.PayParam.Merchant.Id,
|
||||||
PayChannelId: w.PayParam.Channel.Id,
|
PayChannelId: w.PayParam.Channel.Id,
|
||||||
AppId: w.PayParam.App_id,
|
AppId: w.PayParam.App_id,
|
||||||
|
@ -66,8 +66,11 @@ func (w *Pay) CreateOrder(order_type int) {
|
||||||
ExtJson: w.PayParam.ExtJson,
|
ExtJson: w.PayParam.ExtJson,
|
||||||
Desc: w.PayParam.Desc,
|
Desc: w.PayParam.Desc,
|
||||||
Status: common.ORDER_STATUS_WAITPAY,
|
Status: common.ORDER_STATUS_WAITPAY,
|
||||||
},
|
}
|
||||||
)
|
if order_type == common.ORDER_TYPE_REFUND {
|
||||||
|
order.RefundOrderId = w.RelationOrder.Id
|
||||||
|
}
|
||||||
|
w.Order, w.PayCode = services.OrderCreate(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Pay) PayUrl() (url string) {
|
func (w *Pay) PayUrl() (url string) {
|
||||||
|
|
|
@ -61,7 +61,9 @@ func (w *PayCheck) CheckMerchant() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *PayCheck) CheckOrderPay() {
|
func (w *PayCheck) CheckOrderPay() {
|
||||||
w.GetOrder()
|
w.GetOrder(&types.OrderFindOne{
|
||||||
|
OutTradeNo: w.Reqs.OutTradeNo,
|
||||||
|
})
|
||||||
if w.OldOrder != nil {
|
if w.OldOrder != nil {
|
||||||
switch w.OldOrder.Status {
|
switch w.OldOrder.Status {
|
||||||
case common.ORDER_STATUS_CLOSE:
|
case common.ORDER_STATUS_CLOSE:
|
||||||
|
@ -78,27 +80,33 @@ func (w *PayCheck) CheckOrderPay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *PayCheck) CheckOrderRefund() {
|
func (w *PayCheck) CheckOrderRefund() {
|
||||||
w.GetOrder()
|
w.GetOrder(&types.OrderFindOne{
|
||||||
|
OutTradeNo: w.Reqs.RefundOutTradeNo,
|
||||||
|
OrderId: w.Reqs.RefundOrderId,
|
||||||
|
})
|
||||||
if w.OldOrder == nil {
|
if w.OldOrder == nil {
|
||||||
w.CheckCode = errorcode.OrdersNotFound
|
w.CheckCode = errorcode.RefundOrderNotFound
|
||||||
|
return
|
||||||
}
|
}
|
||||||
switch w.OldOrder.Status {
|
if w.OldOrder.Status != common.ORDER_STATUS_PAYED {
|
||||||
case common.ORDER_STATUS_CLOSE:
|
w.CheckCode = errorcode.OrderStatusRefundNotSupport
|
||||||
w.CheckCode = errorcode.OrderClosed
|
|
||||||
case common.ORDER_STATUS_FAILED:
|
|
||||||
w.CheckCode = errorcode.OrderFailed
|
|
||||||
case common.ORDER_STATUS_WAITPAY:
|
|
||||||
w.CheckCode = errorcode.OrderStatusErr
|
|
||||||
case common.ORDER_STATUS_PAYING:
|
|
||||||
w.CheckCode = errorcode.OrderStatusErr
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *PayCheck) GetOrder() {
|
func (w *PayCheck) GetOrder(orderCol *types.OrderFindOne) {
|
||||||
cond := builder.NewCond()
|
cond := builder.NewCond()
|
||||||
cond = cond.And(builder.Eq{"out_trade_no": w.Reqs.OutTradeNo}, builder.Eq{"app_id": w.AppCheck.AppId})
|
cond = cond.And(builder.Eq{"app_id": w.AppCheck.AppId})
|
||||||
|
if orderCol.OrderId == "" && orderCol.OutTradeNo == "" {
|
||||||
|
w.CheckCode = errorcode.OrdersNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if orderCol.OrderId != "" {
|
||||||
|
cond = cond.And(builder.Eq{"order_id": orderCol.OrderId})
|
||||||
|
}
|
||||||
|
if orderCol.OutTradeNo != "" {
|
||||||
|
cond = cond.And(builder.Eq{"out_trade_no": orderCol.OutTradeNo})
|
||||||
|
}
|
||||||
order, code := services.OrderFindOne(&ordersmodel.Orders{}, cond)
|
order, code := services.OrderFindOne(&ordersmodel.Orders{}, cond)
|
||||||
if code == errorcode.SystemError {
|
if code == errorcode.SystemError {
|
||||||
w.CheckCode = code
|
w.CheckCode = code
|
||||||
|
@ -107,5 +115,5 @@ func (w *PayCheck) GetOrder() {
|
||||||
if code == errorcode.Success {
|
if code == errorcode.Success {
|
||||||
w.OldOrder = order
|
w.OldOrder = order
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,12 @@ import "PaymentCenter/app/http/entities/front"
|
||||||
|
|
||||||
type Reqs struct {
|
type Reqs struct {
|
||||||
front.PayCommonReqBody
|
front.PayCommonReqBody
|
||||||
|
OutTradeNo string `json:"out_trade_no"`
|
||||||
|
RefundOutTradeNo string `json:"refund_out_trade_no"`
|
||||||
|
RefundOrderId string `json:"refundOrder_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderFindOne struct {
|
||||||
|
OrderId string
|
||||||
OutTradeNo string `json:"out_trade_no"`
|
OutTradeNo string `json:"out_trade_no"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue