| | |
| | | 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.join.PricingDetailJoinMapper; |
| | | import com.doumee.dao.business.model.BaseParam; |
| | | import com.doumee.dao.business.model.PricingDetail; |
| | | import com.doumee.service.business.BaseParamService; |
| | | import com.doumee.service.business.PricingDetailService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.collections.MapUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import sun.text.resources.et.CollationData_et; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 定价方案明细配置Service实现 |
| | |
| | | |
| | | @Autowired |
| | | PricingDetailJoinMapper pricingDetailJoinMapper; |
| | | |
| | | @Autowired |
| | | BaseParamMapper baseParamMapper; |
| | | |
| | | |
| | | @Override |
| | | public String create(PricingDetail pricingDetail) { |
| | |
| | | insert.setHolidayUnitPrice(Constants.formatDecimalNum(pricingDetail.getHolidayUnitPrice()).multiply(new BigDecimal(100))); |
| | | insert.setInfo(pricingDetail.getInfo()); |
| | | insert.setTitle(pricingDetail.getTitle()); |
| | | pricingDetailMapper.insert(pricingDetail); |
| | | pricingDetailMapper.insert(insert); |
| | | return pricingDetail.getId(); |
| | | } |
| | | |
| | |
| | | wrapper.lambda() |
| | | .eq(PricingDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(PricingDetail::getBikeTypeId,pricingDetail.getBikeTypeId()) |
| | | .eq(PricingDetail::getPricePramId,pricingDetail.getPricePramId()); |
| | | Integer exitCount = pricingDetailMapper.selectCount(wrapper); |
| | | .eq(PricingDetail::getPricePramId,pricingDetail.getPricePramId()) |
| | | .last("limit 1"); |
| | | PricingDetail exitCount = pricingDetailMapper.selectOne(wrapper); |
| | | |
| | | if (exitCount > Constants.ZERO){ |
| | | if (Objects.nonNull(exitCount) && !Objects.equals(exitCount.getId(),pricingDetail.getId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该车型已配置"); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<PricingDetail> findList(PricingDetail pricingDetail) { |
| | | MPJLambdaWrapper<PricingDetail> wrapper = new MPJLambdaWrapper<>(); |
| | | wrapper.leftJoin(BaseParam.class,BaseParam::getId,PricingDetail::getBikeTypeId) |
| | | .eq(BaseParam::getType,Constants.THREE); |
| | | wrapper.eq(PricingDetail::getPricePramId,pricingDetail.getPricePramId()) |
| | | .eq(PricingDetail::getIsdeleted,Constants.ZERO); |
| | | wrapper.rightJoin(BaseParam.class,BaseParam::getId,PricingDetail::getBikeTypeId); |
| | | wrapper.selectAll(PricingDetail.class) |
| | | .selectAs(BaseParam::getId,PricingDetail::getBikeTypeId) |
| | | .selectAs(BaseParam::getName,PricingDetail::getBikeTypeName); |
| | | List<PricingDetail> result = pricingDetailJoinMapper.selectJoinList(PricingDetail.class,wrapper); |
| | | if(result!=null){ |
| | | for(PricingDetail model :result){ |
| | | model.setBasePrice(Constants.translateMoney(model.getBasePrice())); |
| | | model.setHolidayBasePrice(Constants.translateMoney(model.getHolidayBasePrice())); |
| | | model.setUnitPrice(Constants.translateMoney(model.getUnitPrice())); |
| | | model.setHolidayUnitPrice(Constants.translateMoney(model.getHolidayUnitPrice())); |
| | | } |
| | | |
| | | Map<String, PricingDetail> stringPricingDetailMap = Optional.ofNullable(result) |
| | | .map(s -> s.stream().collect(Collectors.toMap(p -> p.getBikeTypeId(), p -> p))) |
| | | .orElse(new HashMap<>()); |
| | | QueryWrapper<BaseParam> baseParamQuery = new QueryWrapper(); |
| | | baseParamQuery.lambda() |
| | | .eq(BaseParam::getIsdeleted,Constants.ZERO) |
| | | .eq(BaseParam::getType,Constants.THREE) |
| | | .orderByAsc(BaseParam::getSortnum); |
| | | List<BaseParam> list = baseParamMapper.selectList(baseParamQuery); |
| | | if (CollectionUtils.isEmpty(list)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"内置数据确实"); |
| | | } |
| | | return result; |
| | | |
| | | List<PricingDetail> collect = list.stream().map(s -> { |
| | | PricingDetail put = stringPricingDetailMap.getOrDefault(s.getId(), new PricingDetail()); |
| | | put.setBikeTypeId(s.getId()); |
| | | put.setPricePramId(pricingDetail.getPricePramId()); |
| | | put.setBikeTypeName(s.getName()); |
| | | put.setBasePrice(Objects.nonNull(put.getBasePrice()) ? Constants.translateMoney(put.getBasePrice()) : null); |
| | | put.setHolidayBasePrice(Objects.nonNull(put.getHolidayBasePrice()) ? Constants.translateMoney(put.getHolidayBasePrice()):null); |
| | | put.setUnitPrice(Objects.nonNull(put.getUnitPrice()) ? Constants.translateMoney(put.getUnitPrice()):null); |
| | | put.setHolidayUnitPrice(Objects.nonNull(put.getHolidayUnitPrice()) ? Constants.translateMoney(put.getHolidayUnitPrice()):null); |
| | | return put; |
| | | }).collect(Collectors.toList()); |
| | | // if(result!=null){ |
| | | // for(PricingDetail model :result){ |
| | | // model.setBasePrice(Constants.translateMoney(model.getBasePrice())); |
| | | // model.setHolidayBasePrice(Constants.translateMoney(model.getHolidayBasePrice())); |
| | | // model.setUnitPrice(Constants.translateMoney(model.getUnitPrice())); |
| | | // model.setHolidayUnitPrice(Constants.translateMoney(model.getHolidayUnitPrice())); |
| | | // } |
| | | // } |
| | | return collect; |
| | | } |
| | | |
| | | @Override |