Merge branch 'menu' of https://github.com/black1552/lkl_sdk into menu

menu
black 2025-10-21 19:33:14 +08:00
commit 9126cbf2c4
50 changed files with 158 additions and 83 deletions

View File

@ -1,8 +1,8 @@
package transpreorder package transpreorder
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
@ -23,3 +23,12 @@ func (tp *TransPreorder) TransPreorder(reqData *TransPreorderRequestData) (*Tran
} }
return tp.client.DoRequest(consts.BASE_URL+consts.LKL_DCP_TRANS_PREORDER_URL, request) return tp.client.DoRequest(consts.BASE_URL+consts.LKL_DCP_TRANS_PREORDER_URL, request)
} }
func (tp *TransPreorder) TransPreorderTest(reqData *TransPreorderRequestData) (*TransPreorderResponse, error) {
// 构建请求结构体
request := &TransPreorderRequest{
ReqTime: gtime.Now().Format("YmdHis"),
Version: "3.0",
ReqData: reqData,
}
return tp.client.DoRequest(consts.BASE_TEST_URL+consts.LKL_DCP_TRANS_PREORDER_URL, request)
}

39
basePay/labs/labs.go Normal file
View File

@ -0,0 +1,39 @@
package labs
import (
"context"
relationclose "github.com/black1552/lkl_sdk/basePay/labs/relationClose"
"github.com/black1552/lkl_sdk/basePay/labs/relationRefund"
"github.com/black1552/lkl_sdk/basePay/labs/relationRevoked"
transmicropay "github.com/black1552/lkl_sdk/basePay/labs/transMicropay"
"github.com/black1552/lkl_sdk/basePay/labs/transMicropayEncry"
"github.com/black1552/lkl_sdk/basePay/labs/transPreorder"
"github.com/black1552/lkl_sdk/basePay/labs/transPreorederEncry"
transquery "github.com/black1552/lkl_sdk/basePay/labs/transQuery"
"github.com/black1552/lkl_sdk/common"
)
type Labs struct {
RelationClose *relationclose.RelationCloseServer
RelationRefund *relationRefund.RelationRefundServer
RelationRevoked *relationRevoked.RelationRevokedServer
TransMicropay *transmicropay.TransMicropayServer
TransMicropayEncry *transMicropayEncry.TransMicropayEncryServer
TransPreorder *transPreorder.TransPreorderServer
TransPreorderEncry *transPreorederEncry.TransPreorderEncryServer
TransQuery *transquery.TransQueryServer
}
func NewLabs(ctx context.Context, cfgJson string) *Labs {
return &Labs{
RelationClose: relationclose.NewRelationCloseServer(common.NewClient[relationclose.RelationCloseResponse](ctx, cfgJson)),
RelationRefund: relationRefund.NewRelationRefundServer(common.NewClient[relationRefund.RelationRefundResponse](ctx, cfgJson)),
RelationRevoked: relationRevoked.NewRelationRevokedServer(common.NewClient[relationRevoked.RelationRevokedResponse](ctx, cfgJson)),
TransMicropay: transmicropay.NewTransMicropayServer(common.NewClient[transmicropay.TransMicropayResponse](ctx, cfgJson)),
TransMicropayEncry: transMicropayEncry.NewTransMicropayEncryServer(common.NewClient[transMicropayEncry.TransMicropayEncryResponse](ctx, cfgJson)),
TransPreorder: transPreorder.NewTransPreorderServer(common.NewClient[transPreorder.TransPreorderResponse](ctx, cfgJson)),
TransPreorderEncry: transPreorederEncry.NewTransPreorderEncryServer(common.NewClient[transPreorederEncry.TransPreorederEncryResponse](ctx, cfgJson)),
TransQuery: transquery.NewTransQueryServer(common.NewClient[transquery.TransQueryResponse](ctx, cfgJson)),
}
}

View File

@ -1,8 +1,8 @@
package relationclose package relationclose
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
@ -30,10 +30,22 @@ func (a *RelationCloseServer) RelationClose(reqData *RelationCloseRequestData) (
Version: "3.0", Version: "3.0",
ReqData: reqData, ReqData: reqData,
} }
// 设置API路径 - 使用consts中的生产环境URL
url := consts.BASE_URL + consts.LKL_BASE_URL_RELATION_CLOSE_URL
// 发送请求 - 使用consts中定义的聚合扫码关单URL // 发送请求 - 使用consts中定义的聚合扫码关单URL
return a.Client.DoRequest(url, request) return a.Client.DoRequest(consts.BASE_URL+consts.LKL_BASE_URL_RELATION_CLOSE_URL, request)
}
// RelationCloseTest 执行聚合扫码关单测试请求
// - merchantNo: 商户号
// - termNo: 终端号
// - 原交易标识originOutTradeNo、originTradeNo、(originOutOrderSource+originOutOrderNo) 三者必选其一
// - locationInfo: 地址位置信息(风控要求必送)
func (a *RelationCloseServer) RelationCloseTest(reqData *RelationCloseRequestData) (*RelationCloseResponse, error) {
// 构建请求结构体
request := &RelationCloseRequest{
ReqTime: gtime.Now().Format("YmdHis"),
Version: "3.0",
ReqData: reqData,
}
// 发送请求 - 使用consts中定义的聚合扫码关单URL
return a.Client.DoRequest(consts.BASE_TEST_URL+consts.LKL_BASE_URL_RELATION_CLOSE_URL, request)
} }

View File

@ -9,13 +9,13 @@ type LocationInfo struct {
// RelationCloseRequestData 聚合扫码关单请求数据结构体 // RelationCloseRequestData 聚合扫码关单请求数据结构体
type RelationCloseRequestData struct { type RelationCloseRequestData struct {
MerchantNo string `json:"merchant_no"` // 商户号 (必填) MerchantNo string `json:"merchant_no" dc:"商户号 (必填)"` // 商户号 (必填)
TermNo string `json:"term_no"` // 终端号 (必填) TermNo string `json:"term_no" dc:"终端号 (必填)"` // 终端号 (必填)
OriginOutTradeNo string `json:"origin_out_trade_no,omitempty"` // 原商户交易流水号 (可选) OriginOutTradeNo string `json:"origin_out_trade_no,omitempty" dc:"原商户交易流水号 (可选)"` // 原商户交易流水号 (可选)
OriginTradeNo string `json:"origin_trade_no,omitempty"` // 原交易拉卡拉交易流水号 (可选) OriginTradeNo string `json:"origin_trade_no,omitempty" dc:"原交易拉卡拉交易流水号 (可选)"` // 原交易拉卡拉交易流水号 (可选)
OriginOutOrderSource string `json:"origin_out_order_source,omitempty"` // 原订单外部订单来源 (可选) OriginOutOrderSource string `json:"origin_out_order_source,omitempty" dc:"原订单外部订单来源 (可选)"` // 原订单外部订单来源 (可选)
OriginOutOrderNo string `json:"origin_out_order_no,omitempty"` // 原订单外部商户订单号 (可选) OriginOutOrderNo string `json:"origin_out_order_no,omitempty" dc:"原订单外部商户订单号 (可选)"` // 原订单外部商户订单号 (可选)
LocationInfo *LocationInfo `json:"location_info"` // 地址位置信息 (必填) LocationInfo *LocationInfo `json:"location_info" dc:"地址位置信息 (必填)"` // 地址位置信息 (必填)
} }
// RelationCloseRequest 聚合扫码关单请求结构体 // RelationCloseRequest 聚合扫码关单请求结构体

View File

@ -1,8 +1,8 @@
package relationRefund package relationRefund
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -1,8 +1,8 @@
package relationRevoked package relationRevoked
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -1,8 +1,8 @@
package transmicropay package transmicropay
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -1,25 +1,25 @@
package transMicropayEncry package transMicropayEncry
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
// TransMicropayEncryServer 聚合扫码被扫接口(全报文加密)服务结构体 // TransMicropayEncryServer 聚合扫码被扫接口(全报文加密)服务结构体
type TransMicropayEncryServer[T any] struct { type TransMicropayEncryServer struct {
Client *common.Client[T] Client *common.Client[TransMicropayEncryResponse]
} }
// NewTransMicropayEncryServer 创建聚合扫码被扫接口(全报文加密)服务实例 // NewTransMicropayEncryServer 创建聚合扫码被扫接口(全报文加密)服务实例
func NewTransMicropayEncryServer(client *common.Client[TransMicropayEncryResponse]) *TransMicropayEncryServer[TransMicropayEncryResponse] { func NewTransMicropayEncryServer(client *common.Client[TransMicropayEncryResponse]) *TransMicropayEncryServer {
return &TransMicropayEncryServer[TransMicropayEncryResponse]{ return &TransMicropayEncryServer{
Client: client, Client: client,
} }
} }
// TransMicropayEncry 聚合扫码被扫接口(全报文加密)接口 // TransMicropayEncry 聚合扫码被扫接口(全报文加密)接口
func (a *TransMicropayEncryServer[TransMicropayEncryResponse]) TransMicropayEncry(reqData *TransMicropayEncryRequestData) (*TransMicropayEncryResponse, error) { func (a *TransMicropayEncryServer) TransMicropayEncry(reqData *TransMicropayEncryRequestData) (*TransMicropayEncryResponse, error) {
// 构建请求体 // 构建请求体
request := &TransMicropayEncryRequest{ request := &TransMicropayEncryRequest{
ReqTime: gtime.Now().Format("20060102150405"), ReqTime: gtime.Now().Format("20060102150405"),

View File

@ -1,17 +1,17 @@
package transPreorder package transPreorder
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
// API 聚合主扫API结构体 // TransPreorderServer 聚合主扫API结构体
type TransPreorderServer struct { type TransPreorderServer struct {
client *common.Client[TransPreorderResponse] client *common.Client[TransPreorderResponse]
} }
// NewAPI 创建聚合主扫API实例 // NewTransPreorderServer 创建聚合主扫API实例
func NewTransPreorderServer(client *common.Client[TransPreorderResponse]) *TransPreorderServer { func NewTransPreorderServer(client *common.Client[TransPreorderResponse]) *TransPreorderServer {
return &TransPreorderServer{ return &TransPreorderServer{
client: client, client: client,

View File

@ -22,7 +22,7 @@ type ResponseData struct {
PrepayId string `json:"prepay_id,omitempty"` // 预支付交易会话ID PrepayId string `json:"prepay_id,omitempty"` // 预支付交易会话ID
} }
// Response 预订单响应结构体 // TransPreorderResponse 预订单响应结构体
type TransPreorderResponse struct { type TransPreorderResponse struct {
RespTime string `json:"resp_time"` RespTime string `json:"resp_time"`
Code string `json:"code"` Code string `json:"code"`

View File

@ -1,25 +1,25 @@
package transPreorederEncry package transPreorederEncry
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
// TransPreorderEncryServer 聚合扫码主扫交易(全报文加密)服务结构体 // TransPreorderEncryServer 聚合扫码主扫交易(全报文加密)服务结构体
type TransPreorderEncryServer[T any] struct { type TransPreorderEncryServer struct {
Client *common.Client[T] Client *common.Client[TransPreorederEncryResponse]
} }
// NewTransPreorderEncryServer 创建聚合扫码主扫交易(全报文加密)服务实例 // NewTransPreorderEncryServer 创建聚合扫码主扫交易(全报文加密)服务实例
func NewTransPreorderEncryServer(client *common.Client[TransPreorederEncryResponse]) *TransPreorderEncryServer[TransPreorederEncryResponse] { func NewTransPreorderEncryServer(client *common.Client[TransPreorederEncryResponse]) *TransPreorderEncryServer {
return &TransPreorderEncryServer[TransPreorederEncryResponse]{ return &TransPreorderEncryServer{
Client: client, Client: client,
} }
} }
// TransPreorderEncry 聚合扫码主扫交易(全报文加密)接口 // TransPreorderEncry 聚合扫码主扫交易(全报文加密)接口
func (a *TransPreorderEncryServer[TransPreorederEncryResponse]) TransPreorderEncry(reqData *TransPreorederEncryRequestData) (*TransPreorederEncryResponse, error) { func (a *TransPreorderEncryServer) TransPreorderEncry(reqData *TransPreorederEncryRequestData) (*TransPreorederEncryResponse, error) {
// 构建请求体 // 构建请求体
request := &TransPreorederEncryRequest{ request := &TransPreorederEncryRequest{
ReqTime: gtime.Now().Format("20060102150405"), ReqTime: gtime.Now().Format("20060102150405"),

View File

@ -1,19 +1,19 @@
package transquery package transquery
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
// API 聚合扫码交易查询API结构体 // API 聚合扫码交易查询API结构体
type API struct { type TransQueryServer struct {
Client *common.Client[TransQueryResponse] Client *common.Client[TransQueryResponse]
} }
// NewAPI 创建聚合扫码交易查询API实例 // NewAPI 创建聚合扫码交易查询API实例
func NewAPI(client *common.Client[TransQueryResponse]) *API { func NewTransQueryServer(client *common.Client[TransQueryResponse]) *TransQueryServer {
return &API{ return &TransQueryServer{
Client: client, Client: client,
} }
} }
@ -23,7 +23,7 @@ func NewAPI(client *common.Client[TransQueryResponse]) *API {
// - termNo: 终端号 // - termNo: 终端号
// - outTradeNo: 商户交易流水号可选与tradeNo二选一 // - outTradeNo: 商户交易流水号可选与tradeNo二选一
// - tradeNo: 拉卡拉交易流水号可选与outTradeNo二选一 // - tradeNo: 拉卡拉交易流水号可选与outTradeNo二选一
func (a *API) TransQuery(reqData *TransQueryRequestData) (*TransQueryResponse, error) { func (a *TransQueryServer) TransQuery(reqData *TransQueryRequestData) (*TransQueryResponse, error) {
// 构建请求结构体 // 构建请求结构体
request := &TransQueryRequest{ request := &TransQueryRequest{
ReqTime: gtime.Now().Format("YmdHis"), ReqTime: gtime.Now().Format("YmdHis"),

View File

@ -1,8 +1,8 @@
package transShareCode package transShareCode
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -2,6 +2,7 @@ package consts
const ( const (
BASE_URL = "https://s2.lakala.com/api" BASE_URL = "https://s2.lakala.com/api"
BASE_TEST_URL = "https://test.wsmsd.cn/sit/api"
) )
// basePay/labs 基础支付聚合扫码API地址 // basePay/labs 基础支付聚合扫码API地址

View File

@ -1,40 +0,0 @@
package unifiedreturn
import (
"context"
"github.com/black1552/lkl_sdk/lklsdk/common"
mergeRefund "github.com/black1552/lkl_sdk/lklsdk/unifiedReturn/mergeRefund"
"github.com/black1552/lkl_sdk/lklsdk/unifiedReturn/refund"
"github.com/black1552/lkl_sdk/lklsdk/unifiedReturn/refundquery"
)
type Server struct {
MergeRefound *mergeRefund.MergeRefund
Refound *refund.Refund
RefoundQuery *refundquery.RefundQuery
}
// NewServer 创建拉卡拉统一退货服务实例
func NewServer(ctx context.Context, cfgJson string) *Server {
return &Server{
MergeRefound: mergeRefund.NewMergeRefund(common.NewClient[mergeRefund.ResponseMergeRefund](ctx, cfgJson)),
Refound: refund.NewRefund(common.NewClient[refund.ResponseRefund](ctx, cfgJson)),
RefoundQuery: refundquery.NewRefundQuery(common.NewClient[refundquery.ResponseRefundQuery](ctx, cfgJson)),
}
}
// MergeRefund 合单退货
func (u *Server) MergeRefund(req *mergeRefund.RequestDataMergeRefund) (*mergeRefund.ResponseMergeRefund, error) {
return u.MergeRefound.MergeRefund(req)
}
// Refund 退货
func (u *Server) Refund(req *refund.RequestDataRefund) (*refund.ResponseRefund, error) {
return u.Refound.Refund(req)
}
// RefundQuery 退货查询
func (u *Server) RefundQuery(req *refundquery.RequestDataRefundQuery) (*refundquery.ResponseRefundQuery, error) {
return u.RefoundQuery.RefundQuery(req)
}

20
sdk.go Normal file
View File

@ -0,0 +1,20 @@
package lklSDK
import (
"context"
"github.com/black1552/lkl_sdk/basePay/labs"
"github.com/black1552/lkl_sdk/unifiedreturn"
)
type SDK struct {
labs *labs.Labs
unifiedReturn *unifiedreturn.Server
}
func NewSDK(ctx context.Context, cfgJson string) *SDK {
return &SDK{
labs: labs.NewLabs(ctx, cfgJson),
unifiedReturn: unifiedreturn.NewServer(ctx, cfgJson),
}
}

View File

@ -1,8 +1,8 @@
package mergerefund package mergerefund
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
@ -24,3 +24,12 @@ func (t *MergeRefund) MergeRefund(req *RequestDataMergeRefund) (*ResponseMergeRe
} }
return t.client.DoRequest(consts.BASE_URL+consts.LKL_UNIFIED_RETURN_MERGE_REFUND_URL, baseReq) return t.client.DoRequest(consts.BASE_URL+consts.LKL_UNIFIED_RETURN_MERGE_REFUND_URL, baseReq)
} }
func (t *MergeRefund) MergeRefundTest(req *RequestDataMergeRefund) (*ResponseMergeRefund, error) {
// 构建BaseModel请求
baseReq := RequestMergeRefund{
ReqTime: gtime.Now().Format("YmdHis"),
Version: "3.0",
ReqData: req,
}
return t.client.DoRequest(consts.BASE_TEST_URL+consts.LKL_UNIFIED_RETURN_MERGE_REFUND_URL, baseReq)
}

View File

@ -1,8 +1,8 @@
package refund package refund
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -1,8 +1,8 @@
package refundquery package refundquery
import ( import (
"github.com/black1552/lkl_sdk/common"
"github.com/black1552/lkl_sdk/consts" "github.com/black1552/lkl_sdk/consts"
"github.com/black1552/lkl_sdk/lklsdk/common"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )

View File

@ -0,0 +1,25 @@
package unifiedreturn
import (
"context"
"github.com/black1552/lkl_sdk/common"
mergeRefund "github.com/black1552/lkl_sdk/unifiedReturn/mergeRefund"
"github.com/black1552/lkl_sdk/unifiedReturn/refund"
"github.com/black1552/lkl_sdk/unifiedReturn/refundquery"
)
type Server struct {
MergeRefound *mergeRefund.MergeRefund
Refound *refund.Refund
RefoundQuery *refundquery.RefundQuery
}
// NewServer 创建拉卡拉统一退货服务实例
func NewServer(ctx context.Context, cfgJson string) *Server {
return &Server{
MergeRefound: mergeRefund.NewMergeRefund(common.NewClient[mergeRefund.ResponseMergeRefund](ctx, cfgJson)),
Refound: refund.NewRefund(common.NewClient[refund.ResponseRefund](ctx, cfgJson)),
RefoundQuery: refundquery.NewRefundQuery(common.NewClient[refundquery.ResponseRefundQuery](ctx, cfgJson)),
}
}