| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.CustomerDto; |
| | | import com.ruoyi.basic.dto.CustomerFollowUpDto; |
| | | import com.ruoyi.basic.excel.CustomerExcelDTO; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.CustomerFollowUp; |
| | |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | private CustomerFollowUpFileService customerFollowUpFileService; |
| | | |
| | | private CustomerReturnVisitService customerReturnVisitService; |
| | | |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | /** |
| | | * 查询客户档案 |
| | |
| | | queryWrapper.like(Customer::getCustomerType, customerType); |
| | | } |
| | | |
| | | |
| | | // 3. 执行分页查询(保留分页元数据) |
| | | IPage<Customer> customerPage = customerMapper.selectPage(page, queryWrapper); |
| | | |
| | |
| | | |
| | | if (followUp != null) { |
| | | c.setFollowUpLevel(followUp.getFollowUpLevel()); |
| | | c.setFollowUpTime(followUp.getFollowUpTime()); |
| | | c.setFollowUpTime( |
| | | Date.from( |
| | | followUp.getFollowUpTime().atZone(ZoneId.systemDefault()).toInstant() |
| | | ) |
| | | ); |
| | | } |
| | | }) |
| | | .collect(Collectors.toList()); |
| | |
| | | */ |
| | | @Override |
| | | public int insertCustomer(Customer customer) { |
| | | // 1. 校验客户名称是否已存在 |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName()); |
| | | List<Customer> customerList = customerMapper.selectList(queryWrapper); |
| | | if (!customerList.isEmpty()) { |
| | | throw new RuntimeException("客户名称已存在"); |
| | | } |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Long tenantId = loginUser.getTenantId(); |
| | | customer.setTenantId(tenantId); |
| | | customer.setCreateUser(loginUser.getUserId().intValue()); |
| | | return customerMapper.insert(customer); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int updateCustomer(Customer customer) { |
| | | // 1. 校验客户名称是否已存在 |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName()); |
| | | queryWrapper.ne(Customer::getId, customer.getId()); |
| | | List<Customer> customerList = customerMapper.selectList(queryWrapper); |
| | | if (!customerList.isEmpty()) { |
| | | throw new RuntimeException("客户名称已存在"); |
| | | } |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Long tenantId = loginUser.getTenantId(); |
| | | customer.setTenantId(tenantId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CustomerExcelDTO> selectCustomerDtoByIds(Long[] ids) { |
| | | return customerMapper.selectCustomerDtoListByIds(Arrays.asList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public List<Customer> selectCustomerLists(Customer customer) { |
| | | return customerMapper.selectList(null); |
| | | } |
| | | |
| | | @Override |
| | | public List<CustomerExcelDTO> selectCustomerDtoLists() { |
| | | return customerMapper.selectCustomerDtoLists(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public int transferCustomer(CustomerDto customerDto) { |
| | | // 校验维护人是否存在 |
| | | SysUser sysUser = sysUserMapper.selectUserById(customerDto.getCreateUser().longValue()); |
| | | if (sysUser == null) { |
| | | throw new RuntimeException("维护人不存在"); |
| | | } |
| | | // 校验客户是否存在 |
| | | Customer customer = customerMapper.selectById(customerDto.getId()); |
| | | if (customer == null) { |
| | | throw new RuntimeException("客户不存在"); |
| | | } |
| | | customer.setMaintainer(sysUser.getNickName()); |
| | | customer.setCreateUser(customerDto.getCreateUser()); |
| | | return customerMapper.updateById(customer); |
| | | } |
| | | } |