PaymentController.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.bosshand.virgo.api.controller;
  2. import com.bosshand.virgo.api.model.Payment;
  3. import com.bosshand.virgo.api.service.PaymentService;
  4. import com.bosshand.virgo.core.response.Response;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. @RestController
  13. @RequestMapping({"payment"})
  14. @Api(tags = {"账单缴费管理"})
  15. public class PaymentController {
  16. @Autowired
  17. PaymentService paymentService;
  18. @ApiOperation("分页获取")
  19. @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
  20. public Response list(@RequestBody Payment payment, @PathVariable int currPage, @PathVariable int pageSize) {
  21. int totalCount = paymentService.getTotalCount(payment);
  22. List<Payment> dataList = paymentService.getLimit(payment, currPage, pageSize);
  23. Map<String, Object> result = new HashMap<>();
  24. result.put("dataList", dataList);
  25. result.put("totalCount", totalCount);
  26. return Response.ok(result);
  27. }
  28. @ApiOperation("详情")
  29. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  30. public Response get(@PathVariable long id) {
  31. return Response.ok(paymentService.get(id));
  32. }
  33. @ApiOperation("更新状态")
  34. @RequestMapping(value = "/updateStatus/{id}/{status}", method = RequestMethod.PUT)
  35. public Response update(@PathVariable long id, @PathVariable Integer status) {
  36. paymentService.updateStatus(id, status);
  37. return Response.ok();
  38. }
  39. @ApiOperation("生成账单")
  40. @RequestMapping(value = "/generate/{contractId}", method = RequestMethod.GET)
  41. public Response generate(@PathVariable long contractId) {
  42. List<Payment> list = paymentService.getContractId(contractId);
  43. if (list.size() > 0) {
  44. return Response.fail(200001, "合同下账单已生成好了!");
  45. }
  46. paymentService.generate(contractId);
  47. return Response.ok("账单已生成!");
  48. }
  49. }