New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.convenient.ConvenientElevatingPointDTO; |
| | | import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; |
| | | import com.panzhihua.common.model.dtos.community.convenient.PageConvenientElevatingPointDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.convenient.ConvenientElevatingPointVO; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ConvenientElevatingPointDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientElevatingPointDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientMerchantDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; |
| | | import com.panzhihua.service_community.service.ConvenientElevatingPointService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.List; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | import static org.apache.commons.lang3.StringUtils.isNotBlank; |
| | | |
| | | /** |
| | | * @ClassName: ConvenientElevatingPointServiceImpl |
| | | * @Author: yh |
| | | * @Date: 2022/11/8 10:34 |
| | | * @Description: 自提点 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ConvenientElevatingPointServiceImpl extends ServiceImpl<ConvenientElevatingPointDAO, ConvenientElevatingPointDO> implements ConvenientElevatingPointService { |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param pageConvenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R pagePoint(PageConvenientElevatingPointDTO pageConvenientElevatingPointDTO) { |
| | | Page page = new Page<>(); |
| | | page.setSize(pageConvenientElevatingPointDTO.getPageSize()); |
| | | page.setCurrent(pageConvenientElevatingPointDTO.getPageNum()); |
| | | IPage<ConvenientElevatingPointVO> iPage = this.baseMapper.page(page, pageConvenientElevatingPointDTO); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | * @param convenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addPoint(ConvenientElevatingPointDTO convenientElevatingPointDTO) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = new ConvenientElevatingPointDO(); |
| | | BeanUtils.copyProperties(convenientElevatingPointDTO,convenientElevatingPointDO); |
| | | String communityId = convenientElevatingPointDTO.getCommunityId(); |
| | | if (nonNull(communityId)) { |
| | | ComActDO comActDO = comActDAO.selectById(Long.parseLong(communityId.substring(communityId.lastIndexOf(",")+1))); |
| | | if(comActDO!=null){ |
| | | convenientElevatingPointDO.setCommunityName(comActDO.getName()); |
| | | } |
| | | } |
| | | this.baseMapper.insert(convenientElevatingPointDO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param convenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R putPoint(ConvenientElevatingPointDTO convenientElevatingPointDTO) { |
| | | Long id = convenientElevatingPointDTO.getId(); |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(id); |
| | | if (isNull(convenientElevatingPointDO)) { |
| | | return R.fail("自提点不存在"); |
| | | } |
| | | String communityId = convenientElevatingPointDTO.getCommunityId(); |
| | | if (nonNull(communityId)) { |
| | | ComActDO comActDO = comActDAO.selectById(Long.parseLong(communityId.substring(communityId.lastIndexOf(",")+1))); |
| | | if(comActDO!=null){ |
| | | convenientElevatingPointDO.setCommunityName(comActDO.getName()); |
| | | } |
| | | } |
| | | BeanUtils.copyProperties(convenientElevatingPointDTO, convenientElevatingPointDO); |
| | | this.baseMapper.updateById(convenientElevatingPointDO); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R deletePoint(Long pointId, Long operator) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(pointId); |
| | | if (convenientElevatingPointDO.getPrepareGoodsNum() > 0){ |
| | | return R.fail("该提货点暂时无法删除!若想删除需保证待提货数量为0"); |
| | | } |
| | | int result = this.baseMapper.deletePointById(pointId, operator); |
| | | if (result > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R detailPoint(Long pointId) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(pointId); |
| | | return R.ok(convenientElevatingPointDO); |
| | | } |
| | | } |