Commit 8e2b3476376986562a72099aa37f246f93113723
1 parent
c0757c2b
feat: ERP升级
1、财务应收创建invoice单据/列表查询/删除/更新操作
Showing
9 changed files
with
463 additions
and
128 deletions
src/main/java/com/order/erp/controller/InvoiceBillOrderController.java
... | ... | @@ -2,8 +2,7 @@ package com.order.erp.controller; |
2 | 2 | |
3 | 3 | import com.order.erp.common.constant.ServerResult; |
4 | 4 | import com.order.erp.common.jsr303.OperateGroup; |
5 | -import com.order.erp.domain.vo.order.InvoiceBillOrderQueryVO; | |
6 | -import com.order.erp.domain.vo.order.InvoiceBillOrderVO; | |
5 | +import com.order.erp.domain.vo.order.*; | |
7 | 6 | import com.order.erp.service.order.InvoiceBillOrderService; |
8 | 7 | import org.springframework.validation.annotation.Validated; |
9 | 8 | import org.springframework.web.bind.annotation.PostMapping; |
... | ... | @@ -20,7 +19,7 @@ import javax.annotation.Resource; |
20 | 19 | * @since 2024-08-05 16:26:34 |
21 | 20 | */ |
22 | 21 | @RestController |
23 | -@RequestMapping("/order/erp/invoice_bill/") | |
22 | +@RequestMapping("/order/erp/invoice_bill") | |
24 | 23 | public class InvoiceBillOrderController { |
25 | 24 | /** |
26 | 25 | * 服务对象 |
... | ... | @@ -34,42 +33,54 @@ public class InvoiceBillOrderController { |
34 | 33 | * @param invoiceBillOrderQueryVO 查询条件 |
35 | 34 | * @return 查询结果 |
36 | 35 | */ |
37 | - @PostMapping("/list") | |
38 | - public ServerResult list(@RequestBody @Validated({OperateGroup.List.class}) InvoiceBillOrderQueryVO invoiceBillOrderQueryVO) { | |
39 | - return invoiceBillOrderService.list(invoiceBillOrderQueryVO); | |
36 | + @PostMapping("/list_by_page") | |
37 | + public ServerResult listByPage(@RequestBody @Validated({OperateGroup.List.class}) InvoiceBillOrderQueryVO invoiceBillOrderQueryVO) { | |
38 | + return invoiceBillOrderService.listByPage(invoiceBillOrderQueryVO); | |
40 | 39 | } |
41 | 40 | |
42 | 41 | /** |
43 | - * 通过主键查询单条数据 | |
42 | + * 基础订单查询 | |
44 | 43 | * |
45 | - * @param invoiceBillOrderQueryVO 查询条件 | |
46 | - * @return 单条数据 | |
44 | + * @param queryVO 查询条件 | |
45 | + * @return 查询结果 | |
47 | 46 | */ |
48 | - @PostMapping("/query_by_id") | |
49 | - public ServerResult queryById(@RequestBody InvoiceBillOrderQueryVO invoiceBillOrderQueryVO) { | |
50 | - return invoiceBillOrderService.queryById(invoiceBillOrderQueryVO); | |
47 | + @PostMapping("/list_base_order_info_by") | |
48 | + public ServerResult listBaseOrderInfoBy(@RequestBody @Validated({OperateGroup.List.class}) InvoiceBaseOrderQueryVO queryVO) { | |
49 | + return invoiceBillOrderService.listBaseOrderInfoBy(queryVO); | |
51 | 50 | } |
52 | 51 | |
52 | + | |
53 | 53 | /** |
54 | - * 新增数据 | |
54 | + * 创建invoice单据 | |
55 | 55 | * |
56 | - * @param invoiceBillOrderVO 数据VO | |
56 | + * @param createVO 数据VO | |
57 | 57 | * @return 新增结果 |
58 | 58 | */ |
59 | - @PostMapping("/add") | |
60 | - public ServerResult add(@RequestBody InvoiceBillOrderVO invoiceBillOrderVO) { | |
61 | - return invoiceBillOrderService.add(invoiceBillOrderVO); | |
59 | + @PostMapping("/create") | |
60 | + public ServerResult create(@RequestBody InvoiceBillCreateVO createVO) { | |
61 | + return invoiceBillOrderService.create(createVO); | |
62 | + } | |
63 | + | |
64 | + /** | |
65 | + * 更新扣款信息 | |
66 | + * | |
67 | + * @param deductInfoVO 数据VO | |
68 | + * @return 编辑结果 | |
69 | + */ | |
70 | + @PostMapping("/update_deduct_info") | |
71 | + public ServerResult updateDeductInfo(@RequestBody InvoiceBillDeductInfoVO deductInfoVO) { | |
72 | + return invoiceBillOrderService.updateDeductInfo(deductInfoVO); | |
62 | 73 | } |
63 | 74 | |
64 | 75 | /** |
65 | - * 编辑数据 | |
76 | + * 更新其他金额信息 | |
66 | 77 | * |
67 | - * @param invoiceBillOrderVO 数据VO | |
78 | + * @param amountInfoVO 数据VO | |
68 | 79 | * @return 编辑结果 |
69 | 80 | */ |
70 | - @PostMapping("/edit") | |
71 | - public ServerResult edit(@RequestBody InvoiceBillOrderVO invoiceBillOrderVO) { | |
72 | - return invoiceBillOrderService.edit(invoiceBillOrderVO); | |
81 | + @PostMapping("/update_amount_info") | |
82 | + public ServerResult updateAmountInfo(@RequestBody InvoiceBillAmountInfoVO amountInfoVO) { | |
83 | + return invoiceBillOrderService.updateAmountInfo(amountInfoVO); | |
73 | 84 | } |
74 | 85 | |
75 | 86 | /** | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBaseOrderQueryVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | |
2 | + | |
3 | +import com.order.erp.domain.vo.BasePageVO; | |
4 | +import lombok.*; | |
5 | +import lombok.experimental.SuperBuilder; | |
6 | + | |
7 | +import javax.validation.constraints.NotBlank; | |
8 | +import java.io.Serializable; | |
9 | + | |
10 | +/** | |
11 | + * 应收款账单表(InvoiceBillOrder)实体类 | |
12 | + * | |
13 | + * @author makejava | |
14 | + * @since 2024-08-05 16:26:34 | |
15 | + */ | |
16 | +@Data | |
17 | +@AllArgsConstructor | |
18 | +@ToString | |
19 | +@NoArgsConstructor | |
20 | +@EqualsAndHashCode(callSuper = false) | |
21 | +@SuperBuilder | |
22 | +public class InvoiceBaseOrderQueryVO extends BasePageVO implements Serializable { | |
23 | + | |
24 | + /** | |
25 | + * 发票单号 | |
26 | + */ | |
27 | + @NotBlank(message = "发票单号不能为空") | |
28 | + private String invoiceNo; | |
29 | +} | |
30 | + | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBillAmountInfoVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | |
2 | + | |
3 | +import lombok.*; | |
4 | +import lombok.experimental.SuperBuilder; | |
5 | + | |
6 | +import java.io.Serializable; | |
7 | +import java.math.BigDecimal; | |
8 | + | |
9 | +/** | |
10 | + * 应收款账单 -- 其他金额信息 | |
11 | + * | |
12 | + * @author makejava | |
13 | + * @since 2024-08-05 16:26:33 | |
14 | + */ | |
15 | +@Data | |
16 | +@AllArgsConstructor | |
17 | +@ToString | |
18 | +@NoArgsConstructor | |
19 | +@EqualsAndHashCode(callSuper = false) | |
20 | +@SuperBuilder | |
21 | +public class InvoiceBillAmountInfoVO implements Serializable { | |
22 | + | |
23 | + private Long id; | |
24 | + | |
25 | + /** | |
26 | + * 报关单url地址 | |
27 | + */ | |
28 | + private String bgUrl; | |
29 | + | |
30 | + /** | |
31 | + * 实际应收金额 | |
32 | + */ | |
33 | + private BigDecimal actualReceivableAmount; | |
34 | + /** | |
35 | + * 实际应付金额1 | |
36 | + */ | |
37 | + private BigDecimal actualPayedAmount1; | |
38 | + /** | |
39 | + * 实际应付金额2 | |
40 | + */ | |
41 | + private BigDecimal actualPayedAmount2; | |
42 | + /** | |
43 | + * 实际应付金额3 | |
44 | + */ | |
45 | + private BigDecimal actualPayedAmount3; | |
46 | + /** | |
47 | + * 其他费用金额 | |
48 | + */ | |
49 | + private BigDecimal otherAmount; | |
50 | + | |
51 | +} | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBillCreateVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | |
2 | + | |
3 | +import lombok.*; | |
4 | +import lombok.experimental.SuperBuilder; | |
5 | + | |
6 | +import java.io.Serializable; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * 应收款账单表(InvoiceBillOrder)实体类 | |
11 | + * | |
12 | + * @author makejava | |
13 | + * @since 2024-08-05 16:26:33 | |
14 | + */ | |
15 | +@Data | |
16 | +@AllArgsConstructor | |
17 | +@ToString | |
18 | +@NoArgsConstructor | |
19 | +@EqualsAndHashCode(callSuper = false) | |
20 | +@SuperBuilder | |
21 | +public class InvoiceBillCreateVO implements Serializable { | |
22 | + private static final long serialVersionUID = 543899167451834300L; | |
23 | + | |
24 | + private Long id; | |
25 | + | |
26 | + /** | |
27 | + * 发票单号 | |
28 | + */ | |
29 | + private String invoiceNo; | |
30 | + | |
31 | + /** | |
32 | + * 报关单url地址 | |
33 | + */ | |
34 | + private String bgUrl; | |
35 | + | |
36 | + /** | |
37 | + * 必须回款日期 | |
38 | + */ | |
39 | + private String backRefundDate; | |
40 | + | |
41 | + /** | |
42 | + * 订单id集合 | |
43 | + */ | |
44 | + private List<Long> orderIds; | |
45 | + | |
46 | + | |
47 | +} | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBillDeductInfoVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | |
2 | + | |
3 | +import lombok.*; | |
4 | +import lombok.experimental.SuperBuilder; | |
5 | + | |
6 | +import java.io.Serializable; | |
7 | +import java.math.BigDecimal; | |
8 | + | |
9 | +/** | |
10 | + * 应收款账单 -- 扣款信息 | |
11 | + * | |
12 | + * @author makejava | |
13 | + * @since 2024-08-05 16:26:33 | |
14 | + */ | |
15 | +@Data | |
16 | +@AllArgsConstructor | |
17 | +@ToString | |
18 | +@NoArgsConstructor | |
19 | +@EqualsAndHashCode(callSuper = false) | |
20 | +@SuperBuilder | |
21 | +public class InvoiceBillDeductInfoVO implements Serializable { | |
22 | + | |
23 | + private Long id; | |
24 | + | |
25 | + /** | |
26 | + * 发票单号 | |
27 | + */ | |
28 | + private String invoiceNo; | |
29 | + | |
30 | + /** | |
31 | + * 发生扣款金额 | |
32 | + */ | |
33 | + private BigDecimal deductAmount; | |
34 | + | |
35 | + /** | |
36 | + * 扣款单url地址 | |
37 | + */ | |
38 | + private String deductUrl; | |
39 | + | |
40 | +} | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBillOrderQueryVO.java
... | ... | @@ -23,53 +23,39 @@ public class InvoiceBillOrderQueryVO extends BasePageVO implements Serializable |
23 | 23 | |
24 | 24 | private List<Long> ids; |
25 | 25 | |
26 | - | |
27 | - private Long id; | |
28 | 26 | /** |
29 | 27 | * 发票单号 |
30 | 28 | */ |
31 | 29 | private String invoiceNo; |
30 | + | |
32 | 31 | /** |
33 | - * 报关单url地址 | |
34 | - */ | |
35 | - private String bgUrl; | |
36 | - /** | |
37 | - * 必须回款日期 | |
38 | - */ | |
39 | - private String backRefundDate; | |
40 | - /** | |
41 | - * 发生扣款金额 | |
42 | - */ | |
43 | - private Double deductAmount; | |
44 | - /** | |
45 | - * 扣款单url地址 | |
46 | - */ | |
47 | - private String deductUrl; | |
48 | - /** | |
49 | - * 实际应收金额 | |
32 | + * 总经理审核状态 0:待审核、1:审核通过,2:审核驳回 | |
50 | 33 | */ |
51 | - private Double actualReceivableAmount; | |
34 | + private Integer status; | |
35 | + | |
52 | 36 | /** |
53 | - * 实际应付金额1 | |
37 | + * 客户编码 | |
54 | 38 | */ |
55 | - private Double actualPayedAmount1; | |
39 | + private String customerCode; | |
40 | + | |
56 | 41 | /** |
57 | - * 实际应付金额2 | |
42 | + * 项目号 | |
58 | 43 | */ |
59 | - private Double actualPayedAmount2; | |
44 | + private String projectNo; | |
45 | + | |
60 | 46 | /** |
61 | - * 实际应付金额3 | |
47 | + * 生产科 | |
62 | 48 | */ |
63 | - private Double actualPayedAmount3; | |
49 | + private String productionDepartment; | |
50 | + | |
64 | 51 | /** |
65 | - * 其他费用金额 | |
52 | + * 内部编号 | |
66 | 53 | */ |
67 | - private Double otherAmount; | |
54 | + private String innerNo; | |
55 | + | |
68 | 56 | /** |
69 | - * 总经理审核状态 0:待审核、1:审核通过,2:审核驳回 | |
57 | + * 客户po号 | |
70 | 58 | */ |
71 | - private Integer status; | |
72 | - | |
73 | - | |
59 | + private String customerPo; | |
74 | 60 | } |
75 | 61 | ... | ... |
src/main/java/com/order/erp/domain/vo/order/InvoiceBillOrderVO.java
... | ... | @@ -4,6 +4,7 @@ import lombok.*; |
4 | 4 | import lombok.experimental.SuperBuilder; |
5 | 5 | |
6 | 6 | import java.io.Serializable; |
7 | +import java.math.BigDecimal; | |
7 | 8 | |
8 | 9 | /** |
9 | 10 | * 应收款账单表(InvoiceBillOrder)实体类 |
... | ... | @@ -21,46 +22,57 @@ public class InvoiceBillOrderVO implements Serializable { |
21 | 22 | private static final long serialVersionUID = 543899167451834300L; |
22 | 23 | |
23 | 24 | private Long id; |
25 | + | |
24 | 26 | /** |
25 | 27 | * 发票单号 |
26 | 28 | */ |
27 | 29 | private String invoiceNo; |
30 | + | |
28 | 31 | /** |
29 | 32 | * 报关单url地址 |
30 | 33 | */ |
31 | 34 | private String bgUrl; |
35 | + | |
32 | 36 | /** |
33 | 37 | * 必须回款日期 |
34 | 38 | */ |
35 | 39 | private String backRefundDate; |
40 | + | |
36 | 41 | /** |
37 | 42 | * 发生扣款金额 |
38 | 43 | */ |
39 | - private Double deductAmount; | |
44 | + private BigDecimal deductAmount; | |
45 | + | |
40 | 46 | /** |
41 | 47 | * 扣款单url地址 |
42 | 48 | */ |
43 | 49 | private String deductUrl; |
50 | + | |
44 | 51 | /** |
45 | 52 | * 实际应收金额 |
46 | 53 | */ |
47 | - private Double actualReceivableAmount; | |
54 | + private BigDecimal actualReceivableAmount; | |
55 | + | |
48 | 56 | /** |
49 | 57 | * 实际应付金额1 |
50 | 58 | */ |
51 | - private Double actualPayedAmount1; | |
59 | + private BigDecimal actualPayedAmount1; | |
60 | + | |
52 | 61 | /** |
53 | 62 | * 实际应付金额2 |
54 | 63 | */ |
55 | - private Double actualPayedAmount2; | |
64 | + private BigDecimal actualPayedAmount2; | |
65 | + | |
56 | 66 | /** |
57 | 67 | * 实际应付金额3 |
58 | 68 | */ |
59 | - private Double actualPayedAmount3; | |
69 | + private BigDecimal actualPayedAmount3; | |
70 | + | |
60 | 71 | /** |
61 | 72 | * 其他费用金额 |
62 | 73 | */ |
63 | - private Double otherAmount; | |
74 | + private BigDecimal otherAmount; | |
75 | + | |
64 | 76 | /** |
65 | 77 | * 总经理审核状态 0:待审核、1:审核通过,2:审核驳回 |
66 | 78 | */ | ... | ... |
src/main/java/com/order/erp/service/order/InvoiceBillOrderService.java
... | ... | @@ -3,8 +3,7 @@ package com.order.erp.service.order; |
3 | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
4 | 4 | import com.order.erp.common.constant.ServerResult; |
5 | 5 | import com.order.erp.domain.dto.order.InvoiceBillOrderDO; |
6 | -import com.order.erp.domain.vo.order.InvoiceBillOrderQueryVO; | |
7 | -import com.order.erp.domain.vo.order.InvoiceBillOrderVO; | |
6 | +import com.order.erp.domain.vo.order.*; | |
8 | 7 | |
9 | 8 | /** |
10 | 9 | * 应收款账单表(InvoiceBillOrder)表服务接口 |
... | ... | @@ -15,36 +14,42 @@ import com.order.erp.domain.vo.order.InvoiceBillOrderVO; |
15 | 14 | public interface InvoiceBillOrderService extends IService<InvoiceBillOrderDO> { |
16 | 15 | |
17 | 16 | /** |
18 | - * 通过ID查询单条数据 | |
19 | - * | |
20 | - * @param invoiceBillOrderQueryVO 主键 | |
21 | - * @return 实例对象 | |
22 | - */ | |
23 | - ServerResult queryById(InvoiceBillOrderQueryVO invoiceBillOrderQueryVO); | |
24 | - | |
25 | - /** | |
26 | 17 | * 分页查询 |
27 | 18 | * |
28 | 19 | * @param invoiceBillOrderQueryVO 筛选条件 |
29 | 20 | * @return 查询结果 |
30 | 21 | */ |
31 | - ServerResult list(InvoiceBillOrderQueryVO invoiceBillOrderQueryVO); | |
22 | + ServerResult listByPage(InvoiceBillOrderQueryVO invoiceBillOrderQueryVO); | |
23 | + | |
24 | + /** | |
25 | + * @param queryVO | |
26 | + * @return | |
27 | + */ | |
28 | + ServerResult listBaseOrderInfoBy(InvoiceBaseOrderQueryVO queryVO); | |
32 | 29 | |
33 | 30 | /** |
34 | 31 | * 新增数据 |
35 | 32 | * |
36 | - * @param invoiceBillOrderVO 数据VO | |
33 | + * @param createVO 数据VO | |
37 | 34 | * @return 新增结果 |
38 | 35 | */ |
39 | - ServerResult add(InvoiceBillOrderVO invoiceBillOrderVO); | |
36 | + ServerResult create(InvoiceBillCreateVO createVO); | |
40 | 37 | |
41 | 38 | /** |
42 | - * 修改数据 | |
39 | + * 更新扣款信息 | |
43 | 40 | * |
44 | - * @param invoiceBillOrderVO 数据VO | |
41 | + * @param deductInfoVO 数据VO | |
45 | 42 | * @return 编辑结果 |
46 | 43 | */ |
47 | - ServerResult edit(InvoiceBillOrderVO invoiceBillOrderVO); | |
44 | + ServerResult updateDeductInfo(InvoiceBillDeductInfoVO deductInfoVO); | |
45 | + | |
46 | + /** | |
47 | + * 更新其他金额信息 | |
48 | + * | |
49 | + * @param amountInfoVO | |
50 | + * @return | |
51 | + */ | |
52 | + ServerResult updateAmountInfo(InvoiceBillAmountInfoVO amountInfoVO); | |
48 | 53 | |
49 | 54 | /** |
50 | 55 | * 通过主键删除数据 | ... | ... |
src/main/java/com/order/erp/service/order/impl/InvoiceBillOrderServiceImpl.java
1 | 1 | package com.order.erp.service.order.impl; |
2 | 2 | |
3 | -import cn.hutool.core.bean.BeanUtil; | |
4 | 3 | import cn.hutool.core.collection.CollUtil; |
5 | 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
6 | -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
7 | 5 | import com.baomidou.mybatisplus.core.metadata.IPage; |
6 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |
8 | 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
9 | 8 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
10 | 9 | import com.order.erp.common.constant.Constant; |
11 | 10 | import com.order.erp.common.constant.ServerResult; |
12 | -import com.order.erp.common.utils.PageUtils; | |
11 | +import com.order.erp.common.exception.BusinessException; | |
12 | +import com.order.erp.common.utils.StringUtils; | |
13 | +import com.order.erp.common.utils.TransactionHelper; | |
14 | +import com.order.erp.domain.dto.BaseDO; | |
15 | +import com.order.erp.domain.dto.order.InvoiceBillMappingDO; | |
13 | 16 | import com.order.erp.domain.dto.order.InvoiceBillOrderDO; |
14 | -import com.order.erp.domain.vo.order.InvoiceBillOrderQueryVO; | |
15 | -import com.order.erp.domain.vo.order.InvoiceBillOrderVO; | |
17 | +import com.order.erp.domain.dto.order.OrderBaseInfoDO; | |
18 | +import com.order.erp.domain.vo.order.*; | |
16 | 19 | import com.order.erp.mapper.order.InvoiceBillOrderMapper; |
20 | +import com.order.erp.service.order.InvoiceBillMappingService; | |
17 | 21 | import com.order.erp.service.order.InvoiceBillOrderService; |
22 | +import com.order.erp.service.order.OrderBaseInfoService; | |
18 | 23 | import lombok.extern.slf4j.Slf4j; |
19 | 24 | import org.springframework.stereotype.Service; |
20 | 25 | |
21 | -import java.util.List; | |
22 | -import java.util.Objects; | |
26 | +import javax.annotation.Resource; | |
27 | +import java.util.*; | |
28 | +import java.util.stream.Collectors; | |
23 | 29 | |
24 | 30 | /** |
25 | 31 | * 应收款账单表(InvoiceBillOrder)表服务实现类 |
... | ... | @@ -32,78 +38,225 @@ import java.util.Objects; |
32 | 38 | public class InvoiceBillOrderServiceImpl extends ServiceImpl<InvoiceBillOrderMapper, InvoiceBillOrderDO> implements InvoiceBillOrderService { |
33 | 39 | |
34 | 40 | |
35 | - /** | |
36 | - * 通过ID查询单条数据 | |
37 | - * <p> | |
38 | - * invoiceBillOrderQueryVO 主键 | |
39 | - * | |
40 | - * @return 实例对象 | |
41 | - */ | |
42 | - @Override | |
43 | - public ServerResult queryById(InvoiceBillOrderQueryVO invoiceBillOrderQueryVO) { | |
44 | - if (Objects.isNull(invoiceBillOrderQueryVO.getId())) { | |
45 | - return ServerResult.fail("id 不能为空"); | |
46 | - } | |
47 | - InvoiceBillOrderDO InvoiceBillOrderDo = getById(invoiceBillOrderQueryVO.getId()); | |
48 | - if (Objects.isNull(InvoiceBillOrderDo)) { | |
49 | - return ServerResult.success(null); | |
50 | - } | |
51 | - return ServerResult.success(BeanUtil.copyProperties(InvoiceBillOrderDo, InvoiceBillOrderVO.class)); | |
52 | - } | |
41 | + @Resource | |
42 | + private OrderBaseInfoService orderBaseInfoService; | |
43 | + | |
44 | + @Resource | |
45 | + private InvoiceBillMappingService invoiceBillMappingService; | |
46 | + | |
47 | + @Resource | |
48 | + private TransactionHelper transactionHelper; | |
49 | + | |
53 | 50 | |
54 | 51 | /** |
55 | 52 | * 分页查询 |
56 | 53 | * |
57 | - * @param invoiceBillOrderQueryVO 筛选条件 | |
54 | + * @param queryVO 筛选条件 | |
58 | 55 | * @return 查询结果 |
59 | 56 | */ |
60 | 57 | @Override |
61 | - public ServerResult list(InvoiceBillOrderQueryVO invoiceBillOrderQueryVO) { | |
58 | + public ServerResult listByPage(InvoiceBillOrderQueryVO queryVO) { | |
59 | + Set<Long> billOrderIds = filterBillOrderIdsBy(queryVO); | |
62 | 60 | |
63 | - LambdaQueryWrapper<InvoiceBillOrderDO> queryWapper = new LambdaQueryWrapper<InvoiceBillOrderDO>() | |
61 | + LambdaQueryWrapper<InvoiceBillOrderDO> queryWrapper = new LambdaQueryWrapper<InvoiceBillOrderDO>() | |
64 | 62 | .eq(InvoiceBillOrderDO::getEnableFlag, Constant.ENABLE_TEN) |
63 | + .in(CollectionUtils.isNotEmpty(billOrderIds), InvoiceBillOrderDO::getId, billOrderIds) | |
64 | + .eq(StringUtils.isNotBlank(queryVO.getInvoiceNo()), InvoiceBillOrderDO::getInvoiceNo, queryVO.getInvoiceNo()) | |
65 | + .eq(Objects.nonNull(queryVO.getStatus()), InvoiceBillOrderDO::getStatus, queryVO.getStatus()) | |
65 | 66 | .orderByDesc(InvoiceBillOrderDO::getId); |
66 | - Page page = new Page<>(invoiceBillOrderQueryVO.getPage(), invoiceBillOrderQueryVO.getPageSize()); | |
67 | - IPage<InvoiceBillOrderDO> iPage = page(page, queryWapper); | |
68 | - invoiceBillOrderQueryVO.setTotal(Long.valueOf(iPage.getTotal()).intValue()); | |
69 | - return ServerResult.success(PageUtils.getPageReturn(null, invoiceBillOrderQueryVO)); | |
67 | + Page page = new Page<>(queryVO.getPage(), queryVO.getPageSize()); | |
68 | + IPage<InvoiceBillOrderDO> iPage = page(page, queryWrapper); | |
69 | + return ServerResult.success(iPage); | |
70 | + } | |
71 | + | |
72 | + @Override | |
73 | + public ServerResult listBaseOrderInfoBy(InvoiceBaseOrderQueryVO queryVO) { | |
74 | + List<InvoiceBillMappingDO> mappingDOS = invoiceBillMappingService.list(new LambdaQueryWrapper<InvoiceBillMappingDO>() | |
75 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
76 | + .eq(InvoiceBillMappingDO::getInvoiceNo, queryVO.getInvoiceNo())); | |
77 | + if (CollectionUtils.isEmpty(mappingDOS)) { | |
78 | + return ServerResult.success(); | |
79 | + } | |
80 | + Set<Long> orderIds = mappingDOS.stream().map(InvoiceBillMappingDO::getOrderId).collect(Collectors.toSet()); | |
81 | + return ServerResult.success(orderBaseInfoService.listByIds(orderIds)); | |
82 | + } | |
83 | + | |
84 | + /** | |
85 | + * @param queryVO | |
86 | + * @return | |
87 | + */ | |
88 | + private Set<Long> filterBillOrderIdsBy(InvoiceBillOrderQueryVO queryVO) { | |
89 | + List<Long> orderIds = filterOrderIdsBy(queryVO); | |
90 | + if (CollectionUtils.isEmpty(orderIds)) { | |
91 | + return null; | |
92 | + } | |
93 | + List<InvoiceBillMappingDO> mappingDOS = invoiceBillMappingService.list(new LambdaQueryWrapper<InvoiceBillMappingDO>().eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
94 | + .in(CollectionUtils.isNotEmpty(orderIds), InvoiceBillMappingDO::getOrderId, orderIds)); | |
95 | + if (CollectionUtils.isEmpty(mappingDOS)) { | |
96 | + Set<Long> ids = new HashSet<>(); | |
97 | + ids.add(-1L); | |
98 | + return ids; | |
99 | + } | |
100 | + return mappingDOS.stream().map(InvoiceBillMappingDO::getInvoiceBillId).collect(Collectors.toSet()); | |
101 | + } | |
102 | + | |
103 | + /** | |
104 | + * @param queryVO | |
105 | + * @return | |
106 | + */ | |
107 | + private List<Long> filterOrderIdsBy(InvoiceBillOrderQueryVO queryVO) { | |
108 | + Boolean flag = false; | |
109 | + if (StringUtils.isNotBlank(queryVO.getCustomerCode())) { | |
110 | + flag = flag | true; | |
111 | + } | |
112 | + if (StringUtils.isNotBlank(queryVO.getProductionDepartment())) { | |
113 | + flag = flag | true; | |
114 | + } | |
115 | + if (StringUtils.isNotBlank(queryVO.getCustomerPo())) { | |
116 | + flag = flag | true; | |
117 | + } | |
118 | + if (StringUtils.isNotBlank(queryVO.getInnerNo())) { | |
119 | + flag = flag | true; | |
120 | + } | |
121 | + if (StringUtils.isNotBlank(queryVO.getProjectNo())) { | |
122 | + flag = flag | true; | |
123 | + } | |
124 | + if (!flag) { | |
125 | + return null; | |
126 | + } | |
127 | + LambdaQueryWrapper<OrderBaseInfoDO> queryWrapper = new LambdaQueryWrapper<OrderBaseInfoDO>() | |
128 | + .eq(OrderBaseInfoDO::getEnableFlag, Constant.ENABLE_TEN) | |
129 | + .eq(StringUtils.isNotBlank(queryVO.getCustomerCode()), OrderBaseInfoDO::getCustomerCode, queryVO.getCustomerCode()) | |
130 | + .eq(StringUtils.isNotBlank(queryVO.getProductionDepartment()), OrderBaseInfoDO::getProductionDepartment, queryVO.getProductionDepartment()) | |
131 | + .eq(StringUtils.isNotBlank(queryVO.getCustomerPo()), OrderBaseInfoDO::getCustomerPo, queryVO.getCustomerPo()) | |
132 | + .eq(StringUtils.isNotBlank(queryVO.getInnerNo()), OrderBaseInfoDO::getInnerNo, queryVO.getInnerNo()) | |
133 | + .eq(StringUtils.isNotBlank(queryVO.getProjectNo()), OrderBaseInfoDO::getProjectNo, queryVO.getProjectNo()); | |
134 | + List<OrderBaseInfoDO> orderBaseInfoDOList = orderBaseInfoService.list(queryWrapper); | |
135 | + if (CollectionUtils.isEmpty(orderBaseInfoDOList)) { | |
136 | + List<Long> orderIds = new ArrayList<>(); | |
137 | + orderIds.add(-1L); | |
138 | + return orderIds; | |
139 | + } | |
140 | + return orderBaseInfoDOList.stream().map(OrderBaseInfoDO::getId).collect(Collectors.toList()); | |
70 | 141 | } |
71 | 142 | |
72 | 143 | /** |
73 | - * 新增数据 | |
144 | + * 创建invoice单据 | |
74 | 145 | * |
75 | - * @param invoiceBillOrderVO 实例对象 | |
146 | + * @param createVO 实例对象 | |
76 | 147 | * @return 实例对象 |
77 | 148 | */ |
78 | 149 | @Override |
79 | - public ServerResult add(InvoiceBillOrderVO invoiceBillOrderVO) { | |
80 | - //todo 校验 | |
81 | - if (Objects.nonNull(invoiceBillOrderVO.getId())) { | |
82 | - invoiceBillOrderVO.setId(null); | |
150 | + public ServerResult create(InvoiceBillCreateVO createVO) { | |
151 | + if (Objects.nonNull(createVO.getId())) { | |
152 | + createVO.setId(null); | |
83 | 153 | } |
84 | - InvoiceBillOrderDO invoiceBillOrderDo = BeanUtil.copyProperties(invoiceBillOrderVO, InvoiceBillOrderDO.class); | |
85 | 154 | |
86 | - save(invoiceBillOrderDo); | |
155 | + validaBillOrder(createVO); | |
156 | + | |
157 | + InvoiceBillOrderDO invoiceBillOrderDO = buildInvoiceBillOrderDO(createVO); | |
158 | + | |
159 | + transactionHelper.run(() -> { | |
160 | + save(invoiceBillOrderDO); | |
161 | + | |
162 | + invoiceBillMappingService.saveBatch(buildInvoiceBillMappingDOS(createVO, invoiceBillOrderDO)); | |
163 | + }); | |
87 | 164 | |
88 | 165 | return ServerResult.success(); |
89 | 166 | } |
90 | 167 | |
91 | 168 | /** |
169 | + * @param createVO | |
170 | + * @return | |
171 | + */ | |
172 | + private InvoiceBillOrderDO buildInvoiceBillOrderDO(InvoiceBillCreateVO createVO) { | |
173 | + return InvoiceBillOrderDO.builder() | |
174 | + .invoiceNo(createVO.getInvoiceNo()) | |
175 | + .bgUrl(createVO.getBgUrl()) | |
176 | + .backRefundDate(createVO.getBackRefundDate()) | |
177 | + .build(); | |
178 | + } | |
179 | + | |
180 | + /** | |
181 | + * @param createVO | |
182 | + * @param invoiceBillOrderDO | |
183 | + * @return | |
184 | + */ | |
185 | + private List<InvoiceBillMappingDO> buildInvoiceBillMappingDOS(InvoiceBillCreateVO createVO, InvoiceBillOrderDO invoiceBillOrderDO) { | |
186 | + return createVO.getOrderIds().stream().map(x -> { | |
187 | + return InvoiceBillMappingDO.builder() | |
188 | + .orderId(x) | |
189 | + .invoiceBillId(invoiceBillOrderDO.getId()) | |
190 | + .invoiceNo(invoiceBillOrderDO.getInvoiceNo()) | |
191 | + .build(); | |
192 | + }).collect(Collectors.toList()); | |
193 | + } | |
194 | + | |
195 | + /** | |
196 | + * @param createVO | |
197 | + */ | |
198 | + private void validaBillOrder(InvoiceBillCreateVO createVO) { | |
199 | + if (CollectionUtils.isEmpty(createVO.getOrderIds())) { | |
200 | + throw new BusinessException("请勾选订单!"); | |
201 | + } | |
202 | + | |
203 | + List<OrderBaseInfoDO> orderBaseInfoDOList = orderBaseInfoService.listByIds(createVO.getOrderIds()); | |
204 | + if (CollectionUtils.isEmpty(orderBaseInfoDOList)) { | |
205 | + throw new BusinessException("勾选的订单信息不存在!"); | |
206 | + } | |
207 | + | |
208 | + if (orderBaseInfoDOList.size() != createVO.getOrderIds().size()) { | |
209 | + throw new BusinessException("勾选的订单信息有误!"); | |
210 | + } | |
211 | + | |
212 | + String invoiceNo = createVO.getInvoiceNo(); | |
213 | + | |
214 | + List<InvoiceBillOrderDO> invoiceBillOrderDOS = list(new LambdaQueryWrapper<InvoiceBillOrderDO>() | |
215 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
216 | + .eq(InvoiceBillOrderDO::getInvoiceNo, invoiceNo)); | |
217 | + if (CollectionUtils.isNotEmpty(invoiceBillOrderDOS)) { | |
218 | + throw new BusinessException("存在相同的invoice订单!"); | |
219 | + } | |
220 | + | |
221 | + } | |
222 | + | |
223 | + /** | |
92 | 224 | * 修改数据 |
93 | 225 | * |
94 | - * @param invoiceBillOrderVO 实例对象 | |
226 | + * @param deductInfoVO 实例对象 | |
95 | 227 | * @return 实例对象 |
96 | 228 | */ |
97 | 229 | @Override |
98 | - public ServerResult edit(InvoiceBillOrderVO invoiceBillOrderVO) { | |
99 | - //todo 校验 | |
100 | - if (Objects.isNull(invoiceBillOrderVO.getId())) { | |
101 | - return ServerResult.fail("id 不能为空"); | |
230 | + public ServerResult updateDeductInfo(InvoiceBillDeductInfoVO deductInfoVO) { | |
231 | + if (Objects.isNull(deductInfoVO.getId())) { | |
232 | + throw new BusinessException("id 不能为空"); | |
102 | 233 | } |
103 | - InvoiceBillOrderDO invoiceBillOrderDo = BeanUtil.copyProperties(invoiceBillOrderVO, InvoiceBillOrderDO.class); | |
104 | - | |
234 | + InvoiceBillOrderDO invoiceBillOrderDo = getById(deductInfoVO.getId()); | |
235 | + if (Objects.isNull(invoiceBillOrderDo)) { | |
236 | + throw new BusinessException("应收款单据不存在"); | |
237 | + } | |
238 | + invoiceBillOrderDo.setDeductUrl(deductInfoVO.getDeductUrl()); | |
239 | + invoiceBillOrderDo.setDeductAmount(deductInfoVO.getDeductAmount()); | |
105 | 240 | updateById(invoiceBillOrderDo); |
241 | + return ServerResult.success(); | |
242 | + } | |
106 | 243 | |
244 | + @Override | |
245 | + public ServerResult updateAmountInfo(InvoiceBillAmountInfoVO amountInfoVO) { | |
246 | + if (Objects.isNull(amountInfoVO.getId())) { | |
247 | + throw new BusinessException("id 不能为空"); | |
248 | + } | |
249 | + InvoiceBillOrderDO invoiceBillOrderDo = getById(amountInfoVO.getId()); | |
250 | + if (Objects.isNull(invoiceBillOrderDo)) { | |
251 | + throw new BusinessException("应收款单据不存在"); | |
252 | + } | |
253 | + invoiceBillOrderDo.setBgUrl(amountInfoVO.getBgUrl()); | |
254 | + invoiceBillOrderDo.setActualReceivableAmount(amountInfoVO.getActualReceivableAmount()); | |
255 | + invoiceBillOrderDo.setActualPayedAmount1(amountInfoVO.getActualPayedAmount1()); | |
256 | + invoiceBillOrderDo.setActualPayedAmount2(amountInfoVO.getActualPayedAmount2()); | |
257 | + invoiceBillOrderDo.setActualPayedAmount3(amountInfoVO.getActualPayedAmount3()); | |
258 | + invoiceBillOrderDo.setOtherAmount(amountInfoVO.getOtherAmount()); | |
259 | + updateById(invoiceBillOrderDo); | |
107 | 260 | return ServerResult.success(); |
108 | 261 | } |
109 | 262 | |
... | ... | @@ -123,11 +276,11 @@ public class InvoiceBillOrderServiceImpl extends ServiceImpl<InvoiceBillOrderMap |
123 | 276 | if (CollUtil.isEmpty(invoiceBillOrderList)) { |
124 | 277 | return ServerResult.success(); |
125 | 278 | } |
126 | - //todo 校验是否可以逻辑删除 | |
127 | - LambdaUpdateWrapper<InvoiceBillOrderDO> updateWrapper = new LambdaUpdateWrapper<InvoiceBillOrderDO>() | |
128 | - .in(InvoiceBillOrderDO::getId, ids) | |
129 | - .set(InvoiceBillOrderDO::getEnableFlag, Constant.UNABLE_TWENTY); | |
130 | - update(updateWrapper); | |
279 | + transactionHelper.run(() -> { | |
280 | + removeByIds(ids); | |
281 | + invoiceBillMappingService.remove(new LambdaQueryWrapper<InvoiceBillMappingDO>().in(InvoiceBillMappingDO::getInvoiceBillId, ids)); | |
282 | + }); | |
283 | + | |
131 | 284 | return ServerResult.success(); |
132 | 285 | } |
133 | 286 | } | ... | ... |