feat(basePay): 添加测试环境支持和新功能
- 为 transPreorder 和 relationClose 添加测试环境请求方法 - 更新所有模块导入路径,统一使用新的 common 包 - 重构多个结构体和服务命名以提高一致性 - 新增 labs 包整合基础支付相关功能模块 - 创建 SDK 入口文件便于统一管理和调用 - 在 consts 中增加 BASE_TEST_URL 常量定义 - 优化请求数据结构体字段注释和文档标签 - 移除冗余代码并调整部分函数签名以增强可读性
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package relationRefund
|
||||
|
||||
import (
|
||||
"github.com/black1552/lkl_sdk/common"
|
||||
"github.com/black1552/lkl_sdk/consts"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// RelationRefundServer 聚合扫码退款API结构体
|
||||
type RelationRefundServer struct {
|
||||
Client *common.Client[RelationRefundResponse]
|
||||
}
|
||||
|
||||
// NewRelationRefundServer 创建聚合扫码退款API实例
|
||||
func NewRelationRefundServer(client *common.Client[RelationRefundResponse]) *RelationRefundServer {
|
||||
return &RelationRefundServer{
|
||||
Client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// RelationRefund 聚合扫码退款方法
|
||||
// - reqData: 退款请求数据
|
||||
func (a *RelationRefundServer) RelationRefund(reqData *RelationRefundRequestData) (*RelationRefundResponse, error) {
|
||||
// 构建请求结构体
|
||||
request := &RelationRefundRequest{
|
||||
ReqTime: gtime.Now().Format("20060102150405"),
|
||||
Version: "3.0",
|
||||
ReqData: reqData,
|
||||
}
|
||||
|
||||
// 调用Client发送请求
|
||||
return a.Client.DoRequest(consts.BASE_URL+consts.LKL_BASE_URL_RELATION_REFUND_URL, request)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package relationRefund
|
||||
|
||||
// LocationInfo 地址位置信息结构体
|
||||
type LocationInfo struct {
|
||||
RequestIP string `json:"request_ip"` // 请求方IP地址,必填
|
||||
BaseStation string `json:"base_station,omitempty"` // 基站信息,可选
|
||||
Location string `json:"location,omitempty"` // 维度,经度,可选
|
||||
}
|
||||
|
||||
// RelationRefundRequestData 聚合扫码退款请求数据结构体
|
||||
type RelationRefundRequestData struct {
|
||||
MerchantNo string `json:"merchant_no"` // 商户号,必填
|
||||
TermNo string `json:"term_no"` // 终端号,必填
|
||||
OutTradeNo string `json:"out_trade_no"` // 商户交易流水号,必填
|
||||
RefundAmount string `json:"refund_amount"` // 退款金额,必填
|
||||
RefundReason string `json:"refund_reason"` // 退款原因,必填
|
||||
OriginOutTradeNo string `json:"origin_out_trade_no,omitempty"` // 原商户交易流水号,可选(退款时origin_out_trade_no,origin_trade_no,origin_log_no必送其一)
|
||||
OriginTradeNo string `json:"origin_trade_no,omitempty"` // 原拉卡拉交易流水号,可选
|
||||
OriginLogNo string `json:"origin_log_no,omitempty"` // 原对账单流水号,可选
|
||||
TradeReqDate string `json:"trade_req_date,omitempty"` // 交易请求日期,可选(送原商户交易流水号退款时必填)
|
||||
LocationInfo LocationInfo `json:"location_info"` // 地址位置信息,必填
|
||||
}
|
||||
|
||||
// RelationRefundRequest 聚合扫码退款请求结构体
|
||||
type RelationRefundRequest struct {
|
||||
ReqTime string `json:"req_time"`
|
||||
Version string `json:"version"`
|
||||
ReqData *RelationRefundRequestData `json:"req_data"`
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package relationRefund
|
||||
|
||||
// RelationRefundResponseData 聚合扫码退款响应数据结构体
|
||||
type RelationRefundResponseData struct {
|
||||
MerchantNo string `json:"merchant_no"` // 商户号
|
||||
OutTradeNo string `json:"out_trade_no"` // 商户请求流水号
|
||||
TradeNo string `json:"trade_no"` // 拉卡拉退款单号
|
||||
LogNo string `json:"log_no"` // 拉卡拉对账单流水号
|
||||
AccTradeNo string `json:"acc_trade_no,omitempty"` // 账户端交易订单号
|
||||
AccountType string `json:"account_type,omitempty"` // 钱包类型
|
||||
TotalAmount string `json:"total_amount"` // 交易金额
|
||||
RefundAmount string `json:"refund_amount"` // 申请退款金额
|
||||
PayerAmount string `json:"payer_amount"` // 实际退款金额
|
||||
TradeTime string `json:"trade_time,omitempty"` // 退款时间
|
||||
OriginTradeNo string `json:"origin_trade_no,omitempty"` // 原拉卡拉订单号
|
||||
OriginOutTradeNo string `json:"origin_out_trade_no,omitempty"` // 原商户请求流水号
|
||||
UpIssAddnData string `json:"up_iss_addn_data,omitempty"` // 单品营销附加数据
|
||||
UpCouponInfo string `json:"up_coupon_info,omitempty"` // 银联优惠信息、出资方信息
|
||||
TradeInfo string `json:"trade_info,omitempty"` // 出资方信息
|
||||
FundBillList string `json:"fund_bill_list,omitempty"` // 交易支付使用的资金渠道
|
||||
}
|
||||
|
||||
// RelationRefundResponse 聚合扫码退款响应结构体
|
||||
type RelationRefundResponse struct {
|
||||
Code string `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
RespTime string `json:"resp_time"`
|
||||
RespData *RelationRefundResponseData `json:"resp_data,omitempty"`
|
||||
}
|
||||
|
||||
// SuccessOrFail 判断响应是否成功
|
||||
func (r *RelationRefundResponse) SuccessOrFail() bool {
|
||||
return r.Code == "BBS00000"
|
||||
}
|
||||
Reference in New Issue
Block a user