| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.CmdContextUtils; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | |
| | | import com.java110.core.smo.IComputeFeeSMO; |
| | | import com.java110.dto.account.AccountDto; |
| | | import com.java110.dto.account.AccountDetailDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.fee.FeeReceiptDetailDto; |
| | | import com.java110.dto.fee.*; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.parking.ParkingSpaceDto; |
| | | import com.java110.dto.repair.RepairDto; |
| | | import com.java110.dto.repair.RepairUserDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.intf.acct.IAccountDetailInnerServiceSMO; |
| | | import com.java110.fee.smo.impl.FeeReceiptInnerServiceSMOImpl; |
| | | import com.java110.intf.acct.IAccountInnerServiceSMO; |
| | | import com.java110.intf.acct.ICouponUserDetailV1InnerServiceSMO; |
| | | import com.java110.intf.acct.ICouponUserV1InnerServiceSMO; |
| | | import com.java110.intf.community.*; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.fee.IFeeAccountDetailServiceSMO; |
| | |
| | | import com.java110.po.owner.RepairUserPo; |
| | | import com.java110.po.payFee.PayFeeDetailDiscountPo; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.FeeFlagTypeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.lock.DistributedLock; |
| | | 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 com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private IFeeAttrInnerServiceSMO feeAttrInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRoomInnerServiceSMO roomInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeReceiptDetailInnerServiceSMO feeReceiptDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRepairUserInnerServiceSMO repairUserInnerServiceSMO; |
| | |
| | | |
| | | @Autowired |
| | | private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IAccountInnerServiceSMO accountInnerServiceSMOImpl; |
| | |
| | | private IRepairUserV1InnerServiceSMO repairUserNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICouponUserDetailV1InnerServiceSMO couponUserDetailV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private FeeReceiptInnerServiceSMOImpl feeReceiptInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeDiscountInnerServiceSMO feeDiscountInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | |
| | | Assert.jsonObjectHaveKey(reqJson, "cycles", "请求报文中未包含cycles节点"); |
| | | Assert.jsonObjectHaveKey(reqJson, "receivedAmount", "请求报文中未包含receivedAmount节点"); |
| | | Assert.jsonObjectHaveKey(reqJson, "feeId", "请求报文中未包含feeId节点"); |
| | | |
| | | Assert.hasLength(reqJson.getString("communityId"), "小区ID不能为空"); |
| | | Assert.hasLength(reqJson.getString("cycles"), "周期不能为空"); |
| | | Assert.hasLength(reqJson.getString("receivedAmount"), "实收金额不能为空"); |
| | | Assert.hasLength(reqJson.getString("feeId"), "费用ID不能为空"); |
| | | |
| | | //判断是否 费用状态为缴费结束 |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(reqJson.getString("feeId")); |
| | |
| | | feeDto = feeDtos.get(0); |
| | | |
| | | if (FeeDto.STATE_FINISH.equals(feeDto.getState())) { |
| | | throw new IllegalArgumentException("收费已经结束,不能再缴费"); |
| | | throw new CmdException("收费已经结束,不能再缴费"); |
| | | } |
| | | |
| | | Date endTime = feeDto.getEndTime(); |
| | |
| | | feeConfigDto.setConfigId(feeDto.getConfigId()); |
| | | feeConfigDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | |
| | | if (feeConfigDtos == null || feeConfigDtos.size() != 1) { |
| | | throw new IllegalArgumentException("费用项不存在"); |
| | | if (ListUtil.isNull(feeConfigDtos)) { |
| | | throw new CmdException("费用项不存在"); |
| | | } |
| | | //一次性费用 和间接性费用 |
| | | // 获取费用结束时间 |
| | | Date maxEndTime = feeDtos.get(0).getDeadlineTime(); |
| | | //周期性费用 |
| | | if (maxEndTime == null || FeeDto.FEE_FLAG_CYCLE.equals(feeConfigDtos.get(0).getFeeFlag())) { |
| | | if (maxEndTime == null) { |
| | | maxEndTime = DateUtil.getDateFromStringA(feeConfigDtos.get(0).getEndTime()); |
| | | } |
| | | |
| | | if (maxEndTime != null && endTime != null && !FeeDto.FEE_FLAG_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) { |
| | | if (maxEndTime != null && endTime != null && !FeeDto.FEE_FLAG_ONCE.equals(feeDtos.get(0).getFeeFlag())) { |
| | | Date newDate = DateUtil.stepMonth(endTime, reqJson.getDouble("cycles").intValue()); |
| | | if (newDate.getTime() > maxEndTime.getTime()) { |
| | | throw new IllegalArgumentException("缴费周期超过 缴费结束时间,请用按结束时间方式缴费"); |
| | | } |
| | | } |
| | | |
| | | String selectUserAccount = reqJson.getString("selectUserAccount"); |
| | | JSONArray params = JSONArray.parseArray(selectUserAccount); |
| | | for (int paramIndex = 0; paramIndex < params.size(); paramIndex++) { |
| | | JSONObject param = params.getJSONObject(paramIndex); |
| | | JSONArray selectUserAccount = reqJson.getJSONArray("selectUserAccount"); |
| | | for (int paramIndex = 0; paramIndex < selectUserAccount.size(); paramIndex++) { |
| | | JSONObject param = selectUserAccount.getJSONObject(paramIndex); |
| | | String maximumNumber = param.getString("maximumNumber"); |
| | | } |
| | | |
| | | |
| | | //todo 是否按缴费时间段缴费 |
| | | validateIfPayFeeStartEndDate(reqJson, feeConfigDtos.get(0)); |
| | | |
| | | //todo 校验 优惠 |
| | | JSONArray selectDiscounts = reqJson.getJSONArray("selectDiscount"); |
| | | if (!ListUtil.isNull(selectDiscounts)) { |
| | | for (int discountIndex = 0; discountIndex < selectDiscounts.size(); discountIndex++) { |
| | | JSONObject param = selectDiscounts.getJSONObject(discountIndex); |
| | | Assert.hasKeyAndValue(param, "discountId", "未包含优惠ID"); |
| | | Assert.hasKeyAndValue(param, "discountPrice", "未包含优惠金额"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject paramObj) throws CmdException { |
| | | logger.debug("paramObj : {}", paramObj); |
| | | |
| | | String userId = cmdDataFlowContext.getReqHeaders().get("user-id"); |
| | | logger.debug("paramObj : {}", paramObj); |
| | | String payOrderId = paramObj.getString("payOrderId"); |
| | | |
| | | String userId = CmdContextUtils.getUserId(cmdDataFlowContext); |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(userId); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | Assert.listOnlyOne(userDtos, "用户未登录"); |
| | | |
| | | String cycle = paramObj.getString("cycle"); |
| | | String cycles = paramObj.getString("cycles"); |
| | | Date endTime = null; |
| | | |
| | | //todo 生成收据编号 |
| | | String receiptCode = feeReceiptInnerServiceSMOImpl.generatorReceiptCode(paramObj.getString("communityId")); |
| | | |
| | | PayFeePo payFeePo = null; |
| | | String requestId = DistributedLock.getLockUUID(); |
| | |
| | | FeeDto feeInfo = (FeeDto) paramObj.get("feeInfo"); |
| | | endTime = feeInfo.getEndTime(); |
| | | feeDetail.put("payableAmount", feeDetail.getString("receivableAmount")); |
| | | //todo 封装 修改费用时间报文 |
| | | JSONObject fee = modifyFee(paramObj); |
| | | payFeePo = BeanConvertUtil.covertBean(fee, PayFeePo.class); |
| | | |
| | | PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(feeDetail, PayFeeDetailPo.class); |
| | | payFeeDetailPo.setReceivableAmount(feeDetail.getString("totalFeePrice")); |
| | | //判断是否有赠送规则 |
| | | hasDiscount(paramObj, payFeePo, payFeeDetailPo); |
| | | //todo 缓存收据编号 |
| | | CommonCache.setValue(payFeeDetailPo.getDetailId() + CommonCache.RECEIPT_CODE, receiptCode, CommonCache.DEFAULT_EXPIRETIME_TWO_MIN); |
| | | |
| | | //todo 封装 修改费用时间报文 |
| | | JSONObject fee = modifyFee(paramObj, payFeeDetailPo); |
| | | payFeePo = BeanConvertUtil.covertBean(fee, PayFeePo.class); |
| | | |
| | | //todo 判断是否有折扣规则 |
| | | hasDiscount(paramObj, payFeePo, payFeeDetailPo, feeInfo); |
| | | |
| | | // todo 处理用户账户 |
| | | dealUserAccount(paramObj, payFeeDetailPo); |
| | | |
| | | |
| | | String oId = Java110TransactionalFactory.getOId(); |
| | | if (StringUtil.isEmpty(oId)) { |
| | |
| | | } |
| | | |
| | | payFeeDetailPo.setPayOrderId(oId); |
| | | // todo 如果 扫码枪支付 输入支付订单ID |
| | | if (!StringUtil.isEmpty(payOrderId)) { |
| | | payFeeDetailPo.setPayOrderId(payOrderId); |
| | | } |
| | | payFeeDetailPo.setCashierId(userDtos.get(0).getUserId()); |
| | | payFeeDetailPo.setCashierName(userDtos.get(0).getName()); |
| | | payFeeDetailPo.setOpenInvoice("N"); |
| | | |
| | | if (!StringUtil.isEmpty(paramObj.getString("cashAmount"))) { |
| | | BigDecimal cashAmount = new BigDecimal(paramObj.getString("cashAmount")).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | if (!StringUtil.isEmpty(payFeeDetailPo.getRemark())) { |
| | | payFeeDetailPo.setRemark(payFeeDetailPo.getRemark() + ",现金账户抵扣" + cashAmount + "元"); |
| | | } else { |
| | | payFeeDetailPo.setRemark("现金账户抵扣" + cashAmount + "元"); |
| | | } |
| | | } |
| | | int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("缴费失败"); |
| | |
| | | throw new CmdException("缴费失败"); |
| | | } |
| | | // todo 如果是按 自定义时间段缴费,这里补一条缴费记录 和 欠费费用 |
| | | ifCustomStartEndTimePayFee(cycle, endTime, payFeeDetailPo, payFeePo, paramObj); |
| | | ifCustomStartEndTimePayFee(cycles, endTime, payFeeDetailPo, payFeePo, paramObj); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | DistributedLock.releaseDistributedLock(key, requestId); |
| | | } |
| | | //账户处理 |
| | | //todo 账户处理 |
| | | dealAccount(paramObj); |
| | | //折扣管理 |
| | | if (paramObj.containsKey("selectDiscount")) { |
| | | JSONObject discountBusiness = null; |
| | | JSONArray selectDiscounts = paramObj.getJSONArray("selectDiscount"); |
| | | for (int discountIndex = 0; discountIndex < selectDiscounts.size(); discountIndex++) { |
| | | JSONObject param = selectDiscounts.getJSONObject(discountIndex); |
| | | addPayFeeDetailDiscount(paramObj, param); |
| | | } |
| | | } |
| | | |
| | | //为停车费单独处理 |
| | | |
| | | //todo 为停车费单独处理 |
| | | updateCarEndTime(paramObj); |
| | | |
| | | //处理报修单 |
| | | //todo 处理报修单 |
| | | doDealRepairOrder(paramObj); |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //根据明细ID 查询收据信息 |
| | | FeeReceiptDetailDto feeReceiptDetailDto = new FeeReceiptDetailDto(); |
| | | feeReceiptDetailDto.setDetailId(paramObj.getString("detailId")); |
| | |
| | | private void dealUserAccount(JSONObject paramObj, PayFeeDetailPo payFeeDetailPo) { |
| | | //判断选择的账号 |
| | | JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount"); |
| | | if (jsonArray == null || jsonArray.size() < 1) { |
| | | if (ListUtil.isNull(jsonArray)) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal integralSum = new BigDecimal(0); |
| | | BigDecimal cashSum = new BigDecimal(0); |
| | | |
| | | for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) { |
| | | JSONObject param = jsonArray.getJSONObject(columnIndex); |
| | | //账户金额 |
| | | BigDecimal amount = new BigDecimal(param.getString("amount")); |
| | | if (AccountDto.ACCT_TYPE_INTEGRAL.equals(param.getString("acctType"))) { //积分账户 |
| | | //获取最大抵扣积分 |
| | | 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"); |
| | | //生成抵扣明细记录 |
| | | if (flag2 == -1) { //积分换算金额小于实付金额 |
| | | subtract = receivedAmount.subtract(divide); |
| | | } else if (flag < 1) { //积分换算金额小于等于实付金额 |
| | | subtract = receivedAmount.subtract(divide); |
| | | } |
| | | integralSum = integralSum.add(subtract); |
| | | payFeeDetailPo.setReceivedAmount(subtract.toString()); |
| | | } else if (AccountDto.ACCT_TYPE_CASH.equals(param.getString("acctType"))) { //现金账户 |
| | | //实收金额 |
| | | 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; |
| | | } |
| | | cashSum = cashSum.add(redepositAmount); |
| | | |
| | | //实收金额 |
| | | 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; |
| | | } |
| | | cashSum = cashSum.add(redepositAmount); |
| | | |
| | | // todo 如果积分大于0 |
| | | if (integralSum.doubleValue() > 0) { |
| | | FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); |
| | | feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); |
| | | feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); |
| | | feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); |
| | | feeAccountDetailPo.setAmount(integralSum.doubleValue() + ""); |
| | | feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 |
| | | feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); |
| | | } |
| | | if (cashSum.doubleValue() > 0) { |
| | | //生成抵扣明细记录 |
| | | FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); |
| | |
| | | BigDecimal receivedAmountDec = new BigDecimal(payFeeDetailPo.getReceivedAmount()); |
| | | receivedAmountDec = receivedAmountDec.subtract(cashSum); |
| | | payFeeDetailPo.setReceivedAmount(receivedAmountDec.doubleValue() + ""); |
| | | payFeeDetailPo.setAcctAmount(cashSum.doubleValue() + ""); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param payFeeDetailPo |
| | | * @throws ParseException |
| | | */ |
| | | private void hasDiscount(JSONObject paramObj, PayFeePo payFeePo, PayFeeDetailPo payFeeDetailPo) throws ParseException { |
| | | private void hasDiscount(JSONObject paramObj, PayFeePo payFeePo, PayFeeDetailPo payFeeDetailPo, FeeDto feeDto) throws ParseException { |
| | | if (!paramObj.containsKey("selectDiscount")) { |
| | | return; |
| | | } |
| | | JSONArray selectDiscount = paramObj.getJSONArray("selectDiscount"); |
| | | JSONArray selectDiscounts = paramObj.getJSONArray("selectDiscount"); |
| | | |
| | | if (selectDiscount == null || selectDiscount.size() < 1) { |
| | | if (ListUtil.isNull(selectDiscounts)) { |
| | | return; |
| | | } |
| | | for (int index = 0; index < selectDiscount.size(); index++) { |
| | | JSONObject paramJson = selectDiscount.getJSONObject(index); |
| | | Map feePriceMap = computeFeeSMOImpl.getFeePrice(feeDto); |
| | | for (int index = 0; index < selectDiscounts.size(); index++) { |
| | | JSONObject paramJson = selectDiscounts.getJSONObject(index); |
| | | if (!"102020008".equals(paramJson.getString("ruleId"))) { //赠送规则 |
| | | continue; |
| | | } |
| | | JSONArray feeDiscountSpecs = paramJson.getJSONArray("feeDiscountSpecs"); |
| | | if (feeDiscountSpecs == null || feeDiscountSpecs.size() < 1) { |
| | | if (ListUtil.isNull(feeDiscountSpecs)) { |
| | | continue; |
| | | } |
| | | for (int specIndex = 0; specIndex < feeDiscountSpecs.size(); specIndex++) { |
| | |
| | | cal.add(Calendar.MONTH, Integer.parseInt(specValue)); |
| | | payFeeDetailPo.setEndTime(df.format(cal.getTime())); |
| | | payFeePo.setEndTime(df.format(cal.getTime())); |
| | | |
| | | BigDecimal value = new BigDecimal(payFeeDetailPo.getGiftAmount()); |
| | | value = value.add(new BigDecimal(specValue).multiply(new BigDecimal(feePriceMap.get("feePrice").toString()))); |
| | | payFeeDetailPo.setGiftAmount(value.doubleValue() + ""); |
| | | } |
| | | } |
| | | |
| | | for (int discountIndex = 0; discountIndex < selectDiscounts.size(); discountIndex++) { |
| | | JSONObject param = selectDiscounts.getJSONObject(discountIndex); |
| | | addPayFeeDetailDiscount(paramObj, param, payFeeDetailPo); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | feeDto.setCommunityId(paramObj.getString("communityId")); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | |
| | | if (feeDtos == null || feeDtos.size() < 1) { |
| | | if (ListUtil.isNull(feeDtos)) { |
| | | return; |
| | | } |
| | | if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDtos.get(0).getPayerObjType())) { |
| | |
| | | OwnerCarDto ownerCarDto = new OwnerCarDto(); |
| | | ownerCarDto.setCommunityId(paramObj.getString("communityId")); |
| | | ownerCarDto.setCarId(feeDtos.get(0).getPayerObjId()); |
| | | ownerCarDto.setCarTypeCd("1001"); //业主车辆 |
| | | //ownerCarDto.setCarTypeCd("1001"); //业主车辆 |
| | | List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto); |
| | | |
| | | if (ownerCarDtos == null || ownerCarDtos.size() < 1) { |
| | | if (ListUtil.isNull(ownerCarDtos)) { |
| | | return; |
| | | } |
| | | //获取车位id |
| | |
| | | * @param paramInJson 接口调用放传入入参 |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public void addPayFeeDetailDiscount(JSONObject paramInJson, JSONObject discountJson) { |
| | | public void addPayFeeDetailDiscount(JSONObject paramInJson, JSONObject discountJson, PayFeeDetailPo payFeeDetailPo) { |
| | | JSONObject businessFee = new JSONObject(); |
| | | businessFee.put("detailDiscountId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailDiscountId)); |
| | | businessFee.put("discountPrice", discountJson.getString("discountPrice")); |
| | |
| | | |
| | | if (fage < 1) { |
| | | throw new CmdException("更新费用信息失败"); |
| | | } |
| | | |
| | | FeeDiscountDto feeDiscountDto = new FeeDiscountDto(); |
| | | feeDiscountDto.setDiscountId(discountJson.getString("discountId")); |
| | | List<FeeDiscountDto> feeDiscountDtos = feeDiscountInnerServiceSMOImpl.queryFeeDiscounts(feeDiscountDto); |
| | | |
| | | if (ListUtil.isNull(feeDiscountDtos)) { |
| | | return; |
| | | } |
| | | |
| | | //todo 打折或者空置房打折 |
| | | if (FeeDiscountRuleDto.DISCOUNT_SMALL_TYPE_DISCOUNT.equals(feeDiscountDtos.get(0).getDiscountSmallType()) |
| | | || FeeDiscountRuleDto.DISCOUNT_SMALL_TYPE_APPLY_DISCOUNT.equals(feeDiscountDtos.get(0).getDiscountSmallType()) |
| | | ) { |
| | | BigDecimal value = new BigDecimal(payFeeDetailPo.getDiscountAmount()); |
| | | value = value.add(new BigDecimal(discountJson.getString("discountPrice"))); |
| | | payFeeDetailPo.setDiscountAmount(value.doubleValue() + ""); |
| | | } else if (FeeDiscountRuleDto.DISCOUNT_SMALL_TYPE_DEDUCTION.equals(feeDiscountDtos.get(0).getDiscountSmallType()) |
| | | || FeeDiscountRuleDto.DISCOUNT_SMALL_TYPE_APPLY_DEDUCTION.equals(feeDiscountDtos.get(0).getDiscountSmallType())) { |
| | | BigDecimal value = new BigDecimal(payFeeDetailPo.getDeductionAmount()); |
| | | value = value.add(new BigDecimal(discountJson.getString("discountPrice"))); |
| | | payFeeDetailPo.setDeductionAmount(value.doubleValue() + ""); |
| | | } else if (FeeDiscountRuleDto.DISCOUNT_SMALL_TYPE_LATE.equals(feeDiscountDtos.get(0).getDiscountSmallType())) { |
| | | BigDecimal value = new BigDecimal(payFeeDetailPo.getLateAmount()); |
| | | value = value.add(new BigDecimal(discountJson.getString("discountPrice"))); |
| | | payFeeDetailPo.setLateAmount(value.doubleValue() + ""); |
| | | } |
| | | } |
| | | |
| | |
| | | feeDto.setFeeId(paramInJson.getString("feeId")); |
| | | feeDto.setCommunityId(paramInJson.getString("communityId")); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | if (feeDtos == null || feeDtos.size() != 1) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据"); |
| | | if (ListUtil.isNull(feeDtos)) { |
| | | throw new CmdException("查询费用信息失败,未查到数据或查到多条数据"); |
| | | } |
| | | if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) { |
| | | businessFeeDetail.put("state", "1400"); |
| | | } |
| | | feeDto = feeDtos.get(0); |
| | | businessFeeDetail.put("startTime", DateUtil.getFormatTimeString(feeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A)); |
| | | int hours = 0; |
| | | businessFeeDetail.put("startTime", DateUtil.getFormatTimeStringA(feeDto.getEndTime())); |
| | | Date targetEndTime = null; |
| | | BigDecimal cycles = null; |
| | | Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto); |
| | | BigDecimal feePrice = new BigDecimal(feePriceAll.get("feePrice").toString()); |
| | | if ("-101".equals(paramInJson.getString("cycles"))) { // 自定义金额交费 |
| | | |
| | | if (PayFeeDataDto.TEMP_CYCLE_CUSTOM_AMOUNT.equals(paramInJson.getString("cycles"))) { // todo 自定义金额交费 |
| | | Date endTime = feeDto.getEndTime(); |
| | | Calendar endCalender = Calendar.getInstance(); |
| | | endCalender.setTime(endTime); |
| | | BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | cycles = receivedAmount.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN); |
| | | endCalender = getTargetEndTime(endCalender, cycles.doubleValue()); |
| | | targetEndTime = endCalender.getTime(); |
| | | targetEndTime = computeFeeSMOImpl.getTargetEndTime(cycles.doubleValue(), endCalender.getTime(), true); |
| | | paramInJson.put("tmpCycles", cycles.doubleValue()); |
| | | businessFeeDetail.put("cycles", cycles.doubleValue()); |
| | | //处理 可能还存在 实收手工减免的情况 |
| | |
| | | if (businessFeeDetail.getDoubleValue("receivableAmount") < receivedAmount.doubleValue()) { |
| | | businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue()); |
| | | } |
| | | } else if ("-103".equals(paramInJson.getString("cycles"))) { //这里按缴费结束时间缴费 |
| | | } else if (PayFeeDataDto.TEMP_CYCLE_CUSTOM_END_TIME.equals(paramInJson.getString("cycles"))) { //todo 这里按缴费结束时间缴费 |
| | | String custEndTime = paramInJson.getString("custEndTime"); |
| | | Date endDates = DateUtil.getDateFromStringB(custEndTime); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | targetEndTime = endDates; |
| | | if (!custEndTime.contains(":")) { |
| | | custEndTime += " 23:59:59"; |
| | | } |
| | | targetEndTime = DateUtil.getDateFromStringA(custEndTime); |
| | | |
| | | BigDecimal receivedAmount1 = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | cycles = receivedAmount1.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN); |
| | | paramInJson.put("tmpCycles", cycles.doubleValue()); |
| | |
| | | if (businessFeeDetail.getDoubleValue("receivableAmount") < receivedAmount.doubleValue()) { |
| | | businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue()); |
| | | } |
| | | } else if ("-105".equals(paramInJson.getString("cycles"))) { //这里按缴费结束时间缴费 |
| | | } else if ("-105".equals(paramInJson.getString("cycles"))) { //这里按自定义时间段 |
| | | String customEndTime = paramInJson.getString("customEndTime"); |
| | | Date endDates = DateUtil.getDateFromStringB(customEndTime); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | targetEndTime = endDates; |
| | | if (!customEndTime.contains(":")) { |
| | | customEndTime += " 23:59:59"; |
| | | } |
| | | targetEndTime = DateUtil.getDateFromStringA(customEndTime); |
| | | BigDecimal receivedAmount1 = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | cycles = receivedAmount1.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN); |
| | | paramInJson.put("tmpCycles", cycles.doubleValue()); |
| | |
| | | } |
| | | } |
| | | |
| | | businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(targetEndTime, DateUtil.DATE_FORMATE_STRING_A)); |
| | | businessFeeDetail.put("endTime", DateUtil.getFormatTimeStringA(targetEndTime)); |
| | | paramInJson.put("feeInfo", feeDto); |
| | | |
| | | return businessFeeDetail; |
| | | } |
| | | |
| | | public JSONObject modifyFee(JSONObject paramInJson) { |
| | | public JSONObject modifyFee(JSONObject paramInJson, PayFeeDetailPo payFeeDetailPo) { |
| | | |
| | | JSONObject businessFee = new JSONObject(); |
| | | FeeDto feeInfo = (FeeDto) paramInJson.get("feeInfo"); |
| | | Date endTime = feeInfo.getEndTime(); |
| | | Calendar endCalender = Calendar.getInstance(); |
| | | endCalender.setTime(endTime); |
| | | int hours = 0; |
| | | //-101自定义金额 -102自定义周期 -103 自定义结束时间 |
| | | if ("-101".equals(paramInJson.getString("cycles"))) { |
| | | endCalender = getTargetEndTime(endCalender, Double.parseDouble(paramInJson.getString("tmpCycles"))); |
| | | } else if ("-103".equals(paramInJson.getString("cycles"))) { |
| | | String custEndTime = paramInJson.getString("custEndTime"); |
| | | Date endDates = DateUtil.getDateFromStringB(custEndTime); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | endCalender.setTime(endDates); |
| | | } else if ("-105".equals(paramInJson.getString("cycles"))) { |
| | | String customEndTime = paramInJson.getString("customEndTime"); |
| | | Date endDates = DateUtil.getDateFromStringB(customEndTime); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | endCalender.setTime(endDates); |
| | | } else { |
| | | endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles"))); |
| | | } |
| | | if (FeeDto.FEE_FLAG_ONCE.equals(feeInfo.getFeeFlag())) { |
| | | if (feeInfo.getDeadlineTime() != null) { |
| | | endCalender.setTime(feeInfo.getDeadlineTime()); |
| | | } else if (!StringUtil.isEmpty(feeInfo.getCurDegrees())) { |
| | | endCalender.setTime(feeInfo.getCurReadingTime()); |
| | | } else if (feeInfo.getImportFeeEndTime() == null) { |
| | | endCalender.setTime(feeInfo.getConfigEndTime()); |
| | | } else { |
| | | endCalender.setTime(feeInfo.getImportFeeEndTime()); |
| | | } |
| | | //businessFee.put("state",FeeDto.STATE_FINISH); |
| | | feeInfo.setState(FeeDto.STATE_FINISH); |
| | | } |
| | | feeInfo.setEndTime(endCalender.getTime()); |
| | | Date maxEndTime = feeInfo.getDeadlineTime(); |
| | | if (FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())) { |
| | | maxEndTime = feeInfo.getConfigEndTime(); |
| | | } |
| | | |
| | | if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeInfo.getFeeFlag())) { |
| | | maxEndTime = feeInfo.getMaxEndTime(); |
| | | } |
| | | String endTime = DateUtil.getNextSecTime(payFeeDetailPo.getEndTime()); |
| | | feeInfo.setEndTime(DateUtil.getDateFromStringA(endTime)); |
| | | |
| | | //如果间歇性费用没有设置结束时间 则取费用项的 |
| | | Date maxEndTime = feeInfo.getMaxEndTime(); |
| | | if (maxEndTime == null) { |
| | | maxEndTime = feeInfo.getConfigEndTime(); |
| | | } |
| | |
| | | businessFee.put("state", FeeDto.STATE_FINISH); |
| | | businessFee.put("endTime", maxEndTime); |
| | | } |
| | | } else { |
| | | businessFee.put("state", FeeDto.STATE_FINISH); |
| | | } |
| | | return businessFee; |
| | | } |
| | |
| | | public void dealAccount(JSONObject paramObj) { |
| | | //判断选择的账号 |
| | | JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount"); |
| | | if (jsonArray == null || jsonArray.size() < 1) { |
| | | if (ListUtil.isNull(jsonArray)) { |
| | | return; |
| | | } |
| | | List<AccountDto> accountDtos = new ArrayList<>(); |
| | |
| | | BigDecimal receivedAmount = new BigDecimal(paramObj.getString("receivedAmount")); //实收款(扣款金额) |
| | | 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")); |
| | | //计算实收款所扣的积分 |
| | | BigDecimal multiply = receivedAmount.multiply(deductionProportion); |
| | | receivedAmount = multiply; |
| | | } |
| | | //账户金额 |
| | | BigDecimal amount = new BigDecimal(param.getString("amount")); |
| | | int flag = amount.compareTo(receivedAmount); |
| | |
| | | redepositAmount = amount;//抵扣金额 |
| | | } else { |
| | | redepositAmount = receivedAmount;//抵扣金额 |
| | | } |
| | | if ("2004".equals(param.getString("acctType"))) { |
| | | //获取最大抵扣积分 |
| | | 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) { //如果最大使用积分大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果最大使用积分大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = maximumNumber; |
| | | } |
| | | } |
| | | if (flag2 > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 |
| | | int flag3 = maximumNumber.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果最大使用积分大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果最大使用积分大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = maximumNumber; |
| | | } |
| | | } |
| | | if (flag2 == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = amount; |
| | | } |
| | | } |
| | | if (flag2 < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = amount; |
| | | } |
| | | } |
| | | if (flag2 == 0) { //账户积分等于最大使用积分 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | 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)) { |
| | |
| | | //查询账户金额 |
| | | accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto); |
| | | Assert.listOnlyOne(accountDtos, "查询账户金额错误!"); |
| | | if (accountDtos != null && accountDtos.size() > 0) { |
| | | if (!ListUtil.isNull(accountDtos)) { |
| | | AccountDto accountDto1 = accountDtos.get(0); |
| | | BigDecimal accountDto1Amount = new BigDecimal(accountDto1.getAmount()); |
| | | if (accountDto1Amount.compareTo(redepositAmount) == -1) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验是否按缴费时间段缴费 |
| | | * |
| | | * @param reqJson |
| | | * @param feeConfigDto |
| | | */ |
| | | private void validateIfPayFeeStartEndDate(JSONObject reqJson, FeeConfigDto feeConfigDto) { |
| | | if (!"-105".equals(reqJson.getString("cycles"))) { |
| | | return; |
| | | } |
| | | // todo 自己是间接性费用 |
| | | if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeConfigDto.getFeeFlag())) { |
| | | return; |
| | | } |
| | | |
| | | FeeConfigDto tmpFeeConfigDto = new FeeConfigDto(); |
| | | tmpFeeConfigDto.setFeeNameEq(feeConfigDto.getFeeName() + "欠费"); |
| | | tmpFeeConfigDto.setFeeFlag(FeeDto.FEE_FLAG_CYCLE_ONCE); |
| | | tmpFeeConfigDto.setComputingFormula(feeConfigDto.getComputingFormula()); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(tmpFeeConfigDto); |
| | | |
| | | Assert.listOnlyOne(feeConfigDtos, "按自定义时间段缴费时,费用必须为间接性费用,或者存在名称为 " + feeConfigDto.getFeeName() + "欠费 的间接性费用,它的公式计算必须要和" + feeConfigDto.getFeeName() + "一致"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义时间段 缴费 |
| | | * |
| | | * @param cycle |
| | | * @param cycles |
| | | * @param endTime |
| | | * @param payFeeDetailPo |
| | | * @param payFeePo |
| | | */ |
| | | private void ifCustomStartEndTimePayFee(String cycle, Date endTime, PayFeeDetailPo payFeeDetailPo, PayFeePo payFeePo, JSONObject reqJson) { |
| | | if (!"-105".equals(cycle)) { |
| | | private void ifCustomStartEndTimePayFee(String cycles, Date endTime, PayFeeDetailPo payFeeDetailPo, PayFeePo payFeePo, JSONObject reqJson) { |
| | | if (!"-105".equals(cycles)) { |
| | | return; |
| | | } |
| | | |
| | | //todo 如果是同一天不创建 |
| | | if (DateUtil.getFormatTimeStringB(endTime).equals(reqJson.getString("customStartTime"))) { |
| | | return; |
| | | } |
| | | |
| | |
| | | tmpPayFeeDetailPo.setPayableAmount("0"); |
| | | tmpPayFeeDetailPo.setStartTime(DateUtil.getFormatTimeStringB(endTime)); |
| | | tmpPayFeeDetailPo.setEndTime(reqJson.getString("customStartTime")); |
| | | tmpPayFeeDetailPo.setState(FeeDetailDto.STATE_OWE); |
| | | tmpPayFeeDetailPo.setOpenInvoice("N"); |
| | | tmpPayFeeDetailPo.setRemark("按缴费时间段缴费,这部分费用按欠费的方式重新生成,请在" + payObjNameRemark + "上查看"); |
| | | |
| | | if (!StringUtil.isEmpty(reqJson.getString("cashAmount"))) { |
| | | BigDecimal cashAmount = new BigDecimal(reqJson.getString("cashAmount")).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | if (!StringUtil.isEmpty(tmpPayFeeDetailPo.getRemark())) { |
| | | tmpPayFeeDetailPo.setRemark(tmpPayFeeDetailPo.getRemark() + ",现金账户抵扣" + cashAmount + "元"); |
| | | } else { |
| | | tmpPayFeeDetailPo.setRemark("现金账户抵扣" + cashAmount + "元"); |
| | | } |
| | | } |
| | | |
| | | int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(tmpPayFeeDetailPo); |
| | | |
| | | if (flag < 1) { |
| | |
| | | } |
| | | |
| | | //todo 生成费用 |
| | | PayFeePo tmpPayFeePo = BeanConvertUtil.covertBean(feeInfo, PayFeePo.class);; |
| | | PayFeePo tmpPayFeePo = BeanConvertUtil.covertBean(feeInfo, PayFeePo.class); |
| | | tmpPayFeePo.setFeeId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_feeId)); |
| | | tmpPayFeePo.setEndTime(DateUtil.getFormatTimeStringB(endTime)); |
| | | tmpPayFeePo.setState(FeeDto.STATE_DOING); |
| | | |
| | | // todo 处理configId |
| | | doChangeConfigId(tmpPayFeePo, feeInfo); |
| | | |
| | | |
| | | flag = payFeeV1InnerServiceSMOImpl.savePayFee(tmpPayFeePo); |
| | | if (flag < 1) { |
| | |
| | | feeAttrDto.setCommunityId(payFeePo.getCommunityId()); |
| | | List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto); |
| | | |
| | | if(feeAttrDtos == null || feeAttrDtos.size() < 1){ |
| | | if (feeAttrDtos == null || feeAttrDtos.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | List<FeeAttrPo> tmpFeeAttrPos = new ArrayList<>(); |
| | | FeeAttrPo tmpFeeAttrPo = null; |
| | | for(FeeAttrDto tmpFeeAttrDto: feeAttrDtos){ |
| | | boolean hasDeadLineTime = false; |
| | | for (FeeAttrDto tmpFeeAttrDto : feeAttrDtos) { |
| | | tmpFeeAttrDto.setFeeId(tmpPayFeePo.getFeeId()); |
| | | tmpFeeAttrDto.setAttrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId,true)); |
| | | tmpFeeAttrDto.setAttrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId, true)); |
| | | |
| | | if(FeeAttrDto.SPEC_CD_ONCE_FEE_DEADLINE_TIME.equals(tmpFeeAttrDto.getSpecCd())){ |
| | | if (FeeAttrDto.SPEC_CD_ONCE_FEE_DEADLINE_TIME.equals(tmpFeeAttrDto.getSpecCd())) { |
| | | tmpFeeAttrDto.setValue(reqJson.getString("customStartTime")); |
| | | hasDeadLineTime = true; |
| | | } |
| | | tmpFeeAttrPo = BeanConvertUtil.covertBean(tmpFeeAttrDto,FeeAttrPo.class); |
| | | tmpFeeAttrPo = BeanConvertUtil.covertBean(tmpFeeAttrDto, FeeAttrPo.class); |
| | | tmpFeeAttrPos.add(tmpFeeAttrPo); |
| | | } |
| | | //todo 没有结束时间时 |
| | | if (!hasDeadLineTime) { |
| | | tmpFeeAttrPo = new FeeAttrPo(); |
| | | tmpFeeAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId, true)); |
| | | tmpFeeAttrPo.setFeeId(tmpPayFeePo.getFeeId()); |
| | | tmpFeeAttrPo.setCommunityId(tmpFeeAttrPo.getCommunityId()); |
| | | tmpFeeAttrPo.setSpecCd(FeeAttrDto.SPEC_CD_ONCE_FEE_DEADLINE_TIME); |
| | | tmpFeeAttrPo.setValue(reqJson.getString("customStartTime")); |
| | | tmpFeeAttrPos.add(tmpFeeAttrPo); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | private static Calendar getTargetEndTime(Calendar endCalender, Double cycles) { |
| | | if (StringUtil.isInteger(cycles.toString())) { |
| | | endCalender.add(Calendar.MONTH, new Double(cycles).intValue()); |
| | | return endCalender; |
| | | /** |
| | | * 处理费用项ID |
| | | * |
| | | * @param tmpPayFeePo |
| | | * @param feeInfo |
| | | */ |
| | | private void doChangeConfigId(PayFeePo tmpPayFeePo, FeeDto feeInfo) { |
| | | FeeConfigDto feeConfigDto = new FeeConfigDto(); |
| | | feeConfigDto.setConfigId(feeInfo.getConfigId()); |
| | | feeConfigDto.setCommunityId(feeInfo.getCommunityId()); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | Assert.listOnlyOne(feeConfigDtos, "费用项不存在"); |
| | | if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) { |
| | | return; |
| | | } |
| | | if (cycles >= 1) { |
| | | endCalender.add(Calendar.MONTH, new Double(Math.floor(cycles)).intValue()); |
| | | cycles = cycles - Math.floor(cycles); |
| | | } |
| | | int futureDay = endCalender.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | int hours = new Double(cycles * futureDay * 24).intValue(); |
| | | endCalender.add(Calendar.HOUR, hours); |
| | | return endCalender; |
| | | |
| | | |
| | | FeeConfigDto tmpFeeConfigDto = new FeeConfigDto(); |
| | | tmpFeeConfigDto.setFeeNameEq(feeConfigDtos.get(0).getFeeName() + "欠费"); |
| | | tmpFeeConfigDto.setFeeFlag(FeeDto.FEE_FLAG_CYCLE_ONCE); |
| | | tmpFeeConfigDto.setComputingFormula(feeConfigDto.getComputingFormula()); |
| | | //todo 校验的时候校验过了 所以这里不可能为空 |
| | | feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(tmpFeeConfigDto); |
| | | |
| | | tmpPayFeePo.setConfigId(feeConfigDtos.get(0).getConfigId()); |
| | | } |
| | | |
| | | } |