PaymentController.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. package com.bosshand.virgo.api.controller;
  2. import com.bosshand.virgo.api.model.Payment;
  3. import com.bosshand.virgo.api.model.PaymentInvoice;
  4. import com.bosshand.virgo.api.model.PaymentOrdinary;
  5. import com.bosshand.virgo.api.model.PaymentRecord;
  6. import com.bosshand.virgo.api.service.PaymentService;
  7. import com.bosshand.virgo.core.response.Response;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Map;
  15. @RestController
  16. @RequestMapping({"payment"})
  17. @Api(tags = {"账单缴费发票管理"})
  18. public class PaymentController {
  19. @Autowired
  20. PaymentService paymentService;
  21. @ApiOperation("分页获取")
  22. @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
  23. public Response list(@RequestBody Payment payment, @PathVariable int currPage, @PathVariable int pageSize) {
  24. int totalCount = paymentService.getTotalCount(payment);
  25. List<Payment> dataList = paymentService.getLimit(payment, currPage, pageSize);
  26. Map<String, Object> result = new HashMap<>();
  27. result.put("dataList", dataList);
  28. result.put("totalCount", totalCount);
  29. return Response.ok(result);
  30. }
  31. @ApiOperation("详情")
  32. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  33. public Response get(@PathVariable long id) {
  34. return Response.ok(paymentService.get(id));
  35. }
  36. @ApiOperation("更新状态")
  37. @RequestMapping(value = "/updateStatus/{id}/{status}", method = RequestMethod.PUT)
  38. public Response update(@PathVariable long id, @PathVariable Integer status) {
  39. paymentService.updateStatus(id, status);
  40. return Response.ok();
  41. }
  42. @ApiOperation("生成账单")
  43. @RequestMapping(value = "/generate/{contractId}", method = RequestMethod.GET)
  44. public Response generate(@PathVariable long contractId) {
  45. List<Payment> list = paymentService.getContractId(contractId);
  46. if (list.size() > 0) {
  47. //return Response.fail(200001, "合同下账单已生成好了!");
  48. }
  49. paymentService.generate(contractId);
  50. return Response.ok("账单已生成!");
  51. }
  52. /**
  53. * 发票记录
  54. */
  55. @ApiOperation("发票记录详情")
  56. @RequestMapping(value = "/invoice/{id}", method = RequestMethod.GET)
  57. public Response getInvoice(@PathVariable long id) {
  58. return Response.ok(paymentService.getInvoice(id));
  59. }
  60. @ApiOperation("保存发票记录")
  61. @RequestMapping(value = "/invoice", method = RequestMethod.POST)
  62. public Response insertInvoice(@RequestBody PaymentInvoice paymentInvoice) {
  63. paymentService.insertInvoice(paymentInvoice);
  64. return Response.ok();
  65. }
  66. @ApiOperation("获取发票记录")
  67. @RequestMapping(value = "/invoice/query", method = RequestMethod.POST)
  68. public Response getInvoiceList(@RequestBody PaymentInvoice paymentInvoice) {
  69. return Response.ok(paymentService.getInvoiceList(paymentInvoice));
  70. }
  71. @ApiOperation("更新发票记录")
  72. @RequestMapping(value = "/invoice/update", method = RequestMethod.PUT)
  73. public Response updateInvoice(@RequestBody PaymentInvoice paymentInvoice) {
  74. paymentService.updateInvoice(paymentInvoice);
  75. return Response.ok();
  76. }
  77. @ApiOperation("删除发票记录")
  78. @RequestMapping(value = "/invoice/delete/{id}", method = RequestMethod.DELETE)
  79. public Response deleteInvoice(@PathVariable long id) {
  80. paymentService.deleteInvoice(id);
  81. return Response.ok();
  82. }
  83. /**
  84. * 付款记录
  85. */
  86. @ApiOperation("付款记录详情")
  87. @RequestMapping(value = "/record/{id}", method = RequestMethod.GET)
  88. public Response getPaymentRecord(@PathVariable long id) {
  89. return Response.ok(paymentService.getPaymentRecord(id));
  90. }
  91. @ApiOperation("保存付款记录")
  92. @RequestMapping(value = "/record", method = RequestMethod.POST)
  93. public Response insertPaymentRecord(@RequestBody PaymentRecord paymentRecord) {
  94. paymentService.insertPaymentRecord(paymentRecord);
  95. return Response.ok();
  96. }
  97. @ApiOperation("获取付款记录")
  98. @RequestMapping(value = "/record/query", method = RequestMethod.POST)
  99. public Response getPaymentRecordList(@RequestBody PaymentRecord paymentRecord) {
  100. return Response.ok(paymentService.getPaymentRecordList(paymentRecord));
  101. }
  102. @ApiOperation("更新付款记录")
  103. @RequestMapping(value = "/record/update", method = RequestMethod.PUT)
  104. public Response updatePaymentRecord(@RequestBody PaymentRecord paymentRecord) {
  105. paymentService.updatePaymentRecord(paymentRecord);
  106. return Response.ok();
  107. }
  108. @ApiOperation("删除付款记录")
  109. @RequestMapping(value = "/record/delete/{id}", method = RequestMethod.DELETE)
  110. public Response deletePaymentRecord(@PathVariable long id) {
  111. paymentService.deletePaymentRecord(id);
  112. return Response.ok();
  113. }
  114. /**
  115. * 普通账单
  116. */
  117. @ApiOperation("普通账单分页获取")
  118. @RequestMapping(value = "/ordinary/{currPage}/{pageSize}", method = RequestMethod.POST)
  119. public Response list(@RequestBody PaymentOrdinary paymentOrdinary, @PathVariable int currPage, @PathVariable int pageSize) {
  120. int totalCount = paymentService.getTotalCount(paymentOrdinary);
  121. List<PaymentOrdinary> dataList = paymentService.getLimit(paymentOrdinary, currPage, pageSize);
  122. Map<String, Object> result = new HashMap<>();
  123. result.put("dataList", dataList);
  124. result.put("totalCount", totalCount);
  125. return Response.ok(result);
  126. }
  127. @ApiOperation("普通账单详情")
  128. @RequestMapping(value = "/ordinary/{id}", method = RequestMethod.GET)
  129. public Response getPaymentOrdinary(@PathVariable long id) {
  130. return Response.ok(paymentService.getPaymentOrdinary(id));
  131. }
  132. @ApiOperation("普通账单保存")
  133. @RequestMapping(value = "/ordinary", method = RequestMethod.POST)
  134. public Response insertPaymentOrdinary(@RequestBody PaymentOrdinary paymentOrdinary) {
  135. paymentService.insertPaymentOrdinary(paymentOrdinary);
  136. return Response.ok();
  137. }
  138. @ApiOperation("普通账单更新")
  139. @RequestMapping(value = "/ordinary", method = RequestMethod.PUT)
  140. public Response updatePaymentOrdinary(@RequestBody PaymentOrdinary paymentOrdinary) {
  141. paymentService.updatePaymentOrdinary(paymentOrdinary);
  142. return Response.ok();
  143. }
  144. @ApiOperation("普通账单删除")
  145. @RequestMapping(value = "/ordinary/{id}", method = RequestMethod.DELETE)
  146. public Response update(@PathVariable long id) {
  147. paymentService.deletePaymentOrdinary(id);
  148. return Response.ok();
  149. }
  150. }