From 6eb064b4aa583bc8be55b23a82badc5d8442cbb1 Mon Sep 17 00:00:00 2001
From: xiaogang <905166056@qq.com>
Date: 星期三, 25 五月 2022 15:27:38 +0800
Subject: [PATCH] 1、优化访客预约等相关设置2、增加积分抵扣
---
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java | 212 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 188 insertions(+), 24 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 9b54c50..1330f50 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
@@ -29,12 +29,14 @@
import com.java110.intf.community.IRepairUserInnerServiceSMO;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.fee.*;
+import com.java110.intf.feeAccountDetail.IFeeAccountDetailServiceSMO;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
import com.java110.po.accountDetail.AccountDetailPo;
import com.java110.po.applyRoomDiscount.ApplyRoomDiscountPo;
import com.java110.po.car.OwnerCarPo;
import com.java110.po.fee.PayFeeDetailPo;
import com.java110.po.fee.PayFeePo;
+import com.java110.po.feeAccountDetail.FeeAccountDetailPo;
import com.java110.po.owner.RepairPoolPo;
import com.java110.po.owner.RepairUserPo;
import com.java110.po.payFeeDetailDiscount.PayFeeDetailDiscountPo;
@@ -53,18 +55,16 @@
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Java110Cmd(serviceCode = "fee.payFee")
public class PayFeeCmd extends AbstractServiceCmdListener {
- private static Logger logger = LoggerFactory.getLogger(PayFeeCmd.class);
+ private static Logger logger = LoggerFactory.getLogger(PayFeeCmd.class);
@Autowired
private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl;
+
@Autowired
private IPayFeeDetailNewV1InnerServiceSMO payFeeDetailNewV1InnerServiceSMOImpl;
@@ -83,7 +83,6 @@
@Autowired
private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
-
@Autowired
private IFeeReceiptDetailInnerServiceSMO feeReceiptDetailInnerServiceSMOImpl;
@@ -99,31 +98,35 @@
@Autowired
private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
-
@Autowired
private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl;
@Autowired
private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
-
@Autowired
private IComputeFeeSMO computeFeeSMOImpl;
@Autowired
private IPayFeeDetailDiscountNewV1InnerServiceSMO payFeeDetailDiscountNewV1InnerServiceSMOImpl;
+
@Autowired
private IRepairPoolNewV1InnerServiceSMO repairPoolNewV1InnerServiceSMOImpl;
+
@Autowired
private IRepairUserNewV1InnerServiceSMO repairUserNewV1InnerServiceSMOImpl;
+
@Autowired
private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl;
+
@Autowired
private ICouponUserDetailV1InnerServiceSMO couponUserDetailV1InnerServiceSMOImpl;
@Autowired
private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl;
+ @Autowired
+ private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl;
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
@@ -172,6 +175,12 @@
logger.error("姣旇緝璐圭敤鏃ユ湡澶辫触", e);
}
}
+ String selectUserAccount = reqJson.getString("selectUserAccount");
+ JSONArray params = JSONArray.parseArray(selectUserAccount);
+ for (int paramIndex = 0; paramIndex < params.size(); paramIndex++) {
+ JSONObject param = params.getJSONObject(paramIndex);
+ String maximumNumber = param.getString("maximumNumber");
+ }
}
@Override
@@ -186,6 +195,98 @@
DistributedLock.waitGetDistributedLock(key, requestId);
JSONObject feeDetail = addFeeDetail(paramObj);
PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(feeDetail, PayFeeDetailPo.class);
+ //鍒ゆ柇閫夋嫨鐨勮处鍙�
+ JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount");
+ if (jsonArray == null || jsonArray.size() < 1) {
+ FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+ feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+ feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId());
+ feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId());
+ feeAccountDetailPo.setState("1001"); //1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
+ feeAccountDetailPo.setAmount(paramObj.getString("receivedAmount"));
+ feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+ }
+ for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) {
+ JSONObject param = jsonArray.getJSONObject(columnIndex);
+ if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { //绉垎璐︽埛
+ //璐︽埛閲戦
+ BigDecimal amount = new BigDecimal(param.getString("amount"));
+ //鑾峰彇鏈�澶ф姷鎵gН鍒�
+ BigDecimal maximumNumber = new BigDecimal(param.getString("maximumNumber"));
+ //鑾峰彇绉垎鎶垫墸
+ BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion"));
+ int flag = amount.compareTo(maximumNumber);
+ BigDecimal redepositAmount = new BigDecimal("0.00");
+ if (flag == 1) { //璐︽埛绉垎澶т簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
+ redepositAmount = maximumNumber;
+ }
+ if (flag > -1) { //璐︽埛绉垎澶т簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
+ redepositAmount = maximumNumber;
+ }
+ if (flag == -1) { //璐︽埛绉垎灏忎簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
+ redepositAmount = amount;
+ }
+ if (flag < 1) { //璐︽埛绉垎灏忎簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
+ redepositAmount = amount;
+ }
+ if (flag == 0) { //璐︽埛绉垎绛変簬鏈�澶т娇鐢ㄧН鍒�
+ redepositAmount = amount;
+ }
+ //璁$畻绉垎鎹㈢畻鐨勯噾棰�
+ BigDecimal divide = redepositAmount.divide(deductionProportion);
+ BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount());
+ //璁$畻瀹炰粯閲戦
+ int flag2 = divide.compareTo(receivedAmount);
+ BigDecimal subtract = new BigDecimal("0.00");
+ //鐢熸垚鎶垫墸鏄庣粏璁板綍
+ FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+ if (flag2 == -1) { //绉垎鎹㈢畻閲戦灏忎簬瀹炰粯閲戦
+ subtract = receivedAmount.subtract(divide);
+ feeAccountDetailPo.setAmount(divide.toString()); //绉垎鎶垫墸閲戦
+ } else if (flag < 1) { //绉垎鎹㈢畻閲戦灏忎簬绛変簬瀹炰粯閲戦
+ subtract = receivedAmount.subtract(divide);
+ feeAccountDetailPo.setAmount(divide.toString()); //绉垎鎶垫墸閲戦
+ } else {
+ feeAccountDetailPo.setAmount(receivedAmount.toString()); //绉垎鎶垫墸閲戦
+ }
+ payFeeDetailPo.setReceivedAmount(subtract.toString());
+ feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+ feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId());
+ feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId());
+ feeAccountDetailPo.setState("1003"); //1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
+ feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+ } else if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2003")) { //鐜伴噾璐︽埛
+ //璐︽埛閲戦
+ BigDecimal amount = new BigDecimal(param.getString("amount"));
+ //瀹炴敹閲戦
+ BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount());
+ int flag = amount.compareTo(receivedAmount);
+ BigDecimal redepositAmount = new BigDecimal("0.00");
+ if (flag == 1) { //鐜伴噾璐︽埛澶т簬瀹炴敹閲戦锛屽氨鐢ㄥ疄鏀堕噾棰�
+ redepositAmount = receivedAmount;
+ }
+ if (flag > -1) { //鐜伴噾璐︽埛澶т簬绛変簬瀹炴敹閲戦锛屽氨鐢ㄥ疄鏀堕噾棰�
+ redepositAmount = receivedAmount;
+ }
+ if (flag == -1) { //鐜伴噾璐︽埛灏忎簬瀹炴敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴�
+ redepositAmount = amount;
+ }
+ if (flag < 1) { //鐜伴噾璐︽埛灏忎簬绛変簬瀹炴敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴�
+ redepositAmount = amount;
+ }
+ if (flag == 0) { //鐜伴噾璐︽埛绛変簬瀹炴敹閲戦
+ redepositAmount = amount;
+ }
+ //鐢熸垚鎶垫墸鏄庣粏璁板綍
+ FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
+ feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
+ feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId());
+ feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId());
+ feeAccountDetailPo.setState("1002"); //1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
+ feeAccountDetailPo.setAmount(redepositAmount.toString()); //绉垎鎶垫墸閲戦
+ feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
+ }
+ }
int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo);
if (flag < 1) {
throw new CmdException("缂磋垂澶辫触");
@@ -528,25 +629,92 @@
if (jsonArray == null || jsonArray.size() < 1) {
return;
}
- //搴旀敹娆� totalFeePrice
- BigDecimal totalFeePrice = new BigDecimal(paramObj.getString("totalFeePrice")); //搴旀敹娆�
- //瀹炴敹娆� receivedAmount
- BigDecimal receivedAmount = new BigDecimal(paramObj.getString("receivedAmount")); //瀹炴敹娆撅紙鎵f閲戦锛�
-
- BigDecimal redepositAmount = new BigDecimal("0.00");//鎶垫墸閲戦
+ List<AccountDto> accountDtos = new ArrayList<>();
for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) {
+ //搴旀敹娆� totalFeePrice
+ BigDecimal totalFeePrice = new BigDecimal(paramObj.getString("totalFeePrice")); //搴旀敹娆�
+ //瀹炴敹娆� receivedAmount
+ BigDecimal receivedAmount = new BigDecimal(paramObj.getString("receivedAmount")); //瀹炴敹娆撅紙鎵f閲戦锛�
+ BigDecimal redepositAmount = new BigDecimal("0.00");//鎶垫墸閲戦
JSONObject param = jsonArray.getJSONObject(columnIndex);
+ if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { //绉垎璐︽埛
+ //鑾峰彇鎶垫墸姣斾緥
+ BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion"));
+ //璁$畻瀹炴敹娆炬墍鎵g殑绉垎
+ BigDecimal multiply = receivedAmount.multiply(deductionProportion);
+ receivedAmount = multiply;
+ }
//璐︽埛閲戦
- BigDecimal amount = new BigDecimal(param.getString("amount")); //璐︽埛閲戦
+ BigDecimal amount = new BigDecimal(param.getString("amount"));
int flag = amount.compareTo(receivedAmount);
- if (flag == -1) {//璐︽埛閲戦灏忎簬瀹炴敹娆�
- receivedAmount = receivedAmount.subtract(amount);
+ if (flag == -1) { //璐︽埛閲戦灏忎簬瀹炴敹娆�
redepositAmount = amount;//鎶垫墸閲戦
} else {
redepositAmount = receivedAmount;//鎶垫墸閲戦
}
- //鍓╀綑閲戦
- amount.compareTo(receivedAmount);
+ if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) {
+ //鑾峰彇鏈�澶ф姷鎵gН鍒�
+ BigDecimal maximumNumber = new BigDecimal(param.getString("maximumNumber"));
+ //鑾峰彇绉垎鎶垫墸
+ BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion"));
+ int flag2 = amount.compareTo(maximumNumber);
+ if (flag2 == 1) { //璐︽埛绉垎澶т簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
+ int flag3 = maximumNumber.compareTo(receivedAmount);
+ if (flag3 == 1) { //濡傛灉鏈�澶т娇鐢ㄧН鍒嗗ぇ浜庡疄鏀堕噾棰濇姷鎵gН鍒嗭紝灏辨妸瀹炴敹閲戦鎶垫墸绉垎璧嬪�肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else if (flag3 > -1) {//濡傛灉鏈�澶т娇鐢ㄧН鍒嗗ぇ浜庣瓑浜庡疄鏀堕噾棰濇姷鎵gН鍒嗭紝灏辨妸瀹炴敹閲戦鎶垫墸绉垎璧嬪�肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else {
+ redepositAmount = maximumNumber;
+ }
+ }
+ if (flag2 > -1) { //璐︽埛绉垎澶т簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
+ int flag3 = maximumNumber.compareTo(receivedAmount);
+ if (flag3 == 1) { //濡傛灉鏈�澶т娇鐢ㄧН鍒嗗ぇ浜庡疄鏀堕噾棰濇姷鎵gН鍒嗭紝灏辨妸瀹炴敹閲戦鎶垫墸绉垎璧嬪�肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else if (flag3 > -1) {//濡傛灉鏈�澶т娇鐢ㄧН鍒嗗ぇ浜庣瓑浜庡疄鏀堕噾棰濇姷鎵gН鍒嗭紝灏辨妸瀹炴敹閲戦鎶垫墸绉垎璧嬪�肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else {
+ redepositAmount = maximumNumber;
+ }
+ }
+ if (flag2 == -1) { //璐︽埛绉垎灏忎簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
+ int flag3 = amount.compareTo(receivedAmount);
+ if (flag3 == 1) { //濡傛灉绉垎璐︽埛澶т簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else if (flag3 > -1) {//濡傛灉绉垎璐︽埛澶т簬绛変簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else {
+ redepositAmount = amount;
+ }
+ }
+ if (flag2 < 1) { //璐︽埛绉垎灏忎簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
+ int flag3 = amount.compareTo(receivedAmount);
+ if (flag3 == 1) { //濡傛灉绉垎璐︽埛澶т簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else if (flag3 > -1) {//濡傛灉绉垎璐︽埛澶т簬绛変簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else {
+ redepositAmount = amount;
+ }
+ }
+ if (flag2 == 0) { //璐︽埛绉垎绛変簬鏈�澶т娇鐢ㄧН鍒�
+ int flag3 = amount.compareTo(receivedAmount);
+ if (flag3 == 1) { //濡傛灉绉垎璐︽埛澶т簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else if (flag3 > -1) {//濡傛灉绉垎璐︽埛澶т簬绛変簬瀹炴敹閲戦鎶垫墸绉垎锛屽氨鎶婂疄鏀堕噾棰濇姷鎵gН鍒嗚祴鍊肩粰鎶垫墸绉垎
+ redepositAmount = receivedAmount;
+ } else {
+ redepositAmount = amount;
+ }
+ }
+ //璁$畻绉垎鎹㈢畻鐨勯噾棰�
+ BigDecimal divide = redepositAmount.divide(deductionProportion);
+ BigDecimal divide1 = receivedAmount.divide(deductionProportion);
+ //璁$畻杩橀渶鏀粯鐨勯噾棰�
+ BigDecimal subtract = divide1.subtract(divide);
+ paramObj.put("receivedAmount", subtract);
+ }
String acctId = param.getString("acctId");
if (StringUtil.isEmpty(acctId)) {
throw new IllegalArgumentException("璐︽埛id涓虹┖锛�");
@@ -554,7 +722,7 @@
AccountDto accountDto = new AccountDto();
accountDto.setAcctId(acctId);
//鏌ヨ璐︽埛閲戦
- List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+ accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
Assert.listOnlyOne(accountDtos, "鏌ヨ璐︽埛閲戦閿欒锛�");
if (accountDtos != null && accountDtos.size() > 0) {
AccountDto accountDto1 = accountDtos.get(0);
@@ -563,8 +731,6 @@
throw new UnsupportedOperationException("璐︽埛閲戦鎶垫墸涓嶈冻锛岃鎮ㄧ‘璁よ处鎴烽噾棰濓紒");
}
}
-
-
AccountDetailPo accountDetailPo = new AccountDetailPo();
accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
int flag1 = redepositAmount.compareTo(BigDecimal.ZERO);
@@ -585,8 +751,6 @@
throw new CmdException("鎵f澶辫触");
}
}
-
-
}
private static Calendar getTargetEndTime(Calendar endCalender, Double cycles) {
--
Gitblit v1.8.0