package lakala

import (
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/globals"
	"testing"
)

func TestCreateSeparate(t *testing.T) {
	parameter := &CreateSeparateReq{
		Version:              "1.0",
		OrderNo:              "KFPT20230223181025407788734",
		OrgCode:              "1",
		MerInnerNo:           "4002021033012340711",
		MerCupNo:             "822*******",
		ContactMobile:        "111111",
		SplitLowestRatio:     0,
		SplitEntrustFileName: "授权委托书.pdf",
		SplitEntrustFilePath: "G1/M00/00/16/CrFdEl0wGu6AHwGQAAAz1tt6luo194.jpg",
		RetUrl:               "http://run.mocky.io/v3/b02c9448-20a2-4ff6-a678-38ecab30161d",
		SplitRuleSource:      "",
		SplitRange:           "",
		SepFundSource:        "",
		EleContractNo:        "",
		SplitLaunchMode:      "",
		SettleType:           "",
		Attachments:          nil,
	}
	api.CreateSeparate(parameter)
}

func TestGetSeparate(t *testing.T) {
	paramter := &SeparateQueryReq{
		Version:  Version2,
		OrderNo:  "KFPT20230223181747812863750",
		OrgCode:  "983931",
		MerCupNo: "822651059990E2S",
	}

	api.SeparateQuery(paramter)
}

func TestQuerySeparateRecipient(t *testing.T) {
	api.QuerySeparateRecipient("SR20240010115366", "SR2024000115366")
}

func TestSubMerchantInfoQuery(t *testing.T) {
	param := &SubMerchantInfoQueryReq{
		Version:         "1.0",
		OrderNo:         "SR2024001011536611",
		OrgCode:         OrgCode,
		MerInnerNo:      "",
		MerCupNo:        "822651059990E2S",
		RegisterChannel: "",
		RegisterType:    "",
		RegisterStatus:  "",
		SubMchId:        "",
	}
	data, err := api.SubMerchantInfoQuery(param)
	globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false))
	globals.SugarLogger.Debugf("data := %v", err)
}

func TestSaveAuthentication(t *testing.T) {
	param := &AuthenticationInfo{
		Version:            "1.0",
		OrderNo:            "2025072918172341473085",
		OrgCode:            "983931",
		MerInnerNo:         "4002025072332184643",
		ContactType:        "LEGAL",
		Name:               "石锋",
		ContactIdDocType:   "IDENTIFICATION_TYPE_IDCARD",
		IdCardNumber:       "610126198012230014",
		ContactPeriodBegin: "2013-01-25",
		ContactPeriodEnd:   "2033-01-25",
		Mobile:             "18048531223",
	}
	api.SaveAuthentication(param, "WXPAY")
}

func TestAccountStatusQuery(t *testing.T) {
	api.AccountStatusQuery("ALIPAY", "2088770536505954", "822651059990E2S")
}

func TestSeparateQueryAmt(t *testing.T) {
	api.SeparateQueryAmt("822651059990E2S", "66222344989495", "20250808")
}

//func TestSeparate(t *testing.T) {
//	api.Separate(&OrderSeparateReq{
//		MerchantNo:    "822651059990E2S",
//		LogNo:         "66222324796612",
//		LogDate:       "20250805",
//		OutSeparateNo: "983931822651059990E2",
//		TotalAmt:      "1",
//		LklOrgNo:      "983931",
//		CalType:       "0",
//		NotifyUrl:     CallbackLaKaLaSeparateUrl,
//		RecvDatas: []RecvDatasParam{
//			{RecvMerchantNo: ,RecvNo: ,SeparateValue: ,},
//		},
//	})
//}

func TestSeparateResultQuery(t *testing.T) {
	api.SeparateResultQuery("822651059990E2S", "20250806770188016288059000")
}

func TestSeparateFallBack(t *testing.T) {
	api.SeparateFallBack(&SeparateFallReq{
		MerchantNo:          "822651059990E2S",
		OriginSeparateNo:    "20250806770188016288059000",
		OutSeparateNo:       "2025080615294731704633",
		OriginOutSeparateNo: "",
		FallbackReason:      "测试",
		TotalAmt:            "9",
		OriginRecvDatas: []*OriginRecvDatas{
			&OriginRecvDatas{
				RecvNo: "822651059990E2S",
				Amt:    "9",
			},
		},
	})
}

func TestApplyElectronicContractByPeople(t *testing.T) {
	api.ApplyElectronicContractByPeople(&ApplyContractByPeople{
		OrderNo:   "202508281435228400125682",
		OrgId:     983931,
		ApplyDesc: "确认信息无误",
		EcApplyId: 1013456771342118912,
		FileData: []ApplyContractFileType{
			{
				AttachType:      "FR_ID_CARD_FRONT",
				AttachExtName:   "png",
				AttachName:      "身份证正面.png",
				AttachStorePath: "MMS/20250828/172420-865c8f87621149d7890296fa290586a2.png",
			}, {
				AttachType:      "FR_ID_CARD_BEHIND",
				AttachExtName:   "png",
				AttachName:      "身份证反面.png",
				AttachStorePath: "MMS/20250828/172445-b3394ff727464f309508df942644d89b.png",
			}, {
				AttachType:      "BANK_CARD",
				AttachName:      "银行卡.jpg",
				AttachExtName:   "jpg",
				AttachStorePath: "MMS/20250828/172508-318661b2a1f347efa0db764565efb45e.jpg",
			},
		},
	})
}
