{
+}
diff --git a/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/CommonInputStreamResource.java b/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/CommonInputStreamResource.java
new file mode 100644
index 0000000..0a645ad
--- /dev/null
+++ b/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/CommonInputStreamResource.java
@@ -0,0 +1,53 @@
+package cn.pluss.platform.klk.service.impl;
+
+import org.springframework.core.io.InputStreamResource;
+
+import java.io.InputStream;
+
+public class CommonInputStreamResource extends InputStreamResource {
+ /***
+ * 文件長度
+ */
+ private int length;
+ /***
+ * 文件名稱
+ */
+ private String fileName;
+ public CommonInputStreamResource(InputStream inputStream) {
+ super(inputStream);
+ }
+ public CommonInputStreamResource(InputStream inputStream, int length,String fileName) {
+ super(inputStream);
+ this.length = length;
+ this.fileName = fileName;
+ }
+ /**
+ * 覆写父类方法
+ * 如果不重写这个方法,并且文件有一定大小,那么服务端会出现异常
+ * {@code The multi-part request contained parameter data (excluding uploaded files) that exceeded}
+ *
+ * @return
+ */
+ @Override
+ public String getFilename() {
+ return this.fileName;
+ }
+ /**
+ * 覆写父类 contentLength 方法
+ * 因为 {@link org.springframework.core.io.AbstractResource#contentLength()}方法会重新读取一遍文件,
+ * 而上传文件时,restTemplate 会通过这个方法获取大小。然后当真正需要读取内容的时候,发现已经读完,会报如下错误。
+ *
+ * java.lang.IllegalStateException: InputStream has already been read - do not use InputStreamResource if a stream needs to be read multiple times
+ * at org.springframework.core.io.InputStreamResource.getInputStream(InputStreamResource.java:96)
+ *
+ *
+ * ref:com.amazonaws.services.s3.model.S3ObjectInputStream#available()
+ *
+ * @return
+ */
+ @Override
+ public long contentLength() {
+ int estimate = length;
+ return estimate == 0 ? 1 : estimate;
+ }
+}
diff --git a/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/LaKalaInterfaceImpl.java b/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/LaKalaInterfaceImpl.java
new file mode 100644
index 0000000..c979b0b
--- /dev/null
+++ b/pluss-service-bundle/src/main/java/cn/pluss/platform/klk/service/impl/LaKalaInterfaceImpl.java
@@ -0,0 +1,789 @@
+package cn.pluss.platform.klk.service.impl;
+
+import cn.pluss.platform.BankCardService;
+import cn.pluss.platform.IdCardService;
+import cn.pluss.platform.channel.ys.impl.YSAuditServiceV3;
+import cn.pluss.platform.dto.AccountDTO;
+import cn.pluss.platform.entity.*;
+import cn.pluss.platform.exception.MsgException;
+import cn.pluss.platform.klk.LaKaLaUtility;
+import cn.pluss.platform.klk.service.*;
+import cn.pluss.platform.klk.vo.*;
+
+import cn.pluss.platform.mcc.MccReflectService;
+import cn.pluss.platform.merchant.AccountService;
+import cn.pluss.platform.merchant.MerchantBaseInfoService;
+import cn.pluss.platform.merchantChannelStatus.MerchantChannelStatusService;
+import cn.pluss.platform.userApp.UserAppService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.Data;
+import lombok.SneakyThrows;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.http.*;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
+@Service
+public class LaKalaInterfaceImpl implements LaKalaInterface {
+ @Resource
+ LklPayService lklPayService;
+ @Resource
+ TbLklRegionBankInfoServiceImpl tbLklRegionBankInfoServiceImpl;
+ @Resource
+ TbPlussBankBranchLklService tbPlussBankBranchLklService;
+
+ @Resource
+ UserAppService uaService;
+ @Resource
+ private MerchantBaseInfoService mbiService;
+ @Resource
+ BankCardService bankCardService;
+ @Resource
+ private TbPlussRegionLklService tbPlussRegionLklService;
+
+ @Resource
+ private IdCardService idCardService;
+ @Resource
+ private TbPlussBankRegionLklService regionLklService;
+
+ @Resource
+ AccountService accountService;
+
+ @Lazy
+ @Resource
+ private MerchantChannelStatusService mcsService;
+ @Resource
+ MerchantBaseInfoService baseInfoService;
+
+ @Resource
+ TbPlussBusinessSmallLklService businessSmallLklService;
+ @Resource
+ MccReflectService service;
+ @Resource
+ PlussMerchantLklService merchantLklService;
+// private static final String client_id = "chaozhanggui";
+// private static final String client_secret = "Y54Gqy6aLpxld3dp";
+// private static final String grant_type = "client_credentials";
+// private static final String userNo = "22241007";
+// /**
+// * 商户进件
+// */
+// private static final String tuoKeMerchat = "https://htkactvi.lakala.com/registration/merchant";
+// /**
+// * 获取地区信息
+// */
+// private static final String organparentCode = "https://htkactvi.lakala.com/registration/organization/";
+// /**
+// * 获取银行地区信息
+// */
+// private static final String organizationBank = "https://htkactvi.lakala.com/registration/organization/bank/";
+// /**
+// * 文件上传
+// */
+// private static final String fileUpload = "https://htkactvi.lakala.com/registration/file/upload";
+// private static final String tuoKeToken = "https://tkapi.lakala.com/auth/oauth/token";
+
+ /************************************************测试信息***************************************************/
+ private static final String client_id = "testsit";
+ private static final String client_secret = "EguwEckByf2I6u6z";
+ private static final String grant_type = "client_credentials";
+ private static final String userNo = "20000101";
+ /**
+ * 商户进件
+ */
+ private static final String tuoKeMerchat = "https://test.wsmsd.cn/sit/htkregistration/merchant";
+ /**
+ * 获取地区信息
+ */
+ private static final String organparentCode = "https://test.wsmsd.cn/sit/htkregistration/organization/";
+ /**
+ * 获取银行地区信息
+ */
+ private static final String organizationBank = "https://test.wsmsd.cn/sit/htkregistration/organization/bank/";
+ /**
+ * 文件上传
+ */
+ private static final String fileUpload = "https://test.wsmsd.cn/sit//htkregistration/file/upload";
+ private static final String tuoKeToken = "https://test.wsmsd.cn/sit/htkauth/oauth/token";
+
+
+
+ /**
+ * 拉卡拉模式进件
+ */
+ @Override
+ public void laKaLaAddMer(LaKaLaVO laVO, String ip) {
+ String apiPath = "/api/v2/mms/openApi/addMer";
+ JSONObject object1 = new JSONObject();
+ JSONObject object2 = new JSONObject();
+ object1.put("reqData", object2);
+ object2.put("version", "1.0"); //接口版本号
+ object2.put("orderNo", laVO.getOrderNo()); //订单编号(便于后续跟踪排查问题及核对报文)
+ object2.put("posType", laVO.getPosType()); //进件POS类型 —按接入系统做控制,参见 【POS类型字典表】
+ object2.put("orgCode", "1"); //机构代码 (合作方在拉卡拉的标识,请联系业务员)
+ object2.put("merRegName", laVO.getMerRegName()); //商户注册名称
+ object2.put("merRegDistCode", laVO.getMerRegDistCode()); //地区代码,参看地区文档]
+ object2.put("merRegAddr", laVO.getMerRegAddr()); //商户详细地址
+ object2.put("mccCode", laVO.getMccCode()); //商户MCC编号
+ if (null != laVO.getMerBlisName() || null != laVO.getMerBlis()) { //小微商户可不传,其它必传,为空则小微商户
+ object2.put("merBlisName", laVO.getMerBlisName()); //营业执照名称
+ object2.put("merBlis", laVO.getMerBlis()); //营业执照号
+ object2.put("merBlisStDt", laVO.getMerBlisStDt()); //营业执照开始日期
+ object2.put("merBlisExpDt", "1.0"); //营业执照有效期
+ }
+
+ object2.put("merBusiContent", laVO.getMerBusiContent()); //参看【经营内容字典表】文档
+ object2.put("larName", laVO.getLarName()); //商户法人姓名
+ object2.put("larIdType", laVO.getLarIdType()); //支持其他证件类型,见参【证件类型字典表】
+ object2.put("larIdcard", laVO.getLarIdcard()); //法人身份证号码
+ object2.put("larIdcardStDt", laVO.getLarIdcardStDt()); //法人身份证开始日期 yyyy-MM-dd
+ object2.put("larIdcardExpDt", laVO.getLarIdcardExpDt()); //法人身份证有效期 yyyy-MM-dd
+ object2.put("merContactMobile", laVO.getMerContactMobile()); //商户联系人手机号码
+ object2.put("merContactName", laVO.getMerContactName()); //商户联系人
+
+ object2.put("openningBankCode", laVO.getOpenningBankCode()); //可根据结算卡信息进行查询,(仅支持对私结算卡查询)参见【卡BIN信息查询】
+ object2.put("openningBankName", laVO.getOpenningBankName()); //可根据结算卡信息进行查询,(仅支持对私结算卡查询)参见【卡BIN信息查询】
+ object2.put("clearingBankCode", laVO.getClearingBankCode()); //可根据结算卡信息进行查询,(仅支持对私结算卡查询)参见【卡BIN信息查询】
+ object2.put("acctNo", laVO.getAcctNo()); //结算账户账号
+ object2.put("acctName", laVO.getAcctName()); //结算账户名称
+ object2.put("acctTypeCode", laVO.getAcctTypeCode()); //结算账户性质 57对公 58 对私
+ object2.put("settlePeriod", laVO.getSettlePeriod()); //结算周期 参见【结算周期表】
+ object2.put("retUrl", "1.0"); //回调地址url
+ object2.put("feeData", laVO.getFeeData()); //费率信息集合 参看下方【费率信息】
+// orderService.createOrder(object1.toString(),apiPath,"");
+ }
+
+ /**
+ * 拉卡拉拓客进件
+ * */
+ public TuoKeVo createTuoKeInfo(String userId) {
+ MerchantBaseInfo merchantBaseInfo = mbiService.getMerchantBaseInfoByUserId(userId);
+ TuoKeVo tuoKeVo = new TuoKeVo();
+ tuoKeVo.setBusiCode(""); //业务类型
+ tuoKeVo.setEmail("chaozhanggui2023@163.com");
+ tuoKeVo.setMerchantCode(merchantBaseInfo.getMerchantCode());
+ tuoKeVo.setMerRegName(merchantBaseInfo.getMerchantName());//商户注册名称
+ if (merchantBaseInfo.getMerchantType().equals("1") || merchantBaseInfo.getMerchantType().equals("2")) { //商户类型/营业执照类型 可选值:1:小微2:个体3:企业
+ tuoKeVo.setMerType("TP_PERSONAL");//商户注册类型 TP_MERCHANT:企业 TP_PERSONAL:⼩微个⼈
+ } else {
+ tuoKeVo.setMerType("TP_MERCHANT");//商户注册类型
+ }
+
+ tuoKeVo.setMerName(merchantBaseInfo.getMerchantName()); //商户名称(经营名称
+ tuoKeVo.setMerAddr(merchantBaseInfo.getAddress()); //市区后的详细地址
+ List proOrganCode = getOrganCode("1");
+ System.out.println("proOrganCode :" + proOrganCode);
+ String cityCode = null;
+ for (OrganVo organVo : proOrganCode) { //省code
+ if (organVo.getName().equals(merchantBaseInfo.getProvince())) {
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("name", merchantBaseInfo.getProvince()).last("limit 1");
+ TbPlussRegionLklEntity one = tbPlussRegionLklService.getOne(wrapper);
+ tuoKeVo.setProvinceCode(one.getCode());
+ cityCode = one.getCode();
+ break;
+ }
+ }
+ List cityOrganCode = getOrganCode(cityCode); //市code
+ for (OrganVo organVo : cityOrganCode) {
+ if (organVo.getName().equals(merchantBaseInfo.getCity())) {
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("name", merchantBaseInfo.getCity()).last("limit 1");
+ TbPlussRegionLklEntity one = tbPlussRegionLklService.getOne(wrapper);
+ tuoKeVo.setCityCode(one.getCode());
+ cityCode = one.getCode();
+ break;
+ }
+ }
+
+ List countyOrganCode = getOrganCode(cityCode); //区code
+ for (OrganVo organVo : countyOrganCode) {
+ if (organVo.getName().equals(merchantBaseInfo.getDistrict())) {
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("name", merchantBaseInfo.getDistrict()).last("limit 1");
+ TbPlussRegionLklEntity one = tbPlussRegionLklService.getOne(wrapper);
+ tuoKeVo.setCountyCode(one.getCode());
+ cityCode = one.getCode();
+ break;
+ }
+ }
+ if (!merchantBaseInfo.getMerchantType().equals("1")) {// 非小微商户类型
+ tuoKeVo.setLicenseName(merchantBaseInfo.getBussAuthName()); //营业执照名称
+ tuoKeVo.setLicenseNo(merchantBaseInfo.getBussAuthNum());//营业执照号码 ⼩微商户可不传, 其他必传
+ tuoKeVo.setLicenseDtStart(merchantBaseInfo.getBussAuthStartTime());//营业执照开始时间⼩微商户可不传, 其他必传,格式yyyy-MM-dd
+ tuoKeVo.setLicenseDtEnd(merchantBaseInfo.getBussAuthEndTime());//⼩微商户可不传, 其他必传,格式yyyy-MM-dd
+ }
+ tuoKeVo.setLatitude("");//经度 进件所在地址经度
+ tuoKeVo.setLongtude("");//纬度 进件所在地址纬度
+ tuoKeVo.setSource("APP"); //进件来源 APP: app H5: h5
+ tuoKeVo.setBusinessContent(merchantBaseInfo.getMccName()); //商户经营内容
+
+ IdCard one = idCardService.getLegalIdCard(userId); //获取法人身份证信息
+ tuoKeVo.setLarName(one.getCertName());
+ tuoKeVo.setLarIdType("01");
+ tuoKeVo.setLarIdCard(one.getCertNo());
+ tuoKeVo.setLarIdCardStart(birthdayDate(one.getCertStartTime()));
+ tuoKeVo.setLarIdCardEnd(birthdayDate(one.getCertEndTime()));
+ tuoKeVo.setContactMobile(merchantBaseInfo.getContactMobile());
+ tuoKeVo.setContactName(merchantBaseInfo.getContactName());
+ QueryWrapper accountQueryWrapper1 = new QueryWrapper<>();
+ accountQueryWrapper1.eq("userId", userId);
+ accountQueryWrapper1.eq("channelType", "D1");
+ Account accountServiceOne1 = accountService.getOne(accountQueryWrapper1);
+ QueryWrapper bankCardWrapper = new QueryWrapper<>();
+ bankCardWrapper.eq("id", accountServiceOne1.getBankCardId());
+ BankCard userBrakCard = bankCardService.getOne(bankCardWrapper);
+ QueryWrapper lklEntityQueryWrapper = new QueryWrapper<>();
+ lklEntityQueryWrapper.eq("branch_bank_no", userBrakCard.getContactLine());
+ TbPlussBankBranchLklEntity lakalaBranchInfo = tbPlussBankBranchLklService.getOne(lklEntityQueryWrapper);
+ tuoKeVo.setOpenningBankCode(lakalaBranchInfo.getBranchBankNo());
+ tuoKeVo.setOpenningBankName(lakalaBranchInfo.getBranchBankName());
+ tuoKeVo.setClearingBankCode(lakalaBranchInfo.getClearNo());
+ QueryWrapper regionLklEntityQueryWrapper = new QueryWrapper<>();
+ regionLklEntityQueryWrapper.eq("code", lakalaBranchInfo.getAreaCode());
+ TbPlussBankRegionLklEntity bankParentCode = regionLklService.getOne(regionLklEntityQueryWrapper); //市code 和 name
+ regionLklEntityQueryWrapper.clear();
+ regionLklEntityQueryWrapper.eq("code", bankParentCode.getParentCode());
+ TbPlussBankRegionLklEntity parentCode = regionLklService.getOne(regionLklEntityQueryWrapper); //省code 和 名称
+ tuoKeVo.setSettleProvinceCode(parentCode.getCode());
+ tuoKeVo.setSettleProvinceName(parentCode.getName());
+ tuoKeVo.setSettleCityCode(bankParentCode.getCode());
+ tuoKeVo.setSettleCityName(bankParentCode.getName());
+ Account account = new Account().setUserId("userId").setChannelType("D1");
+
+ AccountDTO accountV4 = getAccountV4(userId, "D1"); //结算人
+
+
+ /**获取结算人**/
+
+ BankCard bankCard = accountV4.getBankCard();
+ tuoKeVo.setAccountNo(bankCard.getBankCardNo());
+ tuoKeVo.setAccountName(bankCard.getBranchName());
+ if (bankCard.getAccountType().equals("01")) {
+ tuoKeVo.setAccountType("58"); //结算账户类型 57 对公 58 对私
+ } else {
+ tuoKeVo.setAccountType("57");
+ }
+ IdCard idcard = accountV4.getIdcard();
+ tuoKeVo.setAccountIdCard(idcard.getCertNo());//结算人证件号码
+ tuoKeVo.setTermNum("1");
+ tuoKeVo.setFeeCode("SCAN_PAY_SECOND"); //费率类型 参考 附录 费率类型表
+ tuoKeVo.setFeeValue("0.038"); //费率值 百分比费率
+ MerchantBaseInfo merchantBaseInfoByUserId = baseInfoService.getMerchantBaseInfoByUserId(userId);
+
+ QueryWrapper userAppQueryWrapper = new QueryWrapper();
+ userAppQueryWrapper.eq("standard_mcc_code", merchantBaseInfoByUserId.getMcc()).eq("channel_id", "5").last("limit 1");
+ MccReflect mccReflect = service.getOne(userAppQueryWrapper);
+
+ if (null != mccReflect) {
+ tuoKeVo.setMcc("11010"); //商户MCC编号 通过 【商户类别查询→查询小类】接口获取 对应 code字段
+// tuoKeVo.setMcc(mccReflect.getMccCode()); //商户MCC编号 通过 【商户类别查询→查询小类】接口获取 对应 code字段
+ } else {
+ tuoKeVo.setMcc("18001");
+ }
+
+ tuoKeVo.setActivityId("12"); //归属活动信息 由拓客SAAS分配
+
+ Set