Commit 23c95f8b authored by wangp's avatar wangp

拉卡拉退款 post => get

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