|
|
|
@ -282,67 +282,130 @@ public class SaasMerService { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject updateSettleApply(Long applyId) { |
|
|
|
|
try { |
|
|
|
|
// 结算申请
|
|
|
|
|
BsMerSettleAcctApply merSettleAcctApply = merSettleAcctApplyService.getApplyById(applyId); |
|
|
|
|
if (merSettleAcctApply == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的结算申请"); |
|
|
|
|
} |
|
|
|
|
// 平台商户
|
|
|
|
|
BsMerPlatformNo merPlatformNo = merPlatformNoService.getPlatformNo(merSettleAcctApply.getMerId(), PlatformTypeEnum.type1); |
|
|
|
|
if (merPlatformNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到平台商户号"); |
|
|
|
|
} |
|
|
|
|
// 结算申请
|
|
|
|
|
BsMerSettleAcctApply merSettleAcctApply = merSettleAcctApplyService.getApplyById(applyId); |
|
|
|
|
if (merSettleAcctApply == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的结算申请"); |
|
|
|
|
} |
|
|
|
|
// 平台商户
|
|
|
|
|
BsMerPlatformNo merPlatformNo = merPlatformNoService.getPlatformNo(merSettleAcctApply.getMerId(), PlatformTypeEnum.type1); |
|
|
|
|
if (merPlatformNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到平台商户号"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("accountKind", merSettleAcctApply.getSettleType().equals(MerSettleType.status1.getNumber())?"57":"58"); |
|
|
|
|
param.put("accountName", merSettleAcctApply.getSettleIdCardName()); |
|
|
|
|
param.put("accountNo", merSettleAcctApply.getBankCardNo()); |
|
|
|
|
param.put("bankName", merSettleAcctApply.getOpenningBankName()); |
|
|
|
|
param.put("bankNo", merSettleAcctApply.getOpenningBankCode()); |
|
|
|
|
param.put("clearingBankNo", merSettleAcctApply.getClearingBankCode()); |
|
|
|
|
param.put("identityNo", merSettleAcctApply.getSettleIdCardNo()); |
|
|
|
|
param.put("settleCityCode", merSettleAcctApply.getOpenningBankCityCode()); |
|
|
|
|
param.put("settleCityName", merSettleAcctApply.getOpenningBankCityName()); |
|
|
|
|
param.put("settleCountyCode", merSettleAcctApply.getOpenningBankAreaCode()); |
|
|
|
|
param.put("settleCountyName", merSettleAcctApply.getOpenningBankAreaName()); |
|
|
|
|
param.put("settleProvinceCode", merSettleAcctApply.getOpenningBankProvinceCode()); |
|
|
|
|
param.put("settleProvinceName", merSettleAcctApply.getOpenningBankProvinceName()); |
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> attachmentsMapList = new ArrayList<>(); |
|
|
|
|
Map<String, Object> attachmentsMap; |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("accountKind", merSettleAcctApply.getSettleType().equals(MerSettleType.status1.getNumber())?"57":"58"); |
|
|
|
|
param.put("accountName", merSettleAcctApply.getSettleIdCardName()); |
|
|
|
|
param.put("accountNo", merSettleAcctApply.getBankCardNo()); |
|
|
|
|
param.put("bankName", merSettleAcctApply.getOpenningBankName()); |
|
|
|
|
param.put("bankNo", merSettleAcctApply.getOpenningBankCode()); |
|
|
|
|
param.put("clearingBankNo", merSettleAcctApply.getClearingBankCode()); |
|
|
|
|
param.put("identityNo", merSettleAcctApply.getSettleIdCardNo()); |
|
|
|
|
param.put("settleCityCode", merSettleAcctApply.getOpenningBankCityCode()); |
|
|
|
|
param.put("settleCityName", merSettleAcctApply.getOpenningBankCityName()); |
|
|
|
|
param.put("settleCountyCode", merSettleAcctApply.getOpenningBankAreaCode()); |
|
|
|
|
param.put("settleCountyName", merSettleAcctApply.getOpenningBankAreaName()); |
|
|
|
|
param.put("settleProvinceCode", merSettleAcctApply.getOpenningBankProvinceCode()); |
|
|
|
|
param.put("settleProvinceName", merSettleAcctApply.getOpenningBankProvinceName()); |
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> attachmentsMapList = new ArrayList<>(); |
|
|
|
|
Map<String, Object> attachmentsMap; |
|
|
|
|
attachmentsMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(merSettleAcctApply.getBankCardImg())) { |
|
|
|
|
attachmentsMap.put("imgType", "BANK_CARD"); |
|
|
|
|
attachmentsMap.put("imgPath", saasCommon.fileUpload(new File(CommonSysConst.getSysConfig().getFile_url() +"/"+ merSettleAcctApply.getBankCardImg()), "BANK_CARD", "0").getString("url")); |
|
|
|
|
attachmentsMapList.add(attachmentsMap); |
|
|
|
|
} else if (StringUtils.isNotBlank(merSettleAcctApply.getOpenningBankLicenseUrl())) { |
|
|
|
|
attachmentsMap = new HashMap<>(); |
|
|
|
|
attachmentsMap.put("imgType", "OPENING_PERMIT"); |
|
|
|
|
attachmentsMap.put("imgPath", saasCommon.fileUpload(new File(CommonSysConst.getSysConfig().getFile_url() +"/"+ merSettleAcctApply.getOpenningBankLicenseUrl()), "OPENING_PERMIT", "0").getString("url")); |
|
|
|
|
attachmentsMapList.add(attachmentsMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(merSettleAcctApply.getBankCardImg())) { |
|
|
|
|
attachmentsMap.put("imgType", "BANK_CARD"); |
|
|
|
|
attachmentsMap.put("imgPath", saasCommon.fileUpload(new File(CommonSysConst.getSysConfig().getFile_url() +"/"+ merSettleAcctApply.getBankCardImg()), "BANK_CARD", "0").getString("url")); |
|
|
|
|
attachmentsMapList.add(attachmentsMap); |
|
|
|
|
} else if (StringUtils.isNotBlank(merSettleAcctApply.getOpenningBankLicenseUrl())) { |
|
|
|
|
attachmentsMap = new HashMap<>(); |
|
|
|
|
attachmentsMap.put("imgType", "OPENING_PERMIT"); |
|
|
|
|
attachmentsMap.put("imgPath", saasCommon.fileUpload(new File(CommonSysConst.getSysConfig().getFile_url() +"/"+ merSettleAcctApply.getOpenningBankLicenseUrl()), "OPENING_PERMIT", "0").getString("url")); |
|
|
|
|
attachmentsMapList.add(attachmentsMap); |
|
|
|
|
} |
|
|
|
|
param.put("attachments", attachmentsMapList); |
|
|
|
|
|
|
|
|
|
param.put("attachments", attachmentsMapList); |
|
|
|
|
Map<String,Object> header = new HashMap<>(); |
|
|
|
|
header.put("Authorization", "bearer " + saasCommon.getUpdateToken()); |
|
|
|
|
|
|
|
|
|
Map<String,Object> header = new HashMap<>(); |
|
|
|
|
header.put("Authorization", "bearer " + saasCommon.getUpdateToken()); |
|
|
|
|
JSONObject responseObj = HttpsUtils.doPost(SaasConfig.requestMerUrl + "channel/customer/update/settle/" + merPlatformNo.getPlatformNo(), param, header); |
|
|
|
|
System.out.println("body:" + JSONObject.toJSONString(param)); |
|
|
|
|
System.out.println("response:" + responseObj.toJSONString()); |
|
|
|
|
if (responseObj == null || !responseObj.getString("message").equals("SUCCESS")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
merSettleAcctApply.setApplyNo(responseObj.getString("reviewRelatedId")); |
|
|
|
|
merSettleAcctApplyService.editData(merSettleAcctApply); |
|
|
|
|
return responseObj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject responseObj = HttpsUtils.doPost(SaasConfig.requestMerUrl + "channel/customer/update/settle/" + merPlatformNo.getPlatformNo(), param, header); |
|
|
|
|
System.out.println("body:" + JSONObject.toJSONString(param)); |
|
|
|
|
System.out.println("response:" + responseObj.toJSONString()); |
|
|
|
|
if (responseObj == null || !responseObj.getString("message").equals("SUCCESS")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
merSettleAcctApply.setApplyNo(responseObj.getString("reviewRelatedId")); |
|
|
|
|
merSettleAcctApplyService.editData(merSettleAcctApply); |
|
|
|
|
return responseObj; |
|
|
|
|
/** |
|
|
|
|
* 修改费率 |
|
|
|
|
* @param merId 申请id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject updateFee(Long merId) { |
|
|
|
|
// 平台商户
|
|
|
|
|
BsMerPlatformNo merPlatformNo = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type1); |
|
|
|
|
if (merPlatformNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到平台商户号"); |
|
|
|
|
} |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("productCode", "WECHAT_PAY"); |
|
|
|
|
param.put("settlementType", "AUTOMATIC"); |
|
|
|
|
// 商户费率
|
|
|
|
|
List<Map<String, Object>> feesMapList = new ArrayList<>(); |
|
|
|
|
Map<String, Object> feesMap; |
|
|
|
|
List<BsMerRate> rateList = merRateService.getRateListByMerId(merId); |
|
|
|
|
for (BsMerRate rate : rateList) { |
|
|
|
|
feesMap = new HashMap<>(); |
|
|
|
|
feesMap.put("fee", rate.getRatePct()); |
|
|
|
|
feesMap.put("feeType", rate.getRateSaasTypeCode()); |
|
|
|
|
feesMapList.add(feesMap); |
|
|
|
|
} |
|
|
|
|
param.put("fees", feesMapList); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
System.out.println(e); |
|
|
|
|
return null; |
|
|
|
|
Map<String,Object> header = new HashMap<>(); |
|
|
|
|
header.put("Authorization", "bearer " + saasCommon.getUpdateToken()); |
|
|
|
|
|
|
|
|
|
JSONObject responseObj = HttpsUtils.doPost(SaasConfig.requestMerUrl + "channel/customer/update/fee/" + merPlatformNo.getPlatformNo(), param, header); |
|
|
|
|
System.out.println("商户号:" + merPlatformNo.getPlatformNo() + " " + merPlatformNo.getCupNo()); |
|
|
|
|
System.out.println("body:" + JSONObject.toJSONString(param)); |
|
|
|
|
System.out.println("response:" + responseObj.toJSONString()); |
|
|
|
|
if (responseObj == null || !responseObj.getString("message").equals("SUCCESS")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
merPlatformNo.setExt1(responseObj.getString("reviewRelatedId")); |
|
|
|
|
merPlatformNoService.editMerPlatformNo(merPlatformNo); |
|
|
|
|
return responseObj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改费率 |
|
|
|
|
* @param merId 申请id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject queryFee(Long merId) { |
|
|
|
|
// 平台商户
|
|
|
|
|
BsMerPlatformNo merPlatformNo = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type1); |
|
|
|
|
if (merPlatformNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "未找到平台商户号"); |
|
|
|
|
} |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
// param.put("productCode", "WECHAT_PAY");
|
|
|
|
|
|
|
|
|
|
Map<String,Object> header = new HashMap<>(); |
|
|
|
|
header.put("Authorization", "bearer " + saasCommon.getUpdateToken()); |
|
|
|
|
|
|
|
|
|
String doSaasGet = HttpsUtils.doSaasGet(SaasConfig.requestMerUrl + "channel/customer/update/fee/" + merPlatformNo.getPlatformNo(), param, header, false); |
|
|
|
|
JSONObject responseObj = JSONObject.parseObject(doSaasGet); |
|
|
|
|
System.out.println("商户号:" + merPlatformNo.getPlatformNo() + " " + merPlatformNo.getCupNo()); |
|
|
|
|
System.out.println("body:" + JSONObject.toJSONString(param)); |
|
|
|
|
System.out.println("response:" + responseObj.toJSONString()); |
|
|
|
|
if (responseObj == null || !responseObj.getString("message").equals("SUCCESS")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
return responseObj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -367,6 +430,7 @@ public class SaasMerService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject getMerSettle(String customerNo) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
@ -451,4 +515,5 @@ public class SaasMerService { |
|
|
|
|
|
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|