wuxw
2024-12-05 919e2989808dd97ba32b4478dbe95851c70fbce5
service-fee/src/main/java/com/java110/fee/cmd/returnPayFee/UpdateReturnPayFeeCmd.java
@@ -24,14 +24,9 @@
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.CommunitySettingFactory;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.fee.*;
import com.java110.dto.room.RoomDto;
import com.java110.dto.account.AccountDto;
import com.java110.dto.fee.FeeDetailDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.fee.FeeDiscountDto;
import com.java110.dto.fee.FeeDiscountRuleDto;
import com.java110.dto.fee.FeeDiscountSpecDto;
import com.java110.dto.fee.FeeReceiptDetailDto;
import com.java110.dto.wechat.OnlinePayDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.owner.OwnerDto;
@@ -157,6 +152,9 @@
    @Autowired
    private IOnlinePayRefundV1InnerServiceSMO onlinePayRefundV1InnerServiceSMOImpl;
    @Autowired
    private IPayFeeConfigV1InnerServiceSMO payFeeConfigV1InnerServiceSMOImpl;
    private static final String SPEC_RATE = "89002020980015"; //赠送月份
@@ -173,9 +171,9 @@
        Assert.hasKeyAndValue(reqJson, "state", "state不能为空");
        Assert.hasKeyAndValue(reqJson, "feeId", "feeId不能为空");
        if (reqJson.containsKey("cycles")) {
            String cycles = reqJson.getString("cycles");
            if (!cycles.startsWith("-")) {
                throw new IllegalArgumentException("退费周期必须负数");// 这里必须传入负数,否则费用自动相加不会退费
            double cycles = reqJson.getDouble("cycles");
            if (cycles > 0) {
                throw new CmdException("退费周期必须负数");// 这里必须传入负数,否则费用自动相加不会退费
            }
        }
        FeeDetailDto feeDetailDto = new FeeDetailDto();
@@ -203,6 +201,19 @@
        returnPayFeeDto.setReturnFeeId(reqJson.getString("returnFeeId"));
        List<ReturnPayFeeDto> returnPayFeeDtos = returnPayFeeInnerServiceSMOImpl.queryReturnPayFees(returnPayFeeDto);
        Assert.listOnlyOne(returnPayFeeDtos, "未找到需要修改的活动 或多条数据");
        FeeDto feeDto = new FeeDto();
        feeDto.setFeeId((String) reqJson.get("feeId"));
        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
        Assert.listOnlyOne(feeDtos, "费用不存在");
        FeeDto feeDto1 = feeDtos.get(0);
        FeeConfigDto feeConfigDto = new FeeConfigDto();
        feeConfigDto.setConfigId(feeDto1.getConfigId());
        feeConfigDto.setCommunityId(feeDto1.getCommunityId());
        List<FeeConfigDto> feeConfigDtos = payFeeConfigV1InnerServiceSMOImpl.queryPayFeeConfigs(feeConfigDto);
        Assert.listOnlyOne(feeConfigDtos, "费用项不存在");
        // todo 修改退款状态
        updateReturnPayFee(reqJson, userDtos.get(0), returnPayFeeDtos.get(0));
@@ -227,11 +238,7 @@
            // todo 修改 缴费记录
            updateFeeDetail(reqJson);
            //修改pay_fee 费用到期时间  以及如果是押金则修改状态为结束收费
            FeeDto feeDto = new FeeDto();
            feeDto.setFeeId((String) reqJson.get("feeId"));
            List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
            Assert.listOnlyOne(feeDtos, "费用不存在");
            FeeDto feeDto1 = feeDtos.get(0);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            reqJson.put("endTime", DateUtil.getFormatTimeString(feeDetailDto.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
            reqJson.put("amount", feeDto1.getAmount());
@@ -248,9 +255,7 @@
            reqJson.put("payerObjType", feeDto1.getPayerObjType());
            reqJson.put("feeId", feeDto1.getFeeId());
            //1003006 周期性费用  2006012 一次性费用  4012024 间接性费用
            //todo 这里一次性费用还是要恢复成 再用状态 不然会让 物业感觉懵逼,让他自己手工点击结束去
            //if ("2006012".equals(feeDto1.getFeeFlag()) || "888800010006".equals(feeDto1.getFeeTypeCd())) { //888800010006 押金
            if ("888800010006".equals(feeDto1.getFeeTypeCd())) { //888800010006 押金
            if (FeeDto.FEE_FLAG_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) { //888800010006 押金
                reqJson.put("state", "2009001"); //2007001 收费未开始  2008001 有效  2009001 收费结束
            } else {
                reqJson.put("state", "2008001");
@@ -352,37 +357,37 @@
            }
            if ("1003".equals(param.getString("state"))) {
                //积分账户抵扣比例
                BigDecimal deductionProportion = new BigDecimal(CommunitySettingFactory.getValue(reqJson.getString("communityId"), DEDUCTION_PROPORTION));
                BigDecimal returnAmount1 = new BigDecimal(returnAmount);
                BigDecimal money = returnAmount1.multiply(deductionProportion);
                accountDto.setAcctType(AccountDto.ACCT_TYPE_INTEGRAL); //2004  积分账户
                List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
                Assert.listOnlyOne(accountDtos, "查询业主积分账户错误!");
                BigDecimal amount = new BigDecimal(accountDtos.get(0).getAmount());
                BigDecimal newAmount = amount.add(money);
                AccountPo accountPo = new AccountPo();
                accountPo.setAcctId(accountDtos.get(0).getAcctId());
                accountPo.setAmount(String.valueOf(newAmount));
                int flag = accountInnerServiceSMOImpl.updateAccount(accountPo);
                if (flag < 1) {
                    throw new IllegalArgumentException("更新业主积分账户失败!");
                }
                AccountDetailPo accountDetailPo = new AccountDetailPo();
                accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
                accountDetailPo.setAcctId(accountDtos.get(0).getAcctId());
                accountDetailPo.setDetailType("1001"); //1001 转入 2002 转出
                accountDetailPo.setRelAcctId("-1");
                accountDetailPo.setAmount(money.toString());
                accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
                accountDetailPo.setObjId(ownerId);
                accountDetailPo.setOrderId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orderId));
                accountDetailPo.setbId("-1");
                accountDetailPo.setRemark("积分账户退费");
                accountDetailPo.setCreateTime(new Date());
                int i = accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
                if (i < 1) {
                    throw new IllegalArgumentException("保存业主积分账户明细失败!");
                }
//                BigDecimal deductionProportion = new BigDecimal(CommunitySettingFactory.getValue(reqJson.getString("communityId"), DEDUCTION_PROPORTION));
//                BigDecimal returnAmount1 = new BigDecimal(returnAmount);
//                BigDecimal money = returnAmount1.multiply(deductionProportion);
//                accountDto.setAcctType(AccountDto.ACCT_TYPE_INTEGRAL); //2004  积分账户
//                List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
//                Assert.listOnlyOne(accountDtos, "查询业主积分账户错误!");
//                BigDecimal amount = new BigDecimal(accountDtos.get(0).getAmount());
//                BigDecimal newAmount = amount.add(money);
//                AccountPo accountPo = new AccountPo();
//                accountPo.setAcctId(accountDtos.get(0).getAcctId());
//                accountPo.setAmount(String.valueOf(newAmount));
//                int flag = accountInnerServiceSMOImpl.updateAccount(accountPo);
//                if (flag < 1) {
//                    throw new IllegalArgumentException("更新业主积分账户失败!");
//                }
//                AccountDetailPo accountDetailPo = new AccountDetailPo();
//                accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
//                accountDetailPo.setAcctId(accountDtos.get(0).getAcctId());
//                accountDetailPo.setDetailType("1001"); //1001 转入 2002 转出
//                accountDetailPo.setRelAcctId("-1");
//                accountDetailPo.setAmount(money.toString());
//                accountDetailPo.setObjType("6006"); //6006 个人 7007 商户
//                accountDetailPo.setObjId(ownerId);
//                accountDetailPo.setOrderId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orderId));
//                accountDetailPo.setbId("-1");
//                accountDetailPo.setRemark("积分账户退费");
//                accountDetailPo.setCreateTime(new Date());
//                int i = accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo);
//                if (i < 1) {
//                    throw new IllegalArgumentException("保存业主积分账户明细失败!");
//                }
            }