| | |
| | | @Override |
| | | public String create(PricingDetail pricingDetail) { |
| | | |
| | | if ((pricingDetail.getBaseTime() < 0) && |
| | | Objects.isNull(pricingDetail.getBasePrice())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"一口价价格不可为空"); |
| | | } |
| | | |
| | | if ((pricingDetail.getBaseTime() > 0) && |
| | | (Objects.isNull(pricingDetail.getBasePrice()) |
| | | || Objects.isNull(pricingDetail.getUnitTime()) |
| | | || Objects.isNull(pricingDetail.getUnitPrice()))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"阶梯定价参数不可为空"); |
| | | } |
| | | |
| | | if ( Objects.isNull(pricingDetail.getBasePrice()) && (pricingDetail.getHolidayBasePrice().compareTo(BigDecimal.ZERO)<Constants.ZERO) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"节假一口价价格不可为空"); |
| | | } |
| | | |
| | | if ((Objects.isNull(pricingDetail.getHolidayBasePrice()) |
| | | || Objects.isNull(pricingDetail.getHolidayBasePrice()) |
| | | || Objects.isNull(pricingDetail.getHolidayBasePrice()))&&(pricingDetail.getHolidayBasePrice().compareTo(BigDecimal.ZERO)>Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"节假阶梯定价参数不可为空"); |
| | | } |
| | | checkPricingDetail(pricingDetail); |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | PricingDetail insert = new PricingDetail(); |
| | | insert.setCreateDate(new Date()); |
| | |
| | | return pricingDetail.getId(); |
| | | } |
| | | |
| | | private void checkPricingDetail(PricingDetail pricingDetail){ |
| | | if ((Objects.nonNull(pricingDetail.getBaseTime()) && pricingDetail.getBaseTime() < 0) && |
| | | Objects.isNull(pricingDetail.getBasePrice())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"一口价价格不可为空"); |
| | | } |
| | | |
| | | if ((Objects.nonNull(pricingDetail.getBaseTime()) && pricingDetail.getBaseTime() > 0) && |
| | | (Objects.isNull(pricingDetail.getBasePrice()) |
| | | || Objects.isNull(pricingDetail.getUnitTime()) |
| | | || Objects.isNull(pricingDetail.getUnitPrice()))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"阶梯定价参数不可为空"); |
| | | } |
| | | |
| | | if ( (Objects.nonNull(pricingDetail.getHolidayBaseTime()) && pricingDetail.getHolidayBaseTime() < 0) |
| | | && ( Objects.isNull(pricingDetail.getHolidayBasePrice())) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"节假一口价价格不可为空"); |
| | | } |
| | | |
| | | if (((Objects.nonNull(pricingDetail.getHolidayBaseTime()) && pricingDetail.getHolidayBaseTime() > 0)) |
| | | && (Objects.isNull(pricingDetail.getHolidayBasePrice()) |
| | | || Objects.isNull(pricingDetail.getHolidayUnitTime()) |
| | | || Objects.isNull(pricingDetail.getHolidayUnitPrice()))){ |
| | | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"节假阶梯定价参数不可为空"); |
| | | } |
| | | |
| | | QueryWrapper<PricingDetail> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(PricingDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(PricingDetail::getBikeTypeId,pricingDetail.getBikeTypeId()) |
| | | .eq(PricingDetail::getPricePramId,pricingDetail.getPricePramId()); |
| | | Integer exitCount = pricingDetailMapper.selectCount(wrapper); |
| | | |
| | | if (exitCount > Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该车型已配置"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | pricingDetailMapper.deleteById(id); |
| | |
| | | |
| | | @Override |
| | | public void updateById(PricingDetail pricingDetail) { |
| | | checkPricingDetail(pricingDetail); |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | pricingDetail.setEditDate(new Date()); |
| | | pricingDetail.setEditor(principal.getId()); |
| | | pricingDetailMapper.updateById(pricingDetail); |
| | | } |
| | | |