Files
baseapi/platformapi/lakala/lakala_token_test.go
邹宗楠 f08b6e11b3 1
2025-06-30 10:13:46 +08:00

215 lines
6.3 KiB
Go

package lakala
import (
"fmt"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"go.uber.org/zap"
"testing"
)
var (
api *API
sugarLogger *zap.SugaredLogger
)
func init() {
logger, _ := zap.NewDevelopment()
sugarLogger = logger.Sugar()
baseapi.Init(sugarLogger)
incomingToken := "45e36fcc-7fe6-4235-9b15-9de16663be5f"
modifiedToken := "73184b9f-87d7-426a-9474-d8b8c98b037c"
//incomingExpire := time.Now().Unix()+42896
orgCode := "200669"
api = New(AppID, SerialNo, SM4Key, ClientID, ClientSecret, incomingToken, modifiedToken, orgCode)
}
// TestIncomingTest 获取创建token
func TestIncomingTest(t *testing.T) {
incomingToken, expires, err := api.IncomingToken()
fmt.Println(incomingToken, expires, err)
}
// TestModifiedToken 获取更新token
func TestModifiedToken(t *testing.T) {
modifiedToken, modifiedExpires, err := api.ModifiedToken(UserName, Password)
fmt.Println(modifiedToken, modifiedExpires, err)
}
// TestOrganization 获取城市组织代码
func TestOrganization(t *testing.T) {
// 6510 成都市 6515 金牛
organizationList, err := api.GetOrganizationCode("1")
if err != nil {
globals.SugarLogger.Debugf("err := %v", err)
} else {
globals.SugarLogger.Debugf("organizationList := %s", utils.Format4Output(organizationList, false))
}
}
// 获取银行列表
func TestBankList(t *testing.T) {
bankList, err := api.GetBankList("6510", "")
if err != nil {
globals.SugarLogger.Debugf("err := %v", err)
} else {
globals.SugarLogger.Debugf("bankList := %s", utils.Format4Output(bankList, false))
}
}
// TestGetCustomAndCategoryList 获取门店商户类别
func TestGetCustomAndCategoryList(t *testing.T) {
businessScene, err := api.GetMerchantMcc("2", "")
if err != nil {
globals.SugarLogger.Debugf("err := %v", err)
} else {
globals.SugarLogger.Debugf("businessScene := %s", utils.Format4Output(businessScene, false))
}
// 获取餐饮小分类
businessSceneCategory, err := api.GetMerchantMcc("", "11000")
if err != nil {
globals.SugarLogger.Debugf("err := %v", err)
} else {
globals.SugarLogger.Debugf("businessSceneCategory := %s", utils.Format4Output(businessSceneCategory, false))
}
}
func TestUploadImg(t *testing.T) {
filePath := "https://image.jxc4.com/image/7325d87faa6179e0d86dad9ae27cbbc1.jpg"
data, err := api.FileUpload(filePath, IdCardFront, "0", "false")
if err != nil {
fmt.Printf("Error: %v\n", err)
} else {
globals.SugarLogger.Debugf("------%s", utils.Format4Output(data, false))
}
}
func TestIncoming(t *testing.T) {
param := &MerchantIncomingReq{
LarIdType: "01",
Attchments: []AttchmentsList{
{
Id: "merchant/null/20231227172245221010CHECKSTAND_IMG.png",
Type: "CHECKSTAND_IMG",
},
{
Id: "merchant/null/20231227172251776083SHOP_OUTSIDE_IMG.png",
Type: "SHOP_OUTSIDE_IMG",
},
},
LicenseNo: "92450202MA5MWYQK23",
AccountName: "徐丽",
CityCode: "6140",
UserNo: "20000101",
Latitude: "114.034257",
BizContent: BizContentParam{
ActivityId: "37",
Fees: []Fees{
{FeeCode: "WECHAT", FeeValue: "0.60"},
{FeeCode: "ALIPAY", FeeValue: "0.60"},
{FeeCode: "SCAN_PAY", FeeValue: "0.60"},
{TopFee: "20", FeeCode: "DEBIT_CARD", FeeValue: "0.38"},
{FeeCode: "CREDIT_CARD", FeeValue: "0.6"},
{TopFee: "20", FeeCode: "UNIONPAY_WALLET_DEBIT_FEE", FeeValue: "0.38"},
{FeeCode: "UNIONPAY_WALLET_CREDIT_FEE", FeeValue: "0.6"},
},
Mcc: "11002",
TermNum: "1",
},
MerName: "烟酒行批发24小时",
OpenningBankName: "中国农业银行广西柳州市柳南支行营业室",
SettleCityName: "柳州市",
Source: "H5",
LicenseDtEnd: "9999-12-31",
SettleProvinceCode: "45",
Longtude: "22.663572",
AccountNo: "6228480850854176714",
LarName: "徐哈哈",
LarIdCardStart: "2015-01-16",
Email: "2804711849@qq.com",
OpenningBankCode: "103614010818",
ContactMobile: "18276770550",
AccountIdDtStart: "2015-01-16",
LarIdCard: "460027200111297612",
SettleCityCode: "6140",
ProvinceCode: "6100",
ContactName: "徐哈哈",
BusiCode: "WECHAT_PAY",
AccountType: "58",
LicenseName: "烟酒行批发24小时",
MerAddr: "柳州市解放南路金鱼巷1号花旗壹号楼15-10",
LicenseDtStart: "2017-11-21",
LarIdCardEnd: "2035-01-16",
CountyCode: "986140",
AccountIdDtEnd: "2035-01-16",
MerRegName: "烟酒行批发24小时",
AccountIdCard: "460027200111297612",
SettleProvinceName: "广西",
MerType: "TP_PERSONAL",
ClearingBankCode: "103100000026",
BusinessContent: "烟酒行批发24小时",
SettleType: "D1",
}
t.Log(utils.Format4Output(param, false))
api.MerchantIncoming(param)
}
func TestGetMerchantInfo(t *testing.T) {
api.GetMerchantInfo("100139367")
}
// TestFeeQuery 商户费率信息查询
func TestFeeQuery(t *testing.T) {
fees, err := api.MerchantFeeQuery("100139367", "")
if err != nil {
t.Log(err)
} else {
globals.SugarLogger.Debugf("-----fees := %s", utils.Format4Output(fees, false))
}
}
// TestMerchantFeeChange 商户费率变更
func TestMerchantFeeChange(t *testing.T) {
param := &FeeChangeReq{
Attachments: nil,
Fees: []FeeInfoDto{{
Fee: 0.38,
FeeType: "UNIONPAY_WALLET_DEBIT_FEE",
TopFee: 20,
}},
ProductCode: "",
SettleType: "",
WithdrawalType: "",
SettlementType: "",
RegularSettlementTime: "",
}
api.MerchantFeeChange(param, "100139367")
}
// TestQueryMerchantReviewStatus 获取门店审核状态
func TestQueryMerchantReviewStatus(t *testing.T) {
api.QueryMerchantReviewStatus("11111")
}
// TestCheckImgIsSupplement 检查门店需要补充的图片
func TestCheckImgIsSupplement(t *testing.T) {
api.CheckImgIsSupplement("100139367")
}
// TestGetMerchantReportStatus 商户报备查询
func TestGetMerchantReportStatus(t *testing.T) {
api.GetMerchantReportStatus("231464", "22203211", "82212107011011G")
}
// TestGetMerchantTerminal 设备终端报备查询
func TestGetMerchantTerminal(t *testing.T) {
api.GetMerchantTerminal("231464", "22203211", "82212107011011G", "47884567")
}
func TestUnionPayMerInfo(t *testing.T) {
api.UnionPayMerInfo("刘磊", "511324199308263974")
}