From d7d9b601b2e4fdb663375993e2cfbdbd363df421 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 11 七月 2023 22:17:37 +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 | 106 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 93 insertions(+), 13 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 62f4016..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
@@ -11,11 +11,13 @@
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;
import com.java110.intf.community.ICommunityV1InnerServiceSMO;
@@ -30,6 +32,7 @@
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -39,6 +42,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -54,8 +58,8 @@
*/
@Java110Cmd(serviceCode = "fee.payFeePre")
public class PayFeePreCmd extends Cmd {
- private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class);
+ private static Logger logger = LoggerFactory.getLogger(PayFeePreCmd.class);
@Autowired
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
@@ -86,6 +90,7 @@
@Autowired
private IComputeFeeSMO computeFeeSMOImpl;
+
@Autowired
private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl;
@@ -94,6 +99,12 @@
@Autowired
private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl;
+
+ @Autowired
+ private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl;
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
@@ -108,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"));
@@ -228,21 +281,48 @@
reqJson.put("deductionAmount", 0.0);
return 0.0;
}
-
+ BigDecimal money = new BigDecimal(0);
BigDecimal totalAccountAmount = new BigDecimal(0);
for (AccountDto tmpAccountDto : accountDtos) {
- totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount()));
+ if (AccountDto.ACCT_TYPE_CASH.equals(tmpAccountDto.getAcctType())) { //鐜伴噾璐︽埛
+ //璐︽埛閲戦
+ BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount());
+ //鑾峰彇搴旀敹閲戦
+ BigDecimal dedAmount = new BigDecimal("0.00");
+ if (reqJson.containsKey("receivedMoney") && !StringUtil.isEmpty(reqJson.getString("receivedMoney"))) {
+ dedAmount = new BigDecimal(reqJson.getString("receivedMoney"));
+ } else {
+ dedAmount = new BigDecimal(reqJson.getString("deductionAmount"));
+ }
+ int flag = amount.compareTo(dedAmount);
+ BigDecimal redepositAmount = new BigDecimal("0.00");
+ BigDecimal integralAmount = new BigDecimal("0.00");
+ if (flag == 1) { //鐜伴噾璐︽埛澶т簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
+ redepositAmount = dedAmount;
+ integralAmount = amount.subtract(dedAmount);
+ }
+ if (flag > -1) { //鐜伴噾璐︽埛澶т簬绛変簬搴旀敹閲戦锛屽氨鐢ㄥ簲鏀堕噾棰濇姷鎵�
+ redepositAmount = dedAmount;
+ integralAmount = amount.subtract(dedAmount);
+ }
+ if (flag == -1) { //鐜伴噾璐︽埛灏忎簬瀹炴敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴锋姷鎵�
+ redepositAmount = amount;
+ }
+ if (flag < 1) { //鐜伴噾璐︽埛灏忎簬绛変簬搴旀敹閲戦锛屽氨鐢ㄧ幇閲戣处鎴锋姷鎵�
+ redepositAmount = amount;
+ }
+ if (flag == 0) { //鐜伴噾璐︽埛绛変簬搴旀敹閲戦
+ redepositAmount = amount;
+ }
+ 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("deductionAmount", money.doubleValue());
reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));
- return deductionAmount;
+ return money.doubleValue();
}
private double checkCouponUser(JSONObject paramObj) {
--
Gitblit v1.8.0