Ver Fonte

手动计算asset

(cherry picked from commit 3f3c6345ec2c34f26d0564c09a9b5586ac40e52b)
xiongzhu há 3 anos atrás
pai
commit
c8a3ebf37f

+ 1 - 0
src/main/java/com/izouma/nineth/dto/PageQuery.java

@@ -16,4 +16,5 @@ public class PageQuery {
     private String              sort;
     private String              search;
     private Map<String, Object> query = new HashMap<>();
+    private boolean             refresh;
 }

+ 12 - 5
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -12,6 +12,7 @@ import com.izouma.nineth.repo.OrderRepo;
 import com.izouma.nineth.service.AssetService;
 import com.izouma.nineth.service.CacheService;
 import com.izouma.nineth.service.GiftOrderService;
+import com.izouma.nineth.service.UserAssetSummaryService;
 import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
 import io.swagger.annotations.ApiOperation;
@@ -35,11 +36,12 @@ import java.util.concurrent.ExecutionException;
 @RequestMapping("/asset")
 @AllArgsConstructor
 public class AssetController extends BaseController {
-    private AssetService assetService;
-    private AssetRepo assetRepo;
-    private GiftOrderService giftOrderService;
-    private OrderRepo orderRepo;
-    private CacheService cacheService;
+    private AssetService            assetService;
+    private AssetRepo               assetRepo;
+    private GiftOrderService        giftOrderService;
+    private OrderRepo               orderRepo;
+    private CacheService            cacheService;
+    private UserAssetSummaryService userAssetSummaryService;
 
     //@PreAuthorize("hasRole('ADMIN')")
 //    @PostMapping("/save")
@@ -232,6 +234,11 @@ public class AssetController extends BaseController {
     public List<MetaPlayerRoleClassify> MetaPlayerRoles(@PathVariable Long userId) {
         return assetService.metaPlayerRole(userId);
     }
+
+    @GetMapping("/recal")
+    public void recal(@RequestParam Long userId) {
+        userAssetSummaryService.calculateNum(userId);
+    }
 }
 
 

+ 4 - 0
src/main/java/com/izouma/nineth/web/UserAssetSummaryController.java

@@ -3,6 +3,7 @@ package com.izouma.nineth.web;
 import com.izouma.nineth.domain.UserAssetSummary;
 import com.izouma.nineth.service.UserAssetSummaryService;
 import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.utils.SecurityUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
@@ -18,6 +19,9 @@ public class UserAssetSummaryController extends BaseController {
     @PostMapping("/all")
     public Page<UserAssetSummary> all(@RequestBody PageQuery pageQuery) {
         pageQuery.getQuery().putIfAbsent("companyId", 1L);
+        if (pageQuery.isRefresh()) {
+            userAssetSummaryService.calculateNum(SecurityUtils.getAuthenticatedUser().getId());
+        }
         return userAssetSummaryService.all(pageQuery);
     }
 

+ 32 - 19
src/main/vue/src/views/Cache.vue

@@ -9,6 +9,7 @@
                 <el-button @click="clean('userMy')">all userMy</el-button>
                 <el-button @click="clean('collection')">all collection</el-button>
                 <el-button @click="clean('recommend')">all recommend</el-button>
+                <el-button @click="recal">计算asset</el-button>
                 <el-divider></el-divider>
                 <div>
                     <el-button @click="clearUserProperty">清除UserProperty</el-button>
@@ -53,42 +54,42 @@ export default {
                 });
         },
         operatingStockOrSale(operationType) {
-            let collectionId = this.collectionId.replace(/\s*/g,'');
-            let num = this.num.replace(/\s*/g,'');
-            var reg = /^[0-9]*$/
+            let collectionId = this.collectionId.replace(/\s*/g, '');
+            let num = this.num.replace(/\s*/g, '');
+            var reg = /^[0-9]*$/;
             if (collectionId == null || collectionId === undefined || collectionId === '') {
-                this.$message.error('请输入collectionId')
-                return
+                this.$message.error('请输入collectionId');
+                return;
             }
             if (num == null || num === undefined || num === '') {
-                this.$message.error('请输入num')
-                return
+                this.$message.error('请输入num');
+                return;
             }
-            if(!reg.test(this.collectionId)){
-                this.$message.error('请正确输入collectionId,只允许输入数字')
-                return
+            if (!reg.test(this.collectionId)) {
+                this.$message.error('请正确输入collectionId,只允许输入数字');
+                return;
             }
-            if(!reg.test(this.num)){
-                this.$message.error('请正确输入num,只允许输入数字且必须大于0')
-                return
+            if (!reg.test(this.num)) {
+                this.$message.error('请正确输入num,只允许输入数字且必须大于0');
+                return;
             }
             if (this.num <= 0) {
-                this.$message.error('num必须大于0')
-                return
+                this.$message.error('num必须大于0');
+                return;
             }
-            this.loading = true
+            this.loading = true;
             this.$http
                 .post('/cache/operating/' + this.collectionId + '/' + this.num + '/' + operationType)
                 .then(res => {
                     this.loading = false;
                     this.$message.success('成功');
-                    this.num = null
-                    this.collectionId = null
+                    this.num = null;
+                    this.collectionId = null;
                 })
                 .catch(e => {
                     this.loading = false;
                     this.$message.error(e.error || '失败');
-                })
+                });
         },
         clearUserProperty() {
             this.loading = true;
@@ -160,6 +161,18 @@ export default {
                     });
             };
             i.click();
+        },
+        recal() {
+            if (this.param) {
+                this.$http
+                    .get('/asset/recal', { userId: this.param })
+                    .then(res => {
+                        this.$message.success('ok');
+                    })
+                    .catch(e => {
+                        this.$message.error(e.error);
+                    });
+            }
         }
     },
     components: { SingleUpload }