|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
package com.hfkj.channel.saas; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hfkj.channel.saas.config.SaasConfig; |
|
|
|
|
import com.hfkj.channel.saas.utils.GenerateAgreementUtil; |
|
|
|
@ -16,10 +15,7 @@ import com.hfkj.config.CommonSysConst; |
|
|
|
|
import com.hfkj.entity.*; |
|
|
|
|
import com.hfkj.model.MerBasisModel; |
|
|
|
|
import com.hfkj.service.*; |
|
|
|
|
import com.hfkj.sysenum.MerAttachType; |
|
|
|
|
import com.hfkj.sysenum.MerSettleType; |
|
|
|
|
import com.hfkj.sysenum.MerTypeEnum; |
|
|
|
|
import com.hfkj.sysenum.PlatformTypeEnum; |
|
|
|
|
import com.hfkj.sysenum.*; |
|
|
|
|
import freemarker.template.Configuration; |
|
|
|
|
import freemarker.template.Template; |
|
|
|
|
import org.apache.commons.codec.binary.Base64; |
|
|
|
@ -49,10 +45,10 @@ public class SaasMerService { |
|
|
|
|
private BsMerService merService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsIndustryService industryService; |
|
|
|
|
private BsStoreService storeService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private SecRegionService regionService; |
|
|
|
|
private BsIndustryService industryService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsMerRateService merRateService; |
|
|
|
@ -62,9 +58,6 @@ public class SaasMerService { |
|
|
|
|
@Resource |
|
|
|
|
private BsMerPlatformNoService merPlatformNoService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsMerPlatformNoRateService merPlatformNoRateService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BsMerAttachService merAttachService; |
|
|
|
|
|
|
|
|
@ -135,7 +128,8 @@ public class SaasMerService { |
|
|
|
|
if (basisModel.getLarIdCardPeriodType().equals(2)) { |
|
|
|
|
Calendar larIdCardEnd = Calendar.getInstance(); |
|
|
|
|
larIdCardEnd.set(Calendar.YEAR, 2099); |
|
|
|
|
larIdCardEnd.set(Calendar.MONTH, 12); |
|
|
|
|
larIdCardEnd.set(Calendar.MONTH, 11); |
|
|
|
|
larIdCardEnd.set(Calendar.DATE , 31); |
|
|
|
|
body.put("larIdCardEnd", DateUtil.date2String(larIdCardEnd.getTime(), "yyyy-MM-dd")); |
|
|
|
|
} else { |
|
|
|
|
body.put("larIdCardEnd", basisModel.getLarIdCardPeriodEnd().replace(".", "-")); |
|
|
|
@ -172,16 +166,17 @@ public class SaasMerService { |
|
|
|
|
|
|
|
|
|
// 非法人结算
|
|
|
|
|
if (basisModel.getMerSettleAcct().getSettleType().equals(MerSettleType.status3.getNumber())) { |
|
|
|
|
body.put("accountIdType", basisModel.getLarName()); |
|
|
|
|
body.put("accountIdType", "01"); |
|
|
|
|
body.put("accountName", basisModel.getMerSettleAcct().getSettleIdCardName()); |
|
|
|
|
body.put("accountIdDtStart", basisModel.getMerSettleAcct().getSettleIdCardPeriodStart().replace(".", "-")); |
|
|
|
|
if (basisModel.getLarIdCardPeriodType().equals(2)) { |
|
|
|
|
if (basisModel.getMerSettleAcct().getSettleIdPeriodType().equals(2)) { |
|
|
|
|
Calendar accountIdDtEnd = Calendar.getInstance(); |
|
|
|
|
accountIdDtEnd.set(Calendar.YEAR, 2099); |
|
|
|
|
accountIdDtEnd.set(Calendar.MONTH, 12); |
|
|
|
|
accountIdDtEnd.set(Calendar.MONTH, 11); |
|
|
|
|
accountIdDtEnd.set(Calendar.DATE , 31); |
|
|
|
|
body.put("accountIdDtEnd", DateUtil.date2String(accountIdDtEnd.getTime(), "yyyy-MM-dd")); |
|
|
|
|
} else { |
|
|
|
|
body.put("accountIdDtEnd", basisModel.getLarIdCardPeriodEnd().replace(".", "-")); |
|
|
|
|
body.put("accountIdDtEnd", basisModel.getMerSettleAcct().getSettleIdCardPeriodEnd().replace(".", "-")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/** --------- 结算信息---------- **/ |
|
|
|
@ -348,6 +343,83 @@ public class SaasMerService { |
|
|
|
|
return responseObj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 进件复议 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject reconsider(Long merId) throws Exception { |
|
|
|
|
BsMer mer = merService.getMer(merId); |
|
|
|
|
if (mer == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户信息"); |
|
|
|
|
} |
|
|
|
|
if (!mer.getMerStatus().equals(MerStatusEnum.status4.getNumber())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户状态不处于审核驳回状态,无法复议"); |
|
|
|
|
} |
|
|
|
|
mer.setCompleteStatus(MerCompleteStatusEnum.status1.getNumber()); |
|
|
|
|
mer.setMerStatus(MerStatusEnum.status3.getNumber()); |
|
|
|
|
merService.editMer(mer); |
|
|
|
|
|
|
|
|
|
List<BsStore> storeList = storeService.getStoreByMerId(merId, StoreCreateTypeEnum.type1); |
|
|
|
|
storeList.get(0).setAloneSettle(false); |
|
|
|
|
storeList.get(0).setStatus(StoreStatusEnum.status3.getNumber()); |
|
|
|
|
storeService.editStore(storeList.get(0)); |
|
|
|
|
|
|
|
|
|
// 平台
|
|
|
|
|
BsMerPlatformNo platformNo = merPlatformNoService.getPlatformNo(merId, PlatformTypeEnum.type1); |
|
|
|
|
if (platformNo == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未提交过进件"); |
|
|
|
|
} |
|
|
|
|
JSONObject responseObj = reconsiderSubmit(platformNo.getPlatformNo()); |
|
|
|
|
|
|
|
|
|
String orderNo = System.currentTimeMillis()+""; |
|
|
|
|
// 增加进件记录
|
|
|
|
|
BsMerContractRecord record = new BsMerContractRecord(); |
|
|
|
|
record.setMerId(merId); |
|
|
|
|
record.setPlatformType(PlatformTypeEnum.type1.getNumber()); |
|
|
|
|
record.setOrderNo(orderNo); |
|
|
|
|
record.setContractId(responseObj.toJSONString()); |
|
|
|
|
record.setStatus(1); |
|
|
|
|
merContractRecordService.insertRecord(record); |
|
|
|
|
|
|
|
|
|
// 增加进件记录消息
|
|
|
|
|
BsMerContractRecordMsg recordMsg = new BsMerContractRecordMsg(); |
|
|
|
|
recordMsg.setOrderNo(orderNo); |
|
|
|
|
recordMsg.setType(1); |
|
|
|
|
recordMsg.setRequestContent(platformNo.getPlatformNo()); |
|
|
|
|
recordMsg.setResponseCode(null); |
|
|
|
|
recordMsg.setResponseMsg(null); |
|
|
|
|
recordMsg.setResponseContent(responseObj.toJSONString()); |
|
|
|
|
merContractRecordMsgService.insertRecordMsg(recordMsg); |
|
|
|
|
return responseObj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 进件复议提交 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject reconsiderSubmit(String customerNo) throws Exception { |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("customerNo", customerNo); |
|
|
|
|
|
|
|
|
|
Map<String,Object> header = new HashMap<>(); |
|
|
|
|
header.put("Authorization", "bearer " + saasCommon.getToken()); |
|
|
|
|
|
|
|
|
|
JSONObject obj = new JSONObject(); |
|
|
|
|
obj.put("data", Base64.encodeBase64String(RSAUtil.encryptByPrivateKey(JSONObject.toJSONString(param).getBytes(), Base64.decodeBase64(RSAUtil.PRIVATE_KEY)))); |
|
|
|
|
|
|
|
|
|
JSONObject responseObj = HttpsUtils.doPost(SaasConfig.requestMerUrl + "open/merchant/reconsider/submit", obj, header); |
|
|
|
|
System.out.println("请求地址:" + SaasConfig.requestMerUrl + "open/merchant/reconsider/submit"); |
|
|
|
|
System.out.println("body:" + JSONObject.toJSONString(param)); |
|
|
|
|
System.out.println("response:" + responseObj.toJSONString()); |
|
|
|
|
if (responseObj == null || !responseObj.getString("code").equals("000000")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
return JSONObject.parseObject(new String(RSAUtil.decryptByPublicKey(Base64.decodeBase64(responseObj.getString("data")), Base64.decodeBase64(RSAUtil.PUBLIC_KEY)))); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改费率 |
|
|
|
|
* @param merId 申请id |
|
|
|
@ -390,7 +462,7 @@ public class SaasMerService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改费率 |
|
|
|
|
* 查询费率 |
|
|
|
|
* @param merId 申请id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -411,7 +483,7 @@ public class SaasMerService { |
|
|
|
|
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")) { |
|
|
|
|
if (responseObj == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, responseObj.getString("message")); |
|
|
|
|
} |
|
|
|
|
return responseObj; |
|
|
|
@ -439,10 +511,13 @@ public class SaasMerService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询商户结算 |
|
|
|
|
* @param customerNo |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public JSONObject getMerSettle(String customerNo) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("customerNo", customerNo); |
|
|
|
|
|
|
|
|
|