From ff694fb5e989cc421b44efc293092b867b8f9703 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 28 Aug 2023 16:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/TestController.java | 32 ++ .../com/cweb/notify/TianQueController.java | 184 ++++++++ .../channel/tianque/config/TianQueConfig.java | 15 + .../service/TianQueMerElecSignService.java | 82 ++++ .../tianque/service/TianQueMerService.java | 440 ++++++++++++++++++ .../channel/tianque/utils/RSASignature.java | 181 +++++++ .../channel/tianque/utils/RequestUtil.java | 74 +++ .../com/hfkj/common/utils/HttpsUtils.java | 51 ++ .../java/com/hfkj/config/CommonSysConfig.java | 23 +- .../impl/BsMerContractServiceImpl.java | 8 +- .../com/hfkj/sysenum/PlatformTypeEnum.java | 1 + .../resources/dev/commonConfig.properties | 5 + 12 files changed, 1093 insertions(+), 3 deletions(-) create mode 100644 cweb/src/main/java/com/cweb/notify/TianQueController.java create mode 100644 service/src/main/java/com/hfkj/channel/tianque/config/TianQueConfig.java create mode 100644 service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerElecSignService.java create mode 100644 service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java create mode 100644 service/src/main/java/com/hfkj/channel/tianque/utils/RSASignature.java create mode 100644 service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java index afcf44f..92a23c8 100644 --- a/cweb/src/main/java/com/cweb/controller/TestController.java +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -11,6 +11,7 @@ import com.hfkj.channel.saas.SaasActivityService; import com.hfkj.channel.saas.SaasMerService; import com.hfkj.channel.saas.utils.SaasCommon; import com.hfkj.channel.saas.utils.SaasMerRequest; +import com.hfkj.channel.tianque.service.TianQueMerService; import com.hfkj.channel.weixin.WeiXinMerService; import com.hfkj.channel.weixin.utils.WxUtils; import com.hfkj.channel.weixin.utils.sdk.WXPayConstants; @@ -244,6 +245,37 @@ public class TestController { } } + @Resource + private TianQueMerService tianQueMerService; + @RequestMapping(value="/tianQueTest",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "tianQueTest") + public ResponseData tianQueTest(@RequestParam(value = "code", required = true) String code) { + try { + // tianQueMerService.addMer(Long.parseLong(code)); + return ResponseMsgUtil.success(tianQueMerService.queryMerchantInfo(code)); + // return ResponseMsgUtil.success(laKaLaTradeService.queryTrade(code)); + // return ResponseMsgUtil.success(""); + // 1200 + // return ResponseMsgUtil.success(saasCommon.fileUpload(new HashMap<>())); + /* AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); + request.setGrantType("authorization_code"); + request.setCode(code); + AlipaySystemOauthTokenResponse response = AlipayUtils.initClient().certificateExecute(request); + if(response.isSuccess()){ + System.out.println("调用成功"); + return ResponseMsgUtil.success(response); + } else { + System.out.println("调用失败"); + return ResponseMsgUtil.success("调用失败"); + }*/ + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/saasTest",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "saasTest") diff --git a/cweb/src/main/java/com/cweb/notify/TianQueController.java b/cweb/src/main/java/com/cweb/notify/TianQueController.java new file mode 100644 index 0000000..e51f0f1 --- /dev/null +++ b/cweb/src/main/java/com/cweb/notify/TianQueController.java @@ -0,0 +1,184 @@ +package com.cweb.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.lakala.LaKaLaLedgerService; +import com.hfkj.channel.lakala.LaKaLaWalletService; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.*; +import com.hfkj.service.*; +import com.hfkj.sysenum.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedOutputStream; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +/** + * 天阙业务通知 + * @author hurui + */ +@Controller +@Api(value = "天阙通知") +@RequestMapping(value = "/tianqueNotify") +public class TianQueController { + + private static Logger log = LoggerFactory.getLogger(TianQueController.class); + + @Resource + private BsTradeOrderService tradeOrderService; + + @Resource + private BsTradeOrderMsgService tradeOrderMsgService; + @Resource + private BsMerLedgerService merLedgerService; + @Resource + private BsMerLedgerApplyService merLedgerApplyService; + @Resource + private BsMerLedgerReceiverService merLedgerReceiverService; + @Resource + private BsMerLedgerReceiverApplyService merLedgerReceiverApplyService; + @Resource + private LaKaLaLedgerService laKaLaLedgerService; + @Resource + private LaKaLaWalletService laKaLaWalletService; + + @RequestMapping(value="/microPay",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "交易【被扫】通知") + public void microPay(@RequestBody String reqBody, HttpServletResponse response) { + try { + log.info("交易【被扫】通知", reqBody); + System.out.println(reqBody); + + JSONObject body = JSONObject.parseObject(reqBody); + // 请求记录 + BsTradeOrderMsg orderMsg = new BsTradeOrderMsg(); + orderMsg.setOutTradeNo(body.getString("out_trade_no")); + orderMsg.setType(TradeOrderMsgTypeEnum.type2.getNumber()); + orderMsg.setResponseContent(reqBody); + tradeOrderMsgService.editTradeOrderMsg(orderMsg); + + // 查询订单 + BsTradeOrder order = tradeOrderService.getOrderByOutTradeNo(body.getString("out_trade_no")); + if (order != null) { + Map other = new HashMap<>(); + other.put("log_no", body.getString("log_no")); + other.put("acc_trade_no", body.getString("acc_trade_no")); + other.put("card_type", body.getString("card_type")); + + if (body.getString("acc_settle_amount") != null) { + other.put("acc_settle_amount", body.getBigDecimal("acc_settle_amount").divide(new BigDecimal("100"))); + } + if (body.getString("acc_discount_amount") != null) { + other.put("acc_discount_amount", body.getBigDecimal("acc_discount_amount").divide(new BigDecimal("100"))); + } + if (body.getString("acc_mdiscount_amount") != null) { + other.put("acc_mdiscount_amount", body.getBigDecimal("acc_mdiscount_amount").divide(new BigDecimal("100"))); + } + + tradeOrderService.paySuccess( + body.getString("out_trade_no"), + body.getString("trade_no"), + PlatformTypeEnum.type1, + TradeOrderPayModeEnum.getNameByCode(body.getString("account_type")), + body.getBigDecimal("total_amount").divide(new BigDecimal("100")), + body.getString("merchant_no"), + other + ); + +/* order.setPayMode(body.getString("account_type")); + order.setPlatformType(PlatformTypeEnum.type1.getNumber()); + order.setPlatformTradeNo(body.getString("trade_no")); + order.setPlatformLogNo(body.getString("log_no")); + order.setAccTradeNo(body.getString("acc_trade_no")); + order.setTradeActualAmount(body.getBigDecimal("payer_amount").divide(new BigDecimal("100"))); + order.setCardType(body.getString("card_type")); + order.setStatus(TradeOrderStatusEnum.status3.getNumber()); + order.setPayTime(new Date()); + if (body.getString("acc_discount_amount") != null) { + order.setAccDiscountAmount(body.getBigDecimal("acc_discount_amount").divide(new BigDecimal("100"))); + } + if (body.getString("acc_mdiscount_amount") != null) { + order.setAccMdiscountAmount(body.getBigDecimal("acc_mdiscount_amount").divide(new BigDecimal("100"))); + } + tradeOrderService.editOrder(order);*/ + } + + } catch (Exception e) { + log.error("login error!",e); + } finally { + try { + BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); + JSONObject result = new JSONObject(); + result.put("code", "SUCCESS"); + result.put("message", "执行成功"); + out.write(result.toJSONString().getBytes()); + out.flush(); + out.close(); + } catch (Exception e) { + + } + + } + } + + @RequestMapping(value="/applyLedgerMer",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "商户进件通知") + public void merInbound(@RequestBody String reqBody) { + try { + log.info("商户进件通知", reqBody); + System.out.println(reqBody); + + JSONObject respData = JSONObject.parseObject(reqBody); + + BsMerLedgerApply ledgerApply = merLedgerApplyService.getApplyByApplyId(respData.getString("applicationId")); + if (ledgerApply != null) { + ledgerApply.setNotifyBody(reqBody); + merLedgerApplyService.editMerLedgerApply(ledgerApply); + + // 查询商户分账信息 + BsMerLedger merLedger = merLedgerService.getMerLedgerById(ledgerApply.getMerLedgerId()); + if (merLedger != null) { + // 审核状态 1:通过,2拒绝 + if (respData.getString("auditStatus").equals("1")) { + merLedger.setStatus(MerLedgerStatusEnum.status1.getNumber()); + merLedgerService.editMerLedger(merLedger); + // 延迟3秒 + Thread.sleep(3000); + + // 提现通知地址 + String notifyUrl = CommonSysConst.getSysConfig().getDomainName()+"/crest/merWithdrawal/notify?cupNo="+merLedger.getCupNo(); + + // 配置账户自动结算 + laKaLaWalletService.ewalletSettleProfile(1,merLedger.getCupNo(), "02", "06", notifyUrl); + + // 配置分账接收方账户自动结算 + laKaLaWalletService.ewalletSettleProfile(2,merLedger.getReceiverNo(), "02", "06", notifyUrl); + + } else { + merLedger.setStatus(MerLedgerStatusEnum.status3.getNumber()); + merLedger.setRejectReason(respData.getString("remark")); + merLedgerService.editMerLedger(merLedger); + } + } + } + + } catch (Exception e) { + log.error("login error!",e); + } + + } + +} diff --git a/service/src/main/java/com/hfkj/channel/tianque/config/TianQueConfig.java b/service/src/main/java/com/hfkj/channel/tianque/config/TianQueConfig.java new file mode 100644 index 0000000..12448d6 --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/tianque/config/TianQueConfig.java @@ -0,0 +1,15 @@ +package com.hfkj.channel.tianque.config; + +import com.hfkj.config.CommonSysConst; + +/** + * @className: TianQueConfig + * @author: HuRui + * @date: 2023/8/23 + **/ +public class TianQueConfig { + public final static String requestUrl = CommonSysConst.getSysConfig().getTianque_request_url(); + public final static String orgId = CommonSysConst.getSysConfig().getTianque_org_id(); + public final static String priKey = CommonSysConst.getSysConfig().getTianque_private_key(); + public final static String pubKey = CommonSysConst.getSysConfig().getTianque_public_key(); +} diff --git a/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerElecSignService.java b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerElecSignService.java new file mode 100644 index 0000000..c6865ce --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerElecSignService.java @@ -0,0 +1,82 @@ +package com.hfkj.channel.tianque.service; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.tianque.config.TianQueConfig; +import com.hfkj.channel.tianque.utils.RequestUtil; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.RequestUtils; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsMerContractRecord; +import com.hfkj.entity.BsMerContractRecordMsg; +import com.hfkj.entity.BsMerPlatformNo; +import com.hfkj.entity.BsMerRate; +import com.hfkj.model.MerBasisModel; +import com.hfkj.service.BsMerContractRecordMsgService; +import com.hfkj.service.BsMerContractRecordService; +import com.hfkj.service.BsMerPlatformNoService; +import com.hfkj.service.BsMerService; +import com.hfkj.sysenum.MerSettleType; +import com.hfkj.sysenum.MerTypeEnum; +import com.hfkj.sysenum.PlatformTypeEnum; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.io.File; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 商户入网电子协议服务 + * @className: TianQueMerElecSignService + * @author: HuRui + * @date: 2023/8/28 + **/ +@Component +public class TianQueMerElecSignService { + + /** + * 签署协议 + * @param platformMerNo 平台商户号 + * @throws Exception + */ + public JSONObject openElecSignature(String platformMerNo) { + try { + Map param = new HashMap<>(); + param.put("mno", platformMerNo); + param.put("signType", "01"); // 签署方式,取值范围:00 页面签署,01 接口签署 + param.put("signIp", InetAddress.getLocalHost().getAddress()); + return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/elecSignature/openElecSignature", param); + } catch (Exception e) { + return null; + } + } + + /** + * 商户协议签署查询 + * @param platformMerNo 平台商户号 + * @throws Exception + */ + public JSONObject selectSign(String platformMerNo) { + Map param = new HashMap<>(); + param.put("mno", platformMerNo); + return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/elecSignature/selectSign", param); + } + + /** + * 商户协议下载 + * @param platformMerNo 平台商户号 + * @throws Exception + */ + public JSONObject downFile(String platformMerNo) { + Map param = new HashMap<>(); + param.put("mno", platformMerNo); + return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/elecSignature/downFile", param); + } + +} diff --git a/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java new file mode 100644 index 0000000..43ced07 --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/tianque/service/TianQueMerService.java @@ -0,0 +1,440 @@ +package com.hfkj.channel.tianque.service; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.tianque.config.TianQueConfig; +import com.hfkj.channel.tianque.utils.RequestUtil; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsMerContractRecord; +import com.hfkj.entity.BsMerContractRecordMsg; +import com.hfkj.entity.BsMerPlatformNo; +import com.hfkj.entity.BsMerRate; +import com.hfkj.model.MerBasisModel; +import com.hfkj.service.BsMerContractRecordMsgService; +import com.hfkj.service.BsMerContractRecordService; +import com.hfkj.service.BsMerPlatformNoService; +import com.hfkj.service.BsMerService; +import com.hfkj.sysenum.MerSettleType; +import com.hfkj.sysenum.MerTypeEnum; +import com.hfkj.sysenum.PlatformTypeEnum; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @className: TianQueMerService + * @author: HuRui + * @date: 2023/8/23 + **/ +@Component +public class TianQueMerService { + + @Resource + public BsMerService merService; + @Resource + private BsMerPlatformNoService merPlatformNoService; + @Resource + private BsMerContractRecordService merContractRecordService; + @Resource + private BsMerContractRecordMsgService merContractRecordMsgService; + + /** + * 商户进件 + * @param merId + * @throws Exception + */ + public void addMer(Long merId) { + MerBasisModel basisModel = merService.getMerDetail(merId); + + Map param = new HashMap<>(); + param.put("mecDisNm", basisModel.getMerAbbreviate()); + param.put("mblNo", basisModel.getRegPhone()); + param.put("operationalType", "01"); + if (basisModel.getMerType().equals(MerTypeEnum.status1.getNumber())) { + param.put("haveLicenseNo", "02"); + } else if (basisModel.getMerType().equals(MerTypeEnum.status2.getNumber())) { + param.put("haveLicenseNo", "03"); + } else if (basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("haveLicenseNo", "01"); + } + param.put("mecTypeFlag", "00"); + + param.put("cprRegAddr", basisModel.getMerRegion().getAddress()); + param.put("regProvCd", basisModel.getMerRegion().getProvinceCode() + "000000"); + param.put("regCityCd", basisModel.getMerRegion().getCityCode() + "000000"); + param.put("regDistCd", basisModel.getMerRegion().getAreaCode() + "000000"); + param.put("mccCd", basisModel.getMerMccCode()); + param.put("csTelNo", basisModel.getStoreModel().getTelephone()); + + /********* 功能类信息 ***********/ + List> qrcodeList = new ArrayList<>(); + Map qrcode; + for (BsMerRate merRate : basisModel.getMerSettleAcct().getMerRateList()) { + qrcode = new HashMap<>(); + + // 微信 + if (merRate.getRateTypeCode().equals(302)) { + qrcode.put("rateType", "01"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 支付宝 + } else if (merRate.getRateTypeCode().equals(303)) { + qrcode.put("rateType", "02"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付借记卡小于1000 + } else if (merRate.getRateTypeCode().equals(411)) { + qrcode.put("rateType", "061"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付借记卡大于1000 + } else if (merRate.getRateTypeCode().equals(315)) { + qrcode.put("rateType", "071"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + qrcode = new HashMap<>(); + qrcode.put("rateType", "072"); + qrcode.put("rate", "20"); + qrcodeList.add(qrcode); + + // 云闪付贷记卡小于1000 + } else if (merRate.getRateTypeCode().equals(412)) { + qrcode.put("rateType", "06"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付贷记卡大于1000 + } else if (merRate.getRateTypeCode().equals(314)) { + qrcode.put("rateType", "07"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + } + } + param.put("qrcodeList", qrcodeList); + param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/crest/tianqueNotify/applyLedgerMer"); + /********* 功能类信息 ***********/ + + /********* 资质证照信息 ***********/ + if (!basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("cprRegNmCn", basisModel.getBlisName()); + param.put("registCode", basisModel.getBlisNo()); + param.put("licenseMatch", "00"); + param.put("businessLicStt", basisModel.getBlisPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getBlisPeriodType().equals(2)) { + param.put("businessLicEnt", "29991231"); + } else { + param.put("businessLicEnt", basisModel.getBlisPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + } + + param.put("identityName", basisModel.getLarName()); + param.put("identityTyp", "00"); + param.put("identityNo", basisModel.getLarIdCard()); + param.put("legalPersonLicStt", basisModel.getLarIdCardPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getLarIdCardPeriodType().equals(2)) { + param.put("businessLicStt", "29991231"); + } else { + param.put("legalPersonLicEnt", basisModel.getLarIdCardPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + /********* 资质证照信息 ***********/ + + + /********* 结算信息 ***********/ + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("actNm", basisModel.getBlisName()); + } else { + param.put("actNm", basisModel.getMerSettleAcct().getBankCardHolder()); + } + param.put("actTyp",basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())?"00":"01"); + param.put("actNoType", "00"); + param.put("stmManIdNo", basisModel.getMerSettleAcct().getSettleIdCardNo()); + param.put("accountLicStt", basisModel.getMerSettleAcct().getSettleIdCardPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getMerSettleAcct().getSettleIdPeriodType().equals(2)) { + param.put("accountLicEnt", "29991231"); + } else { + param.put("accountLicEnt", basisModel.getMerSettleAcct().getSettleIdCardPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + param.put("actNo", basisModel.getMerSettleAcct().getBankCardNo()); + param.put("lbnkNo", basisModel.getMerSettleAcct().getOpenningBankCode()); + /********* 结算信息 ***********/ + + /********* 图片信息 ***********/ + param.put("legalPersonidPositivePic", RequestUtil.requestUpload("02", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getLarIdCardPortraitImg())).getString("PhotoUrl")); + param.put("legalPersonidOppositePic", RequestUtil.requestUpload("03", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getLarIdCardNationalEmblemImg())).getString("PhotoUrl")); + param.put("storePic", RequestUtil.requestUpload("10", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getStoreModel().getDoorHeadImg())).getString("PhotoUrl")); + param.put("insideScenePic", RequestUtil.requestUpload("11", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getStoreModel().getInternalImg())).getString("PhotoUrl")); + + if (!basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("licensePic", RequestUtil.requestUpload("13", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getBlisUrl())).getString("PhotoUrl")); + } + + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("openingAccountLicensePic", RequestUtil.requestUpload("65", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getOpenningBankLicenseUrl())).getString("PhotoUrl")); + } + if (!basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("settlePersonIdcardPositive", RequestUtil.requestUpload("08", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getSettleIdCardPortraitImg())).getString("PhotoUrl")); + param.put("settlePersonIdcardOpposite", RequestUtil.requestUpload("07", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getSettleIdCardNationalEmblemImg())).getString("PhotoUrl")); + param.put("bankCardPositivePic", RequestUtil.requestUpload("05", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getBankCardImg())).getString("PhotoUrl")); + } + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status3.getNumber())) { + param.put("letterOfAuthPic", RequestUtil.requestUpload("26", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getCommissionImg())).getString("PhotoUrl")); + } + /********* 图片信息 ***********/ + + JSONObject response = RequestUtil.request(TianQueConfig.requestUrl + "/merchant/income", param); + if (!"0000".equals(response.getString("bizCode"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("bizMsg")); + } + response.getString("mno"); + response.getString("applicationId"); + + BsMerPlatformNo platform = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type5); + if (platform != null) { + platform.setStatus(0); + merPlatformNoService.editMerPlatformNo(platform); + } + + platform = new BsMerPlatformNo(); + platform.setCompanyId(basisModel.getCompanyId()); + platform.setAgentId(basisModel.getAgentId()); + platform.setMerId(basisModel.getId()); + platform.setMerNo(basisModel.getMerNo()); + platform.setPlatformType(PlatformTypeEnum.type5.getNumber()); + platform.setPlatformNo(response.getString("mno")); + merPlatformNoService.editMerPlatformNo(platform); + + // 增加进件记录 + BsMerContractRecord record = new BsMerContractRecord(); + record.setMerId(merId); + record.setPlatformType(PlatformTypeEnum.type5.getNumber()); + record.setOrderNo(response.getString("applicationId")); + record.setContractId(response.toJSONString()); + record.setStatus(1); + merContractRecordService.insertRecord(record); + + // 增加进件记录消息 + BsMerContractRecordMsg recordMsg = new BsMerContractRecordMsg(); + recordMsg.setOrderNo(record.getOrderNo()); + recordMsg.setType(1); + recordMsg.setRequestContent(JSONObject.toJSONString(param)); + recordMsg.setResponseMsg(null); + recordMsg.setResponseContent(response.toJSONString()); + merContractRecordMsgService.insertRecordMsg(recordMsg); + + } + + /** + * 商户进件修改 + * 注:商户入驻修改接口应用于入驻审核未通过的情况。 + * @param merId + * @throws Exception + */ + public void updateMerchantInfo(Long merId) { + MerBasisModel basisModel = merService.getMerDetail(merId); + + Map param = new HashMap<>(); + param.put("mecDisNm", basisModel.getMerAbbreviate()); + param.put("mblNo", basisModel.getRegPhone()); + param.put("operationalType", "01"); + if (basisModel.getMerType().equals(MerTypeEnum.status1.getNumber())) { + param.put("haveLicenseNo", "02"); + } else if (basisModel.getMerType().equals(MerTypeEnum.status2.getNumber())) { + param.put("haveLicenseNo", "03"); + } else if (basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("haveLicenseNo", "01"); + } + param.put("mecTypeFlag", "00"); + + param.put("cprRegAddr", basisModel.getMerRegion().getAddress()); + param.put("regProvCd", basisModel.getMerRegion().getProvinceCode() + "000000"); + param.put("regCityCd", basisModel.getMerRegion().getCityCode() + "000000"); + param.put("regDistCd", basisModel.getMerRegion().getAreaCode() + "000000"); + param.put("mccCd", basisModel.getMerMccCode()); + param.put("csTelNo", basisModel.getStoreModel().getTelephone()); + + /********* 功能类信息 ***********/ + List> qrcodeList = new ArrayList<>(); + Map qrcode; + for (BsMerRate merRate : basisModel.getMerSettleAcct().getMerRateList()) { + qrcode = new HashMap<>(); + + // 微信 + if (merRate.getRateTypeCode().equals(302)) { + qrcode.put("rateType", "01"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 支付宝 + } else if (merRate.getRateTypeCode().equals(303)) { + qrcode.put("rateType", "02"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付借记卡小于1000 + } else if (merRate.getRateTypeCode().equals(411)) { + qrcode.put("rateType", "061"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付借记卡大于1000 + } else if (merRate.getRateTypeCode().equals(315)) { + qrcode.put("rateType", "071"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + qrcode = new HashMap<>(); + qrcode.put("rateType", "072"); + qrcode.put("rate", "20"); + qrcodeList.add(qrcode); + + // 云闪付贷记卡小于1000 + } else if (merRate.getRateTypeCode().equals(412)) { + qrcode.put("rateType", "06"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + + // 云闪付贷记卡大于1000 + } else if (merRate.getRateTypeCode().equals(314)) { + qrcode.put("rateType", "07"); + qrcode.put("rate", merRate.getRatePct()+""); + qrcodeList.add(qrcode); + } + } + param.put("qrcodeList", qrcodeList); + param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/crest/tianqueNotify"); + /********* 功能类信息 ***********/ + + /********* 资质证照信息 ***********/ + if (!basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("cprRegNmCn", basisModel.getBlisName()); + param.put("registCode", basisModel.getBlisNo()); + param.put("licenseMatch", "00"); + param.put("businessLicStt", basisModel.getBlisPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getBlisPeriodType().equals(2)) { + param.put("businessLicEnt", "29991231"); + } else { + param.put("businessLicEnt", basisModel.getBlisPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + } + + param.put("identityName", basisModel.getLarName()); + param.put("identityTyp", "00"); + param.put("identityNo", basisModel.getLarIdCard()); + param.put("legalPersonLicStt", basisModel.getLarIdCardPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getLarIdCardPeriodType().equals(2)) { + param.put("businessLicStt", "29991231"); + } else { + param.put("legalPersonLicEnt", basisModel.getLarIdCardPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + /********* 资质证照信息 ***********/ + + + /********* 结算信息 ***********/ + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("actNm", basisModel.getBlisName()); + } else { + param.put("actNm", basisModel.getMerSettleAcct().getBankCardHolder()); + } + param.put("actTyp",basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())?"00":"01"); + param.put("actNoType", "00"); + param.put("stmManIdNo", basisModel.getMerSettleAcct().getSettleIdCardNo()); + param.put("accountLicStt", basisModel.getMerSettleAcct().getSettleIdCardPeriodStart().replace(".", "").replace("年","").replace("月","").replace("日","")); + if (basisModel.getMerSettleAcct().getSettleIdPeriodType().equals(2)) { + param.put("accountLicEnt", "29991231"); + } else { + param.put("accountLicEnt", basisModel.getMerSettleAcct().getSettleIdCardPeriodEnd().replace(".", "").replace("年","").replace("月","").replace("日","")); + } + param.put("actNo", basisModel.getMerSettleAcct().getBankCardNo()); + param.put("lbnkNo", basisModel.getMerSettleAcct().getOpenningBankCode()); + /********* 结算信息 ***********/ + + /********* 图片信息 ***********/ + param.put("legalPersonidPositivePic", RequestUtil.requestUpload("02", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getLarIdCardPortraitImg())).getString("PhotoUrl")); + param.put("legalPersonidOppositePic", RequestUtil.requestUpload("03", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getLarIdCardNationalEmblemImg())).getString("PhotoUrl")); + param.put("storePic", RequestUtil.requestUpload("10", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getStoreModel().getDoorHeadImg())).getString("PhotoUrl")); + param.put("insideScenePic", RequestUtil.requestUpload("11", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getStoreModel().getInternalImg())).getString("PhotoUrl")); + + if (!basisModel.getMerType().equals(MerTypeEnum.status3.getNumber())) { + param.put("licensePic", RequestUtil.requestUpload("13", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getBlisUrl())).getString("PhotoUrl")); + } + + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("openingAccountLicensePic", RequestUtil.requestUpload("65", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getOpenningBankLicenseUrl())).getString("PhotoUrl")); + } + if (!basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status1.getNumber())) { + param.put("settlePersonIdcardPositive", RequestUtil.requestUpload("08", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getSettleIdCardPortraitImg())).getString("PhotoUrl")); + param.put("settlePersonIdcardOpposite", RequestUtil.requestUpload("07", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getSettleIdCardNationalEmblemImg())).getString("PhotoUrl")); + param.put("bankCardPositivePic", RequestUtil.requestUpload("05", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getBankCardImg())).getString("PhotoUrl")); + } + if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status3.getNumber())) { + param.put("letterOfAuthPic", RequestUtil.requestUpload("26", new File(CommonSysConst.getSysConfig().getFile_url() + "/" + basisModel.getMerSettleAcct().getCommissionImg())).getString("PhotoUrl")); + } + /********* 图片信息 ***********/ + + JSONObject response = RequestUtil.request(TianQueConfig.requestUrl + "/merchant/income", param); + if (!"0000".equals(response.getString("bizCode"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("bizMsg")); + } + response.getString("mno"); + response.getString("applicationId"); + + BsMerPlatformNo platform = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type5); + if (platform != null) { + platform.setStatus(0); + merPlatformNoService.editMerPlatformNo(platform); + } + + platform = new BsMerPlatformNo(); + platform.setCompanyId(basisModel.getCompanyId()); + platform.setAgentId(basisModel.getAgentId()); + platform.setMerId(basisModel.getId()); + platform.setMerNo(basisModel.getMerNo()); + platform.setPlatformType(PlatformTypeEnum.type5.getNumber()); + platform.setPlatformNo(response.getString("mno")); + merPlatformNoService.editMerPlatformNo(platform); + + // 增加进件记录 + BsMerContractRecord record = new BsMerContractRecord(); + record.setMerId(merId); + record.setPlatformType(PlatformTypeEnum.type5.getNumber()); + record.setOrderNo(response.getString("applicationId")); + record.setContractId(response.toJSONString()); + record.setStatus(1); + merContractRecordService.insertRecord(record); + + // 增加进件记录消息 + BsMerContractRecordMsg recordMsg = new BsMerContractRecordMsg(); + recordMsg.setOrderNo(record.getOrderNo()); + recordMsg.setType(1); + recordMsg.setRequestContent(JSONObject.toJSONString(param)); + recordMsg.setResponseMsg(null); + recordMsg.setResponseContent(response.toJSONString()); + merContractRecordMsgService.insertRecordMsg(recordMsg); + + } + + /** + * 商户进件结果 + * @param applicationId 进件申请ID + * @throws Exception + */ + public JSONObject queryMerchantInfo(String applicationId) { + Map param = new HashMap<>(); + // param.put("applicationId", "4149b8c5dafe4d15a3dd24df5cf9621d"); + param.put("applicationId", applicationId); + return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/queryMerchantInfo", param); + } + + +} diff --git a/service/src/main/java/com/hfkj/channel/tianque/utils/RSASignature.java b/service/src/main/java/com/hfkj/channel/tianque/utils/RSASignature.java new file mode 100644 index 0000000..0468810 --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/tianque/utils/RSASignature.java @@ -0,0 +1,181 @@ +package com.hfkj.channel.tianque.utils; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.tianque.config.TianQueConfig; + +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.*; + +/** + * RSA签名验签类 + */ +public class RSASignature { + + /** + * 签名算法 + */ + public static final String SIGN_ALGORITHMS = "SHA1WithRSA"; + + /** + * 针对参数进行排序拼装 + * @param requestParam + * @return + */ + public static String getContent(Map requestParam) { + Map sortedParams = new TreeMap(); + if ((requestParam != null) && (requestParam.size() > 0)) { + sortedParams.putAll(requestParam); + } + StringBuffer content = new StringBuffer(); + List keys = new ArrayList(sortedParams.keySet()); + Collections.sort(keys); + int index = 0; + for (int i = 0; i < keys.size(); i++) { + String key = keys.get(i); + Object value = sortedParams.get(key); + if (key!=null &&!"".equals(key)&& value != null) { + content.append((index == 0 ? "" : "&") + key + "=" + value); + index++; + } + } + return content.toString(); + } + + /** + * rsa 签名 + * @param content 待签名内容 + * @param privateKey 私钥 + * @return + */ + public static byte[] sign(String content, String privateKey) { + try { + PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(decryptBASE64(privateKey)); + KeyFactory keyf = KeyFactory.getInstance("RSA"); + PrivateKey priKey = keyf.generatePrivate(priPKCS8); + java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS); + signature.initSign(priKey); + signature.update(content.getBytes("UTF-8")); + byte[] signed = signature.sign(); + return signed; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * RSA验签名检查 + * @param content 待签名数据 + * @param sign 签名值 + * @param publicKey 分配给开发商公钥 + * @return 布尔值 + */ + public static boolean doCheck(String content, String sign, String publicKey) { + try { + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + byte[] encodedKey = decryptBASE64(publicKey); + PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey)); + + + java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS); + + signature.initVerify(pubKey); + signature.update(content.getBytes("UTF-8")); + + boolean bverify = signature.verify(decryptBASE64(sign)); + return bverify; + + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public static String encryptBASE64(byte[] key) { + String base64encodedString = Base64.getEncoder().encodeToString(key); + return base64encodedString.replaceAll("[\\s*\t\n\r]", ""); + } + public static byte[] decryptBASE64(String key) { + byte[] base64decodedBytes = Base64.getDecoder().decode(key.replaceAll("[\\s*\t\n\r]", "")); + return base64decodedBytes; + } + + + public static void main(String[] args) { + String paramStr = "{\n" + + "\t\"orgId\": \"00205462\",\n" + + "\t\"reqData\": {\n" + + "\t\t\"cprRegAddr\": \"贵州省贵阳市观山湖区观山西路与诚信南路交叉市科技馆主楼第一层1号\",\n" + + "\t\t\"businessLicStt\": \"20210617\",\n" + + "\t\t\"operationalType\": \"01\",\n" + + "\t\t\"settlePersonIdcardOpposite\": \"deb136972d01478ca322508edcb5b607\",\n" + + "\t\t\"letterOfAuthPic\": \"9d6c22c4449746c0a97b0f599bfb449f\",\n" + + "\t\t\"insideScenePic\": \"8661acbd30504501bf219ac385531e1a\",\n" + + "\t\t\"businessLicEnt\": \"29991231\",\n" + + "\t\t\"identityNo\": \"511303200001121959\",\n" + + "\t\t\"licenseMatch\": \"00\",\n" + + "\t\t\"haveLicenseNo\": \"02\",\n" + + "\t\t\"legalPersonidOppositePic\": \"ce26a46dbf5c43f98cfcf0cf548555ea\",\n" + + "\t\t\"cprRegNmCn\": \"贵州拾贰季企业管理咨询有限公司\",\n" + + "\t\t\"mccCd\": \"5812\",\n" + + "\t\t\"regDistCd\": \"520111000000\",\n" + + "\t\t\"identityName\": \"胡锐\",\n" + + "\t\t\"regCityCd\": \"520100000000\",\n" + + "\t\t\"mecTypeFlag\": \"00\",\n" + + "\t\t\"licensePic\": \"43250a93a3fe4c9e80a172d208a2b5d9\",\n" + + "\t\t\"legalPersonLicEnt\": \"20290823\",\n" + + "\t\t\"qrcodeList\": [{\n" + + "\t\t\t\"rateType\": \"061\",\n" + + "\t\t\t\"rate\": \"0.30\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"01\",\n" + + "\t\t\t\"rate\": \"0.30\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"06\",\n" + + "\t\t\t\"rate\": \"0.30\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"02\",\n" + + "\t\t\t\"rate\": \"0.30\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"07\",\n" + + "\t\t\t\"rate\": \"0.54\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"071\",\n" + + "\t\t\t\"rate\": \"0.45\"\n" + + "\t\t}, {\n" + + "\t\t\t\"rateType\": \"072\",\n" + + "\t\t\t\"rate\": \"0.45\"\n" + + "\t\t}],\n" + + "\t\t\"legalPersonidPositivePic\": \"4afe2a2d2763465c9f792f97668ee170\",\n" + + "\t\t\"regProvCd\": \"520000000000\",\n" + + "\t\t\"legalPersonLicStt\": \"20190823\",\n" + + "\t\t\"accountLicEnt\": \"20380706\",\n" + + "\t\t\"storePic\": \"7c814e656ff04ad7b2814007d7de18a6\",\n" + + "\t\t\"identityTyp\": \"00\",\n" + + "\t\t\"actNm\": \"尹永喜\",\n" + + "\t\t\"mecDisNm\": \"测试商户\",\n" + + "\t\t\"mblNo\": \"15583658692\",\n" + + "\t\t\"actTyp\": \"01\",\n" + + "\t\t\"actNo\": \"6210813520003655795\",\n" + + "\t\t\"lbnkNo\": \"102701007053\",\n" + + "\t\t\"registCode\": \"91520115MAALPPMM90\",\n" + + "\t\t\"accountLicStt\": \"20180706\",\n" + + "\t\t\"settlePersonIdcardPositive\": \"f999d38a95ee4115b9d82c1d82365dd7\",\n" + + "\t\t\"csTelNo\": \"15583658692\",\n" + + "\t\t\"bankCardPositivePic\": \"976899f062904c82b52a7161574b0b8b\",\n" + + "\t\t\"stmManIdNo\": \"150221198809057119\",\n" + + "\t\t\"actNoType\": \"00\"\n" + + "\t},\n" + + "\t\"reqId\": \"202392942026175103\",\n" + + "\t\"signType\": \"RSA\",\n" + + "\t\"timestamp\": \"20230825134026\",\n" + + "\t\"version\": \"1.0\"\n" + + "}"; + System.out.println(RSASignature.encryptBASE64(RSASignature.sign(RSASignature.getContent(JSONObject.parseObject(paramStr, Map.class)), TianQueConfig.priKey))); + } + +} diff --git a/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java b/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java new file mode 100644 index 0000000..3f80f1b --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/tianque/utils/RequestUtil.java @@ -0,0 +1,74 @@ +package com.hfkj.channel.tianque.utils; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.tianque.config.TianQueConfig; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.common.utils.IdentifyUtil; + +import java.io.File; +import java.util.*; + +/** + * @className: RequestUtil + * @author: HuRui + * @date: 2023/8/23 + **/ +public class RequestUtil { + + /** + * 请求 + * @param reqData + * @return + */ + public static JSONObject request(String url,Map reqData) { + Map header = new HashMap<>(); + header.put("Content-Type", "application/json"); + + TreeMap treeMap = new TreeMap(); + treeMap.putAll(reqData); + + Map param = new LinkedHashMap<>(); + param.put("orgId", TianQueConfig.orgId); + param.put("reqData", JSONObject.toJSON(reqData)); + param.put("reqId", IdentifyUtil.getGuid()); + param.put("signType", "RSA"); + param.put("timestamp", DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); + param.put("version", "1.0"); + param.put("sign", RSASignature.encryptBASE64(RSASignature.sign(RSASignature.getContent(param), TianQueConfig.priKey))); + + JSONObject response = HttpsUtils.doPost(url, param, header); + System.out.println("请求参数:" + JSONObject.toJSONString(param)); + System.out.println("响应参数:" + response); + if (response != null && !"0000".equals(response.getString("code"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("msg")); + } + // 验证签名 + String resSign = response.getString("sign"); + response.remove("sign"); + if (!RSASignature.doCheck(RSASignature.getContent(JSONObject.toJavaObject(response, Map.class)), resSign, TianQueConfig.pubKey)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "响应参数签名失败"); + } + return response.getJSONObject("respData"); + } + + /** + * 文件上传请求 + * @param file + * @return + */ + public static JSONObject requestUpload(String pictureType,File file) { + Map param = new HashMap<>(); + param.put("orgId", TianQueConfig.orgId); + param.put("reqId", IdentifyUtil.Guid); + param.put("pictureType", pictureType); + JSONObject response = HttpsUtils.doPostUpload(TianQueConfig.requestUrl + "/merchant/uploadPicture", file, param); + if (response != null && !"0000".equals(response.getString("code"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("msg")); + } + return response.getJSONObject("respData"); + } +} diff --git a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java index a6e4956..043343b 100644 --- a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java @@ -768,6 +768,57 @@ public class HttpsUtils { return null; } + public static JSONObject doPostUpload(String apiUrl, File file, Map params) { + CloseableHttpClient httpClient = null; + if (apiUrl.startsWith("https")) { + httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) + .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); + } else { + httpClient = HttpClients.createDefault(); + } + + StringBuffer param = new StringBuffer(); + int i = 0; + for (String key : params.keySet()) { + if (i == 0) + param.append("?"); + else + param.append("&"); + param.append(key).append("=").append(params.get(key)); + i++; + } + + String httpStr = null; + CloseableHttpResponse response = null; + + try { + apiUrl += param; + HttpPost httpPost = new HttpPost(apiUrl); + httpPost.setConfig(requestConfig); + + MultipartEntity entity = new MultipartEntity(); + entity.addPart("file", new FileBody(file)); + + httpPost.setEntity(entity); + response = httpClient.execute(httpPost); + HttpEntity responseEntity = response.getEntity(); + httpStr = EntityUtils.toString(responseEntity, "UTF-8"); + return JSON.parseObject(httpStr); + } catch (Exception e) { + log.error(e.getMessage(),e); + } finally { + if (response != null) { + try { + EntityUtils.consume(response.getEntity()); + } catch (IOException e) { + log.error(e.getMessage(),e); + } + } + } + return null; + } + + /** * Saas 请求 * @param url diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index bab1cba..5d562dc 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -85,11 +85,10 @@ public class CommonSysConfig { private String lkl_mer_contract_ret_url; /** - * 拉卡拉交易【被扫】回调地址 + * 拉卡拉SAAS请求地址、秘钥 */ private String lkl_micro_pay_ret_url; private String lkl_open_api_pay_notify_url; - private String lkl_saas_client_id; private String lkl_saas_client_secret; private String lkl_saas_activity_id; @@ -103,6 +102,26 @@ public class CommonSysConfig { private String lkl_saas_public_key; private String lkl_saas_private_key; + /** + * 【随行付】天阙请求地址 + */ + private String tianque_request_url; + + /** + * 【随行付】天阙请求机构编号 + */ + private String tianque_org_id; + + /** + * 【随行付】天阙请求私钥 + */ + private String tianque_private_key; + + /** + * 【随行付】天阙请求公钥 + */ + private String tianque_public_key; + /** * 域名 */ diff --git a/service/src/main/java/com/hfkj/service/impl/BsMerContractServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsMerContractServiceImpl.java index 3a5f768..1dbc0ce 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsMerContractServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsMerContractServiceImpl.java @@ -1,6 +1,7 @@ package com.hfkj.service.impl; import com.hfkj.channel.saas.SaasMerService; +import com.hfkj.channel.tianque.service.TianQueMerService; import com.hfkj.channel.weixin.WeiXinMerService; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; @@ -25,6 +26,9 @@ public class BsMerContractServiceImpl implements BsMerContractService { @Resource private WeiXinMerService weiXinMerService; + @Resource + private TianQueMerService tianQueMerService; + @Resource private BsMerService merService; @@ -52,8 +56,10 @@ public class BsMerContractServiceImpl implements BsMerContractService { } else if (platform.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { weiXinMerService.addMer(merId); - } + } else if (platform.getPlatformType().equals(PlatformTypeEnum.type5.getNumber())) { + tianQueMerService.addMer(merId); + } } @Override diff --git a/service/src/main/java/com/hfkj/sysenum/PlatformTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/PlatformTypeEnum.java index a81f954..f7b4567 100644 --- a/service/src/main/java/com/hfkj/sysenum/PlatformTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/PlatformTypeEnum.java @@ -12,6 +12,7 @@ public enum PlatformTypeEnum { type2(2, "国通"), type3(3, "建行"), type4(4, "微信"), + type5(5, "随行付"), ; diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index 7d1930b..43b118f 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -47,6 +47,11 @@ lkl_saas_private_key="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKnlpXdmJc # lkl_saas_public_key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDAUkzRA+4GOS5OzYqxD/UJwM6p9to1dPvetL/7RbMa93o46qToPlPtaW61EvblOldHcBEHo7AGXXKmIYr7t2Up1PZC0g7UMpno/b5WkT6ieJ601Xreuj8hhyf2/xoej5vpi4/+lAr9YF+5GcyaVf4gfzTNJrmKj9PfvX5B3rUH2QIDAQAB # lkl_saas_private_key=MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMBSTNED7gY5Lk7NirEP9QnAzqn22jV0+960v/tFsxr3ejjqpOg+U+1pbrUS9uU6V0dwEQejsAZdcqYhivu3ZSnU9kLSDtQymej9vlaRPqJ4nrTVet66PyGHJ/b/Gh6Pm+mLj/6UCv1gX7kZzJpV/iB/NM0muYqP09+9fkHetQfZAgMBAAECgYB42D3kaC+8QVnTsluffoNeKYSyT6Y1SNiqy7CGVvl/zFlEQkx0khVybHlf1hbFWq9U+Bn7TuNgXH+Z3CHUoRwy4Ap/kMx637iRatoC8F/kcPaiB7JFQfdrxhgK858dSyHCQ2OXXQDJgJdth+oF9FylVsrDu5Sw3ha4OuzrmufuwQJBAPnPPSeFr1wu7kH6I+A5E49fMbAm7EU+3TYVzxNH1lr3X/LWuK9pi/LVPrSR4eNgAypyQWREIqdpBIiJ9bOnwa0CQQDFFl0zTQTVTWf5r/hwgCUMo4gHr2y/q7XMNe6n5fh4SQuQ+o4gW+BGHzDrT97G5hFGPL+w5niGuEBHWSo5/9xdAkEAnrxdM7vzDjSUGUCFg3lBQJ1QyYoyIF4t2qxJBQtk3jDKu1hNysjasNdoHP2F+CGOYW5wtvHEw3Qr+UcQ5bP3kQJABPAcga6KUnXQBxd7mAX956UpQVgJ13uL4IPxaM+APDNIUOeWLAVhRyB870hfAoi9Ig9fliUQG//9zEvVnQJmGQJBAOb8Z0mGMEbEeAyEKjqoNiQkkIcoBdmPKNFUoUJ6ohcBNOoMfklvNsf2+BPfuhs26tvhYDBRgCAfOVhqTQcGj6I= +# TianQue config +tianque_request_url=https://openapi-test.tianquetech.com +tianque_org_id=00205462 +tianque_private_key=MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD7amtTqsq2cKBv5YpAL49dEXyx76LB2c6G9tGPfOVBk5skOxmII1bFIvUyrQsmLtM+sRg0tzi6EXBu40YW7scTKqe6UA1XHSVYHvooDL1P6E3luJu0eNh7x2yiS8vqq4v8xceRVjXBf1aBe/bPuEqG3W1v76Gw8PqNn+QUeLQrv6QCYBJC5I3Vg2AHrN4udFKnzvIZjV92gx/D9FWTpwU338I1Mw5twRbCCu8f91kmRsOa9atWbN3kM/fZI+uzaEFf9soolKNfhlP7Qhbm0/e6sciv6UDHgpSuXNl/uCYDxZ9YsSyUTJR0Ep+M7l8b4AITFjyE26jqSkUYHcGBRy5ZAgMBAAECggEAfCMMgVA4LSKpJPbab1zMVbC3uAfRfhO0NNGToVySufFOzfHcZmrEgiwDk5T7h0vhg/ffMtAw0zafJDFVvycA5obOMGEsZRIACWWqMLIxm03hgIbJYq+0fFF4Yx43vlQbl6B0LF+7xSHBrcdukxu0uKiGS5mvZXVm0RzcefsrQtmvcGFMcAAeC34aBMOnA/rfSGU82aKoy5A4WcAUSU8r6fOwQMV3aUsyI1z3QbG0RJeE1qPNAs/cVjSVlepLo0BgmePl4DDmBP21AOxnoE70XbVJdFEYGjiF/A1bZID5DEo0rqnvWCUQdWaBUT1QwDFoMITv7CgsaQyG1rlKewaJ/QKBgQD/y7qCsQjpKLHR8Y1tTIDOPedaJTaysWVadTxaVAtjlWnik1V5q+VHtOYN/14p7X587CtTD5MiN6PHRjAWTPHIr8Y87Z2ipqljscDkZb5sOsN3RzriZERLg8bcB6GRlcHkeNUNGLpBPTObIvpWTLvL+mnt4cTF/1ck2li/fX/fywKBgQD7ncutu6QK7FAlkGjX3cBSTT76sBOJYZe7LmvsJJBM+7nmly3/WO1OF/dAFrWqTXjP6PTtCPQ1+z2/kNtgJLJMJVPYeTZauq9OfT+4Ls1318vEr9KXSm/E3rTZLmpxSzgKEzDoYVeyrPh0QdaWvaP5k3BUGl3Scd5cHJKsxshd6wKBgAq+wyH0T9yDghzAmeFKgmqnfQ1zXL3a59gJ7rQYrbXMM/t5lvCagPInLjbOUGVQfay/uv4tPFAGqFGZqDF3n/x/LcOnc6S+fYUblW/CumIPgeCD1HxoG9pUOclKZMYZ1WBElyaKsGBHMuDEcmGnrYffCA4fGsX6eO2qYmoA2ptLAoGBALpQTdGHcCDmezJVjEzL1u0aZdgbKVxA96mS5jclm/RlMXKd32GE57M768l5B2vjkeHiDfq29p5CO6buDINUqPHZcgyJNMZaFhV4iQZJIbvr/ubVioqcg8azYhavWAIsQIK1UzG/YsDbc94iIlPceN8FXdfo7jA2QQDT54goaZWhAoGAQPk/qXBTzJzE6yeDVSC6edYzrVMRTqqNR70HgSY+7GqDsNWb+9otKUkyhCSDOMT8GOFQzNqPRgPBC9LD/Jf8owPExjdl3x/lmmnnc+WeaYyPYpbRuaz1eMmsCLXBMcPmLgj+xOp7J/xtLFGXTfIk7ozRDGJ2BFUJvBOUFLSSNeY= +tianque_public_key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCOmsrFtFPTnEzfpJ/hDl5RODBxw4i9Ex3NmmG/N7A1+by032zZZgLLpdNh8y5otjFY0E37Nyr4FGKFRSSuDiTk8vfx3pv6ImS1Rxjjg4qdVHIfqhCeB0Z2ZPuBD3Gbj8hHFEtXZq8+msAFu/5ZQjiVhgs5WWBjh54LYWSum+d9+wIDAQAB wechat_pay_notify_url=https://gratia-pay.dctpay.com/crest/weiXinNotify/jsapiPay