package com.doumee.service.business.impl; 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.doumee.core.constants.Constants; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Utils; import com.doumee.dao.business.OtherOrdersMapper; import com.doumee.dao.business.model.OtherOrders; import com.doumee.service.business.OtherOrdersService; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Objects; /** * 其他订单记录Service实现 * @author rk * @date 2026/04/16 */ @Service public class OtherOrdersServiceImpl implements OtherOrdersService { @Autowired private OtherOrdersMapper otherOrdersMapper; @Override public Integer create(OtherOrders otherOrders) { otherOrdersMapper.insert(otherOrders); return otherOrders.getId(); } @Override public void deleteById(Integer id) { otherOrdersMapper.update(new UpdateWrapper().lambda() .set(OtherOrders::getDeleted, Constants.ONE) .eq(OtherOrders::getId, id)); } @Override public void delete(OtherOrders otherOrders) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(otherOrders); otherOrdersMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (ids == null || ids.isEmpty()) { return; } otherOrdersMapper.deleteBatchIds(ids); } @Override public void updateById(OtherOrders otherOrders) { otherOrdersMapper.updateById(otherOrders); } @Override public void updateByIdInBatch(List otherOrdersList) { if (otherOrdersList == null || otherOrdersList.isEmpty()) { return; } for (OtherOrders otherOrders : otherOrdersList) { this.updateById(otherOrders); } } @Override public OtherOrders findById(Integer id) { OtherOrders otherOrders = otherOrdersMapper.selectById(id); if (Objects.isNull(otherOrders)) { throw new BusinessException(com.doumee.core.constants.ResponseStatus.DATA_EMPTY); } return otherOrders; } @Override public OtherOrders findOne(OtherOrders otherOrders) { QueryWrapper wrapper = new QueryWrapper<>(otherOrders); return otherOrdersMapper.selectOne(wrapper); } @Override public List findList(OtherOrders otherOrders) { QueryWrapper wrapper = new QueryWrapper<>(otherOrders); return otherOrdersMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper() .selectAll(OtherOrders.class); Utils.MP.blankToNull(pageWrap.getModel()); pageWrap.getModel().setDeleted(Constants.ZERO); OtherOrders model = pageWrap.getModel(); if (model.getType() != null) { queryWrapper.eq(OtherOrders::getType, model.getType()); } if (model.getMemberId() != null) { queryWrapper.eq(OtherOrders::getMemberId, model.getMemberId()); } if (model.getPayStatus() != null) { queryWrapper.eq(OtherOrders::getPayStatus, model.getPayStatus()); } if (model.getOrderId() != null) { queryWrapper.eq(OtherOrders::getOrderId, model.getOrderId()); } for (PageWrap.SortData sortData : pageWrap.getSorts()) { if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { queryWrapper.orderByDesc(sortData.getProperty()); } else { queryWrapper.orderByAsc(sortData.getProperty()); } } return PageData.from(otherOrdersMapper.selectJoinPage(page, OtherOrders.class, queryWrapper)); } @Override public long count(OtherOrders otherOrders) { QueryWrapper wrapper = new QueryWrapper<>(otherOrders); return otherOrdersMapper.selectCount(wrapper); } }