Pārlūkot izejas kodu

志愿者钱包管理相关接口

lsd 3 mēneši atpakaļ
vecāks
revīzija
95670ee039

+ 41 - 23
leromro-core/src/main/java/com/leromro/core/controller/VolunteerAccountController.java

@@ -1,35 +1,26 @@
 package com.leromro.core.controller;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.leromro.common.core.controller.BaseController;
+import com.leromro.common.core.domain.R;
+import com.leromro.common.core.page.TableDataInfo;
+import com.leromro.common.utils.poi.ExcelUtil;
+import com.leromro.core.domain.VolunteerAccount;
+import com.leromro.core.domain.dto.VolunteerAccountListDTO;
 import com.leromro.core.domain.dto.VolunteerSubmitAmountDTO;
+import com.leromro.core.domain.vo.VolunteerAccountStatisticsVO;
+import com.leromro.core.domain.vo.VolunteerAccountVO;
 import com.leromro.core.facade.VolunteerAccountFacade;
+import com.leromro.core.service.IVolunteerAccountService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import com.leromro.common.core.domain.R;
-import org.apache.poi.ss.formula.functions.T;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.leromro.common.annotation.Log;
-import com.leromro.common.core.controller.BaseController;
-import com.leromro.common.core.domain.AjaxResult;
-import com.leromro.common.enums.BusinessType;
-import com.leromro.core.domain.VolunteerAccount;
-import com.leromro.core.service.IVolunteerAccountService;
-import com.leromro.common.utils.poi.ExcelUtil;
-import com.leromro.common.core.page.TableDataInfo;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 志愿者账户Controller
@@ -98,7 +89,34 @@ public class VolunteerAccountController extends BaseController {
         return volunteerAccountFacade.getWithdrawStatus();
     }
 
+    /**
+     * 获取志愿者钱包列表
+     */
+    @ApiOperation("获取志愿者钱包列表")
+    @GetMapping("/getVolunteerAccountList")
+    public TableDataInfo<VolunteerAccountVO> getVolunteerAccountList(VolunteerAccountListDTO volunteerAccountListDTO) {
+        List<VolunteerAccountVO> list = volunteerAccountService.getVolunteerAccountList(volunteerAccountListDTO);
+        return getDataTable(list);
+    }
 
+    /**
+     * 导出志愿者钱包列表
+     */
+    @ApiOperation("导出志愿者钱包列表")
+    @PostMapping("/export/VolunteerAccountList")
+    public void exportVolunteerAccountList(HttpServletResponse response,VolunteerAccountListDTO volunteerAccountListDTO) {
+        List<VolunteerAccountVO> list = volunteerAccountService.getVolunteerAccountList(volunteerAccountListDTO);
+        ExcelUtil<VolunteerAccountVO> util = new ExcelUtil<VolunteerAccountVO>(VolunteerAccountVO.class);
+        util.exportExcel(response, list, "志愿者钱包列表");
+    }
 
-
+    /**
+     * 获取平台志愿者钱包统计
+     */
+    @ApiOperation("获取平台志愿者钱包统计")
+    @GetMapping("/getPlatformVolunteerWalletStatistics")
+    public R<VolunteerAccountStatisticsVO> getPlatformVolunteerWalletStatistics() {
+        VolunteerAccountStatisticsVO vo = volunteerAccountService.getPlatformVolunteerWalletStatistics();
+        return R.ok(vo);
+    }
 }

+ 26 - 0
leromro-core/src/main/java/com/leromro/core/domain/dto/VolunteerAccountListDTO.java

@@ -0,0 +1,26 @@
+package com.leromro.core.domain.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class VolunteerAccountListDTO {
+    // 最后变动时间范围查询(开始时间)
+    private Date lastChangeTimeStart;
+
+    // 最后变动时间范围查询(结束时间)
+    private Date lastChangeTimeEnd;
+
+    // 志愿者名称
+    private String volunteerName;
+
+    // 志愿者手机号
+    private String volunteerPhone;
+
+    // 区域公司名称
+    private String areaName;
+
+    // 服务中心名称
+    private String serviceCentreName;
+}

+ 34 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/VolunteerAccountStatisticsVO.java

@@ -0,0 +1,34 @@
+package com.leromro.core.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 志愿者账户统计信息
+ */
+@ApiOperation("志愿者账户统计信息")
+@Data
+public class VolunteerAccountStatisticsVO {
+    // 总金额
+    @ApiModelProperty("总金额")
+    private BigDecimal totalAmount;
+
+    // 可提现金额
+    @ApiModelProperty("可提现金额")
+    private BigDecimal balance;
+
+    // 提现中金额
+    @ApiModelProperty("提现中金额")
+    private BigDecimal beBalance;
+
+    // 已提现金额
+    @ApiModelProperty("已提现金额")
+    private BigDecimal withdrawAmount;
+
+    // 待入账金额
+    @ApiModelProperty("待入账金额")
+    private BigDecimal orderFrozenBalance;
+}

+ 69 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/VolunteerAccountVO.java

@@ -0,0 +1,69 @@
+package com.leromro.core.domain.vo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.leromro.common.config.serializer.BigDecimalSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 志愿者账户信息
+ */
+@ApiOperation("志愿者账户信息")
+@Data
+public class VolunteerAccountVO {
+    @ApiModelProperty("id")
+    private Long volunteerAccountId;
+
+    @ApiModelProperty("志愿者id")
+    private Long volunteerId;
+
+    @ApiModelProperty("可提现金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal balance;
+
+    @ApiModelProperty("累计可提现金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal totalBalance;
+
+    @ApiModelProperty("订单冻结金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal orderFrozenBalance;
+
+    @ApiModelProperty("提现中金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal beBalance;
+
+    @ApiModelProperty("余额最后变动时间")
+    private Date lastChangeTime;
+
+    // 区域公司名称
+    @ApiModelProperty("区域公司名称")
+    private String areaName;
+
+    // 服务中心名称
+    @ApiModelProperty("服务中心名称")
+    private String serviceCentreName;
+
+    // 志愿者姓名
+    @ApiModelProperty("志愿者姓名")
+    private String volunteerName;
+
+    // 志愿者手机号
+    @ApiModelProperty("志愿者手机号")
+    private String volunteerPhone;
+
+    // 总金额
+    @ApiModelProperty("总金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal totalAmount;
+
+    // 已提现金额
+    @ApiModelProperty("已提现金额")
+    @JsonSerialize(using = BigDecimalSerializer.class)
+    private BigDecimal withdrawnAmount;
+
+}

+ 9 - 1
leromro-core/src/main/java/com/leromro/core/mapper/VolunteerAccountMapper.java

@@ -1,8 +1,12 @@
 package com.leromro.core.mapper;
 
-import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.leromro.core.domain.VolunteerAccount;
+import com.leromro.core.domain.dto.VolunteerAccountListDTO;
+import com.leromro.core.domain.vo.VolunteerAccountStatisticsVO;
+import com.leromro.core.domain.vo.VolunteerAccountVO;
+
+import java.util.List;
 
 /**
  * 志愿者账户Mapper接口
@@ -61,4 +65,8 @@ public interface VolunteerAccountMapper extends BaseMapper<VolunteerAccount>
     public int deleteVolunteerAccountByVolunteerAccountIds(Long[] volunteerAccountIds);
 
     void updateVolunteerAccountList(List<VolunteerAccount> newVolunteerAccountList);
+
+    List<VolunteerAccountVO> getVolunteerAccountList(VolunteerAccountListDTO volunteerAccountListDTO);
+
+    VolunteerAccountStatisticsVO getPlatformVolunteerWalletStatistics();
 }

+ 18 - 1
leromro-core/src/main/java/com/leromro/core/service/IVolunteerAccountService.java

@@ -1,8 +1,12 @@
 package com.leromro.core.service;
 
-import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.leromro.core.domain.VolunteerAccount;
+import com.leromro.core.domain.dto.VolunteerAccountListDTO;
+import com.leromro.core.domain.vo.VolunteerAccountStatisticsVO;
+import com.leromro.core.domain.vo.VolunteerAccountVO;
+
+import java.util.List;
 
 /**
  * 志愿者账户Service接口
@@ -59,4 +63,17 @@ public interface IVolunteerAccountService extends IService<VolunteerAccount>
      * @return 结果
      */
     public int deleteVolunteerAccountByVolunteerAccountId(Long volunteerAccountId);
+
+    /**
+     * 获取志愿者钱包列表
+     * @param volunteerAccountListDTO
+     * @return
+     */
+    List<VolunteerAccountVO> getVolunteerAccountList(VolunteerAccountListDTO volunteerAccountListDTO);
+
+    /**
+     * 获取平台志愿者钱包统计
+     * @return
+     */
+    VolunteerAccountStatisticsVO getPlatformVolunteerWalletStatistics();
 }

+ 21 - 7
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerAccountServiceImpl.java

@@ -1,18 +1,20 @@
 package com.leromro.core.service.impl;
 
-import java.math.BigDecimal;
-import java.util.List;
-
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.leromro.common.utils.PageUtils;
+import com.leromro.core.domain.VolunteerAccount;
+import com.leromro.core.domain.dto.VolunteerAccountListDTO;
+import com.leromro.core.domain.vo.VolunteerAccountStatisticsVO;
+import com.leromro.core.domain.vo.VolunteerAccountVO;
 import com.leromro.core.mapper.VolunteerAccountMapper;
-import com.leromro.common.utils.DateUtils;
+import com.leromro.core.service.IVolunteerAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.leromro.core.mapper.VolunteerAccountMapper;
-import com.leromro.core.domain.VolunteerAccount;
-import com.leromro.core.service.IVolunteerAccountService;
+
+import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 志愿者账户Service业务层处理
@@ -108,4 +110,16 @@ public class VolunteerAccountServiceImpl extends ServiceImpl<VolunteerAccountMap
     {
         return volunteerAccountMapper.deleteVolunteerAccountByVolunteerAccountId(volunteerAccountId);
     }
+
+    @Override
+    public List<VolunteerAccountVO> getVolunteerAccountList(VolunteerAccountListDTO volunteerAccountListDTO) {
+        PageUtils.startPage();
+        List<VolunteerAccountVO> list = volunteerAccountMapper.getVolunteerAccountList(volunteerAccountListDTO);
+        return list;
+    }
+
+    @Override
+    public VolunteerAccountStatisticsVO getPlatformVolunteerWalletStatistics() {
+        return volunteerAccountMapper.getPlatformVolunteerWalletStatistics();
+    }
 }

+ 57 - 0
leromro-core/src/main/resources/mapper/core/VolunteerAccountMapper.xml

@@ -38,6 +38,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where volunteer_account_id = #{volunteerAccountId}
     </select>
 
+    <select id="getVolunteerAccountList" parameterType="com.leromro.core.domain.dto.VolunteerAccountListDTO" resultType="com.leromro.core.domain.vo.VolunteerAccountVO">
+        SELECT
+        a.volunteer_account_id AS volunteerAccountId,
+        a.volunteer_id AS volunteerId,
+        a.balance AS balance,
+        ROUND(a.total_balance+order_frozen_balance,2) AS totalAmount,
+        a.order_frozen_balance AS orderFrozenBalance,
+        a.be_balance AS beBalance,
+        a.last_change_time AS lastChangeTime,
+        l_volunteer_info.name AS volunteerName,
+        l_volunteer_info.phonenumber AS volunteerPhone,
+        d1.dept_name AS areaName,
+        d2.dept_name AS serviceCentreName,
+        ROUND(a.total_balance-balance-be_balance,2) AS withdrawnAmount
+        FROM l_volunteer_account a
+        LEFT JOIN sys_user u ON a.volunteer_id = u.user_id
+        LEFT JOIN sys_dept d1 ON u.area_id = d1.dept_id
+        LEFT JOIN sys_dept d2 ON u.service_centre_id = d2.dept_id
+        LEFT JOIN (select l_volunteer_info.volunteer_id,l_volunteer_info.name,l_volunteer_info.phonenumber
+                   from l_volunteer_info group by volunteer_id) l_volunteer_info
+            ON a.volunteer_id = l_volunteer_info.volunteer_id
+        <where>
+            <if test="volunteerName != null and volunteerName != ''">
+                AND l_volunteer_info.name LIKE CONCAT('%', #{volunteerName}, '%')
+            </if>
+            <if test="volunteerPhone != null and volunteerPhone != ''">
+                AND l_volunteer_info.phonenumber LIKE CONCAT('%', #{volunteerPhone}, '%')
+            </if>
+            <if test="areaName != null and areaName != ''">
+                AND d1.dept_name LIKE CONCAT('%', #{areaName}, '%')
+            </if>
+            <if test="serviceCentreName != null and serviceCentreName != ''">
+                AND d2.dept_name LIKE CONCAT('%', #{serviceCentreName}, '%')
+            </if>
+            <if test="lastChangeTimeStart != null">
+                AND a.last_change_time >= #{lastChangeTimeStart}
+            </if>
+            <if test="lastChangeTimeEnd != null">
+                <![CDATA[
+                    AND a.last_change_time <= #{lastChangeTimeEnd}
+                ]]>
+            </if>
+        </where>
+        ORDER BY a.last_change_time DESC
+    </select>
+
+    <select id="getPlatformVolunteerWalletStatistics"
+            resultType="com.leromro.core.domain.vo.VolunteerAccountStatisticsVO">
+        SELECT
+        ROUND(SUM(balance),2) AS balance,
+        ROUND(SUM(total_balance),2) AS totalAmount,
+        ROUND(SUM(order_frozen_balance),2) AS orderFrozenBalance,
+        ROUND(SUM(be_balance),2) AS beBalance,
+        ROUND(SUM(total_balance)-SUM(balance)-SUM(be_balance),2) AS withdrawAmount
+        FROM l_volunteer_account
+    </select>
+
     <insert id="insertVolunteerAccount" parameterType="VolunteerAccount" useGeneratedKeys="true" keyProperty="volunteerAccountId">
         insert into l_volunteer_account
         <trim prefix="(" suffix=")" suffixOverrides=",">