xiongzhu преди 4 години
родител
ревизия
6c9ba95dba

+ 7 - 0
src/main/java/com/izouma/nineth/service/UserBalanceService.java

@@ -27,6 +27,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.util.TempFile;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.multipart.MultipartFile;
@@ -134,6 +135,12 @@ public class UserBalanceService {
         settleRecordRepo.save(new SettleRecord(date, orders.size(), totalAmount, royaltiesAmount, serviceChargeAmount));
     }
 
+    @Async
+    @Transactional
+    public ExportWithdraw exportWithdrawAsync(String remark) throws IOException, InvalidFormatException {
+        return exportWithdraw(remark);
+    }
+
     @Transactional
     public ExportWithdraw exportWithdraw(String remark) throws IOException, InvalidFormatException {
         List<UserBalance> balanceList = userBalanceRepo.findByBalanceGreaterThan(BigDecimal.ZERO);

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

@@ -53,8 +53,8 @@ public class UserBalanceController extends BaseController {
     }
 
     @PostMapping(value = "/exportWithdraw")
-    public ExportWithdraw exportWithdraw(String remark) throws IOException, InvalidFormatException {
-        return userBalanceService.exportWithdraw(remark);
+    public void exportWithdraw(String remark) throws IOException, InvalidFormatException {
+        userBalanceService.exportWithdrawAsync(remark);
     }
 
     @PostMapping(value = "/exportHistory")