|
@@ -0,0 +1,100 @@
|
|
|
+package com.fjhx.sale.service.after.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
+import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.sale.entity.after.dto.AfterSalesDto;
|
|
|
+import com.fjhx.sale.entity.after.dto.AfterSalesSelectDto;
|
|
|
+import com.fjhx.sale.entity.after.po.AfterSales;
|
|
|
+import com.fjhx.sale.entity.after.vo.AfterSalesVo;
|
|
|
+import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
+import com.fjhx.sale.mapper.after.AfterSalesMapper;
|
|
|
+import com.fjhx.sale.service.after.AfterSalesService;
|
|
|
+import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * <p>
|
|
|
+ * sale_售后管理 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-01-31
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSales> implements AfterSalesService {
|
|
|
+
|
|
|
+ private final ContractProductService contractProductService;
|
|
|
+ private final ProductInfoService productInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public AfterSalesServiceImpl(ContractProductService contractProductService, ProductInfoService productInfoService) {
|
|
|
+ this.contractProductService = contractProductService;
|
|
|
+ this.productInfoService = productInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<AfterSalesVo> getPage(AfterSalesSelectDto dto) {
|
|
|
+ IWrapper<AfterSales> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("as1", AfterSales::getId);
|
|
|
+ Page<AfterSalesVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<AfterSalesVo> records = page.getRecords();
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ productInfoService.attributeAssign(records, AfterSalesVo::getProductId, (detail, product) -> {
|
|
|
+ detail.setProductCode(product.getCustomCode());
|
|
|
+ detail.setProductName(product.getName());
|
|
|
+ detail.setProductLength(product.getLength());
|
|
|
+ detail.setProductWidth(product.getWidth());
|
|
|
+ detail.setProductHeight(product.getHeight());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ UserUtil.assignmentNickName(records, AfterSalesVo::getUserId, AfterSalesVo::setUserName);
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AfterSalesVo detail(Long id) {
|
|
|
+ AfterSales AfterSales = this.getById(id);
|
|
|
+ AfterSalesVo result = BeanUtil.toBean(AfterSales, AfterSalesVo.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(AfterSalesDto afterSalesDto) {
|
|
|
+ Long contractProductId = afterSalesDto.getContractProductId();
|
|
|
+ ContractProduct contractProduct = contractProductService.getById(contractProductId);
|
|
|
+ Assert.notEmpty(contractProduct, "查询不到订单产品信息!");
|
|
|
+
|
|
|
+
|
|
|
+ afterSalesDto.setContractId(contractProduct.getContractId());
|
|
|
+ afterSalesDto.setProductId(contractProduct.getProductId());
|
|
|
+
|
|
|
+ this.save(afterSalesDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(AfterSalesDto afterSalesDto) {
|
|
|
+ this.updateById(afterSalesDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|