SettlementController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package com.trade.finance.controller;
  18. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  19. import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  20. import com.trade.finance.dto.SettlementDTO;
  21. import com.trade.finance.entity.Items;
  22. import com.trade.finance.entity.Settlement;
  23. import com.trade.finance.service.IItemsService;
  24. import com.trade.finance.service.ISettlementService;
  25. import com.trade.finance.vo.SettlementVO;
  26. import io.swagger.annotations.Api;
  27. import io.swagger.annotations.ApiOperation;
  28. import io.swagger.annotations.ApiParam;
  29. import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
  30. import lombok.AllArgsConstructor;
  31. import javax.validation.Valid;
  32. import org.springblade.client.entity.CorpsDesc;
  33. import org.springblade.client.feign.ICorpsDescClient;
  34. import org.springblade.core.mp.support.Condition;
  35. import org.springblade.core.mp.support.Query;
  36. import org.springblade.core.secure.utils.SecureUtil;
  37. import org.springblade.core.tool.api.R;
  38. import org.springblade.core.tool.utils.Func;
  39. import org.springframework.web.bind.annotation.*;
  40. import com.baomidou.mybatisplus.core.metadata.IPage;
  41. import org.springblade.core.boot.ctrl.BladeController;
  42. import java.util.List;
  43. import java.util.Map;
  44. /**
  45. * 结算表 控制器
  46. *
  47. * @author BladeX
  48. * @since 2021-11-03
  49. */
  50. @RestController
  51. @AllArgsConstructor
  52. @RequestMapping("/settlement")
  53. @Api(value = "收款付款", tags = "收款付款-接口")
  54. public class SettlementController extends BladeController {
  55. private final ISettlementService settlementService;
  56. private final IItemsService itemsService;
  57. private ICorpsDescClient corpsDescClient;//获取客户信息
  58. /**
  59. * 详情
  60. */
  61. @GetMapping("/detail")
  62. @ApiOperationSupport(order = 1)
  63. @ApiOperation(value = "详情", notes = "传入settlement")
  64. public R<Settlement> detail(Settlement settlement) {
  65. Settlement detail = settlementService.getOne(Condition.getQueryWrapper(settlement));
  66. LambdaQueryWrapper<Items> itemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
  67. itemsLambdaQueryWrapper.eq(Items::getPid,detail.getId());
  68. List<Items> list = itemsService.list(itemsLambdaQueryWrapper);
  69. detail.setItemsList(list);
  70. //获取客户中文名
  71. if (detail.getCorpId() != null){
  72. R<List<Map<String,Object>>> corpMessage = corpsDescClient.getCorpsMessage(detail.getCorpId().toString());
  73. if (corpMessage.isSuccess() && corpMessage.getData() != null){
  74. detail.setCustomerModel(corpMessage.getData());
  75. }
  76. }
  77. return R.data(detail);
  78. }
  79. /**
  80. * 分页 结算表
  81. */
  82. @GetMapping("/list")
  83. @ApiOperationSupport(order = 2)
  84. @ApiOperation(value = "分页", notes = "传入settlement")
  85. public R<IPage<Settlement>> list(Settlement settlement, Query query) {
  86. settlement.setTenantId(SecureUtil.getTenantId());
  87. settlement.setIsDeleted(0);
  88. IPage<Settlement> pages = settlementService.page(Condition.getPage(query), Condition.getQueryWrapper(settlement));
  89. List<Settlement> settlementList = pages.getRecords();
  90. if(CollectionUtils.isNotEmpty(settlementList))
  91. {
  92. settlementList.forEach(e->{
  93. R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
  94. if(corpMessage.getData()!=null)
  95. {
  96. e.setCorpName(corpMessage.getData().getCname());
  97. }
  98. });
  99. }
  100. return R.data(pages);
  101. }
  102. /**
  103. * 自定义分页 结算表
  104. */
  105. @GetMapping("/page")
  106. @ApiOperationSupport(order = 3)
  107. @ApiOperation(value = "分页", notes = "传入settlement")
  108. public R<IPage<SettlementVO>> page(SettlementVO settlement, Query query) {
  109. IPage<SettlementVO> pages = settlementService.selectSettlementPage(Condition.getPage(query), settlement);
  110. return R.data(pages);
  111. }
  112. @PostMapping("modify")
  113. @ApiOperation(value = "修改新增收付款信息", notes = "传入修改新增收付款信息对象")
  114. public R modify(@RequestBody SettlementDTO dto)
  115. {
  116. settlementService.modify(dto);
  117. return R.success("操作成功");
  118. }
  119. /**
  120. * 新增 结算表
  121. @PostMapping("/save")
  122. @ApiOperationSupport(order = 4)
  123. @ApiOperation(value = "新增", notes = "传入settlement")
  124. public R save(@Valid @RequestBody Settlement settlement) {
  125. return R.status(settlementService.save(settlement));
  126. }
  127. *//**
  128. * 修改 结算表
  129. *//*
  130. @PostMapping("/update")
  131. @ApiOperationSupport(order = 5)
  132. @ApiOperation(value = "修改", notes = "传入settlement")
  133. public R update(@Valid @RequestBody Settlement settlement) {
  134. return R.status(settlementService.updateById(settlement));
  135. }*/
  136. /**
  137. * 新增或修改 结算表
  138. */
  139. @PostMapping("/submit")
  140. @ApiOperationSupport(order = 6)
  141. @ApiOperation(value = "新增或修改", notes = "传入settlement")
  142. public R submit(@Valid @RequestBody Settlement settlement) {
  143. return R.status(settlementService.saveOrUpdate(settlement));
  144. }
  145. /**
  146. * 删除 结算表
  147. */
  148. @PostMapping("/remove")
  149. @ApiOperationSupport(order = 8)
  150. @ApiOperation(value = "删除", notes = "传入ids")
  151. public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
  152. return R.status(settlementService.removeByIds(Func.toLongList(ids)));
  153. }
  154. }