1
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -167,7 +166,6 @@ func (a *API) AccessAPISign(baseUrl, action, method string, pathParam string, bi
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
globals.SugarLogger.Debugf("------Authorization:= %s", Authorization)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
|
||||
@@ -465,14 +465,119 @@ func (a *API) QueryCarBin(orderNo, orgCode, cardNo string) (*BinInfo, error) {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
type BinInfo struct {
|
||||
CardBin string `json:"cardBin"` // 卡bin
|
||||
BankCode string `json:"bankCode"` // 开户行号
|
||||
OrderNo string `json:"orderNo"` // 订单号
|
||||
CardName string `json:"cardName"` // 卡种名称
|
||||
OrgCode string `json:"orgCode"` // 机构代码
|
||||
CardType string `json:"cardType"` // 银行卡类别
|
||||
BankName string `json:"bankName"` // 开户行名称
|
||||
ClearingBankCode string `json:"clearingBankCode"` // 清算行号
|
||||
CardNo string `json:"cardNo"` // 银行卡号
|
||||
// SaveAuthentication 微信支付宝认证
|
||||
func (a *API) SaveAuthentication(param *AuthenticationInfo, authType string) error {
|
||||
reqData := utils.Struct2Map(param, "", false)
|
||||
activityUrl := WeChatAuthentication
|
||||
if authType == AuthenticationType {
|
||||
reqData["realNameType"] = AuthenticationType
|
||||
activityUrl = AlibabaAuthentication
|
||||
}
|
||||
reqParameter := map[string]interface{}{
|
||||
"req_data": reqData,
|
||||
"ver": Version,
|
||||
"timestamp": utils.Int64ToStr(time.Now().Unix()),
|
||||
"reqId": utils.GetUUID(),
|
||||
}
|
||||
result, err := a.AccessAPISign(SeparateAccountProdUrl, activityUrl, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return errors.New(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAuthentication 实名认证修改
|
||||
// https://o.lakala.com/#/home/document/detail?id=183
|
||||
func (a *API) UpdateAuthentication(param *UpdateAuthentication, authType string) error {
|
||||
reqData := utils.Struct2Map(param, "", false)
|
||||
activityUrl := WeChatUpdateAuthentication
|
||||
if authType == AuthenticationType {
|
||||
activityUrl = AlibabaUpdateAuthentication
|
||||
}
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": reqData,
|
||||
"ver": Version,
|
||||
"timestamp": utils.Int64ToStr(time.Now().Unix()),
|
||||
"reqId": utils.GetUUID(),
|
||||
}
|
||||
result, err := a.AccessAPISign(SeparateAccountProdUrl, activityUrl, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return errors.New(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryAuthentication 实名认证查询
|
||||
// https://o.lakala.com/#/home/document/detail?id=181
|
||||
func (a *API) QueryAuthentication(param *QueryAuthentication, authType string) (*QueryAuthenticationResp, error) {
|
||||
reqData := utils.Struct2Map(param, "", false)
|
||||
activityUrl := WeChatQueryAuthentication
|
||||
if authType == AuthenticationType {
|
||||
reqData["realNameType"] = AuthenticationType
|
||||
activityUrl = AlibabaQueryAuthentication
|
||||
}
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": reqData,
|
||||
"ver": Version,
|
||||
"timestamp": utils.Int64ToStr(time.Now().Unix()),
|
||||
"reqId": utils.GetUUID(),
|
||||
}
|
||||
result, err := a.AccessAPISign(SeparateAccountProdUrl, activityUrl, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, errors.New(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
body, err := json.Marshal(result["respData"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := &QueryAuthenticationResp{}
|
||||
if err = json.Unmarshal(body, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// AccountStatusQuery 开户状态查询
|
||||
// https://o.lakala.com/#/home/document/detail?id=528
|
||||
func (a *API) AccountStatusQuery(tradeMode, subMerchantId, merchantNo string) (map[string]interface{}, error) {
|
||||
activityUrl := ""
|
||||
switch tradeMode {
|
||||
case "ALIPAY":
|
||||
activityUrl = AlibabaAccountStatusQuery
|
||||
case "WECHAT":
|
||||
activityUrl = WeChatAccountStatusQuery
|
||||
}
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": map[string]interface{}{"tradeMode": tradeMode, "subMerchantId": subMerchantId, "merchantNo": merchantNo},
|
||||
"ver": Version,
|
||||
"timestamp": utils.Int64ToStr(time.Now().Unix()),
|
||||
"reqId": utils.GetUUID(),
|
||||
}
|
||||
result, err := a.AccessAPISign(PayAccountProdUrl, activityUrl, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, errors.New(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
return result["respData"].(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ const (
|
||||
Version3 = "3.0"
|
||||
SplitLaunchModeAuto = "AUTO" // 自动规则分账
|
||||
SplitLaunchModePointRule = "POINTRULE" // 指定规则分账
|
||||
AuthenticationType = "ZFBZF" // 支付宝支付
|
||||
|
||||
)
|
||||
|
||||
@@ -18,17 +19,27 @@ const (
|
||||
const (
|
||||
SeparateAccountTestUrl = "https://test.wsmsd.cn/sit/api/v2/mms/openApi/" // 测试
|
||||
SeparateAccountProdUrl = "https://s2.lakala.com/api/v2/mms/openApi" // 生产
|
||||
PayAccountProdUrl = "https://s2.lakala.com/api/v2/mms" // 生产
|
||||
|
||||
SeparateAccountApplyAction = "ledger/applyLedgerMer" // 商户申请开通分账
|
||||
SeparateAccountModifyAction = "ledger/modifyLedgerMer" // 商户变更申请开通分账
|
||||
SeparateAccountQueryAction = "ledger/queryLedgerMer" // 商户分账信息查询
|
||||
SeparateReceiverApplyAction = "ledger/applyLedgerReceiver" // 分账接受方创建
|
||||
SeparateReceiverModifyAction = "ledger/modifyLedgerReceiver" // 分账接受方变更
|
||||
SeparateReceiverQueryAction = "ledger/queryReceiverDetail" // 分账接受方查询
|
||||
SeparateBindAction = "ledger/applyBind" // 分账关系绑定
|
||||
SeparateUnBindAction = "ledger/applyUnBind" // 分账关系解除绑定
|
||||
SeparateCardBinAction = "cardBin" // 卡BIN查询
|
||||
AttachmentUpload = "uploadFile" // 附件上传
|
||||
WeChatAuthentication = "realName/saveContactInfo" // 微信实名认证
|
||||
AlibabaAuthentication = "realName/saveAlipayContactInfo" // 阿里实名认证
|
||||
WeChatUpdateAuthentication = "wechatRealName/modifyCommit" // 微信修改实名认证
|
||||
AlibabaUpdateAuthentication = "alipayRealName/modifyCommit" // 阿里修改实名认证
|
||||
WeChatQueryAuthentication = "wechatRealNameQuery" // 微信实名认证结果查询
|
||||
AlibabaQueryAuthentication = "alipayRealNameQuery" // 阿里修改实名认证
|
||||
WeChatAccountStatusQuery = "alipayRealNameQuery" // 微信开户状态差取暖
|
||||
AlibabaAccountStatusQuery = "alipayRealNameQuery" // 阿里开户状态查询
|
||||
|
||||
SeparateAccountApplyAction = "ledger/applyLedgerMer" // 商户申请开通分账
|
||||
SeparateAccountModifyAction = "ledger/modifyLedgerMer" // 商户变更申请开通分账
|
||||
SeparateAccountQueryAction = "ledger/queryLedgerMer" // 商户分账信息查询
|
||||
SeparateReceiverApplyAction = "ledger/applyLedgerReceiver" // 分账接受方创建
|
||||
SeparateReceiverModifyAction = "ledger/modifyLedgerReceiver" // 分账接受方变更
|
||||
SeparateReceiverQueryAction = "ledger/queryReceiverDetail" // 分账接受方查询
|
||||
SeparateBindAction = "ledger/applyBind" // 分账关系绑定
|
||||
SeparateUnBindAction = "ledger/applyUnBind" // 分账关系解除绑定
|
||||
SeparateCardBinAction = "cardBin" // 卡BIN查询
|
||||
AttachmentUpload = "uploadFile" // 附件上传
|
||||
)
|
||||
|
||||
// 分账
|
||||
@@ -418,3 +429,69 @@ type SeparateQueryAmtResp struct {
|
||||
LogDate string `json:"log_date"` // 拉卡拉对账单交易日期
|
||||
LogNo string `json:"log_no"` // 拉卡拉对账单流水号
|
||||
}
|
||||
|
||||
// BinInfo 卡bin查询
|
||||
type BinInfo struct {
|
||||
CardBin string `json:"cardBin"` // 卡bin
|
||||
BankCode string `json:"bankCode"` // 开户行号
|
||||
OrderNo string `json:"orderNo"` // 订单号
|
||||
CardName string `json:"cardName"` // 卡种名称
|
||||
OrgCode string `json:"orgCode"` // 机构代码
|
||||
CardType string `json:"cardType"` // 银行卡类别
|
||||
BankName string `json:"bankName"` // 开户行名称
|
||||
ClearingBankCode string `json:"clearingBankCode"` // 清算行号
|
||||
CardNo string `json:"cardNo"` // 银行卡号
|
||||
}
|
||||
|
||||
// AuthenticationInfo 支付认证
|
||||
type AuthenticationInfo struct {
|
||||
Version string `json:"version"` // 接口版本号 1.0
|
||||
OrderNo string `json:"orderNo"` // 14位年月日时(24小时制)分秒+8位的随机数(不重复)如
|
||||
OrgCode int `json:"orgCode"` // 机构代码
|
||||
MerInnerNo string `json:"merInnerNo"` // 拉卡拉内部商户号
|
||||
ContactType string `json:"contactType"` // 联系人类型 LEGAL:经营者/法人 SUPER:经办人
|
||||
Name string `json:"name"` // 联系人名称
|
||||
ContactIdDocType string `json:"contactIdDocType"` // 联系人证件类型 IDENTIFICATION_TYPE_IDCARD
|
||||
IdCardNumber string `json:"idCardNumber"` // 联系人证件号码
|
||||
ContactPeriodBegin string `json:"contactPeriodBegin"` // 联系人证件有效期开始时间
|
||||
ContactPeriodEnd string `json:"contactPeriodEnd"` // 联系人证件有效期结束时间
|
||||
Mobile string `json:"mobile"` // 联系人手机号
|
||||
}
|
||||
|
||||
// UpdateAuthentication 修改报备请求
|
||||
type UpdateAuthentication struct {
|
||||
Version string `json:"version"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
OrgCode string `json:"orgCode"`
|
||||
MerInnerNo string `json:"merInnerNo"`
|
||||
ReceOrgNo string `json:"receOrgNo"`
|
||||
SubMchId string `json:"subMchId"`
|
||||
ChannelId string `json:"channelId"`
|
||||
ApplymentId string `json:"applymentId"`
|
||||
}
|
||||
|
||||
// QueryAuthentication 认证结果查询
|
||||
type QueryAuthentication struct {
|
||||
Version string `json:"version"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
OrgCode string `json:"orgCode"`
|
||||
MerInnerNo string `json:"merInnerNo"`
|
||||
SubMchId string `json:"subMchId"`
|
||||
ChannelId string `json:"channelId"`
|
||||
}
|
||||
|
||||
// QueryAuthenticationResp 认证结果查询
|
||||
type QueryAuthenticationResp struct {
|
||||
MerInnerNo string `json:"merInnerNo"` // 拉卡拉内部商户号
|
||||
SubMchId string `json:"subMchId"` // 账户端子商户号
|
||||
ChannelId string `json:"channelId"` // 渠道号
|
||||
ApplymentState string `json:"applymentState"` // 申请状态
|
||||
ReceOrgNo string `json:"receOrgNo"` // 从业机构号
|
||||
ApplymentId string `json:"applymentId"` // 申请编号
|
||||
AuthorizeState string `json:"authorizeState"` // 认证状态
|
||||
RegisterChannel string `json:"registerChannel"` // 报备通道
|
||||
QrcodeData string `json:"qrcodeData"` // 小程序码图片
|
||||
RealNameType string `json:"realNameType"` // 实名认证类型
|
||||
RejectParameter string `json:"rejectParameter"` // 驳回参数
|
||||
RejectReason string `json:"rejectReason"` // 驳回原因
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func TestIncoming(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMerchantInfo(t *testing.T) {
|
||||
result, err := api.GetMerchantInfo("141698705")
|
||||
result, err := api.GetMerchantInfo("141804158")
|
||||
globals.SugarLogger.Debugf("---------result:;= %s", utils.Format4Output(result, false))
|
||||
globals.SugarLogger.Debugf("---------result:;= %v", err)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestGetSkuDetail(t *testing.T) {
|
||||
|
||||
// 查询商品详情本地商品id
|
||||
func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
data, err := a.GetSkuDetail("3765728861137010842", "")
|
||||
data, err := a.GetSkuDetail("3749499171854483927", "")
|
||||
fmt.Println(err)
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user