parent
1709249a6a
commit
ff694fb5e9
@ -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<String,Object> 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); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -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(); |
||||
} |
@ -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<String,Object> 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<String,Object> 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<String,Object> param = new HashMap<>(); |
||||
param.put("mno", platformMerNo); |
||||
return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/elecSignature/downFile", param); |
||||
} |
||||
|
||||
} |
@ -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<String,Object> 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<Map<String,Object>> qrcodeList = new ArrayList<>(); |
||||
Map<String,Object> 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<String,Object> 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<Map<String,Object>> qrcodeList = new ArrayList<>(); |
||||
Map<String,Object> 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<String,Object> param = new HashMap<>(); |
||||
// param.put("applicationId", "4149b8c5dafe4d15a3dd24df5cf9621d");
|
||||
param.put("applicationId", applicationId); |
||||
return RequestUtil.request(TianQueConfig.requestUrl + "/merchant/queryMerchantInfo", param); |
||||
} |
||||
|
||||
|
||||
} |
@ -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<String, Object> requestParam) { |
||||
Map<String, Object> sortedParams = new TreeMap<String, Object>(); |
||||
if ((requestParam != null) && (requestParam.size() > 0)) { |
||||
sortedParams.putAll(requestParam); |
||||
} |
||||
StringBuffer content = new StringBuffer(); |
||||
List<String> keys = new ArrayList<String>(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))); |
||||
} |
||||
|
||||
} |
@ -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<String,Object> reqData) { |
||||
Map<String,Object> header = new HashMap<>(); |
||||
header.put("Content-Type", "application/json"); |
||||
|
||||
TreeMap<String,Object> treeMap = new TreeMap(); |
||||
treeMap.putAll(reqData); |
||||
|
||||
Map<String,Object> 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<String,Object> 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"); |
||||
} |
||||
} |
Loading…
Reference in new issue