SettlementController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.baomidou.mybatisplus.core.toolkit.StringUtils;
  21. import com.trade.finance.dto.ApplyDTO;
  22. import com.trade.finance.dto.SettlementDTO;
  23. import com.trade.finance.entity.Acc;
  24. import com.trade.finance.entity.Items;
  25. import com.trade.finance.entity.Settlement;
  26. import com.trade.finance.service.IItemsService;
  27. import com.trade.finance.service.ISettlementService;
  28. import com.trade.finance.vo.SettlementVO;
  29. import io.swagger.annotations.Api;
  30. import io.swagger.annotations.ApiModelProperty;
  31. import io.swagger.annotations.ApiOperation;
  32. import io.swagger.annotations.ApiParam;
  33. import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
  34. import lombok.AllArgsConstructor;
  35. import javax.validation.Valid;
  36. import lombok.Data;
  37. import org.springblade.client.entity.CorpsBank;
  38. import org.springblade.client.entity.CorpsDesc;
  39. import org.springblade.client.feign.ICorpsDescClient;
  40. import org.springblade.client.feign.IFeesDescClient;
  41. import org.springblade.core.mp.support.Condition;
  42. import org.springblade.core.mp.support.Query;
  43. import org.springblade.core.secure.utils.AuthUtil;
  44. import org.springblade.core.secure.utils.SecureUtil;
  45. import org.springblade.core.tool.api.R;
  46. import org.springblade.core.tool.utils.Func;
  47. import org.springblade.system.user.feign.IUserClient;
  48. import org.springframework.web.bind.annotation.*;
  49. import com.baomidou.mybatisplus.core.metadata.IPage;
  50. import org.springblade.core.boot.ctrl.BladeController;
  51. import java.util.List;
  52. import java.util.Map;
  53. /**
  54. * 结算表 控制器
  55. *
  56. * @author BladeX
  57. * @since 2021-11-03
  58. */
  59. @RestController
  60. @AllArgsConstructor
  61. @RequestMapping("/settlement")
  62. @Api(value = "收款付款", tags = "收款付款-接口")
  63. public class SettlementController extends BladeController {
  64. private final ISettlementService settlementService;
  65. private final IItemsService itemsService;
  66. private final ICorpsDescClient corpsDescClient;//获取客户信息
  67. private final IUserClient iUserClient;
  68. private final IFeesDescClient iFeesDescClient;
  69. /**
  70. * 详情
  71. */
  72. @GetMapping("/detail")
  73. @ApiOperationSupport(order = 1)
  74. @ApiOperation(value = "详情", notes = "传入settlement")
  75. public R<Settlement> detail(Settlement settlement) {
  76. Settlement detail = settlementService.getOne(Condition.getQueryWrapper(settlement));
  77. LambdaQueryWrapper<Items> itemsLambdaQueryWrapper=new LambdaQueryWrapper<>();
  78. itemsLambdaQueryWrapper.eq(Items::getPid,detail.getId());
  79. List<Items> list = itemsService.list(itemsLambdaQueryWrapper);
  80. if(CollectionUtils.isNotEmpty(list))
  81. {
  82. list.forEach(e->{
  83. //录入人
  84. e.setCreateUserName(iUserClient.userInfoById(e.getCreateUser()).getData().getRealName());
  85. //客户名称
  86. e.setCorpName(corpsDescClient.getCorpMessage(e.getCorpId()).getData().getCname());
  87. //费用名称
  88. e.setItemName(iFeesDescClient.detail(Long.valueOf(e.getCostType())).getData().getCname());
  89. });
  90. }
  91. detail.setItemsList(list);
  92. //获取客户中文名
  93. if (detail.getCorpId() != null){
  94. R<List<Map<String,Object>>> corpMessage = corpsDescClient.getCorpsMessage(detail.getCorpId().toString());
  95. if (corpMessage.isSuccess() && corpMessage.getData() != null){
  96. detail.setCustomerModel(corpMessage.getData());
  97. }
  98. }
  99. List<CorpsBank> corpsBanks = corpsDescClient.listBankByCorpId(detail.getCorpId());
  100. detail.setBankList(corpsBanks);
  101. //制单人
  102. detail.setCreateUserName(iUserClient.userInfoById(detail.getCreateUser()).getData().getRealName());
  103. return R.data(detail);
  104. }
  105. /**
  106. * 分页 结算表
  107. */
  108. @GetMapping("/list")
  109. @ApiOperationSupport(order = 2)
  110. @ApiOperation(value = "分页", notes = "传入settlement")
  111. public R<IPage<Settlement>> list(Settlement settlement, Query query) {
  112. LambdaQueryWrapper<Settlement> settlementLambdaQueryWrapper=new LambdaQueryWrapper<>();
  113. settlementLambdaQueryWrapper.between(StringUtils.isNotBlank(settlement.getSettlementStartDate())&&StringUtils.isNotBlank(settlement.getSettlementEndDate()),Settlement::getSettlementDate,settlement.getSettlementStartDate(),settlement.getSettlementEndDate());
  114. settlementLambdaQueryWrapper.between(StringUtils.isNotBlank(settlement.getCreateStartDate())&&StringUtils.isNotBlank(settlement.getCreateEndDate()),Settlement::getCreateTime,settlement.getCreateStartDate(),settlement.getCreateEndDate());
  115. settlementLambdaQueryWrapper.like(StringUtils.isNotBlank(settlement.getSrcOrderno()),Settlement::getSrcOrderno,settlement.getSrcOrderno());
  116. settlementLambdaQueryWrapper.like(StringUtils.isNotBlank(settlement.getBillNo()),Settlement::getBillNo,settlement.getBillNo());
  117. settlementLambdaQueryWrapper.like(StringUtils.isNotBlank(settlement.getRemark()),Settlement::getRemark,settlement.getRemark());
  118. settlementLambdaQueryWrapper.like(StringUtils.isNotBlank(settlement.getAccountName()),Settlement::getAccountName,settlement.getAccountName());
  119. settlementLambdaQueryWrapper.like(settlement.getCorpId()!=null,Settlement::getCorpId,settlement.getCorpId());
  120. settlementLambdaQueryWrapper.eq(StringUtils.isNotBlank(settlement.getFinanceStatus()),Settlement::getFinanceStatus,settlement.getFinanceStatus());
  121. settlementLambdaQueryWrapper.eq(StringUtils.isNotBlank(settlement.getCheckStatus()),Settlement::getCheckStatus,settlement.getCheckStatus());
  122. settlementLambdaQueryWrapper.eq(StringUtils.isNotBlank(settlement.getBillType()),Settlement::getBillType,settlement.getBillType());
  123. settlementLambdaQueryWrapper.eq(Settlement::getTenantId, AuthUtil.getTenantId());
  124. settlementLambdaQueryWrapper.eq(Settlement::getIsDeleted, 0);
  125. IPage<Settlement> pages = settlementService.page(Condition.getPage(query), settlementLambdaQueryWrapper);
  126. List<Settlement> settlementList = pages.getRecords();
  127. if(CollectionUtils.isNotEmpty(settlementList))
  128. {
  129. settlementList.forEach(e->{
  130. R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(e.getCorpId());
  131. if(corpMessage.getData()!=null)
  132. {
  133. e.setCorpName(corpMessage.getData().getCname());
  134. }
  135. });
  136. }
  137. return R.data(pages);
  138. }
  139. /**
  140. * 自定义分页 结算表
  141. */
  142. @GetMapping("/page")
  143. @ApiOperationSupport(order = 3)
  144. @ApiOperation(value = "分页", notes = "传入settlement")
  145. public R<IPage<SettlementVO>> page(SettlementVO settlement, Query query) {
  146. IPage<SettlementVO> pages = settlementService.selectSettlementPage(Condition.getPage(query), settlement);
  147. return R.data(pages);
  148. }
  149. @PostMapping("modify")
  150. @ApiOperation(value = "修改新增收付款信息", notes = "传入修改新增收付款信息对象")
  151. public R modify(@RequestBody SettlementDTO dto)
  152. {
  153. settlementService.modify(dto);
  154. return R.data(dto);
  155. }
  156. @PostMapping("saveOrEdit")
  157. @ApiOperation(value = "保存收付款信息", notes = "保存收付款信息")
  158. public R saveOrEdit(@RequestBody SettlementDTO dto)
  159. {
  160. settlementService.saveOrEdit(dto);
  161. return R.data(dto);
  162. }
  163. /**
  164. * 新增 结算表
  165. @PostMapping("/save")
  166. @ApiOperationSupport(order = 4)
  167. @ApiOperation(value = "新增", notes = "传入settlement")
  168. public R save(@Valid @RequestBody Settlement settlement) {
  169. return R.status(settlementService.save(settlement));
  170. }
  171. *//**
  172. * 修改 结算表
  173. *//*
  174. @PostMapping("/update")
  175. @ApiOperationSupport(order = 5)
  176. @ApiOperation(value = "修改", notes = "传入settlement")
  177. public R update(@Valid @RequestBody Settlement settlement) {
  178. return R.status(settlementService.updateById(settlement));
  179. }*/
  180. /**
  181. * 新增或修改 结算表
  182. */
  183. @PostMapping("/submit")
  184. @ApiOperationSupport(order = 6)
  185. @ApiOperation(value = "新增或修改", notes = "传入settlement")
  186. public R submit(@Valid @RequestBody Settlement settlement) {
  187. settlementService.saveOrUpdate(settlement);
  188. return R.data(settlement);
  189. }
  190. /**
  191. * 删除 结算表
  192. */
  193. @PostMapping("/remove")
  194. @ApiOperationSupport(order = 8)
  195. @ApiOperation(value = "删除", notes = "传入ids")
  196. public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
  197. return R.status(settlementService.removeByIds(Func.toLongList(ids)));
  198. }
  199. /**
  200. * 申请货款(申请/付费)
  201. * */
  202. @PostMapping("/apply")
  203. @ApiOperationSupport(order = 8)
  204. @ApiOperation(value = "请货款(收费/付费)", notes = "传入Finance_items")
  205. public R apply(@RequestBody ApplyDTO dto)
  206. {
  207. if(CollectionUtils.isEmpty(dto.getItemsList()))
  208. {
  209. throw new SecurityException("传入数据不能为空");
  210. }
  211. return R.data(settlementService.apply(dto.getItemsList(),dto.getBillType()));
  212. }
  213. /**
  214. * 付款申请-清核
  215. * */
  216. @PostMapping("/check")
  217. @ApiOperationSupport(order = 8)
  218. @ApiOperation(value = "付款申请-清核", notes = "传入付款申请对象")
  219. public R check (@RequestBody Settlement settlement)
  220. {
  221. settlementService.check(settlement);
  222. R<Settlement> detail = this.detail(settlement);
  223. if(detail.getData()!=null)
  224. {
  225. return R.data(detail.getData());
  226. }
  227. else
  228. {
  229. return R.data(null);
  230. }
  231. }
  232. /**
  233. * 销售-收款结算
  234. * */
  235. @PostMapping("/paymentApply")
  236. @ApiOperationSupport(order = 8)
  237. @ApiOperation(value = "付销售-收款结算-生成-销售收费账单", notes = "传入销售申请对象")
  238. public R paymentApply (@RequestBody ApplyDTO dto)
  239. {
  240. settlementService.paymentApply(dto.getItemsList(),dto.getBillType());
  241. return R.success("操作成功");
  242. }
  243. }