| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.DiscountLogMapper; |
| | | import com.doumee.dao.business.model.DiscountLog; |
| | | import com.doumee.dao.business.model.DiscountMember; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.DiscountLogService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * ç¨æ·å¥é¤å¡ä½¿ç¨è°æ´æ¥å¿è¡¨Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/02/17 09:43 |
| | | */ |
| | | @Service |
| | | public class DiscountLogServiceImpl implements DiscountLogService { |
| | | |
| | | @Autowired |
| | | private DiscountLogMapper discountLogMapper; |
| | | |
| | | @Override |
| | | public String create(DiscountLog discountLog) { |
| | | discountLogMapper.insert(discountLog); |
| | | return discountLog.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | discountLogMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(DiscountLog discountLog) { |
| | | UpdateWrapper<DiscountLog> deleteWrapper = new UpdateWrapper<>(discountLog); |
| | | discountLogMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<String> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | discountLogMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(DiscountLog discountLog) { |
| | | discountLogMapper.updateById(discountLog); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<DiscountLog> discountLogs) { |
| | | if (CollectionUtils.isEmpty(discountLogs)) { |
| | | return; |
| | | } |
| | | for (DiscountLog discountLog: discountLogs) { |
| | | this.updateById(discountLog); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public DiscountLog findById(String id) { |
| | | return discountLogMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public DiscountLog findOne(DiscountLog discountLog) { |
| | | QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog); |
| | | return discountLogMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<DiscountLog> findList(DiscountLog discountLog) { |
| | | QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog); |
| | | return discountLogMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<DiscountLog> findPage(PageWrap<DiscountLog> pageWrap) { |
| | | IPage<DiscountLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<DiscountLog> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | DiscountLog model = pageWrap.getModel(); |
| | | queryWrapper.selectAll(DiscountLog.class) |
| | | .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,DiscountLog::getCreator) |
| | | .eq(DiscountLog::getIsdeleted, Constants.ZERO) |
| | | .eq(Objects.nonNull(model.getType()),DiscountLog::getType,model.getType()) |
| | | .eq(StringUtils.isNotBlank(model.getDiscountMemberId()),DiscountLog::getDiscountMemberId,model.getDiscountMemberId()); |
| | | PageData<DiscountLog> pageData = PageData.from(discountLogMapper.selectJoinPage(page, DiscountLog.class,queryWrapper)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(pageData.getRecords())){ |
| | | for (DiscountLog discountLog:pageData.getRecords()) { |
| | | if(Constants.equalsInteger(discountLog.getType(),Constants.ZERO)&&Objects.nonNull(discountLog.getRidePrice())){ |
| | | discountLog.setRidePrice( |
| | | Constants.translateMoney(discountLog.getRidePrice()) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | return pageData; |
| | | } |
| | | |
| | | @Override |
| | | public long count(DiscountLog discountLog) { |
| | | QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog); |
| | | return discountLogMapper.selectCount(wrapper); |
| | | } |
| | | } |