| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | |
| | | |
| | | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | String userId = context.getReqHeaders().get("user-id"); |
| | | UserDto userDto = new UserDto(); |
| | |
| | | |
| | | List<PayFeeDetailMonthDto> payFeeDetailMonthDtos = (List<PayFeeDetailMonthDto>) reqJson.get("payFeeDetailMonthDtos"); |
| | | |
| | | Calendar createTimeCal = Calendar.getInstance(); |
| | | |
| | | Map<String, FeeDto> feeDtoMap = new HashMap<>(); |
| | | |
| | | JSONArray details = new JSONArray(); |
| | | for (PayFeeDetailMonthDto payFeeDetailMonthDto : payFeeDetailMonthDtos) { |
| | | // todo 费用只查一次提高 效率 |
| | | if (!feeDtoMap.containsKey(payFeeDetailMonthDto.getFeeId())) { |
| | | //todo 查询费用是否存在 |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(payFeeDetailMonthDto.getFeeId()); |
| | | feeDto.setCommunityId(payFeeDetailMonthDto.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | if (feeDtos == null || feeDtos.size() != 1) { |
| | | throw new CmdException("费用不存在"); |
| | | } |
| | | feeDtoMap.put(payFeeDetailMonthDto.getFeeId(), feeDtos.get(0)); |
| | | } |
| | | createTimeCal.add(Calendar.SECOND, 1); |
| | | try { |
| | | doMonthFee(payFeeDetailMonthDto, context, userDtos.get(0), reqJson); |
| | | doMonthFee(payFeeDetailMonthDto, context, userDtos.get(0), reqJson, createTimeCal.getTime(), feeDtoMap); |
| | | } catch (Exception e) { |
| | | logger.error("处理异常", e); |
| | | throw new CmdException(e.getMessage()); |
| | |
| | | * @param userDto |
| | | * @param reqJson |
| | | */ |
| | | private void doMonthFee(PayFeeDetailMonthDto payFeeDetailMonthDto, ICmdDataFlowContext context, UserDto userDto, JSONObject reqJson) { |
| | | private void doMonthFee(PayFeeDetailMonthDto payFeeDetailMonthDto, ICmdDataFlowContext context, UserDto userDto, JSONObject reqJson, Date createTime, Map<String, FeeDto> feeDtoMap) { |
| | | //todo 计算结束时间 |
| | | Date startTime = DateUtil.getDateFromStringB(payFeeDetailMonthDto.getCurMonthTime()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | calendar.add(Calendar.MONTH, 1); |
| | | String endTime = DateUtil.getFormatTimeStringB(calendar.getTime()); |
| | | |
| | | //todo 查询费用是否存在 |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(payFeeDetailMonthDto.getFeeId()); |
| | | feeDto.setCommunityId(payFeeDetailMonthDto.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | if (feeDtos == null || feeDtos.size() != 1) { |
| | | throw new CmdException("费用不存在"); |
| | | } |
| | | |
| | | //获取订单ID |
| | | String oId = Java110TransactionalFactory.getOId(); |
| | |
| | | } |
| | | payFeeDetailPo.setPayOrderId(oId); |
| | | payFeeDetailPo.setEndTime(endTime); |
| | | // todo 按月交费时 主要按时间顺序排序时 能够整齐 |
| | | payFeeDetailPo.setCreateTime(DateUtil.getFormatTimeStringA(createTime)); |
| | | |
| | | int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("缴费失败"); |
| | | } |
| | | payFeePo = modifyFee(payFeeDetailMonthDto, reqJson, feeDtos.get(0), endTime); |
| | | payFeePo = modifyFee(payFeeDetailMonthDto, reqJson, feeDtoMap.get(payFeeDetailMonthDto.getFeeId()), endTime); |
| | | |
| | | flag = payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo); |
| | | if (flag < 1) { |
| | |
| | | payFeeDetailMonthDto.setDetailId(payFeeDetailPo.getDetailId()); |
| | | |
| | | } finally { |
| | | DistributedLock.releaseDistributedLock(requestId, key); |
| | | DistributedLock.releaseDistributedLock(key, requestId); |
| | | } |
| | | //车辆延期 |
| | | updateOwnerCarEndTime(payFeePo, reqJson, feeDtos.get(0)); |
| | | updateOwnerCarEndTime(payFeePo, reqJson, feeDtoMap.get(payFeeDetailMonthDto.getFeeId())); |
| | | |
| | | //处理报修单 |
| | | doDealRepairOrder(payFeeDetailMonthDto, feeDtos.get(0)); |
| | | doDealRepairOrder(payFeeDetailMonthDto, feeDtoMap.get(payFeeDetailMonthDto.getFeeId())); |
| | | |
| | | |
| | | } |
| | |
| | | for (PayFeeDetailMonthDto tmpFeeDetailMonthDto : feeDetailMonthDtos) { |
| | | if (Integer.parseInt(tmpFeeDetailMonthDto.getDetailYear()) <= Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailYear()) |
| | | && Integer.parseInt(tmpFeeDetailMonthDto.getDetailMonth()) < Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailMonth())) { |
| | | throw new CmdException("未连续缴费,请选择" + tmpFeeDetailMonthDto.getDetailYear() + "-" + tmpFeeDetailMonthDto.getDetailMonth() + " ," + tmpFeeDetailMonthDto.getFeeName()); |
| | | throw new CmdException("未连续缴费,请选择" + tmpFeeDetailMonthDto.getDetailYear() + "-" + tmpFeeDetailMonthDto.getDetailMonth() |
| | | + " ," + tmpPayFeeDetailMonthDto.getFeeName()); |
| | | } |
| | | if (Integer.parseInt(tmpFeeDetailMonthDto.getDetailYear()) == Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailYear()) |
| | | && Integer.parseInt(tmpFeeDetailMonthDto.getDetailMonth()) == Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailMonth())) { |