소스 검색

add:积分统计

ct 1 일 전
부모
커밋
73486f0331

+ 38 - 0
fs-admin/src/main/java/com/fs/his/controller/FsUserIntegralLogsController.java

@@ -3,14 +3,17 @@ package com.fs.his.controller;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.his.domain.FsUserIntegralLogs;
 import com.fs.his.param.FsUserIntegralLogsParam;
+import com.fs.his.param.FsUserIntegralLogsStatisticsParam;
 import com.fs.his.service.IFsUserIntegralLogsService;
 import com.fs.his.vo.FsTestReportListVO;
 import com.fs.his.vo.FsUserIntegralLogsListVO;
+import com.fs.his.vo.FsUserIntegralLogsStatisticsVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -110,4 +113,39 @@ public class FsUserIntegralLogsController extends BaseController
     {
         return toAjax(fsUserIntegralLogsService.deleteFsUserIntegralLogsByIds(ids));
     }
+
+    /**
+     * 统计
+     */
+    @PreAuthorize("@ss.hasPermi('his:statistics:integral')")
+    @GetMapping("/statistics")
+    public R statistics(FsUserIntegralLogsStatisticsParam param)
+    {
+        if (param.getType() != null && param.getType().equals(2)) {
+            if (param.getUserId() == null || param.getUserId() < 0L) {
+                return R.error("用户维度需要输入用户id");
+            }
+        }
+        List<FsUserIntegralLogsStatisticsVo> list = fsUserIntegralLogsService.statisticsList(param);
+        return R.ok().put("list",list);
+    }
+
+    /**
+     * 导出统计
+     */
+    @PreAuthorize("@ss.hasPermi('his:statistics:commissionExport')")
+    @GetMapping("/exportCommission")
+    @Log(title = "积分统计导出", businessType = BusinessType.EXPORT)
+    public AjaxResult exportCommission(FsUserIntegralLogsStatisticsParam param)
+    {
+        if (param.getType() != null && param.getType().equals(2)) {
+            if (param.getUserId() == null || param.getUserId() < 0L) {
+                return AjaxResult.error("用户维度需要输入用户id");
+            }
+        }
+        List<FsUserIntegralLogsStatisticsVo> list = fsUserIntegralLogsService.statisticsList(param);
+
+        ExcelUtil<FsUserIntegralLogsStatisticsVo> util = new ExcelUtil<FsUserIntegralLogsStatisticsVo>(FsUserIntegralLogsStatisticsVo.class);
+        return util.exportExcel(list, "积分统计数据");
+    }
 }

+ 5 - 4
fs-service/src/main/java/com/fs/his/mapper/FsUserIntegralLogsMapper.java

@@ -6,10 +6,7 @@ import com.fs.his.domain.FsUserIntegralLogs;
 import com.fs.his.param.AdProfitDetailStatisticsParam;
 import com.fs.his.param.FsUserIntegralLogsListUParam;
 import com.fs.his.param.FsUserIntegralLogsParam;
-import com.fs.his.vo.ExchangeDetailVo;
-import com.fs.his.vo.FsUserIntegralLogsListUVO;
-import com.fs.his.vo.FsUserIntegralLogsListVO;
-import com.fs.his.vo.SubIntegralVO;
+import com.fs.his.vo.*;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -151,4 +148,8 @@ public interface FsUserIntegralLogsMapper
     List<ExchangeDetailVo> getExchangDetailList(ExchangeDetailVo detailVo);
 
     Long sumIntegralByLogTypeAndCreateTime(@Param("logType") Integer logType,@Param("param") AdProfitDetailStatisticsParam param);
+
+    List<FsUserIntegralLogsStatisticsVo> statisticsListByCompany();
+
+    List<FsUserIntegralLogsStatisticsVo> statisticsListByUser(@Param("userId")Long userId);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/his/param/FsUserIntegralLogsStatisticsParam.java

@@ -0,0 +1,10 @@
+package com.fs.his.param;
+
+import lombok.Data;
+
+@Data
+public class FsUserIntegralLogsStatisticsParam {
+//    Integer type;//"类型 1今天 2昨天 3 本周 4 上周 5本月 6上月 7本季度 8上季度 9本年 10去年
+    Integer type;//1 公司维度 2用户维度
+    Long userId;
+}

+ 3 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserIntegralLogsService.java

@@ -5,6 +5,7 @@ import com.fs.his.domain.FsUserIntegralLogs;
 import com.fs.his.param.*;
 import com.fs.his.vo.FsUserIntegralLogsListUVO;
 import com.fs.his.vo.FsUserIntegralLogsListVO;
+import com.fs.his.vo.FsUserIntegralLogsStatisticsVo;
 
 import java.util.List;
 
@@ -85,4 +86,6 @@ public interface IFsUserIntegralLogsService
     R getNewcomerBenefits(Long userId);
 
     Long sumIntegralByLogTypeAndCreateTime(Integer value, AdProfitDetailStatisticsParam param);
+
+    List<FsUserIntegralLogsStatisticsVo> statisticsList(FsUserIntegralLogsStatisticsParam param);
 }

+ 18 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserIntegralLogsServiceImpl.java

@@ -22,6 +22,7 @@ import com.fs.his.param.*;
 import com.fs.his.service.IFsUserIntegralLogsService;
 import com.fs.his.vo.FsUserIntegralLogsListUVO;
 import com.fs.his.vo.FsUserIntegralLogsListVO;
+import com.fs.his.vo.FsUserIntegralLogsStatisticsVo;
 import com.fs.his.vo.SubIntegralVO;
 import com.fs.system.service.ISysConfigService;
 import org.slf4j.Logger;
@@ -751,4 +752,21 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
     public Long sumIntegralByLogTypeAndCreateTime(Integer logType, AdProfitDetailStatisticsParam param) {
         return fsUserIntegralLogsMapper.sumIntegralByLogTypeAndCreateTime(logType,param);
     }
+
+    @Override
+    public List<FsUserIntegralLogsStatisticsVo> statisticsList(FsUserIntegralLogsStatisticsParam param) {
+        List<FsUserIntegralLogsStatisticsVo> list = new ArrayList<>();
+        Integer type = param.getType();
+        if (type != null){
+            if (type==1){
+                //公司维度
+                list = fsUserIntegralLogsMapper.statisticsListByCompany();
+            } else if (type==2){
+                //用户维度
+                list = fsUserIntegralLogsMapper.statisticsListByUser(param.getUserId());
+            }
+        }
+        return list;
+
+    }
 }

+ 21 - 0
fs-service/src/main/java/com/fs/his/vo/FsUserIntegralLogsStatisticsVo.java

@@ -0,0 +1,21 @@
+package com.fs.his.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FsUserIntegralLogsStatisticsVo {
+    @Excel(name = "id")
+    private Long id;
+    @Excel(name = "名称")
+    private String name;
+    @Excel(name = "现有总积分")
+    private Long nowIntegral;
+    @Excel(name = "可提现积分")
+    private Long withdrawIntegral;
+    @Excel(name = "不可提现积分")
+    private Long disableIntegral;
+    @Excel(name = "已提现积分")
+    private Long finishIntegral;
+
+}

+ 31 - 0
fs-service/src/main/resources/mapper/his/FsUserIntegralLogsMapper.xml

@@ -80,6 +80,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="sumIntegralByLogTypeAndCreateTime" resultType="java.lang.Long">
         SELECT COALESCE(SUM(a.integral), 0) FROM fs_user_integral_logs a where a.log_type = #{logType} and <include refid="timeCondition"/>
     </select>
+    <select id="statisticsListByCompany" resultType="com.fs.his.vo.FsUserIntegralLogsStatisticsVo">
+        SELECT
+        COALESCE(cuu.company_id, 0) AS id,
+        CASE
+        WHEN cuu.company_id IS NULL OR cuu.company_id &lt;= 0 THEN '公域用户'
+        ELSE MAX(c.company_name)
+        END AS `name`,
+        SUM(f.integral) AS now_integral,
+        SUM(f.withdraw_integral) AS withdraw_integral,
+        SUM(f.integral) - SUM(f.withdraw_integral) AS disable_integral,
+        SUM(f.withdraw_finish) AS finish_integral
+        FROM fs_user f
+        LEFT JOIN (
+        SELECT DISTINCT user_id, company_id
+        FROM company_user_user
+        WHERE user_id IS NOT NULL
+        AND company_id IS NOT NULL
+        AND company_id > 0
+        ) cuu ON cuu.user_id = f.user_id
+        LEFT JOIN company c ON c.company_id = cuu.company_id
+        GROUP BY
+        CASE
+        WHEN cuu.company_id IS NULL OR cuu.company_id &lt;= 0 THEN 0
+        ELSE cuu.company_id
+        END;
+    </select>
+    <select id="statisticsListByUser" resultType="com.fs.his.vo.FsUserIntegralLogsStatisticsVo">
+        SELECT user_id AS id ,nick_name AS `name`, integral AS now_integral,withdraw_integral,
+               integral-withdraw_integral AS disable_integral,withdraw_finish AS finish_integral
+        FROM fs_user WHERE user_id = #{userId}
+    </select>
 
     <insert id="insertFsUserIntegralLogs" parameterType="FsUserIntegralLogs" useGeneratedKeys="true" keyProperty="id">
         insert into fs_user_integral_logs