From 6a7f5fd729b81ea583048eac5117678dfcd1050f Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 23 八月 2022 22:14:55 +0800
Subject: [PATCH] 优化超过缴费时间时 提心不能缴费
---
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java | 103 +++++++++++++++++++++++++++++----------------------
1 files changed, 58 insertions(+), 45 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java
index 2f602e1..0887fba 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java
@@ -165,15 +165,11 @@
//涓�娆℃�ц垂鐢� 鍜岄棿鎺ユ�ц垂鐢�
Date maxEndTime = feeDtos.get(0).getDeadlineTime();
//鍛ㄦ湡鎬ц垂鐢�
- if (FeeDto.FEE_FLAG_CYCLE.equals(feeConfigDtos.get(0).getFeeFlag())
- || FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())
- || FeeDto.FEE_FLAG_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) {
- try {
- maxEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A);
- } catch (ParseException e) {
- } catch (Exception e) {
- logger.error("姣旇緝璐圭敤鏃ユ湡澶辫触", e);
- }
+ if (maxEndTime == null) {
+ maxEndTime = DateUtil.getDateFromStringA(feeConfigDtos.get(0).getEndTime());
+ }
+
+ if (maxEndTime != null && endTime != null) {
Date newDate = DateUtil.stepMonth(endTime, reqJson.getDouble("cycles").intValue());
if (newDate.getTime() > maxEndTime.getTime()) {
throw new IllegalArgumentException("缂磋垂鍛ㄦ湡瓒呰繃 缂磋垂缁撴潫鏃堕棿");
@@ -204,33 +200,7 @@
payFeePo = BeanConvertUtil.covertBean(fee, PayFeePo.class);
PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(feeDetail, PayFeeDetailPo.class);
//鍒ゆ柇鏄惁鏈夎禒閫佽鍒�
- if (paramObj.containsKey("selectDiscount")) {
- JSONArray selectDiscount = paramObj.getJSONArray("selectDiscount");
- if (selectDiscount != null && selectDiscount.size() > 0) {
- for (int index = 0; index < selectDiscount.size(); index++) {
- JSONObject paramJson = selectDiscount.getJSONObject(index);
- if (!StringUtil.isEmpty(paramJson.getString("ruleId")) && paramJson.getString("ruleId").equals("102020008")) { //璧犻�佽鍒�
- JSONArray feeDiscountSpecs = paramJson.getJSONArray("feeDiscountSpecs");
- if (feeDiscountSpecs.size() > 0) {
- for (int specIndex = 0; specIndex < feeDiscountSpecs.size(); specIndex++) {
- JSONObject paramIn = feeDiscountSpecs.getJSONObject(specIndex);
- if (!StringUtil.isEmpty(paramIn.getString("specId")) && paramIn.getString("specId").equals("89002020980015")) { //璧犻�佹湀浠�
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String specValue = paramIn.getString("specValue");
- //鑾峰彇璐圭敤缁撴潫鏃堕棿(涔熷氨鏄笅娆¤垂鐢ㄥ紑濮嬫椂闂�)
- Date endTime = df.parse(payFeeDetailPo.getEndTime());
- Calendar cal = Calendar.getInstance();
- cal.setTime(endTime);
- cal.add(Calendar.MONTH, Integer.parseInt(specValue));
- payFeeDetailPo.setEndTime(df.format(cal.getTime()));
- payFeePo.setEndTime(df.format(cal.getTime()));
- }
- }
- }
- }
- }
- }
- }
+ hasDiscount(paramObj, payFeePo, payFeeDetailPo);
//鍒ゆ柇閫夋嫨鐨勮处鍙�
JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount");
if (jsonArray == null || jsonArray.size() < 1) {
@@ -382,6 +352,49 @@
// }
cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(feeReceiptDetailDto));
+ }
+
+ /**
+ * 鏀归�犺禒閫侀�昏緫 if 宓屽鏈夌偣澶� 浼樺寲
+ * @param paramObj
+ * @param payFeePo
+ * @param payFeeDetailPo
+ * @throws ParseException
+ */
+ private void hasDiscount(JSONObject paramObj, PayFeePo payFeePo, PayFeeDetailPo payFeeDetailPo) throws ParseException {
+ if (!paramObj.containsKey("selectDiscount")) {
+ return;
+ }
+ JSONArray selectDiscount = paramObj.getJSONArray("selectDiscount");
+
+ if (selectDiscount == null || selectDiscount.size() < 1) {
+ return;
+ }
+ for (int index = 0; index < selectDiscount.size(); index++) {
+ JSONObject paramJson = selectDiscount.getJSONObject(index);
+ if (!"102020008".equals(paramJson.getString("ruleId"))) { //璧犻�佽鍒�
+ continue;
+ }
+ JSONArray feeDiscountSpecs = paramJson.getJSONArray("feeDiscountSpecs");
+ if (feeDiscountSpecs == null || feeDiscountSpecs.size() < 1) {
+ continue;
+ }
+ for (int specIndex = 0; specIndex < feeDiscountSpecs.size(); specIndex++) {
+ JSONObject paramIn = feeDiscountSpecs.getJSONObject(specIndex);
+ if (!"89002020980015".equals(paramIn.getString("specId"))) { //璧犻�佹湀浠�
+ continue;
+ }
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String specValue = paramIn.getString("specValue");
+ //鑾峰彇璐圭敤缁撴潫鏃堕棿(涔熷氨鏄笅娆¤垂鐢ㄥ紑濮嬫椂闂�)
+ Date endTime = df.parse(payFeeDetailPo.getEndTime());
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(endTime);
+ cal.add(Calendar.MONTH, Integer.parseInt(specValue));
+ payFeeDetailPo.setEndTime(df.format(cal.getTime()));
+ payFeePo.setEndTime(df.format(cal.getTime()));
+ }
+ }
}
/**
@@ -585,9 +598,9 @@
paramInJson.put("tmpCycles", cycles.doubleValue());
businessFeeDetail.put("cycles", cycles.doubleValue());
//澶勭悊 鍙兘杩樺瓨鍦� 瀹炴敹鎵嬪伐鍑忓厤鐨勬儏鍐�
- if(paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))){
+ if (paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))) {
businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount"));
- }else {
+ } else {
businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
}
} else if ("-103".equals(paramInJson.getString("cycles"))) { //杩欓噷鎸夌即璐圭粨鏉熸椂闂寸即璐�
@@ -598,15 +611,15 @@
c.add(Calendar.DAY_OF_MONTH, 1);
endDates = c.getTime();//杩欐槸鏄庡ぉ
targetEndTime = endDates;
- BigDecimal receivedAmount1 = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
+ BigDecimal receivedAmount1 = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
cycles = receivedAmount1.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN);
paramInJson.put("tmpCycles", cycles.doubleValue());
businessFeeDetail.put("cycles", cycles.doubleValue());
BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
//澶勭悊 鍙兘杩樺瓨鍦� 瀹炴敹鎵嬪伐鍑忓厤鐨勬儏鍐�
- if(paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))){
+ if (paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))) {
businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount"));
- }else {
+ } else {
businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
}
} else {
@@ -617,8 +630,8 @@
//鍑虹閫掑闂澶勭悊
if (FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) {
- computeFeeSMOImpl.dealRentRateCycle(feeDto,cycles.doubleValue());
- if(feeDto.getOweFee()> 0){
+ computeFeeSMOImpl.dealRentRateCycle(feeDto, cycles.doubleValue());
+ if (feeDto.getOweFee() > 0) {
businessFeeDetail.put("receivableAmount", feeDto.getAmountOwed());
}
}
@@ -671,7 +684,7 @@
maxEndTime = feeInfo.getConfigEndTime();
}
- if(FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeInfo.getFeeFlag())){
+ if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeInfo.getFeeFlag())) {
maxEndTime = feeInfo.getMaxEndTime();
}
@@ -681,7 +694,7 @@
}
//鍒ゆ柇 缁撴潫鏃堕棿 鏄惁澶т簬 璐圭敤椤� 缁撴潫鏃堕棿锛岃繖閲� 瀹归敊涓�涓嬶紝濡傛灉 璐圭敤缁撴潫鏃堕棿澶т簬 璐圭敤椤圭粨鏉熸椂闂� 30澶� 璧版姤閿� 灞炰簬澶氱即璐�
- if(maxEndTime != null) {
+ if (maxEndTime != null) {
if (feeInfo.getEndTime().getTime() - maxEndTime.getTime() > 30 * 24 * 60 * 60 * 1000L) {
throw new IllegalArgumentException("缂磋垂瓒呰繃浜� 璐圭敤椤圭粨鏉熸椂闂�");
}
--
Gitblit v1.8.0