Commit 23c95f8b authored by wangp's avatar wangp

拉卡拉退款 post => get

parent c5969647
......@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"strconv"
"system_pay/controller/base"
"system_pay/models"
"system_pay/repository/pay"
......@@ -50,31 +51,45 @@ func (l *PayController) UnifiedOrder(c *gin.Context) {
base.ResponseSuccess(c, rtn)
}
// UnifiedRefund 拉卡拉退款
// Refund 拉卡拉退款
// @Summary 拉卡拉退款
// @Description 拉卡拉退款
// @Tags 拉卡拉退款
// @Accept application/json
// @Produce application/json
// @Param body body models.RefundParamInput true "参数"
// @Param orderId path string true "退款号:原对账单流水号"
// @Param operator path string true "操作人/退款原因"
// @Param money path string true "退款金额,个位为分"
// @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文"
// @Success 200
// @router /api/v1/pay/unified_refund [post]
func (l *PayController) UnifiedRefund(c *gin.Context) {
ph := new(models.RefundParamInput)
err := c.ShouldBindJSON(ph)
// @router /api/v1/pay/refund/{orderId}/{operator}/{money} [put]
func (l *PayController) Refund(c *gin.Context) {
//ph := new(models.RefundParamInput)
//err := c.ShouldBindJSON(ph)
//if err != nil {
// zap.L().Error(err.Error())
// base.ResponseErrorWithMsg(c, base.ServerError)
// return
//}
//退款金额,个位为分
money, err := strconv.ParseFloat(c.Param("money"), 64)
if err != nil {
zap.L().Error(err.Error())
base.ResponseErrorWithMsg(c, base.ServerError)
fmt.Println("退款金额转换失败:", err)
return
}
var ph models.RefundParamInput
ph.RefundNo = c.Param("orderId") //退款号:原对账单流水号
ph.RefundAmount = money //退款金额,个位为分
ph.RefundReason = c.Param("operator") //退款原因
ip := c.ClientIP()
fmt.Println("ip="+ip)
// 拉卡拉退款
rtn, err := pay.UnifiedRefund(ph, ip)
rtn, err := pay.UnifiedRefund(&ph, ip)
if err != nil {
zap.L().Error(err.Error())
base.ResponseErrorMsg(c, err.Error())
......@@ -90,13 +105,13 @@ func (l *PayController) UnifiedRefund(c *gin.Context) {
// @Tags 拉卡拉支付查询
// @Accept application/json
// @Produce application/json
// @Param order_id path string true "订单号"
// @Param orderId path string true "订单号"
// @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文"
// @Success 200
// @router /api/v1/pay/order_state/{order_id} [get]
// @router /api/v1/pay/order_state/{orderId} [get]
func (l *PayController) OrderState(c *gin.Context) {
orderID := c.Param("order_id")
orderID := c.Param("orderId")
// 拉卡拉支付查询
rtn, err := pay.OrderState(orderID)
......
......@@ -60,7 +60,7 @@ var doc = `{
}
}
},
"/api/v1/pay/order_state/{order_id}": {
"/api/v1/pay/order_state/{orderId}": {
"get": {
"description": "拉卡拉支付查询",
"consumes": [
......@@ -77,7 +77,7 @@ var doc = `{
{
"type": "string",
"description": "订单号",
"name": "order_id",
"name": "orderId",
"in": "path",
"required": true
},
......@@ -95,9 +95,9 @@ var doc = `{
}
}
},
"/api/v1/pay/scan_notice": {
"post": {
"description": "拉卡拉统一支付回调(聚合扫码)",
"/api/v1/pay/refund/{orderId}/{operator}/{money}": {
"put": {
"description": "拉卡拉退款",
"consumes": [
"application/json"
],
......@@ -105,18 +105,30 @@ var doc = `{
"application/json"
],
"tags": [
"拉卡拉统一支付回调"
"拉卡拉退款"
],
"summary": "拉卡拉统一支付回调(聚合扫码)",
"summary": "拉卡拉退款",
"parameters": [
{
"description": "参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ScanNoticeInput"
}
"type": "string",
"description": "退款号:原对账单流水号",
"name": "orderId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "操作人/退款原因",
"name": "operator",
"in": "path",
"required": true
},
{
"type": "string",
"description": "退款金额,个位为分",
"name": "money",
"in": "path",
"required": true
},
{
"type": "string",
......@@ -132,9 +144,9 @@ var doc = `{
}
}
},
"/api/v1/pay/unified_order": {
"/api/v1/pay/scan_notice": {
"post": {
"description": "拉卡拉统一支付",
"description": "拉卡拉统一支付回调(聚合扫码)",
"consumes": [
"application/json"
],
......@@ -142,9 +154,9 @@ var doc = `{
"application/json"
],
"tags": [
"拉卡拉统一支付"
"拉卡拉统一支付回调"
],
"summary": "拉卡拉统一支付",
"summary": "拉卡拉统一支付回调(聚合扫码)",
"parameters": [
{
"description": "参数",
......@@ -152,7 +164,7 @@ var doc = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.PlaceAnOrderParamInput"
"$ref": "#/definitions/models.ScanNoticeInput"
}
},
{
......@@ -169,9 +181,9 @@ var doc = `{
}
}
},
"/api/v1/pay/unified_refund": {
"/api/v1/pay/unified_order": {
"post": {
"description": "拉卡拉退款",
"description": "拉卡拉统一支付",
"consumes": [
"application/json"
],
......@@ -179,9 +191,9 @@ var doc = `{
"application/json"
],
"tags": [
"拉卡拉退款"
"拉卡拉统一支付"
],
"summary": "拉卡拉退款",
"summary": "拉卡拉统一支付",
"parameters": [
{
"description": "参数",
......@@ -189,7 +201,7 @@ var doc = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RefundParamInput"
"$ref": "#/definitions/models.PlaceAnOrderParamInput"
}
},
{
......@@ -360,23 +372,6 @@ var doc = `{
}
}
},
"models.RefundParamInput": {
"type": "object",
"properties": {
"refund_amount": {
"description": "退款金额,个位为分",
"type": "number"
},
"refund_no": {
"description": "退款号:原对账单流水号",
"type": "string"
},
"refund_reason": {
"description": "退款原因",
"type": "string"
}
}
},
"models.ScanNoticeInput": {
"type": "object",
"properties": {
......
......@@ -44,7 +44,7 @@
}
}
},
"/api/v1/pay/order_state/{order_id}": {
"/api/v1/pay/order_state/{orderId}": {
"get": {
"description": "拉卡拉支付查询",
"consumes": [
......@@ -61,7 +61,7 @@
{
"type": "string",
"description": "订单号",
"name": "order_id",
"name": "orderId",
"in": "path",
"required": true
},
......@@ -79,9 +79,9 @@
}
}
},
"/api/v1/pay/scan_notice": {
"post": {
"description": "拉卡拉统一支付回调(聚合扫码)",
"/api/v1/pay/refund/{orderId}/{operator}/{money}": {
"put": {
"description": "拉卡拉退款",
"consumes": [
"application/json"
],
......@@ -89,18 +89,30 @@
"application/json"
],
"tags": [
"拉卡拉统一支付回调"
"拉卡拉退款"
],
"summary": "拉卡拉统一支付回调(聚合扫码)",
"summary": "拉卡拉退款",
"parameters": [
{
"description": "参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ScanNoticeInput"
}
"type": "string",
"description": "退款号:原对账单流水号",
"name": "orderId",
"in": "path",
"required": true
},
{
"type": "string",
"description": "操作人/退款原因",
"name": "operator",
"in": "path",
"required": true
},
{
"type": "string",
"description": "退款金额,个位为分",
"name": "money",
"in": "path",
"required": true
},
{
"type": "string",
......@@ -116,9 +128,9 @@
}
}
},
"/api/v1/pay/unified_order": {
"/api/v1/pay/scan_notice": {
"post": {
"description": "拉卡拉统一支付",
"description": "拉卡拉统一支付回调(聚合扫码)",
"consumes": [
"application/json"
],
......@@ -126,9 +138,9 @@
"application/json"
],
"tags": [
"拉卡拉统一支付"
"拉卡拉统一支付回调"
],
"summary": "拉卡拉统一支付",
"summary": "拉卡拉统一支付回调(聚合扫码)",
"parameters": [
{
"description": "参数",
......@@ -136,7 +148,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.PlaceAnOrderParamInput"
"$ref": "#/definitions/models.ScanNoticeInput"
}
},
{
......@@ -153,9 +165,9 @@
}
}
},
"/api/v1/pay/unified_refund": {
"/api/v1/pay/unified_order": {
"post": {
"description": "拉卡拉退款",
"description": "拉卡拉统一支付",
"consumes": [
"application/json"
],
......@@ -163,9 +175,9 @@
"application/json"
],
"tags": [
"拉卡拉退款"
"拉卡拉统一支付"
],
"summary": "拉卡拉退款",
"summary": "拉卡拉统一支付",
"parameters": [
{
"description": "参数",
......@@ -173,7 +185,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RefundParamInput"
"$ref": "#/definitions/models.PlaceAnOrderParamInput"
}
},
{
......@@ -344,23 +356,6 @@
}
}
},
"models.RefundParamInput": {
"type": "object",
"properties": {
"refund_amount": {
"description": "退款金额,个位为分",
"type": "number"
},
"refund_no": {
"description": "退款号:原对账单流水号",
"type": "string"
},
"refund_reason": {
"description": "退款原因",
"type": "string"
}
}
},
"models.ScanNoticeInput": {
"type": "object",
"properties": {
......
......@@ -113,18 +113,6 @@ definitions:
description: WAP网站URL地址, 支付方式为微信MWEB时 必传
type: string
type: object
models.RefundParamInput:
properties:
refund_amount:
description: 退款金额,个位为分
type: number
refund_no:
description: 退款号:原对账单流水号
type: string
refund_reason:
description: 退款原因
type: string
type: object
models.ScanNoticeInput:
properties:
acc_activity_id:
......@@ -227,7 +215,7 @@ paths:
summary: 拉卡拉统一支付回调(收银台)
tags:
- 拉卡拉统一支付回调
/api/v1/pay/order_state/{order_id}:
/api/v1/pay/order_state/{orderId}:
get:
consumes:
- application/json
......@@ -235,7 +223,7 @@ paths:
parameters:
- description: 订单号
in: path
name: order_id
name: orderId
required: true
type: string
- description: 语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文
......@@ -250,18 +238,27 @@ paths:
summary: 拉卡拉支付查询
tags:
- 拉卡拉支付查询
/api/v1/pay/scan_notice:
post:
/api/v1/pay/refund/{orderId}/{operator}/{money}:
put:
consumes:
- application/json
description: 拉卡拉统一支付回调(聚合扫码)
description: 拉卡拉退款
parameters:
- description: 参数
in: body
name: body
- description: 退款号:原对账单流水号
in: path
name: orderId
required: true
schema:
$ref: '#/definitions/models.ScanNoticeInput'
type: string
- description: 操作人/退款原因
in: path
name: operator
required: true
type: string
- description: 退款金额,个位为分
in: path
name: money
required: true
type: string
- description: 语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文
in: header
name: language
......@@ -271,21 +268,21 @@ paths:
responses:
"200":
description: ""
summary: 拉卡拉统一支付回调(聚合扫码)
summary: 拉卡拉退款
tags:
- 拉卡拉统一支付回调
/api/v1/pay/unified_order:
- 拉卡拉退款
/api/v1/pay/scan_notice:
post:
consumes:
- application/json
description: 拉卡拉统一支付
description: 拉卡拉统一支付回调(聚合扫码)
parameters:
- description: 参数
in: body
name: body
required: true
schema:
$ref: '#/definitions/models.PlaceAnOrderParamInput'
$ref: '#/definitions/models.ScanNoticeInput'
- description: 语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文
in: header
name: language
......@@ -295,21 +292,21 @@ paths:
responses:
"200":
description: ""
summary: 拉卡拉统一支付
summary: 拉卡拉统一支付回调(聚合扫码)
tags:
- 拉卡拉统一支付
/api/v1/pay/unified_refund:
- 拉卡拉统一支付回调
/api/v1/pay/unified_order:
post:
consumes:
- application/json
description: 拉卡拉退款
description: 拉卡拉统一支付
parameters:
- description: 参数
in: body
name: body
required: true
schema:
$ref: '#/definitions/models.RefundParamInput'
$ref: '#/definitions/models.PlaceAnOrderParamInput'
- description: 语言类型 zh-CN简体中文 en-US英文 ja-JP日文 默认中文
in: header
name: language
......@@ -319,9 +316,9 @@ paths:
responses:
"200":
description: ""
summary: 拉卡拉退款
summary: 拉卡拉统一支付
tags:
- 拉卡拉退款
- 拉卡拉统一支付
securityDefinitions:
ApiKeyAuth:
in: header
......
......@@ -20,9 +20,9 @@ func PayRouter (r *gin.Engine) {
r.POST(pack.PayUrlPacking("scan_notice"), PayController.ScanNotice)
// 拉卡拉支付查询
r.GET(pack.PayUrlPacking("order_state/:order_id"), PayController.OrderState)
r.GET(pack.PayUrlPacking("order_state/:orderId"), PayController.OrderState)
// 拉卡拉退款
r.POST(pack.PayUrlPacking("unified_refund"), PayController.UnifiedRefund)
r.PUT(pack.PayUrlPacking("refund/:orderId/:operator/:money"), PayController.Refund)
}
......@@ -125,7 +125,7 @@ type Lakala struct {
// Init 支持热修改的viper设置
func Init() error {
viper.SetConfigFile("conf/dev/config.yaml") // 指定配置文件路径
viper.SetConfigFile("conf/config.yaml") // 指定配置文件路径
err := viper.ReadInConfig() // 读取配置信息
if err != nil { // 读取配置信息失败
fmt.Printf("viper.ReadInConfig failed, new_error:%v\n", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment