Procházet zdrojové kódy

首页红包统计接口调整

Long před 1 týdnem
rodič
revize
dc42ed5149

+ 0 - 45
fs-admin-saas/src/main/java/com/fs/company/controller/company/FsRedPacketController.java

@@ -1,45 +0,0 @@
-package com.fs.company.controller.company;
-
-import com.fs.common.core.controller.BaseController;
-import com.fs.common.core.domain.R;
-import com.fs.common.utils.ServletUtils;
-import com.fs.company.domain.Company;
-import com.fs.framework.security.LoginUser;
-import com.fs.framework.service.TokenService;
-import com.fs.his.domain.FsRedPacket;
-import com.fs.his.service.IFsRedPacketService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.context.annotation.Profile;
-
-/**
- * @description: 红包信息
- * @author: Xgb
- * @createDate: 2025/11/4
- * @version: 1.0
- */
-@Profile("company")
-@RestController
-@RequestMapping("/his/redPacket")
-public class FsRedPacketController extends BaseController {
-
-    @Autowired
-    private IFsRedPacketService fsRedPacketService;
-
-    @Autowired
-    private TokenService tokenService;
-
-    @GetMapping("/info")
-    public R info() {
-        com.fs.framework.security.LoginUser loginUser = (com.fs.framework.security.LoginUser) tokenService.getLoginUser(ServletUtils.getRequest());
-
-        Company company = loginUser.getCompany();
-        FsRedPacket redPacket=fsRedPacketService.getInfo(company.getCompanyId());
-        return  R.ok().put("data",redPacket);
-    }
-
-
-
-}

+ 56 - 0
fs-admin-saas/src/main/java/com/fs/his/controller/FsRedPacketController.java

@@ -0,0 +1,56 @@
+package com.fs.his.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.company.domain.Company;
+import com.fs.company.service.ICompanyService;
+import com.fs.his.domain.FsRedPacket;
+import com.fs.his.service.IFsRedPacketService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @description: 红包信息
+ * @author: Xgb
+ * @createDate: 2025/11/4
+ * @version: 1.0
+ */
+@RestController
+@RequestMapping("/his/redPacket")
+public class FsRedPacketController extends BaseController {
+
+    @Autowired
+    private IFsRedPacketService fsRedPacketService;
+
+    @Autowired
+    private ICompanyService companyService;
+
+    @GetMapping("/info")
+    public R info() {
+        FsRedPacket result;
+
+        result = new FsRedPacket();
+        BigDecimal totalBalance = BigDecimal.ZERO;
+        BigDecimal totalTodayConsumption = BigDecimal.ZERO;
+        List<Company> companies = companyService.selectCompanyList(new Company());
+        for (Company c : companies) {
+            FsRedPacket info = fsRedPacketService.getInfo(c.getCompanyId());
+            if (info.getRedBalance() != null) {
+                totalBalance = totalBalance.add(info.getRedBalance());
+            }
+            if (info.getRedTodayComsumption() != null) {
+                totalTodayConsumption = totalTodayConsumption.add(info.getRedTodayComsumption());
+            }
+        }
+        result.setRedBalance(totalBalance);
+        result.setRedTodayComsumption(totalTodayConsumption);
+        return R.ok().put("data", result);
+    }
+}