feat:增加钱包流水导出
This commit is contained in:
1 parent
c2a8b38c7d
commit
3df60e707c
15 files changed
+159
-29
No files matched your search
+6
@@ -28,6 +28,12 @@ public enum WalletBizEnum {
|
||||
);
|
||||
}
|
||||
|
||||
public static WalletBizEnum valueOfByType(String code) {
|
||||
return Arrays.stream(WalletBizEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
public static WalletBizEnum descOf(String description) {
|
||||
return Arrays.stream(WalletBizEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
|
||||
+6
@@ -16,6 +16,12 @@ public enum WalletBizRechargeEnum {
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static WalletBizRechargeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(WalletBizRechargeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
public static WalletBizRechargeEnum descOf(String description) {
|
||||
return Arrays.stream(WalletBizRechargeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
|
||||
+10
@@ -19,10 +19,20 @@ public class WalletRechargeImportDto extends WalletRechargeImportEntity {
|
||||
|
||||
private Long userDeptId;
|
||||
|
||||
/**
|
||||
* 是否深度搜索deptId
|
||||
*/
|
||||
private Boolean isDeepDept;
|
||||
|
||||
/**
|
||||
* 部门ids
|
||||
*/
|
||||
private List<Long> userDeptIds;
|
||||
|
||||
private LocalDateTime[] createTimeList;
|
||||
|
||||
private LocalDateTime[] processTimeList;
|
||||
|
||||
private String bizType;
|
||||
|
||||
}
|
||||
+4
@@ -52,4 +52,8 @@ public class WalletRechargeImportVo extends WalletRechargeImportEntity implement
|
||||
private String walletTypeUniqueCode;
|
||||
|
||||
private String walletTypeIcon;
|
||||
|
||||
private String priceStr;
|
||||
|
||||
private String importTimeStr;
|
||||
}
|
||||
+2
-2
@@ -96,7 +96,7 @@ public class WalletTransactionController {
|
||||
@PostMapping("/page-cz")
|
||||
public R pageCz(@ParameterObject Page page, @RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
|
||||
dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
// dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
DataScope dataScope = new DataScope();
|
||||
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class WalletTransactionController {
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
|
||||
public void exportCz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
|
||||
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
|
||||
dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
// dto.setType(WalletTransactionDto.TYPE_INCOME);
|
||||
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
|
||||
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
|
||||
}
|
||||
|
||||
+55
-5
@@ -1,7 +1,15 @@
|
||||
package com.bsd.pjcloud.wallet.controller.recharge;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -9,9 +17,15 @@ import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeImportService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -22,7 +36,12 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -57,9 +76,9 @@ public class WalletRechargeImportController {
|
||||
}
|
||||
|
||||
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
|
||||
@GetMapping("/page-join")
|
||||
@PostMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeImport_view')")
|
||||
public R scopePageList(@ParameterObject Page page, @ParameterObject WalletRechargeImportDto dto) {
|
||||
public R scopePageList(@ParameterObject Page page, @RequestBody WalletRechargeImportDto dto) {
|
||||
return R.ok(walletRechargeImportService.scopePageList(page, dto, DataScope.of()));
|
||||
}
|
||||
|
||||
@@ -95,9 +114,40 @@ public class WalletRechargeImportController {
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PostMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeImport_export')")
|
||||
public List<WalletRechargeImportEntity> export(WalletRechargeImportEntity walletRechargeImport, Long[] ids) {
|
||||
return walletRechargeImportService.list(Wrappers.lambdaQuery(walletRechargeImport).in(ArrayUtil.isNotEmpty(ids), WalletRechargeImportEntity::getId, ids));
|
||||
public void export(HttpServletResponse response, @RequestBody WalletRechargeImportDto dto) throws IOException {
|
||||
List<WalletRechargeImportVo> list = walletRechargeImportService.scopeList(dto, DataScope.of());
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/批量充值扣款流水明细.xlsx")).build()) {
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getCreateTimeList())) {
|
||||
map.put("timeSpan", " 到 ");
|
||||
map.put("startTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
map.put("endTime", LocalDateTimeUtil.format(dto.getCreateTimeList()[0], DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
BigDecimal priceStrSum = BigDecimal.ZERO;
|
||||
for (WalletRechargeImportVo v : list) {
|
||||
if (ObjectUtil.isNotEmpty(v.getPrice())) {
|
||||
priceStrSum = priceStrSum.add(BigDecimal.valueOf(v.getPrice()));
|
||||
v.setPriceStr(BigDecimal.valueOf(v.getPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getImportTime())) {
|
||||
v.setImportTimeStr(LocalDateTimeUtil.format(v.getImportTime(), DatePattern.NORM_MONTH_PATTERN));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getBizType())) {
|
||||
v.setBizType(WalletBizRechargeEnum.valueOfByType(v.getBizType()).getDesc());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getWalletTypeUniqueCode())) {
|
||||
v.setWalletTypeUniqueCode(WalletTypeEnum.valueOfByCode(v.getWalletTypeUniqueCode()).getDesc());
|
||||
}
|
||||
}
|
||||
map.put("priceStrSum", priceStrSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
excelWriter.fill(map, writeSheet);
|
||||
excelWriter.fill(list, fillConfig, writeSheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -17,6 +17,8 @@ public interface WalletRechargeImportMapper extends PjcloudBaseMapper<WalletRech
|
||||
|
||||
Page<WalletRechargeImportVo> scopePageList(Page page, @Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
List<WalletRechargeImportVo> scopeList(@Param("dto") WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
default Page<WalletRechargeImportVo> pageJoin(Page page, WalletRechargeImportDto dto) {
|
||||
MPJLambdaWrapper<WalletRechargeImportEntity> wrapper = new MPJLambdaWrapper<WalletRechargeImportEntity>()
|
||||
.eqIfExists(WalletRechargeImportEntity::getId, dto.getId())
|
||||
|
||||
+2
@@ -18,5 +18,7 @@ public interface WalletRechargeImportService extends IService<WalletRechargeImpo
|
||||
|
||||
Page<WalletRechargeImportVo> scopePageList(Page page, WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
List<WalletRechargeImportVo> scopeList(WalletRechargeImportDto dto, DataScope dataScope);
|
||||
|
||||
Boolean recover(Long id);
|
||||
}
|
||||
+4
@@ -21,6 +21,7 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
@@ -217,6 +218,9 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
|
||||
priceTotal = priceTotal.add(BigDecimal.valueOf(v.getPrice()));
|
||||
v.setPriceStr(BigDecimal.valueOf(v.getPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(v.getBizType())) {
|
||||
v.setBizType(WalletBizEnum.valueOfByType(v.getBizType()).getDesc());
|
||||
}
|
||||
}
|
||||
map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
|
||||
}
|
||||
|
||||
+53
-21
@@ -4,8 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserDTO;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
@@ -23,7 +22,6 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
|
||||
@@ -37,6 +35,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 充值导入表
|
||||
@@ -94,26 +93,37 @@ public class WalletRechargeImportServiceImpl extends ServiceImpl<WalletRechargeI
|
||||
|
||||
@Override
|
||||
public Page<WalletRechargeImportVo> scopePageList(Page page, WalletRechargeImportDto dto, DataScope dataScope) {
|
||||
Page<WalletRechargeImportVo> list = baseMapper.scopePageList(page, dto, dataScope);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 用户
|
||||
List<Long> userIds = list.getRecords().stream().map(WalletRechargeImportVo::getUserId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<UserVO>> userList = userService.getUserDeptByIds(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserDeptList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), UserVO::getUserId));
|
||||
}
|
||||
}
|
||||
// 饭卡类型
|
||||
List<Long> walletTypeId = list.getRecords().stream().map(WalletRechargeImportVo::getWalletTypeId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(walletTypeId)) {
|
||||
WalletTypeDto walletTypeDto = new WalletTypeDto();
|
||||
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(walletTypeDto);
|
||||
if (ObjectUtil.isNotEmpty(walletTypeList)) {
|
||||
WalletDataUtil.convertWalletTypeList(list.getRecords(), CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
|
||||
}
|
||||
// 查询部门
|
||||
if (ObjectUtil.isNotEmpty(dto.getIsDeepDept()) && dto.getIsDeepDept() && ObjectUtil.isNotEmpty(dto.getUserDeptId())) {
|
||||
List<SysDept> deptList = deptService.getDescendantList(dto.getUserDeptId()).getData();
|
||||
dto.setUserDeptId(null);
|
||||
if (ObjectUtil.isNotEmpty(deptList)) {
|
||||
dto.setUserDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getUserDeptIds())) {
|
||||
dto.setUserDeptId(null);
|
||||
}
|
||||
Page<WalletRechargeImportVo> list = baseMapper.scopePageList(page, dto, dataScope);
|
||||
disposeList(list.getRecords(), dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WalletRechargeImportVo> scopeList(WalletRechargeImportDto dto, DataScope dataScope) {
|
||||
// 查询部门
|
||||
if (ObjectUtil.isNotEmpty(dto.getIsDeepDept()) && dto.getIsDeepDept() && ObjectUtil.isNotEmpty(dto.getUserDeptId())) {
|
||||
List<SysDept> deptList = deptService.getDescendantList(dto.getUserDeptId()).getData();
|
||||
dto.setUserDeptId(null);
|
||||
if (ObjectUtil.isNotEmpty(deptList)) {
|
||||
dto.setUserDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(dto.getUserDeptIds())) {
|
||||
dto.setUserDeptId(null);
|
||||
}
|
||||
List<WalletRechargeImportVo> list = baseMapper.scopeList(dto, dataScope);
|
||||
disposeList(list, dto);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -138,4 +148,26 @@ public class WalletRechargeImportServiceImpl extends ServiceImpl<WalletRechargeI
|
||||
walletTransactionService.addWalletBalance(wallet.getId(), rechargeImport.getPrice(), String.valueOf(rechargeImport.getId()), WalletBizEnum.BATCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void disposeList(List<WalletRechargeImportVo> list, WalletRechargeImportDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
// 用户
|
||||
List<Long> userIds = list.stream().map(WalletRechargeImportVo::getUserId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(userIds)) {
|
||||
R<List<UserVO>> userList = userService.getUserDeptByIds(new ArrayList<>(userIds));
|
||||
if (ObjectUtil.isNotEmpty(userList.getData())) {
|
||||
DataUtil.convertUserDeptList(list, CollectionUtils.convertMap(userList.getData(), UserVO::getUserId));
|
||||
}
|
||||
}
|
||||
// 饭卡类型
|
||||
List<Long> walletTypeId = list.stream().map(WalletRechargeImportVo::getWalletTypeId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(walletTypeId)) {
|
||||
WalletTypeDto walletTypeDto = new WalletTypeDto();
|
||||
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(walletTypeDto);
|
||||
if (ObjectUtil.isNotEmpty(walletTypeList)) {
|
||||
WalletDataUtil.convertWalletTypeList(list, CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+15
-1
@@ -34,6 +34,9 @@
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = 0
|
||||
<if test="dto.userId != null">
|
||||
and a.user_id = #{dto.userId}
|
||||
</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=",">
|
||||
@@ -60,7 +63,7 @@
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo">
|
||||
<sql id="selectJoin">
|
||||
<include refid="selectA"/>
|
||||
p.id as applyId,
|
||||
p.dept_id,
|
||||
@@ -75,6 +78,9 @@
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
and p.process_id is not null
|
||||
<if test="dto.bizType != null and dto.bizType != ''">
|
||||
and p.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.processStatus != null and dto.processStatus != ''">
|
||||
and p.process_status = #{dto.processStatus}
|
||||
</if>
|
||||
@@ -86,5 +92,13 @@
|
||||
</if>
|
||||
</where>
|
||||
order by a.create_time desc
|
||||
</sql>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo">
|
||||
<include refid="selectJoin"/>
|
||||
</select>
|
||||
|
||||
<select id="scopeList" resultType="com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo">
|
||||
<include refid="selectJoin"/>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user