package com.ruoyi.aftersalesservice.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.ruoyi.aftersalesservice.mapper.AfterSalesNearExpiryMapper;
|
import com.ruoyi.aftersalesservice.pojo.AfterSalesNearExpiry;
|
import com.ruoyi.aftersalesservice.service.AfterSalesNearExpiryService;
|
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.utils.SecurityUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.Arrays;
|
|
/**
|
* <br>
|
* 临期售后管理接口实现类
|
* </br>
|
*
|
* @author deslrey
|
* @version 1.0
|
* @since 2026/03/02 14:46
|
*/
|
@Service
|
public class AfterSalesNearExpiryServiceImpl extends ServiceImpl<AfterSalesNearExpiryMapper, AfterSalesNearExpiry> implements AfterSalesNearExpiryService {
|
|
@Override
|
public void add(AfterSalesNearExpiry entity) {
|
if (entity == null) {
|
throw new ServiceException("添加失败,数据不能为空");
|
}
|
if (entity.getProductName() == null || entity.getProductName().trim().isEmpty()) {
|
throw new ServiceException("产品名称不能为空");
|
}
|
if (entity.getBatchNumber() == null || entity.getBatchNumber().trim().isEmpty()) {
|
throw new ServiceException("产品批号不能为空");
|
}
|
if (entity.getExpireDate() == null) {
|
throw new ServiceException("临期日期不能为空");
|
}
|
|
entity.setId(null);
|
entity.setStatus(1);
|
entity.setDisposeUserId(null);
|
entity.setDisposeNickName(null);
|
entity.setDisDate(null);
|
entity.setCreateTime(LocalDateTime.now());
|
entity.setCreateUser(SecurityUtils.getLoginUser().getUserId());
|
entity.setUpdateUser(null);
|
entity.setUpdateTime(null);
|
entity.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
|
int result = baseMapper.insert(entity);
|
if (result <= 0) {
|
throw new ServiceException("新增失败");
|
}
|
}
|
|
@Override
|
public void update(AfterSalesNearExpiry entity) {
|
if (entity == null || entity.getId() == null) {
|
throw new ServiceException("更新失败,数据不完整");
|
}
|
entity.setStatus(2);
|
entity.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
|
entity.setUpdateTime(LocalDateTime.now());
|
int result = baseMapper.updateById(entity);
|
if (result <= 0) {
|
throw new ServiceException("更新失败");
|
}
|
}
|
|
@Override
|
public void delete(Long[] ids) {
|
if (ids == null || ids.length == 0) {
|
throw new ServiceException("请选择要删除的数据");
|
}
|
int result = baseMapper.deleteBatchIds(Arrays.asList(ids));
|
if (result <= 0) {
|
throw new ServiceException("删除失败");
|
}
|
}
|
|
@Override
|
public IPage<AfterSalesNearExpiry> listPage(Page<AfterSalesNearExpiry> page, AfterSalesNearExpiry entity) {
|
return baseMapper.listPage(page, entity);
|
}
|
}
|