From 4ed693f48d1435de7a6333df17c2b34154731429 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期三, 05 七月 2023 22:26:27 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
---
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java | 187 ++++++++++++----------------------------------
1 files changed, 51 insertions(+), 136 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
index 99847f6..ad00a50 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
@@ -4,18 +4,19 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.core.log.LoggerFactory;
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.account.AccountDto;
import com.java110.dto.community.CommunityDto;
-import com.java110.dto.couponUser.CouponUserDto;
+import com.java110.dto.coupon.CouponUserDto;
import com.java110.dto.fee.FeeAttrDto;
+import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDetailDto;
import com.java110.dto.fee.FeeDto;
-import com.java110.dto.feeDiscount.ComputeDiscountDto;
+import com.java110.dto.fee.ComputeDiscountDto;
import com.java110.intf.acct.IAccountDetailInnerServiceSMO;
import com.java110.intf.acct.IAccountInnerServiceSMO;
import com.java110.intf.acct.ICouponUserV1InnerServiceSMO;
@@ -23,11 +24,7 @@
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.account.AccountPo;
-import com.java110.po.accountDetail.AccountDetailPo;
-import com.java110.po.feeAccountDetail.FeeAccountDetailPo;
import com.java110.utils.cache.CommonCache;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.CmdException;
@@ -60,9 +57,9 @@
* // modify by 寮犱笁 at 2021-09-12 绗�10琛屽湪鏌愮鍦烘櫙涓嬪瓨鍦ㄦ煇绉峛ug 闇�瑕佷慨澶嶏紝娉ㄩ噴10鑷�20琛� 鍔犲叆 20琛岃嚦30琛�
*/
@Java110Cmd(serviceCode = "fee.payFeePre")
-public class PayFeePreCmd extends AbstractServiceCmdListener {
- private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class);
+public class PayFeePreCmd extends Cmd {
+ private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class);
@Autowired
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
@@ -122,14 +119,56 @@
Assert.hasLength(reqJson.getString("receivedAmount"), "瀹炴敹閲戦涓嶈兘涓虹┖");
Assert.hasLength(reqJson.getString("feeId"), "璐圭敤ID涓嶈兘涓虹┖");
Assert.hasLength(reqJson.getString("appId"), "appId涓嶈兘涓虹┖");
+
+
+ //鍒ゆ柇鏄惁 璐圭敤鐘舵�佷负缂磋垂缁撴潫
+ FeeDto feeDto = new FeeDto();
+ feeDto.setFeeId(reqJson.getString("feeId"));
+ feeDto.setCommunityId(reqJson.getString("communityId"));
+ List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+ Assert.listOnlyOne(feeDtos, "浼犲叆璐圭敤ID閿欒");
+
+ feeDto = feeDtos.get(0);
+
+ if (FeeDto.STATE_FINISH.equals(feeDto.getState())) {
+ throw new IllegalArgumentException("鏀惰垂宸茬粡缁撴潫锛屼笉鑳藉啀缂磋垂");
+ }
+
+ Date endTime = feeDto.getEndTime();
+
+ FeeConfigDto feeConfigDto = new FeeConfigDto();
+ feeConfigDto.setConfigId(feeDto.getConfigId());
+ feeConfigDto.setCommunityId(reqJson.getString("communityId"));
+ List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
+
+ if (feeConfigDtos != null && feeConfigDtos.size() == 1) {
+ try {
+ Date configEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A);
+ configEndTime = DateUtil.stepDay(configEndTime, 5);
+
+ Date newDate = DateUtil.stepMonth(endTime, reqJson.getInteger("cycles"));
+
+ if (newDate.getTime() > configEndTime.getTime()) {
+ throw new IllegalArgumentException("缂磋垂鍛ㄦ湡瓒呰繃 缂磋垂缁撴潫鏃堕棿");
+ }
+
+ } catch (Exception e) {
+ logger.error("姣旇緝璐圭敤鏃ユ湡澶辫触", e);
+ }
+ }
+
}
@Override
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
logger.debug("ServiceDataFlowEvent : {}", event);
+ String userId = cmdDataFlowContext.getReqHeaders().get("user-id");
+
String appId = cmdDataFlowContext.getReqHeaders().get("app-id");
reqJson.put("appId", appId);
+ reqJson.put("userId",userId);
FeeDto feeDto = new FeeDto();
feeDto.setFeeId(reqJson.getString("feeId"));
@@ -242,84 +281,10 @@
reqJson.put("deductionAmount", 0.0);
return 0.0;
}
-
BigDecimal money = new BigDecimal(0);
BigDecimal totalAccountAmount = new BigDecimal(0);
for (AccountDto tmpAccountDto : accountDtos) {
- if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2004")) { //绉垎璐︽埛
- //璐︽埛閲戦
- BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
- //鑾峰彇鏈�澶ф姷鎵gН鍒�
- BigDecimal maximumNumber = new BigDecimal(tmpAccountDto.getMaximumNumber());
- //鑾峰彇绉垎鎶垫墸姣斾緥
- BigDecimal deductionProportion = new BigDecimal(tmpAccountDto.getDeductionProportion());
- int flag = amount.compareTo(maximumNumber);
- BigDecimal redepositAmount = new BigDecimal("0.00");
- BigDecimal integralAmount = new BigDecimal("0.00");
- if (flag == 1) { //璐︽埛绉垎澶т簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
- redepositAmount = maximumNumber;
- integralAmount = amount.subtract(maximumNumber);
- }
- if (flag > -1) { //璐︽埛绉垎澶т簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤鏈�澶т娇鐢ㄧН鍒嗘姷鎵�
- redepositAmount = maximumNumber;
- integralAmount = amount.subtract(maximumNumber);
- }
- if (flag == -1) { //璐︽埛绉垎灏忎簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
- redepositAmount = amount;
- }
- if (flag < 1) { //璐︽埛绉垎灏忎簬绛変簬鏈�澶т娇鐢ㄧН鍒嗭紝灏辩敤璐︽埛绉垎鎶垫墸
- redepositAmount = amount;
- }
- if (flag == 0) { //璐︽埛绉垎绛変簬鏈�澶т娇鐢ㄧН鍒�
- redepositAmount = amount;
- }
- //鏇存柊璐︽埛淇℃伅
- AccountPo accountPo = new AccountPo();
- accountPo.setAcctId(tmpAccountDto.getAcctId());
- accountPo.setAmount(integralAmount.toString());
- accountInnerServiceSMOImpl.updateAccount(accountPo);
- //鐢熸垚璐︽埛璇︽儏
- AccountDetailPo accountDetailPo = new AccountDetailPo();
- accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
- accountDetailPo.setAcctId(tmpAccountDto.getAcctId());
- accountDetailPo.setDetailType("2002"); //1001 杞叆 2002 杞嚭
- accountDetailPo.setRelAcctId("-1");
- accountDetailPo.setAmount(redepositAmount.toString());
- accountDetailPo.setObjType("6006"); //6006 涓汉 7007 鍟嗘埛
- accountDetailPo.setObjId(tmpAccountDto.getObjId());
- accountDetailPo.setOrderId("-1");
- accountDetailPo.setbId("-1");
- accountDetailPo.setRemark("鎵嬫満绔Н鍒嗘姷鎵�");
- accountDetailPo.setCreateTime(new Date());
- accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
- //璁$畻绉垎鎹㈢畻鐨勯噾棰�
- BigDecimal divide = redepositAmount.divide(deductionProportion);
- BigDecimal dedAmount = new BigDecimal(deductionAmount);
- //璁$畻瀹炰粯閲戦
- int flag2 = divide.compareTo(dedAmount);
- BigDecimal subtract = new BigDecimal("0.00");
- //鐢熸垚鎶垫墸鏄庣粏璁板綍
- FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
- if (flag2 == -1) { //绉垎鎹㈢畻閲戦灏忎簬搴斾粯閲戦
- subtract = dedAmount.subtract(divide);
- BigDecimal multiply = divide.multiply(deductionProportion);
- feeAccountDetailPo.setAmount(multiply.toString()); //绉垎鎶垫墸閲戦
- } else if (flag < 1) { //绉垎鎹㈢畻閲戦灏忎簬绛変簬搴斾粯閲戦
- subtract = dedAmount.subtract(divide);
- BigDecimal multiply = divide.multiply(deductionProportion);
- feeAccountDetailPo.setAmount(multiply.toString()); //绉垎鎶垫墸閲戦
- } else {
- BigDecimal multiply = dedAmount.multiply(deductionProportion);
- feeAccountDetailPo.setAmount(multiply.toString()); //绉垎鎶垫墸閲戦
- }
- reqJson.put("receivedMoney", subtract);
- feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
- feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
- feeAccountDetailPo.setCommunityId(reqJson.getString("communityId"));
- feeAccountDetailPo.setState("1003"); //1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
- feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
- money = subtract;
- } else if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2003")) { //鐜伴噾璐︽埛
+ if (AccountDto.ACCT_TYPE_CASH.equals(tmpAccountDto.getAcctType())) { //鐜伴噾璐︽埛
//璐︽埛閲戦
BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
//鑾峰彇搴旀敹閲戦
@@ -349,62 +314,12 @@
if (flag == 0) { //鐜伴噾璐︽埛绛変簬搴旀敹閲戦
redepositAmount = amount;
}
- //鏇存柊璐︽埛淇℃伅
- AccountPo accountPo = new AccountPo();
- accountPo.setAcctId(tmpAccountDto.getAcctId());
- accountPo.setAmount(integralAmount.toString());
- accountInnerServiceSMOImpl.updateAccount(accountPo);
- //鐢熸垚璐︽埛璇︽儏
- AccountDetailPo accountDetailPo = new AccountDetailPo();
- accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
- accountDetailPo.setAcctId(tmpAccountDto.getAcctId());
- accountDetailPo.setDetailType("2002"); //1001 杞叆 2002 杞嚭
- accountDetailPo.setRelAcctId("-1");
- accountDetailPo.setAmount(redepositAmount.toString());
- accountDetailPo.setObjType("6006"); //6006 涓汉 7007 鍟嗘埛
- accountDetailPo.setObjId(tmpAccountDto.getObjId());
- accountDetailPo.setOrderId("-1");
- accountDetailPo.setbId("-1");
- accountDetailPo.setRemark("鎵嬫満绔幇閲戣处鎴锋姷鎵�");
- accountDetailPo.setCreateTime(new Date());
- accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
- //鐢熸垚鎶垫墸鏄庣粏璁板綍
- FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo();
- feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId));
- feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId());
- feeAccountDetailPo.setCommunityId(reqJson.getString("communityId"));
- feeAccountDetailPo.setState("1002"); //1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
- feeAccountDetailPo.setAmount(redepositAmount.toString()); //绉垎鎶垫墸閲戦
- feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo);
- int flag2 = money.compareTo(amount);
- if (flag2 == 1) { //鍓╀綑閲戦澶т簬鐜伴噾璐︽埛
- money = money.subtract(amount);
- }
- if (flag > -1) { //鍓╀綑閲戦澶т簬绛変簬鐜伴噾璐︽埛
- money = money.subtract(amount);
- }
- if (flag == -1) { //鍓╀綑閲戦灏忎簬鐜伴噾璐︽埛
- money = new BigDecimal(0);
- }
- if (flag < 1) { //鍓╀綑閲戦灏忎簬绛変簬鐜伴噾璐︽埛
- money = new BigDecimal(0);
- }
- if (flag == 0) { //鍓╀綑閲戦绛変簬鐜伴噾璐︽埛
- money = new BigDecimal(0);
- }
+ money = money.add(redepositAmount);
}
// totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount()));
}
- /* double tmpDeductionAmount = totalAccountAmount.subtract(new BigDecimal(deductionAmount)).doubleValue();
- if (tmpDeductionAmount < 0) {
- reqJson.put("deductionAmount", totalAccountAmount.doubleValue());
- reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
- return totalAccountAmount.doubleValue();
- }
- reqJson.put("deductionAmount", deductionAmount);
- reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
- return deductionAmount;*/
+
reqJson.put("deductionAmount", money.doubleValue());
reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
return money.doubleValue();
--
Gitblit v1.8.0