| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.BaseParamMapper; |
| | | import com.doumee.dao.business.PricingDetailMapper; |
| | | import com.doumee.dao.business.PricingParamMapper; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | import com.doumee.dao.business.model.PricingDetail; |
| | | import com.doumee.dao.business.model.PricingParam; |
| | | import com.doumee.service.business.PricingParamService; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 定价方案配置Service实现 |
| | |
| | | |
| | | @Autowired |
| | | private PricingDetailMapper pricingDetailMapper; |
| | | |
| | | @Autowired |
| | | private BaseParamMapper baseParamMapper; |
| | | |
| | | @Override |
| | | public String create(PricingParam pricingParam) { |
| | |
| | | .set(PricingParam::getName,pricingParam.getName()) |
| | | // .set(PricingParam::getStatus,pricingParam.getStatus()) |
| | | .set(PricingParam::getStartDate,pricingParam.getStartDate()) |
| | | .set(PricingParam::getEndDate,pricingParam.getEndDate()) |
| | | .set(PricingParam::getEndDate,Utils.Date.getDayOfEnd(pricingParam.getEndDate())) |
| | | .set(PricingParam::getSortnum,pricingParam.getSortnum()); |
| | | pricingParamMapper.update(null,wrapper); |
| | | } |
| | |
| | | wrapper.lambda() |
| | | .eq(PricingDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(PricingDetail::getPricePramId,pricingParam.getId()); |
| | | Integer integer = pricingDetailMapper.selectCount(wrapper); |
| | | if (integer == 0 ){ |
| | | List<PricingDetail> pricingDetails = pricingDetailMapper.selectList(wrapper); |
| | | QueryWrapper<BaseParam> baseParamQuery = new QueryWrapper<>(); |
| | | baseParamQuery.lambda() |
| | | .eq(BaseParam::getIsdeleted,Constants.ZERO) |
| | | .eq(BaseParam::getType,Constants.THREE); |
| | | List<BaseParam> baseParams = baseParamMapper.selectList(baseParamQuery); |
| | | if (CollectionUtils.isEmpty(pricingDetails)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该定价方案下没有配置价格"); |
| | | } |
| | | List<String> collect = pricingDetails.stream().map(s -> s.getBikeTypeId()).collect(Collectors.toList()); |
| | | boolean b = baseParams.stream().map(s -> s.getId()).allMatch(s -> collect.contains(s)); |
| | | |
| | | if (!b){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该定价方案下没有配置完整"); |
| | | } |
| | | PricingParam pricingParam1 = new PricingParam(); |
| | | pricingParam1.setId(pricingParam.getId()); |
| | | pricingParam1.setStatus(pricingParam.getStatus()); |