瀏覽代碼

对账单

24282 1 年之前
父節點
當前提交
8609ef86c1

+ 23 - 2
sd-business/src/main/java/com/sd/business/controller/statement/StatementOfAccountController.java

@@ -2,16 +2,21 @@ package com.sd.business.controller.statement;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.sd.business.entity.statement.dto.FileUploadDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
+import com.sd.business.entity.statement.vo.ReconciliationDetailVo;
 import com.sd.business.entity.statement.vo.StatementOfAccountVo;
 import com.sd.business.service.statement.StatementOfAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -40,7 +45,7 @@ public class StatementOfAccountController {
      * 对账单明细
      */
     @PostMapping("/detail")
-    public StatementOfAccountVo detail(@RequestBody BaseSelectDto dto) {
+    public List<ReconciliationDetailVo> detail(@RequestBody BaseSelectDto dto) {
         return statementOfAccountService.detail(dto.getId());
     }
 
@@ -48,7 +53,7 @@ public class StatementOfAccountController {
      * 对账单新增
      */
     @PostMapping("/add")
-    public void add(@RequestBody StatementOfAccountDto statementOfAccountDto) {
+    public void add(@Validated @RequestBody StatementOfAccountDto statementOfAccountDto) {
         statementOfAccountService.add(statementOfAccountDto);
     }
 
@@ -61,6 +66,22 @@ public class StatementOfAccountController {
     }
 
     /**
+     * 编辑对账单文件
+     */
+    @PostMapping("/editReceiptFile")
+    public void editReceiptFile(@RequestBody FileUploadDto dto) {
+        statementOfAccountService.editFile(dto, 1);
+    }
+
+    /**
+     * 编辑转账凭证文件
+     */
+    @PostMapping("/editProofFile")
+    public void editProofFile(@RequestBody FileUploadDto dto) {
+        statementOfAccountService.editFile(dto, 2);
+    }
+
+    /**
      * 对账单删除
      */
     @PostMapping("/delete")

+ 23 - 0
sd-business/src/main/java/com/sd/business/entity/statement/dto/FileUploadDto.java

@@ -0,0 +1,23 @@
+package com.sd.business.entity.statement.dto;
+
+import com.fjhx.file.entity.ObsFile;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class FileUploadDto {
+
+    /**
+     * 对账单id
+     */
+    private Long id;
+
+    /**
+     * 文件列表
+     */
+    private List<ObsFile> fileList;
+
+}

+ 9 - 0
sd-business/src/main/java/com/sd/business/entity/statement/dto/StatementOfAccountDto.java

@@ -4,6 +4,9 @@ import com.sd.business.entity.statement.po.StatementOfAccount;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
 /**
  * 对账单新增编辑入参实体
  *
@@ -14,4 +17,10 @@ import lombok.Setter;
 @Setter
 public class StatementOfAccountDto extends StatementOfAccount {
 
+    /**
+     * 订单id
+     */
+    @NotEmpty(message = "订单id列表不能为空")
+    private List<Long> orderIdList;
+
 }

+ 11 - 0
sd-business/src/main/java/com/sd/business/entity/statement/dto/StatementOfAccountSelectDto.java

@@ -14,4 +14,15 @@ import lombok.Setter;
 @Setter
 public class StatementOfAccountSelectDto extends BaseSelectDto {
 
+    /**
+     * 事业部id
+     */
+    private Long departmentId;
+
+    /**
+     * 对账单号
+     */
+    private String code;
+
+
 }

+ 3 - 0
sd-business/src/main/java/com/sd/business/entity/statement/po/StatementOfAccount.java

@@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -29,11 +30,13 @@ public class StatementOfAccount extends BasePo {
     /**
      * 事业部id
      */
+    @NotNull(message = "事业部id不能为空")
     private Long departmentId;
 
     /**
      * 对账金额
      */
+    @NotNull(message = "对账金额不能为空")
     private BigDecimal amount;
 
     /**

+ 69 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/ReconciliationDetailVo.java

@@ -0,0 +1,69 @@
+package com.sd.business.entity.statement.vo;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+@Builder
+public class ReconciliationDetailVo {
+
+    /**
+     * 订单id
+     */
+    private Long orderId;
+
+    /**
+     * 事业部id
+     */
+    private Long departmentId;
+
+    /**
+     * 事业部名称
+     */
+    private String departmentName;
+
+    /**
+     * 订单号
+     */
+    private String orderCode;
+
+    /**
+     * 订单总金额
+     */
+    private BigDecimal totalAmount;
+
+    /**
+     * 产品总金额
+     */
+    private BigDecimal productTotalAmount;
+
+    /**
+     * 定制加工费
+     */
+    private BigDecimal customProcessingFee;
+
+    /**
+     * 代发费
+     */
+    private BigDecimal lssueFee;
+
+    /**
+     * 快递包材费
+     */
+    private BigDecimal deliveryMaterialsFee;
+
+    /**
+     * 包装人工费
+     */
+    private BigDecimal packingLabor;
+
+    /**
+     * 包材费
+     */
+    private BigDecimal packagingMaterialCost;
+
+}

+ 28 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/StatementOfAccountVo.java

@@ -1,9 +1,12 @@
 package com.sd.business.entity.statement.vo;
 
+import com.fjhx.file.entity.FileInfoVo;
 import com.sd.business.entity.statement.po.StatementOfAccount;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * 对账单列表查询返回值实体
  *
@@ -14,4 +17,29 @@ import lombok.Setter;
 @Setter
 public class StatementOfAccountVo extends StatementOfAccount {
 
+    /**
+     * 事业部名称
+     */
+    private String departmentName;
+
+    /**
+     * 订单编号关联
+     */
+    private String orderCodeJoin;
+
+    /**
+     * 订单数量
+     */
+    private int orderNum;
+
+    /**
+     * 对账单
+     */
+    private List<FileInfoVo> receiptFileList;
+
+    /**
+     * 转正凭证
+     */
+    private List<FileInfoVo> proofFileList;
+
 }

+ 10 - 1
sd-business/src/main/java/com/sd/business/service/statement/StatementOfAccountService.java

@@ -2,11 +2,15 @@ package com.sd.business.service.statement;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.service.BaseService;
+import com.sd.business.entity.statement.dto.FileUploadDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
 import com.sd.business.entity.statement.po.StatementOfAccount;
+import com.sd.business.entity.statement.vo.ReconciliationDetailVo;
 import com.sd.business.entity.statement.vo.StatementOfAccountVo;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -26,7 +30,7 @@ public interface StatementOfAccountService extends BaseService<StatementOfAccoun
     /**
      * 对账单明细
      */
-    StatementOfAccountVo detail(Long id);
+    List<ReconciliationDetailVo> detail(Long id);
 
     /**
      * 对账单新增
@@ -43,4 +47,9 @@ public interface StatementOfAccountService extends BaseService<StatementOfAccoun
      */
     void delete(Long id);
 
+    /**
+     * 更新文件
+     */
+    void editFile(FileUploadDto dto, int type);
+
 }

+ 128 - 3
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountServiceImpl.java

@@ -1,17 +1,33 @@
 package com.sd.business.service.statement.impl;
 
-import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.file.entity.FileInfoVo;
+import com.fjhx.file.utils.ObsFileUtil;
+import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.sd.business.entity.order.po.OrderInfo;
+import com.sd.business.entity.statement.dto.FileUploadDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountDto;
 import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
 import com.sd.business.entity.statement.po.StatementOfAccount;
+import com.sd.business.entity.statement.vo.ReconciliationDetailVo;
 import com.sd.business.entity.statement.vo.StatementOfAccountVo;
 import com.sd.business.mapper.statement.StatementOfAccountMapper;
+import com.sd.business.service.department.DepartmentService;
+import com.sd.business.service.order.OrderService;
 import com.sd.business.service.statement.StatementOfAccountService;
+import com.sd.business.util.CodeEnum;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.*;
+import java.util.stream.Collectors;
+
 
 /**
  * <p>
@@ -24,34 +40,143 @@ import org.springframework.stereotype.Service;
 @Service
 public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccountMapper, StatementOfAccount> implements StatementOfAccountService {
 
+    @Autowired
+    private OrderService orderService;
+
+    @Autowired
+    private DepartmentService departmentService;
+
     @Override
     public Page<StatementOfAccountVo> getPage(StatementOfAccountSelectDto dto) {
+
         IWrapper<StatementOfAccount> wrapper = getWrapper();
+        wrapper.eq("soa", StatementOfAccount::getDepartmentId, dto.getDepartmentId());
+        wrapper.like("soa", StatementOfAccount::getCode, dto.getCode());
+        wrapper.ge("soa", StatementOfAccount::getCreateTime, dto.getBeginTime());
+        wrapper.le("soa", StatementOfAccount::getCreateTime, dto.getEndTime());
         wrapper.orderByDesc("soa", StatementOfAccount::getId);
+
         Page<StatementOfAccountVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<StatementOfAccountVo> records = page.getRecords();
+        if (records.size() == 0) {
+            return page;
+        }
+
+        // 查询对账单和转帐凭证
+        List<Long> idList = records.stream().map(BaseIdPo::getId).collect(Collectors.toList());
+        Map<Long, List<FileInfoVo>> receiptFileMap = ObsFileUtil.getFileMap(idList, 1);
+        Map<Long, List<FileInfoVo>> proofFileMap = ObsFileUtil.getFileMap(idList, 2);
+
+        List<String> orderIdList = records.stream()
+                .map(StatementOfAccount::getOrderIdJoin)
+                .filter(StrUtil::isNotBlank)
+                .flatMap(item -> Arrays.stream(item.split(",")))
+                .distinct()
+                .collect(Collectors.toList());
+
+        Map<Long, String> orderIdCodeMap;
+        if (orderIdList.size() == 0) {
+            orderIdCodeMap = orderService.mapKV(BaseIdPo::getId, OrderInfo::getCode,
+                    q -> q.select(BaseIdPo::getId, OrderInfo::getCode).in(BaseIdPo::getId, orderIdList));
+        } else {
+            orderIdCodeMap = new HashMap<>();
+        }
+
+        for (StatementOfAccountVo record : records) {
+            record.setReceiptFileList(receiptFileMap.getOrDefault(record.getId(), Collections.emptyList()));
+            record.setProofFileList(proofFileMap.getOrDefault(record.getId(), Collections.emptyList()));
+
+            String orderIdJoin = record.getOrderIdJoin();
+            StringJoiner codeJoiner = new StringJoiner(",");
+            int orderNum = 0;
+            for (String orderId : orderIdJoin.split(",")) {
+                if (StrUtil.isBlank(orderId)) {
+                    continue;
+                }
+                String orderCode = orderIdCodeMap.get(Convert.toLong(orderId));
+                if (StrUtil.isBlank(orderCode)) {
+                    continue;
+                }
+                codeJoiner.add(orderCode);
+                orderNum++;
+            }
+            record.setOrderCodeJoin(codeJoiner.toString());
+            record.setOrderNum(orderNum);
+        }
+
         return page;
     }
 
     @Override
-    public StatementOfAccountVo detail(Long id) {
+    public List<ReconciliationDetailVo> detail(Long id) {
         StatementOfAccount StatementOfAccount = this.getById(id);
-        StatementOfAccountVo result = BeanUtil.toBean(StatementOfAccount, StatementOfAccountVo.class);
+        String orderIdJoin = StatementOfAccount.getOrderIdJoin();
+
+        List<ReconciliationDetailVo> result = Arrays.stream(orderIdJoin.split(","))
+                .map(Convert::toLong)
+                .filter(ObjectUtil::isNotNull)
+                .distinct()
+                .map(item -> ReconciliationDetailVo.builder().orderId(item).build())
+                .collect(Collectors.toList());
+
+        orderService.attributeAssign(result, ReconciliationDetailVo::getOrderId, (item, order) -> {
+            item.setDepartmentId(order.getDepartmentId());
+            item.setOrderCode(order.getCode());
+            item.setTotalAmount(order.getTotalAmount());
+            item.setProductTotalAmount(order.getProductTotalAmount());
+            item.setCustomProcessingFee(order.getCustomProcessingFee());
+            item.setLssueFee(order.getLssueFee());
+            item.setDeliveryMaterialsFee(order.getDeliveryMaterialsFee());
+            item.setPackingLabor(order.getPackingLabor());
+            item.setPackagingMaterialCost(order.getPackagingMaterialCost());
+        });
+
+        result = result.stream().filter(item -> ObjectUtil.isNotEmpty(item.getOrderCode())).collect(Collectors.toList());
+
+        departmentService.attributeAssign(result, ReconciliationDetailVo::getDepartmentId, (item, department) -> {
+            item.setDepartmentName(department.getName());
+        });
+
         return result;
     }
 
     @Override
     public void add(StatementOfAccountDto statementOfAccountDto) {
+
+        String orderIdJoin = statementOfAccountDto.getOrderIdList()
+                .stream()
+                .map(Convert::toStr)
+                .collect(Collectors.joining(","));
+
+        statementOfAccountDto.setCode(CodeEnum.STATEMENT_OF_ACCOUNT_CODE.getCode());
+        statementOfAccountDto.setType(1);
+        statementOfAccountDto.setOrderIdJoin(orderIdJoin);
         this.save(statementOfAccountDto);
     }
 
     @Override
     public void edit(StatementOfAccountDto statementOfAccountDto) {
+
+        String orderIdJoin = statementOfAccountDto.getOrderIdList()
+                .stream()
+                .map(Convert::toStr)
+                .collect(Collectors.joining(","));
+
+        statementOfAccountDto.setOrderIdJoin(orderIdJoin);
+
         this.updateById(statementOfAccountDto);
     }
 
+    @DSTransactional
     @Override
     public void delete(Long id) {
         this.removeById(id);
+        ObsFileUtil.removeFile(id);
+    }
+
+    @Override
+    public void editFile(FileUploadDto dto, int type) {
+        ObsFileUtil.editFile(dto.getFileList(), dto.getId(), type);
     }
 
 }

+ 3 - 1
sd-business/src/main/resources/mapper/statement/StatementOfAccountMapper.xml

@@ -12,8 +12,10 @@
                soa.create_user,
                soa.create_time,
                soa.update_user,
-               soa.update_time
+               soa.update_time,
+               d.name departmentName
         from statement_of_account soa
+                 left join department d on d.id = soa.department_id
             ${ew.customSqlSegment}
     </select>
 

+ 3 - 0
sd-wln/src/main/java/com/sd/wln/service/WlnStatementOfAccount.java

@@ -2,6 +2,9 @@ package com.sd.wln.service;
 
 public interface WlnStatementOfAccount {
 
+    /**
+     * 生成对账单
+     */
     void createStatementOfAccount();
 
 }