You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.2 KiB

  1. package com.example.demo.controller.cash;
  2. import com.example.demo.Util.JWTUtil;
  3. import com.example.demo.domain.entity.Admin;
  4. import com.example.demo.domain.entity.CashRecord;
  5. import com.example.demo.domain.vo.cash.CashCollection;
  6. import com.example.demo.domain.vo.coin.Page;
  7. import com.example.demo.domain.vo.coin.Result;
  8. import com.example.demo.service.cash.CashCollectionService;
  9. import com.github.pagehelper.PageInfo;
  10. import jakarta.servlet.http.HttpServletRequest;
  11. import lombok.RequiredArgsConstructor;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import org.springframework.web.context.request.RequestContextHolder;
  16. import org.springframework.web.context.request.ServletRequestAttributes;
  17. import java.util.Arrays;
  18. import java.util.List;
  19. /**
  20. * @program: gold-java
  21. * @ClassName CashCollectionController
  22. * @description:
  23. * @author: Ethan
  24. * @create: 202509-26 10:22
  25. * @Version 1.0
  26. **/
  27. @RestController
  28. @RequestMapping("/cashCollection")
  29. @RequiredArgsConstructor
  30. @Slf4j
  31. @CrossOrigin
  32. public class CashCollectionController {
  33. @Autowired
  34. private CashCollectionService cashCollectionService;
  35. //新增收款订单
  36. @PostMapping("/add")
  37. public Result add(@RequestBody CashCollection cashCollection) {
  38. try {
  39. return cashCollectionService.add(cashCollection);
  40. } catch (Exception e) {
  41. return Result.error(e.getMessage());
  42. }
  43. }
  44. //撤回未审核的收款订单
  45. @PostMapping("/cancel")
  46. public Result cancel(@RequestBody CashRecord cashRecord) {
  47. try {
  48. return cashCollectionService.cancel(cashRecord.getOrderCode());
  49. }catch (Exception e){
  50. return Result.error(e.getMessage());
  51. }
  52. }
  53. //重新提交审核的收款订单
  54. @PostMapping("/reSubmit")
  55. public Result reSubmit(@RequestBody CashRecord cashRecord) {
  56. try {
  57. return cashCollectionService.reSubmit(cashRecord);
  58. }catch (Exception e){
  59. return Result.error(e.getMessage());
  60. }
  61. }
  62. //多条件查询收款订单列表
  63. @PostMapping("/selectCollection")
  64. public PageInfo<CashCollection> selectCollection(
  65. @RequestBody Page page) throws Exception{
  66. Integer pageNum = page.getPageNum();
  67. Integer pageSize = page.getPageSize();
  68. CashCollection cashCollection = page.getCashCollection();
  69. //解token权限
  70. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
  71. String token = request.getHeader("token");
  72. Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class);
  73. if (admin != null) {
  74. List<String> list = Arrays.asList(admin.getMarkets().split(","));
  75. cashCollection.setMarkets(list);
  76. }
  77. return cashCollectionService.selectCollection(pageNum, pageSize, cashCollection);
  78. }
  79. //补全手续费等
  80. @PostMapping("/complete")
  81. public Result complete(@RequestBody CashRecord cashRecord) {
  82. try {
  83. return cashCollectionService.complete(cashRecord);
  84. }catch (Exception e){
  85. return Result.error(e.getMessage());
  86. }
  87. }
  88. }