feat:导出统计
This commit is contained in:
1 parent
e717df69ba
commit
dbee49727e
7 files changed
+180
-1
No files matched your search
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletTypeCountVo {
|
||||
|
||||
/**
|
||||
* 充值次数
|
||||
*/
|
||||
private Long timeTotal;
|
||||
|
||||
/**
|
||||
* 充值次数
|
||||
*/
|
||||
private Long priceTotal;
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletTypeTotalVo {
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private Long totalPrice;
|
||||
|
||||
/**
|
||||
* 总次数
|
||||
*/
|
||||
private Long totalTime;
|
||||
|
||||
/**
|
||||
* 消费钱包总金额
|
||||
*/
|
||||
private Long xfTotalPrice;
|
||||
|
||||
/**
|
||||
* 消费钱包总次数
|
||||
*/
|
||||
private Long xfTotalTime;
|
||||
|
||||
/**
|
||||
* 饭卡钱包总金额
|
||||
*/
|
||||
private Long eatTotalPrice;
|
||||
|
||||
/**
|
||||
* 饭卡钱包总次数
|
||||
*/
|
||||
private Long eatTotalTime;
|
||||
|
||||
}
|
||||
+41
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionSumAndCountDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
|
||||
@@ -198,6 +199,14 @@ public class WalletTransactionController {
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
|
||||
}
|
||||
|
||||
@Operation(summary = "充值统计", description = "充值统计")
|
||||
@PostMapping("/cz-total")
|
||||
public R<WalletTypeTotalVo> czTotal(@RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
|
||||
dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "记账扣款导出", description = "记账扣款导出")
|
||||
@PostMapping("/export-jz")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
@@ -213,6 +222,14 @@ public class WalletTransactionController {
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人记账扣款明细.xlsx", list);
|
||||
}
|
||||
|
||||
@Operation(summary = "记账扣款统计", description = "记账扣款统计")
|
||||
@PostMapping("/jz-total")
|
||||
public R<WalletTypeTotalVo> jzTotal(@RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
|
||||
dto.setType(WalletTransactionDto.TYPE_EXPENSE);
|
||||
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "消费导出", description = "消费导出")
|
||||
@PostMapping("/export-xf")
|
||||
@@ -228,6 +245,13 @@ public class WalletTransactionController {
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list);
|
||||
}
|
||||
|
||||
@Operation(summary = "消费统计", description = "消费统计")
|
||||
@PostMapping("/xf-total")
|
||||
public R<WalletTypeTotalVo> xfTotal(@RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
|
||||
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "退款导出", description = "退款导出")
|
||||
@PostMapping("/export-tk")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
@@ -243,6 +267,14 @@ public class WalletTransactionController {
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list);
|
||||
}
|
||||
|
||||
@Operation(summary = "退款统计", description = "退款统计")
|
||||
@PostMapping("/tk-total")
|
||||
public R<WalletTypeTotalVo> tkTotal(@RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
|
||||
dto.setIsFindOrder(true);
|
||||
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@Operation(summary = "后台退还各自食堂记录导出", description = "后台退还各自食堂记录导出")
|
||||
@PostMapping("/export-th")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
@@ -257,4 +289,13 @@ public class WalletTransactionController {
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, dataScope);
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/退还各自食堂明细.xlsx", list);
|
||||
}
|
||||
|
||||
@Operation(summary = "退还各自食堂统计", description = "退还各自食堂统计")
|
||||
@PostMapping("/th-total")
|
||||
public R<WalletTypeTotalVo> thTotal(@RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(List.of(WalletBizEnum.RETURN_CANTEEN.getCode()));
|
||||
dto.setIsFindOrder(false);
|
||||
return R.ok(walletTransactionService.walletTypetotal(dto, DataScope.of()));
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -13,6 +13,8 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplySelectCompareVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -67,6 +69,8 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
|
||||
return list;
|
||||
}
|
||||
|
||||
WalletTypeCountVo walletTypetotal(@Param("dto") WalletTransactionDto dto, @Param("dataScope") DataScope dataScope);
|
||||
|
||||
default List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope) {
|
||||
List<WalletTransactionEntity> list = selectListByScope(commonWrapperQuery(dto), dataScope);
|
||||
return BeanUtils.toBean(list, WalletTransactionVo.class);
|
||||
|
||||
+3
-1
@@ -6,10 +6,10 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface WalletTransactionService extends IService<WalletTransactionEntity> {
|
||||
@@ -23,6 +23,8 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
|
||||
|
||||
List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope);
|
||||
|
||||
WalletTypeTotalVo walletTypetotal(WalletTransactionDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 扣减钱包余额
|
||||
*
|
||||
|
||||
+30
@@ -17,6 +17,7 @@ import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
@@ -29,6 +30,8 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletTypeTotalVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
@@ -196,6 +199,33 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletTypeTotalVo walletTypetotal(WalletTransactionDto dto, DataScope dataScope) {
|
||||
WalletTypeTotalVo result = new WalletTypeTotalVo();
|
||||
// 查询钱包类型
|
||||
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(new WalletTypeDto());
|
||||
if (ObjectUtil.isEmpty(walletTypeList)) return null;
|
||||
for (WalletTypeEntity v : walletTypeList) {
|
||||
WalletTransactionDto queryDto = BeanUtils.toBean(dto, WalletTransactionDto.class);
|
||||
queryDto.setWalletTypeId(v.getId());
|
||||
WalletTypeCountVo total = baseMapper.walletTypetotal(queryDto, dataScope);
|
||||
if (ObjectUtil.isEmpty(total)) continue;
|
||||
if (ObjectUtil.equals(v.getUniqueCode(), WalletTypeEnum.EAT.getCode())) {
|
||||
result.setEatTotalPrice(total.getPriceTotal());
|
||||
result.setEatTotalTime(total.getTimeTotal());
|
||||
continue;
|
||||
}
|
||||
if (ObjectUtil.equals(v.getUniqueCode(), WalletTypeEnum.PAY.getCode())) {
|
||||
result.setXfTotalPrice(total.getPriceTotal());
|
||||
result.setXfTotalTime(total.getTimeTotal());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result.setTotalPrice(result.getEatTotalPrice() + result.getXfTotalPrice());
|
||||
result.setTotalTime(result.getEatTotalTime() + result.getXfTotalTime());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportByTemplate(HttpServletResponse response, WalletTransactionDto dto, String fileName, List<WalletTransactionVo> list) {
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream(fileName)).build()) {
|
||||
|
||||
+46
@@ -44,12 +44,46 @@
|
||||
<if test="dto.bizType != null">
|
||||
and a.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.deptId != null">
|
||||
and a.dept_id = #{dto.deptId}
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type == 1 ">
|
||||
and a.price > 0
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type == 2 ">
|
||||
and a.price < 0
|
||||
</if>
|
||||
<if test="dto.userIds != null and dto.userIds.size() != 0">
|
||||
and a.user_id in
|
||||
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.bizTypes != null and dto.bizTypes.size() != 0">
|
||||
and a.biz_type in
|
||||
<foreach collection="dto.bizTypes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
|
||||
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
<choose>
|
||||
<when test="dto.isInclude != null and dto.isInclude == true">
|
||||
and a.dept_id IN
|
||||
</when>
|
||||
<when test="dto.isInclude != null and dto.isInclude == false">
|
||||
and a.dept_id NOT IN
|
||||
</when>
|
||||
<otherwise>
|
||||
and a.dept_id IN
|
||||
</otherwise>
|
||||
</choose>
|
||||
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopeJzPageList" resultType="com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo">
|
||||
@@ -177,4 +211,16 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="walletTypetotal" resultType="com.bsd.pjcloud.wallet.api.vo.WalletTypeCountVo">
|
||||
select ifnull(sum(a.price), 0) as priceTotal, count(0) as timeTotal
|
||||
FROM wallet_transaction a
|
||||
left join wallet_manage m on m.id = a.wallet_id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
<if test="dto.walletTypeId != null">
|
||||
and m.wallet_type_id = #{dto.walletTypeId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user