Commit af1afef6 authored by wangp's avatar wangp

lakala

parent 2d3b8c66
...@@ -47,7 +47,7 @@ func (l *PayController) WxNotice(c *gin.Context) { ...@@ -47,7 +47,7 @@ func (l *PayController) WxNotice(c *gin.Context) {
base.ResponseWxNotice(c, response) base.ResponseWxNotice(c, response)
return return
} }
//fmt.Println(ph) fmt.Println(ph)
// 拉卡拉统一支付微信回调 // 拉卡拉统一支付微信回调
response, err := pay.WxNotice(ph) response, err := pay.WxNotice(ph)
......
...@@ -50,3 +50,37 @@ func (l *PayController) UnifiedOrder(c *gin.Context) { ...@@ -50,3 +50,37 @@ func (l *PayController) UnifiedOrder(c *gin.Context) {
base.ResponseSuccess(c, rtn) base.ResponseSuccess(c, rtn)
} }
// UnifiedRefund 拉卡拉退款
// @Summary 拉卡拉退款
// @Description 拉卡拉退款
// @Tags 拉卡拉退款
// @Accept application/json
// @Produce application/json
// @Param body body models.RefundParamInput true "参数"
// @Param language header string ture "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文"
// @Success 200
// @router /api/v1/pay/unified_refund [post]
func (l *PayController) UnifiedRefund(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
}
ip := c.ClientIP()
fmt.Println("ip="+ip)
// 拉卡拉退款
rtn, err := pay.UnifiedRefund(ph, ip)
if err != nil {
zap.L().Error(err.Error())
base.ResponseErrorMsg(c, err.Error())
return
}
base.ResponseSuccess(c, rtn)
}
\ No newline at end of file
...@@ -60,6 +60,43 @@ var doc = `{ ...@@ -60,6 +60,43 @@ var doc = `{
} }
} }
}, },
"/api/v1/pay/unified_refund": {
"post": {
"description": "拉卡拉退款",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"拉卡拉退款"
],
"summary": "拉卡拉退款",
"parameters": [
{
"description": "参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RefundParamInput"
}
},
{
"type": "string",
"description": "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文",
"name": "language",
"in": "header"
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/pay/wx_notice": { "/api/v1/pay/wx_notice": {
"post": { "post": {
"description": "拉卡拉统一支付微信回调", "description": "拉卡拉统一支付微信回调",
...@@ -167,6 +204,17 @@ var doc = `{ ...@@ -167,6 +204,17 @@ var doc = `{
} }
} }
}, },
"models.RefundParamInput": {
"type": "object",
"properties": {
"goods_price": {
"type": "number"
},
"order_id": {
"type": "string"
}
}
},
"models.WxNoticeInput": { "models.WxNoticeInput": {
"type": "object", "type": "object",
"properties": { "properties": {
...@@ -204,7 +252,7 @@ var doc = `{ ...@@ -204,7 +252,7 @@ var doc = `{
"type": "string" "type": "string"
}, },
"total_amount": { "total_amount": {
"type": "string" "type": "number"
}, },
"trans_merchant_no": { "trans_merchant_no": {
"type": "string" "type": "string"
......
...@@ -44,6 +44,43 @@ ...@@ -44,6 +44,43 @@
} }
} }
}, },
"/api/v1/pay/unified_refund": {
"post": {
"description": "拉卡拉退款",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"拉卡拉退款"
],
"summary": "拉卡拉退款",
"parameters": [
{
"description": "参数",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RefundParamInput"
}
},
{
"type": "string",
"description": "语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文",
"name": "language",
"in": "header"
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/pay/wx_notice": { "/api/v1/pay/wx_notice": {
"post": { "post": {
"description": "拉卡拉统一支付微信回调", "description": "拉卡拉统一支付微信回调",
...@@ -151,6 +188,17 @@ ...@@ -151,6 +188,17 @@
} }
} }
}, },
"models.RefundParamInput": {
"type": "object",
"properties": {
"goods_price": {
"type": "number"
},
"order_id": {
"type": "string"
}
}
},
"models.WxNoticeInput": { "models.WxNoticeInput": {
"type": "object", "type": "object",
"properties": { "properties": {
...@@ -188,7 +236,7 @@ ...@@ -188,7 +236,7 @@
"type": "string" "type": "string"
}, },
"total_amount": { "total_amount": {
"type": "string" "type": "number"
}, },
"trans_merchant_no": { "trans_merchant_no": {
"type": "string" "type": "string"
......
...@@ -44,6 +44,13 @@ definitions: ...@@ -44,6 +44,13 @@ definitions:
wap_url: wap_url:
type: string type: string
type: object type: object
models.RefundParamInput:
properties:
goods_price:
type: number
order_id:
type: string
type: object
models.WxNoticeInput: models.WxNoticeInput:
properties: properties:
channel_id: channel_id:
...@@ -69,7 +76,7 @@ definitions: ...@@ -69,7 +76,7 @@ definitions:
term_no: term_no:
type: string type: string
total_amount: total_amount:
type: string type: number
trans_merchant_no: trans_merchant_no:
type: string type: string
trans_term_no: trans_term_no:
...@@ -105,6 +112,30 @@ paths: ...@@ -105,6 +112,30 @@ paths:
summary: 拉卡拉统一支付 summary: 拉卡拉统一支付
tags: tags:
- 拉卡拉统一支付 - 拉卡拉统一支付
/api/v1/pay/unified_refund:
post:
consumes:
- application/json
description: 拉卡拉退款
parameters:
- description: 参数
in: body
name: body
required: true
schema:
$ref: '#/definitions/models.RefundParamInput'
- description: 语言类型 zh-CN简体中文 en-US英文 ja 日文 默认中文
in: header
name: language
type: string
produces:
- application/json
responses:
"200":
description: ""
summary: 拉卡拉退款
tags:
- 拉卡拉退款
/api/v1/pay/wx_notice: /api/v1/pay/wx_notice:
post: post:
consumes: consumes:
......
...@@ -2,22 +2,41 @@ package models ...@@ -2,22 +2,41 @@ package models
// WxNoticeInput 微信回调输入参数 // WxNoticeInput 微信回调输入参数
type WxNoticeInput struct { type WxNoticeInput struct {
ChannelId string `json:"channel_id" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"` ChannelId string `json:"channel_id" description:"渠道号"`
MerchantNo string `json:"merchant_no" description:"平台信息"` MerchantNo string `json:"merchant_no" description:"结算商户号"`
OrderCreateTime string `json:"order_create_time" description:"商品描述"` OrderCreateTime string `json:"order_create_time" description:"订单创建时间"`
OrderEfficientTime string `json:"order_efficient_time" description:"商品详情"` OrderEfficientTime string `json:"order_efficient_time" description:"订单有效时间"`
OrderInfo string `json:"order_info" description:"附加信息"` OrderInfo string `json:"order_info" description:"订单描述"`
OrderStatus string `json:"order_status" description:"商品金额,个位为分"` OrderStatus string `json:"order_status" description:"订单状态"`
OutOrderNo string `json:"out_order_no" description:"客户端回调的url"` OutOrderNo string `json:"out_order_no" description:"商户订单号"`
PayOrderNo string `json:"pay_order_no" description:"1: 微信,2: 支付宝, 3: 拉卡拉 4: 收钱吧"` PayOrderNo string `json:"pay_order_no" description:"支付订单号"`
TermNo string `json:"term_no" description:"1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) 9: B2C 10:bk支付宝web 11:bk 支付宝手机"` TermNo string `json:"term_no" description:"结算终端号"`
TotalAmount float64 `json:"total_amount" description:"此参数 支付类型是 JS API 的时候 必传"` TotalAmount int64 `json:"total_amount" description:"订单金额,单位:分"`
TransMerchantNo string `json:"trans_merchant_no" description:"WAP网站URL地址, 支付方式为微信MWEB时 必传"` TransMerchantNo string `json:"trans_merchant_no" description:"交易商户号"`
TransTermNo string `json:"trans_term_no" description:"WAP网站名称, 支付方式为微信MWEB时 必传"` TransTermNo string `json:"trans_term_no" description:"交易终端号"`
OrderTradeInfo interface{} `json:"order_trade_info" description:""` OrderTradeInfo interface{} `json:"order_trade_info" description:""`
SplitInfo interface{} `json:"split_info" description:""` SplitInfo interface{} `json:"split_info" description:""`
} }
//订单交易信息
//type OrderTradeInfo struct {
// AccTradeNo string `json:"acc_trade_no"`
// AccType string `json:"acc_type"`
// BusiType string `json:"busi_type"`
// LogNo string `json:"log_no"`
// PayMode string `json:"pay_mode"`
// PayerAmount int64 `json:"payer_amount"`
// SettleMerchantNo string `json:"settle_merchant_no"`
// SettleTermNo string `json:"settle_term_no"`
// TradeAmount int64 `json:"trade_amount"`
// TradeNo string `json:"trade_no"`
// TradeStatus string `json:"trade_status"`
// TradeTime string `json:"trade_time"`
// TradeType string `json:"trade_type"`
// UserId1 string `json:"user_id1"`
// UserId2 string `json:"user_id2"`
//}
// CallbackResponse is 回调给业务方的信息 // CallbackResponse is 回调给业务方的信息
type CallbackResponse struct { type CallbackResponse struct {
OutTradeNo string `json:"out_trade_no"` // 订单号 OutTradeNo string `json:"out_trade_no"` // 订单号
......
package models package models
//支付
type PlaceAnOrderParamInput struct { type PlaceAnOrderParamInput struct {
PlatformType uint8 `json:"platform_type" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"` PlatformType uint8 `json:"platform_type" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"`
PlatformInfo string `json:"platform_info" description:"平台信息"` PlatformInfo string `json:"platform_info" description:"平台信息"`
...@@ -45,6 +46,12 @@ type PlaceAnOrderParamInput struct { ...@@ -45,6 +46,12 @@ type PlaceAnOrderParamInput struct {
// return nil // return nil
//} //}
//退款
type RefundParamInput struct {
OrderId string `json:"order_id" description:"订单号"`
GoodsPrice float64 `json:"goods_price" description:"商品金额,个位为分"`
}
type LakalaParamInput struct { type LakalaParamInput struct {
Version string `json:"version" description:"版本"` Version string `json:"version" description:"版本"`
ReqTime string `json:"req_time" description:"请求时间"` ReqTime string `json:"req_time" description:"请求时间"`
...@@ -59,7 +66,6 @@ type LakalaParamData struct { ...@@ -59,7 +66,6 @@ type LakalaParamData struct {
OrderEfficientTime string `json:"order_efficient_time" description:"订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天"` OrderEfficientTime string `json:"order_efficient_time" description:"订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天"`
NotifyUrl string `json:"notify_url" description:"订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com"` NotifyUrl string `json:"notify_url" description:"订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com"`
CallbackUrl string `json:"callback_url" description:"客户端下单完成支付后返回的商户网页跳转地址"` CallbackUrl string `json:"callback_url" description:"客户端下单完成支付后返回的商户网页跳转地址"`
OrderInfo string `json:"order_info" description:"订单标题,在使用收银台扫码支付时必输入,交易时送往账户端"` OrderInfo string `json:"order_info" description:"订单标题,在使用收银台扫码支付时必输入,交易时送往账户端"`
GoodsMark string `json:"goods_mark" description:"商品信息标识 (1:含商品信息,不填默认不含商品信息)"` GoodsMark string `json:"goods_mark" description:"商品信息标识 (1:含商品信息,不填默认不含商品信息)"`
......
...@@ -52,12 +52,38 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) { ...@@ -52,12 +52,38 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
fmt.Println("222") fmt.Println("222")
//if noticeRequest.ReturnCode == "SUCCESS" {
// 把订单状态置为 结算成功
err = BillPayStateSuccess(tx, billID)
if err != nil {
//beego.Error("微信回调, 根据订单id 把订单置为结算成功 失败: ", err)
//response.ReturnCode = "FAIL"
//response.ReturnMsg = "db operation fail"
//return response, nil
response.Code = "FAIL"
response.Message = "db operation fail2"
InsertPayBillDetailNoticeResponseBody(tx, billID, response)
return response, err
}
//} else {
//
// // 把订单状态置为 结算失败
// err = repository.BillPayStateFail(tx, billID)
// if err != nil {
// beego.Error("微信回调, 根据订单id 把订单置为结算成功 失败: ", err)
// response.ReturnCode = "FAIL"
// response.ReturnMsg = "db operation fail"
// return response, nil
// }
//}
//2.存入 notice_request_body //2.存入 notice_request_body
err = InsertPayBillDetailNoticeRequestBody(tx, billID, input) err = InsertPayBillDetailNoticeRequestBody(tx, billID, input)
if err != nil { if err != nil {
//beego.Error("微信回调, 根据订单id 插入回调Request参数 失败: ", err) //beego.Error("微信回调, 根据订单id 插入回调Request参数 失败: ", err)
response.Code = "FAIL" response.Code = "FAIL"
response.Message = "db operation fail2" response.Message = "db operation fail3"
InsertPayBillDetailNoticeResponseBody(tx, billID, response) InsertPayBillDetailNoticeResponseBody(tx, billID, response)
return response, err return response, err
} }
...@@ -66,7 +92,6 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) { ...@@ -66,7 +92,6 @@ func WxNotice(input *models.WxNoticeInput) (*base.ResponseDataWxNotice, error) {
//3.拉卡拉订收银台订单查询 - check todo //3.拉卡拉订收银台订单查询 - check todo
//3.存入 notice_response_body //3.存入 notice_response_body
//err = InsertPayBillDetailNoticeResponseBody(billID, response) //err = InsertPayBillDetailNoticeResponseBody(billID, response)
//if err != nil { //if err != nil {
......
This diff is collapsed.
...@@ -15,5 +15,8 @@ func PayRouter (r *gin.Engine) { ...@@ -15,5 +15,8 @@ func PayRouter (r *gin.Engine) {
// 卡拉卡统一支付回调 // 卡拉卡统一支付回调
r.POST(pack.PayUrlPacking("wx_notice"), PayController.WxNotice) r.POST(pack.PayUrlPacking("wx_notice"), PayController.WxNotice)
// 卡拉卡统一支付
r.POST(pack.PayUrlPacking("unified_refund"), PayController.UnifiedRefund)
} }
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