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 {
......
...@@ -174,7 +174,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -174,7 +174,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data["req_data"] = data2 data["req_data"] = data2
} else if input.SourceCode==9 { } else if input.SourceCode==9 {
//收钱吧(扫码枪) //扫码枪
if input.DynamicID=="" { if input.DynamicID=="" {
return nil, errors.New("输入项「dynamic_id」为空错误") return nil, errors.New("输入项「dynamic_id」为空错误")
} }
...@@ -232,7 +232,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -232,7 +232,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
//调拉卡拉接口 //调拉卡拉接口
err, response, lakala_rtn := lakala_post(input.SourceCode, url, data_json) err, response, lakala_rtn := lakala_post(input.SourceCode, url, data_json)
if err != nil { if err != nil {
InsertPayBillDetailResponseBody(tx, billID, lakala_rtn) InsertPayBillDetailResponseBody(tx, billID, err) //todo
return nil, err return nil, err
} }
...@@ -254,6 +254,10 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -254,6 +254,10 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
} }
func lakala_post(source_code uint8, url string, data_json []byte) (error, interface{}, interface{}) { func lakala_post(source_code uint8, url string, data_json []byte) (error, interface{}, interface{}) {
if source_code<0 || source_code>6 {
return errors.New("输入参数「source_code」错误"), "", nil
}
authorization, err := getAuthorization(string(data_json)) authorization, err := getAuthorization(string(data_json))
if err != nil { if err != nil {
return err, "", nil return err, "", nil
...@@ -274,7 +278,6 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf ...@@ -274,7 +278,6 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
} }
temp := make(map[string]interface{}, 0) temp := make(map[string]interface{}, 0)
if err = json.Unmarshal(body, &temp); err != nil { if err = json.Unmarshal(body, &temp); err != nil {
return err, "", nil return err, "", nil
} }
...@@ -318,9 +321,6 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf ...@@ -318,9 +321,6 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
response["prepay_id"] = temp3["prepay_id"].(string) response["prepay_id"] = temp3["prepay_id"].(string)
response["sign_type"] = temp3["sign_type"].(string) response["sign_type"] = temp3["sign_type"].(string)
response["timeStamp"] = temp3["time_stamp"].(string) response["timeStamp"] = temp3["time_stamp"].(string)
} else {
return errors.New("输入参数「source_code」错误"), "", temp
} }
return nil, response, temp return nil, response, temp
...@@ -515,6 +515,34 @@ func BillPayStateFail(tx *sql.Tx, billID int64) error { ...@@ -515,6 +515,34 @@ func BillPayStateFail(tx *sql.Tx, billID int64) error {
return nil return nil
} }
//InsertRefundBill is 插入 支付订单表中
func InsertRefundBill(tx *sql.Tx, p *models.RefundParamInput, refundID string) (int64, error) {
var billID int64
//todo
//insertSQL := `insert system_pay_bill set platform_type = ?, source_code = ?,
//payment_order_code = ?, paymoney = ?*1000, pay_type = 4, attach = ?, _type = 1, original_payment_order_code = ?`
//platformType, sourceCode, checkSn, refundAmount, attach, orderID
//result, err := tx.Exec(insertSQL, p.PlatformType, p.PlatformInfo, p.SourceCode,
// orderID, p.GoodsPrice, p.GoodsDes, p.GoodsDetail, p.AttachInfo, p.NoticeURL, p.PayType, p.IsServe)
insertSQL := `insert system_pay_bill set original_payment_order_code=?, payment_order_code=?, paymoney=?*1000, pay_type=4, _type=1`
//platformType, sourceCode, checkSn, refundAmount, attach, orderID
result, err := tx.Exec(insertSQL, p.OrderId, refundID, p.GoodsPrice)
if err != nil {
return billID, err
}
billID, err = result.LastInsertId()
if err != nil {
return billID, err
}
return billID, nil
}
//InsertPayBill is 插入 支付订单表中 //InsertPayBill is 插入 支付订单表中
func InsertPayBill(tx *sql.Tx, p *models.PlaceAnOrderParamInput, orderID string) (int64, error) { func InsertPayBill(tx *sql.Tx, p *models.PlaceAnOrderParamInput, orderID string) (int64, error) {
...@@ -603,99 +631,102 @@ func GetUID() string { ...@@ -603,99 +631,102 @@ func GetUID() string {
return strings.Replace(id, "-", "", -1) return strings.Replace(id, "-", "", -1)
} }
//生产随机字符串 // 拉卡拉退款
//func RandomString(n int) string { func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, error) {
// var letters = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
// result := make([]byte, n)
// rand2.Seed(time.Now().Unix())
// for i := range result {
// result[i] = letters[rand2.Intn(len(letters))]
// }
// return string(result)
//}
fmt.Println("谛宝多多输入参数(退款)")
fmt.Println(input)
refundID := GetUID()
// 插入数据库
db, err := mysql.NewPayConn()
if err != nil {
return 0, err
}
tx, err := db.Begin()
if err != nil {
return nil, err
}
defer mysql.CloseTx(tx, err)
//订单存在check
err = SelectPayBill(tx, input)
if err != nil {
return nil, err
}
//聚合被扫 billID, err := InsertRefundBill(tx, input, refundID)
func UnifiedOrder2(input *models.PlaceAnOrderParamInput) (interface{}, error) { if err != nil {
return nil, err
}
//Params //数据重组 - start
//var input model.PlaceAnOrderParamInput data := make(map[string]interface{})
//if err := json.Unmarshal(this.Ctx.Input.RequestBody, &input); err != nil { var url string
// this.Data["json"] = utils.CheckError(err, "") now := time.Now()
// this.ServeJSON() now.Add(time.Minute * 60)
// return date_time1 := now.Format("20060102150405")
// //this.Data["json"] = utils.CheckError(errors.New(languages.ParamsError), languages.SystemError)
// //this.ServeJSON()
// //return
//}
//
////validate
//if err := input.ValidPlaceAnOrderParamInput(); err != nil {
// this.Data["json"] = utils.CheckError(err,"")
// this.ServeJSON()
// return
//}
//if input.PayType==1 { url = "https://test.wsmsd.cn/sit/api/v3/labs/relation/refund" //扫码-退款交易
//
//}
data := make(map[string]interface{}) data["req_time"] = date_time1
data["req_time"] = "20220714160009"
data["version"] = "3.0" data["version"] = "3.0"
data["out_org_code"] = "OP00000003" data["out_org_code"] = "OP00000003"
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
data2["merchant_no"] = "822290070111135"
data2["term_no"] = "29034705" //聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
//data2["out_trade_no"] = "FD660E1FAA3A4470933CDEDAE1EC1D8E" //data2["merchant_no"] = "8221210594300JY"
data2["out_trade_no"] = "FD660E1FAA3A4470933CDEDAE1EC1D8E"
//聚合主扫(微信JSAPI、微信小程序)
data2["merchant_no"] = "8222900581201QB"
data2["term_no"] = "D0027598"
//扫码枪
//data2["merchant_no"] = "822290070111135"
//data2["term_no"] = "29034705"
data2["out_trade_no"] = refundID //随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
//扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明 //扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明
data2["auth_code"] = "135178236713755038" //data2["auth_code"] = "135178236713755038"
data2["total_amount"] = "123" //data2["auth_code"] = input.DynamicID
//data2["out_order_no"] = "08F4542EEC6A4497BC419161747A92FA" data2["refund_amount"] = input.GoodsPrice*100 //退款金额
data2["out_order_no"] = "08F4542EEC6A4497BC419161747A92FA" data2["refund_reason"] = "" //退款原因
data["req_data"] = make(map[string]interface{})
data["req_data"] = data2 //input.OrderId = "23070311012001101011001021042"
data2["origin_out_trade_no"] = input.OrderId //原商户交易流水号
//data2["origin_trade_no"] = input.OrderId //原拉卡拉交易流水号
//data2["origin_log_no"] = input.OrderId //原对账单流水号
data3 := make(map[string]interface{}) data3 := make(map[string]interface{})
data3["request_ip"] = "10.176.1.192" //data3["request_ip"] = "10.176.1.192"
data3["location"] = "+37.123456789,-121.123456789" data3["request_ip"] = ip
//data3["location"] = "+37.123456789,-121.123456789"
data2["location_info"] = make(map[string]interface{}) data2["location_info"] = make(map[string]interface{})
data2["location_info"] = data3 data2["location_info"] = data3
//data2["out_order_no"] = input.AttachInfo //商户订单号 data["req_data"] = make(map[string]interface{})
//data2["total_amount"] = input.AttachInfo //订单金额,单位:分 data["req_data"] = data2
//data2["order_efficient_time"] = input.AttachInfo //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
//data2["notify_url"] = input.AttachInfo //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
//data2["callback_url"] = input.AttachInfo //商户订单号
//data2["order_info"] = input.AttachInfo //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
//var data model.LakalaParamInput
//data.Version = "3.0"
//data.ReqTime = "20220714160009"
//data.ReqData.OutOrderNo = input.AttachInfo //商户订单号 //return nil, errors.New("输入参数「source_code」错误,有效值为[1-6,9]")
////data.ReqData.MerchantNo = //银联商户号
//data.ReqData.TotalAmount = input.GoodsPrice //订单金额,单位:分
////data.ReqData.OrderEfficientTime = //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
//data.ReqData.NotifyUrl = input.NoticeURL //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
//data.ReqData.CallbackUrl = input.ReturnURL //客户端下单完成支付后返回的商户网页跳转地址
////data.ReqData.OrderInfo = input.OrderId //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data.ReqData.GoodsMark = input.GoodsDes //商品信息标识 (1:含商品信息,不填默认不含商品信息)
//数据重组 - end //数据重组 - end
fmt.Println("拉卡拉输入参数(退款)")
fmt.Println(data)
fmt.Println("拉卡拉接口url(退款)")
fmt.Println(url)
////var data = input.ReqData // 插入退款请求参数
//fmt.Println(111) err = InsertPayBillDetailRequestBody(tx, billID, data)
//fmt.Println(data) if err != nil {
return nil, err
}
data_json, err := json.Marshal(data) data_json, err := json.Marshal(data)
if err != nil { if err != nil {
...@@ -704,30 +735,58 @@ func UnifiedOrder2(input *models.PlaceAnOrderParamInput) (interface{}, error) { ...@@ -704,30 +735,58 @@ func UnifiedOrder2(input *models.PlaceAnOrderParamInput) (interface{}, error) {
return nil, err return nil, err
} }
//url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder" //聚合主扫
url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/micropay" //聚合被扫
//url := "https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create" //聚合收银台
//调拉卡拉接口 //调拉卡拉接口
err, _, _ = lakala_post(input.SourceCode, url, data_json) err, _, lakala_rtn := lakala_post(0, url, data_json)
if err != nil { if err != nil {
//this.Data["json"] = utils.CheckError(err,"拉卡拉错误") InsertPayBillDetailResponseBody(tx, billID, lakala_rtn)
//this.ServeJSON()
return nil, err return nil, err
} }
return nil, nil // 插入退款成功后返回的参数
//response := make(map[string]string) err = InsertPayBillDetailResponseBody(tx, billID, lakala_rtn)
//response["m_web_url"] = m_web_url if err != nil {
//beego.Error("退款请求成功 --- 但退款成功后的参数失败")
return nil, err
}
//调拉卡拉接口 response := make(map[string]string)
//err = lakala_post(url, data_json) response["payment_order_code"] = refundID
//if err != nil { return response, nil
// this.Data["json"] = utils.CheckError(err,"拉卡拉错误")
// this.ServeJSON()
// return
//}
//
//this.Data["json"] = utils.Success(nil)
//this.ServeJSON()
} }
func SelectPayBill(tx *sql.Tx, input *models.RefundParamInput) error {
var billID int64
var status uint
//payment_order_code, paymoney
selectPayBillDetailSQL := `select id, result_code from system_pay_bill where _type=0 and payment_order_code=?`
err := tx.QueryRow(selectPayBillDetailSQL, input.OrderId).Scan(&billID, &status)
if err != nil {
return errors.New("订单不存在1")
}
// 订单不存在
if billID <= 0 {
return errors.New("订单不存在2")
}
// 订单未结算
if status != 1 {
return errors.New("订单未结算")
}
return nil
}
//生产随机字符串
//func RandomString(n int) string {
// var letters = []byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
// result := make([]byte, n)
// rand2.Seed(time.Now().Unix())
// for i := range result {
// result[i] = letters[rand2.Intn(len(letters))]
// }
// return string(result)
//}
...@@ -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