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.

141 lines
4.9 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.entity.RechargeActivity;
  6. import com.example.demo.domain.entity.User;
  7. import com.example.demo.domain.vo.cash.CashCollection;
  8. import com.example.demo.domain.vo.coin.Page;
  9. import com.example.demo.domain.vo.coin.Result;
  10. import com.example.demo.service.cash.CashCollectionService;
  11. import com.github.pagehelper.PageInfo;
  12. import jakarta.servlet.http.HttpServletRequest;
  13. import lombok.RequiredArgsConstructor;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.util.ObjectUtils;
  17. import org.springframework.web.bind.annotation.*;
  18. import org.springframework.web.context.request.RequestContextHolder;
  19. import org.springframework.web.context.request.ServletRequestAttributes;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. /**
  23. * @program: gold-java
  24. * @ClassName CashCollectionController
  25. * @description:
  26. * @author: Ethan
  27. * @create: 202509-26 10:22
  28. * @Version 1.0
  29. **/
  30. @RestController
  31. @RequestMapping("/cashCollection")
  32. @RequiredArgsConstructor
  33. @Slf4j
  34. @CrossOrigin
  35. public class CashCollectionController {
  36. @Autowired
  37. private CashCollectionService cashCollectionService;
  38. //根据精网号获取姓名和地区
  39. @PostMapping("/getNameAndMarket")
  40. public Result getNameAndMarket(@RequestBody Integer jwcode) {
  41. try {
  42. return Result.success(cashCollectionService.getNameAndMarket(jwcode));
  43. } catch (Exception e) {
  44. return Result.error(e.getMessage());
  45. }
  46. }
  47. //获取收款活动列表
  48. @PostMapping("/getActivityList")
  49. public Result getActivityList()
  50. {
  51. List<RechargeActivity> list = cashCollectionService.getActivityList();
  52. return Result.success(list);
  53. }
  54. //新增收款订单
  55. @PostMapping("/add")
  56. public Result add(@RequestBody CashCollection cashCollection) {
  57. try {
  58. return Result.success(cashCollectionService.add(cashCollection));
  59. } catch (Exception e) {
  60. return Result.error(e.getMessage());
  61. }
  62. }
  63. //撤回未审核的收款订单
  64. @PostMapping("/cancel")
  65. public Result cancel(@RequestBody CashRecord cashRecord) {
  66. try {
  67. return Result.success( cashCollectionService.cancel(cashRecord.getOrderCode()));
  68. }catch (Exception e){
  69. return Result.error(e.getMessage());
  70. }
  71. }
  72. //重新提交审核的收款订单
  73. @PostMapping("/reSubmit")
  74. public Result reSubmit(@RequestBody CashCollection cashRecord) {
  75. try {
  76. return Result.success(cashCollectionService.reSubmit(cashRecord));
  77. }catch (Exception e){
  78. return Result.error(e.getMessage());
  79. }
  80. }
  81. //多条件查询收款订单列表
  82. @PostMapping("/selectCollection")
  83. public Result selcetAll(@RequestBody Page page){
  84. try {
  85. if (ObjectUtils.isEmpty(page.getPageNum())) {
  86. return Result.error("页码数为空!");
  87. }
  88. if (ObjectUtils.isEmpty(page.getPageSize())) {
  89. return Result.error("页大小为空!");
  90. } else {
  91. //解token权限
  92. HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
  93. String token = request.getHeader("token");
  94. Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class);
  95. if (admin != null) {
  96. List<String> list = Arrays.asList(admin.getMarkets().split(","));
  97. page.getCashCollection().setMarkets(list);}
  98. else{
  99. return Result.error("角色为空");
  100. }
  101. return Result.success(cashCollectionService.selectCollection(page.getPageNum(), page.getPageSize(),page.getCashCollection()));
  102. }} catch (Exception e) {
  103. return Result.error(e.getMessage());
  104. }}
  105. //补全手续费等
  106. @PostMapping("/complete")
  107. public Result complete(@RequestBody CashCollection cashRecord) {
  108. try {
  109. return Result.success(cashCollectionService.complete(cashRecord));
  110. }catch (Exception e){
  111. return Result.error(e.getMessage());
  112. }
  113. }
  114. //同步g_order订单到cash_record表
  115. @PostMapping("/syncToCashRecord")
  116. public Result syncToCashRecord() {
  117. try {
  118. return Result.success(cashCollectionService.syncToCashRecord());
  119. }catch (Exception e){
  120. return Result.error(e.getMessage());
  121. }
  122. }
  123. //根据id查询收款订单
  124. @PostMapping("/selectById")
  125. public Result selectById(@RequestBody CashCollection cashCollection) {
  126. try {
  127. return Result.success(cashCollectionService.selectById(cashCollection));
  128. }catch (Exception e){
  129. return Result.error(e.getMessage());
  130. }
  131. }
  132. }