| | |
| | | package com.ruoyi.aftersalesservice.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.project.system.service.ISysNoticeService; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | @Autowired |
| | | private ISalesLedgerService salesLedgerService; |
| | | @Autowired |
| | | private ISysNoticeService sysNoticeService; |
| | | |
| | | @Override |
| | | public IPage<AfterSalesServiceNewDto> listPage(Page page, AfterSalesServiceNewDto afterSalesService) { |
| | |
| | | @Override |
| | | public boolean addAfterSalesServiceDto(AfterSalesServiceNewDto afterSalesServiceNewDto) { |
| | | afterSalesServiceNewDto.setStatus(1); |
| | | if (afterSalesServiceNewDto.getProductModelIdList() != null && afterSalesServiceNewDto.getProductModelIdList().isEmpty() ) { |
| | | if (afterSalesServiceNewDto.getProductModelIdList() != null && !afterSalesServiceNewDto.getProductModelIdList().isEmpty() ) { |
| | | String productModelIds = afterSalesServiceNewDto.getProductModelIdList().stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | afterSalesServiceNewDto.setProductModelIds(productModelIds); |
| | | } |
| | | if (afterSalesServiceNewDto.getAfterSalesProductList() != null && !afterSalesServiceNewDto.getAfterSalesProductList().isEmpty()) { |
| | | afterSalesServiceNewDto.setAfterSalesProducts(JSON.toJSONString(afterSalesServiceNewDto.getAfterSalesProductList())); |
| | | } |
| | | SysUser sysUser = sysUserMapper.selectUserById(afterSalesServiceNewDto.getCheckUserId()); |
| | | if(sysUser == null) throw new RuntimeException("审核人不存在"); |
| | |
| | | String string = OrderUtils.countAfterServiceTodayByCreateTime(afterSalesServiceMapper, "SH_"); |
| | | afterSalesServiceNewDto.setAfterSalesServiceNo(string); |
| | | } |
| | | return this.save(afterSalesServiceNewDto); |
| | | boolean saved = this.save(afterSalesServiceNewDto); |
| | | |
| | | if (saved && afterSalesServiceNewDto.getSalesLedgerId() != null) { |
| | | try { |
| | | SalesLedger salesLedger = salesLedgerService.getById(afterSalesServiceNewDto.getSalesLedgerId()); |
| | | if (salesLedger != null && StringUtils.isNotEmpty(salesLedger.getEntryPerson())) { |
| | | Long entryUserId = Long.parseLong(salesLedger.getEntryPerson()); |
| | | String webPath = "/customerService/afterSalesHandling?afterSalesServiceNo=" + afterSalesServiceNewDto.getAfterSalesServiceNo(); |
| | | sysNoticeService.simpleNoticeByUser( |
| | | "新增售后单通知", |
| | | "您录入的销售订单有一条新的售后记录,售后单号:" + afterSalesServiceNewDto.getAfterSalesServiceNo(), |
| | | Collections.singletonList(entryUserId), |
| | | webPath |
| | | ); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("发送售后新增通知失败: ", e); |
| | | } |
| | | } |
| | | return saved; |
| | | } |
| | | |
| | | @Override |
| | |
| | | SalesLedger byId = salesLedgerService.getById(afterSalesService.getSalesLedgerId()); |
| | | List<Long> collect = Arrays.stream(afterSalesService.getProductModelIds().split(",")).map(Long::valueOf).collect(Collectors.toList()); |
| | | List<SalesLedgerProduct> list = salesLedgerProductService.list(new QueryWrapper<SalesLedgerProduct>().lambda().in(SalesLedgerProduct::getId, collect)); |
| | | |
| | | if (StringUtils.isNotEmpty(afterSalesService.getAfterSalesProducts())) { |
| | | List<com.ruoyi.aftersalesservice.dto.AfterSalesProductDto> afterSalesProductList = com.alibaba.fastjson2.JSON.parseArray(afterSalesService.getAfterSalesProducts(), com.ruoyi.aftersalesservice.dto.AfterSalesProductDto.class); |
| | | for (SalesLedgerProduct product : list) { |
| | | for (com.ruoyi.aftersalesservice.dto.AfterSalesProductDto productDto : afterSalesProductList) { |
| | | if (product.getId().equals(productDto.getId())) { |
| | | product.setAfterSalesQuantity(productDto.getAfterSalesQuantity()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | AfterSalesServiceNewDto afterSalesServiceNewDto = new AfterSalesServiceNewDto(); |
| | | BeanUtils.copyProperties(afterSalesService, afterSalesServiceNewDto); |
| | | SalesLedgerDto salesLedgerDto = new SalesLedgerDto(); |