wuxw
2023-11-23 9b30285de6191e5fb2df447684ba2ed2c28d9db3
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
@@ -11,12 +11,12 @@
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;
@@ -25,17 +25,11 @@
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.fee.*;
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;
import com.java110.utils.exception.ListenerExecuteException;
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 com.java110.utils.util.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -183,13 +177,16 @@
        feeDto = feeDtos.get(0);
        reqJson.put("feeTypeCd", feeDto.getFeeTypeCd());
        reqJson.put("feeId", feeDto.getFeeId());
        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
        //todo 计算应收
        BigDecimal receivableAmount = new BigDecimal(feePriceAll.get("feePrice").toString());
        BigDecimal cycles = new BigDecimal(Double.parseDouble(reqJson.getString("cycles")));
        double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        JSONObject paramOut = new JSONObject();
        paramOut.put("receivableAmount", tmpReceivableAmount);
        paramOut.put("oId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_oId));
        //实收金额
        BigDecimal tmpReceivedAmout = new BigDecimal(tmpReceivableAmount);
@@ -211,6 +208,13 @@
        if (receivedAmount <= 0) {
            receivedAmount = 0.0;
        }
        //todo 小数点处理
        receivedAmount = MoneyUtil.computePriceScale(
                receivedAmount,
                feeDto.getScale(),
                Integer.parseInt(feeDto.getDecimalPlace())
        );
        paramOut.put("receivedAmount", receivedAmount);
        String feeName = getObjName(feeDto);
@@ -284,8 +288,44 @@
            reqJson.put("deductionAmount", 0.0);
            return 0.0;
        }
        BigDecimal money = new BigDecimal(0);
        BigDecimal totalAccountAmount = new BigDecimal(0);
        for (AccountDto tmpAccountDto : accountDtos) {
             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()));
        }
        reqJson.put("deductionAmount", money.doubleValue());
        reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos));