lidongze 3 年之前
父節點
當前提交
302e365028

+ 15 - 6
src/main/java/com/izouma/nineth/web/UserBalanceController.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.web;
 
+import cn.hutool.core.math.Money;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.github.kevinsawicki.http.HttpRequest;
@@ -14,21 +15,29 @@ import com.izouma.nineth.enums.PayMethod;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.*;
 import com.izouma.nineth.service.UserBalanceService;
+import com.izouma.nineth.utils.DateTimeUtils;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.IOUtils;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.springframework.core.io.InputStreamResource;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.time.LocalDate;
 import java.util.concurrent.ExecutionException;
 
@@ -62,32 +71,32 @@ public class UserBalanceController extends BaseController {
     }
 
     @PostMapping("/settle")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public void settle(@RequestParam LocalDate start, @RequestParam LocalDate end) {
         userBalanceService.settle(start, end);
     }
 
     @PostMapping(value = "/exportWithdraw")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public void exportWithdraw(String remark) throws IOException, InvalidFormatException {
         userBalanceService.exportWithdrawAsync(remark);
     }
 
     @PostMapping(value = "/exportHistory")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public Page<ExportWithdraw> exportHistory(Pageable pageable) {
         return exportWithdrawRepo.findAll(pageable);
     }
 
     @PostMapping("/importFail")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public void importFail(@RequestPart("withdrawList") MultipartFile withdrawFile,
                            @RequestPart("failList") MultipartFile failFile) throws IOException {
         userBalanceService.importFail(withdrawFile, failFile);
     }
 
     @PostMapping("/autoWithdraw")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public void autoWithdraw() throws ExecutionException, InterruptedException {
 
         LocalDate date = LocalDate.now();
@@ -141,7 +150,7 @@ public class UserBalanceController extends BaseController {
     }
 
     @PostMapping("/testRecharge")
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     public void testRecharge(Long userId, BigDecimal money) {
         RechargeOrder rechargeOrder = RechargeOrder.builder()
                 .id(snowflakeIdWorker.nextId())

+ 3 - 3
src/main/java/com/izouma/nineth/web/WithdrawApplyController.java

@@ -33,20 +33,20 @@ public class WithdrawApplyController extends BaseController {
         return withdrawApplyService.all(pageQuery);
     }
 
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PreAuthorize("hasRole('ADMIN')")
     @GetMapping("/get/{id}")
     public WithdrawApply get(@PathVariable Long id) {
         return withdrawApplyRepo.findById(id).orElseThrow(new BusinessException("无记录"));
     }
 
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @GetMapping("/excel")
     @ResponseBody
     public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
         List<WithdrawApply> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
     }
 
-    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
+    @PostMapping("/apply")
     public WithdrawApply apply(@RequestParam BigDecimal amount) {
         return withdrawApplyService.apply(SecurityUtils.getAuthenticatedUser().getId(), amount);
     }