From 66d041ed14b3ed3ed7183a28a5c588e235fc21d0 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 26 五月 2026 11:14:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_pro_河南鹤壁' into dev_鹤壁_强信宇_pro
---
src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 109 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java b/src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java
index 4f8237f..0feab41 100644
--- a/src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java
+++ b/src/main/java/com/ruoyi/aftersalesservice/service/impl/AfterSalesServiceServiceImpl.java
@@ -1,17 +1,34 @@
package com.ruoyi.aftersalesservice.service.impl;
+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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.aftersalesservice.dto.AfterSalesServiceNewDto;
+import com.ruoyi.aftersalesservice.dto.CountDto;
import com.ruoyi.aftersalesservice.mapper.AfterSalesServiceMapper;
import com.ruoyi.aftersalesservice.pojo.AfterSalesService;
import com.ruoyi.aftersalesservice.service.AfterSalesServiceService;
+import com.ruoyi.common.utils.OrderUtils;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysDeptMapper;
+import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.sales.dto.SalesLedgerDto;
+import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
+import com.ruoyi.sales.service.ISalesLedgerService;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* @author :yys
@@ -19,22 +36,106 @@
*/
@Service
@Slf4j
+@RequiredArgsConstructor
public class AfterSalesServiceServiceImpl extends ServiceImpl<AfterSalesServiceMapper, AfterSalesService> implements AfterSalesServiceService {
- @Autowired
- private AfterSalesServiceMapper afterSalesServiceMapper;
-
- @Autowired
- private SysDeptMapper sysDeptMapper;
+ private final AfterSalesServiceMapper afterSalesServiceMapper;
+ private final SysDeptMapper sysDeptMapper;
+ private final SysUserMapper sysUserMapper;
+ private final ISalesLedgerProductService salesLedgerProductService;
+ private final ISalesLedgerService salesLedgerService;
+ private final com.ruoyi.sales.mapper.ShippingInfoMapper shippingInfoMapper;
@Override
- public IPage<AfterSalesService> listPage(Page page, AfterSalesService afterSalesService) {
+ public IPage<AfterSalesServiceNewDto> listPage(Page page, AfterSalesServiceNewDto afterSalesService) {
Long tenantId = SecurityUtils.getLoginUser().getTenantId();
SysDept sysDept = sysDeptMapper.selectDeptById(tenantId);
- IPage<AfterSalesService> afterSalesServiceIPage = afterSalesServiceMapper.listPage(page, afterSalesService);
+ IPage<AfterSalesServiceNewDto> afterSalesServiceIPage = afterSalesServiceMapper.listPage(page, afterSalesService);
afterSalesServiceIPage.getRecords().forEach(item -> {
item.setDeptName(sysDept.getDeptName());
});
return afterSalesServiceIPage;
}
+
+ @Override
+ public boolean addAfterSalesServiceDto(AfterSalesServiceNewDto afterSalesServiceNewDto) {
+ afterSalesServiceNewDto.setStatus(1);
+ if (afterSalesServiceNewDto.getProductModelIdList() != null && afterSalesServiceNewDto.getProductModelIdList().isEmpty() ) {
+ String productModelIds = afterSalesServiceNewDto.getProductModelIdList().stream()
+ .map(String::valueOf)
+ .collect(Collectors.joining(","));
+ afterSalesServiceNewDto.setProductModelIds(productModelIds);
+ }
+ SysUser sysUser = sysUserMapper.selectUserById(afterSalesServiceNewDto.getCheckUserId());
+ if(sysUser == null) throw new RuntimeException("瀹℃牳浜轰笉瀛樺湪");
+ afterSalesServiceNewDto.setCheckNickName(sysUser.getNickName());
+ if (StringUtils.isEmpty(afterSalesServiceNewDto.getAfterSalesServiceNo())) {
+ String string = OrderUtils.countAfterServiceTodayByCreateTime(afterSalesServiceMapper, "SH_");
+ afterSalesServiceNewDto.setAfterSalesServiceNo(string);
+ }
+ return this.save(afterSalesServiceNewDto);
+ }
+
+ @Override
+ public AfterSalesServiceNewDto getAfterSalesServiceNewDtoById(Long id) {
+ AfterSalesService afterSalesService = afterSalesServiceMapper.selectById(id);
+ 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.getProductModelQuantities())) {
+ String[] quantities = afterSalesService.getProductModelQuantities().split(",");
+ for (int i = 0; i < collect.size(); i++) {
+ Long productId = collect.get(i);
+ for (SalesLedgerProduct product : list) {
+ if (product.getId().equals(productId)) {
+ if (i < quantities.length && StringUtils.isNotEmpty(quantities[i])) {
+ product.setQuantity(new java.math.BigDecimal(quantities[i]));
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ for (SalesLedgerProduct product : list) {
+ com.ruoyi.sales.pojo.ShippingInfo shippingInfo = shippingInfoMapper.selectOne(
+ new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.ruoyi.sales.pojo.ShippingInfo>()
+ .eq(com.ruoyi.sales.pojo.ShippingInfo::getSalesLedgerProductId, product.getId())
+ .orderByDesc(com.ruoyi.sales.pojo.ShippingInfo::getCreateTime)
+ .last("limit 1")
+ );
+ if (shippingInfo != null) {
+ product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+ product.setShippingDate(shippingInfo.getShippingDate());
+ product.setShippingStatus(shippingInfo.getStatus());
+ product.setExpressCompany(shippingInfo.getExpressCompany());
+ product.setExpressNumber(shippingInfo.getExpressNumber());
+ }
+ }
+
+ AfterSalesServiceNewDto afterSalesServiceNewDto = new AfterSalesServiceNewDto();
+ BeanUtils.copyProperties(afterSalesService, afterSalesServiceNewDto);
+ SalesLedgerDto salesLedgerDto = new SalesLedgerDto();
+ BeanUtils.copyProperties(byId, salesLedgerDto);
+ salesLedgerDto.setProductData( list);
+ afterSalesServiceNewDto.setSalesLedgerDto(salesLedgerDto);
+ return afterSalesServiceNewDto;
+ }
+
+ @Override
+ public List<CountDto> countAfterSalesService() {
+ List<CountDto> stringIntegerHashMap = afterSalesServiceMapper.countAfterSalesService();
+ Integer total = 0;
+ for (CountDto countDto : stringIntegerHashMap) {
+ total += countDto.getCount();
+ }
+ CountDto countDto = new CountDto();
+ countDto.setStatus(3);
+ countDto.setCount(total);
+ stringIntegerHashMap.add(countDto);
+
+ return stringIntegerHashMap;
+
+ }
}
--
Gitblit v1.9.3