Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-02-21 16:15:30 +08:00
commit 1c779026f8
27 files changed
+446 -265

No files matched your search

@@ -75,8 +75,8 @@ public interface RemoteUserService {
* @param userIds ID
* @return SysUser
*/
@GetMapping("/user/list")
R<List<SysUser>> getUserById(@RequestParam("userIds") List<Long> userIds);
@PostMapping("/user/list")
R<List<SysUser>> getUserById(@RequestBody List<Long> userIds);
@GetMapping("/user/user-dept")
R<List<UserVO>> getUserDeptByIds(@RequestParam("userIds") List<Long> userIds);
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.common.excel.annotation.ExcelLine;
import lombok.Data;
import jakarta.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;
@@ -20,87 +21,87 @@ import java.time.LocalDateTime;
@ColumnWidth(30)
public class UserExcelVO implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
private Long lineNum;
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
private Long lineNum;
/**
* 主键ID
*/
@ExcelProperty("用户编号")
private Long userId;
/**
* 主键ID
*/
@ExcelProperty("用户编号")
private Long userId;
/**
* 用户名
*/
@NotBlank(message = "用户名不能为空")
@ExcelProperty("用户名")
private String username;
/**
* 用户名
*/
@NotBlank(message = "用户名不能为空")
@ExcelProperty("用户名")
private String username;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空")
@ExcelProperty("手机号")
private String phone;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空")
@ExcelProperty("手机号")
private String phone;
/**
* 手机号
*/
@NotBlank(message = "昵称不能为空")
@ExcelProperty("昵称")
private String nickname;
/**
* 手机号
*/
@NotBlank(message = "昵称不能为空")
@ExcelProperty("昵称")
private String nickname;
/**
* 手机号
*/
@NotBlank(message = "姓名不能为空")
@ExcelProperty("姓名")
private String name;
/**
* 手机号
*/
@NotBlank(message = "姓名不能为空")
@ExcelProperty("姓名")
private String name;
/**
* 手机号
*/
@NotBlank(message = "邮箱不能为空")
@ExcelProperty("邮箱")
private String email;
/**
* 手机号
*/
@NotBlank(message = "邮箱不能为空")
@ExcelProperty("邮箱")
private String email;
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空")
@ExcelProperty("部门名称")
private String deptName;
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空")
@ExcelProperty("部门名称")
private String deptName;
/**
* 角色列表
*/
@NotBlank(message = "角色不能为空")
@ExcelProperty("角色")
private String roleNameList;
/**
* 角色列表
*/
@NotBlank(message = "角色不能为空")
@ExcelProperty("角色")
private String roleNameList;
/**
* 角色列表
*/
@NotBlank(message = "岗位不能为空")
@ExcelProperty("岗位名称")
private String postNameList;
/**
* 角色列表
*/
@NotBlank(message = "岗位不能为空")
@ExcelProperty("岗位名称")
private String postNameList;
/**
* 锁定标记
*/
@ExcelProperty("锁定标记,0:正常,9:已锁定")
private String lockFlag;
/**
* 锁定标记
*/
@ExcelProperty("锁定标记,0:正常,9:已锁定")
private String lockFlag;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private LocalDateTime createTime;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private LocalDateTime createTime;
}
@@ -20,7 +20,6 @@
package com.bsd.pjcloud.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -247,10 +246,10 @@ public class SysUserController {
* @return
*/
@ResponseExcel
@GetMapping("/export")
@PostMapping("/export")
@HasPermission("sys_user_export")
public List export(UserDTO userDTO, Long[] ids) {
return userService.listUser(userDTO, ids);
public List export(@RequestBody UserDTO userDTO) {
return userService.listUser(userDTO, null);
}
/**
@@ -347,8 +346,8 @@ public class SysUserController {
* @param userIds ID列表
* @return 用户列表
*/
@GetMapping("/list")
public R<List<SysUser>> getUserListByIds(@RequestParam("userIds") List<Long> userIds) {
@PostMapping("/list")
public R<List<SysUser>> getUserListByIds(@RequestBody List<Long> userIds) {
return R.ok(userService.list(Wrappers.<SysUser>lambdaQuery().in(SysUser::getUserId, userIds)));
}
@@ -380,11 +379,11 @@ public class SysUserController {
@GetMapping("/getSimpleUserAll")
@Schema(description = "简要用户信息")
public R<List<SimpleUserAllListVO>> getSimpleUserAllList(@RequestParam(value = "mobile",required = false) String mobile,
@RequestParam(value = "name",required = false) String name){
public R<List<SimpleUserAllListVO>> getSimpleUserAllList(@RequestParam(value = "mobile", required = false) String mobile,
@RequestParam(value = "name", required = false) String name) {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(mobile),SysUser::getPhone,mobile);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(name),SysUser::getName,name);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(mobile), SysUser::getPhone, mobile);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(name), SysUser::getName, name);
List<SimpleUserAllListVO> list = userService.listScope(sysUserLambdaQueryWrapper);
return R.ok(list);
@@ -220,6 +220,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public IPage getUsersWithRolePage(Page page, UserDTO userDTO) {
// 部门
if (ObjectUtil.isNotEmpty(userDTO.getIsDeepDept()) && userDTO.getIsDeepDept() && ObjectUtil.isNotEmpty(userDTO.getDeptId())) {
List<SysDept> deptList = sysDeptService.listDescendant(userDTO.getDeptId());
userDTO.setDeptId(null);
@@ -227,6 +228,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userDTO.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(userDTO.getDeptIds())) {
userDTO.setDeptId(null);
}
IPage<UserVO> list = baseMapper.getUserVosPage(page, userDTO, DataScope.of());
if (ObjectUtil.isNotEmpty(list.getRecords())) {
List<Long> userIds = list.getRecords().stream().map(UserVO::getUserId).distinct().toList();
@@ -363,6 +367,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public List<UserExcelVO> listUser(UserDTO userDTO, Long[] ids) {
// 部门
if (ObjectUtil.isNotEmpty(userDTO.getIsDeepDept()) && userDTO.getIsDeepDept() && ObjectUtil.isNotEmpty(userDTO.getDeptId())) {
List<SysDept> deptList = sysDeptService.listDescendant(userDTO.getDeptId());
userDTO.setDeptId(null);
if (ObjectUtil.isNotEmpty(deptList)) {
userDTO.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(userDTO.getDeptIds())) {
userDTO.setDeptId(null);
}
// 根据数据权限查询全部的用户信息
List<UserVO> voList = baseMapper.selectVoListByScope(userDTO, ids, DataScope.of());
// 转换成execl 对象输出
@@ -768,7 +783,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
public List<SimpleUserAllListVO> listScope(LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper) {
List<SysUser> sysUsers = baseMapper.selectListByScope(sysUserLambdaQueryWrapper,DataScope.of());
List<SysUser> sysUsers = baseMapper.selectListByScope(sysUserLambdaQueryWrapper, DataScope.of());
List<SimpleUserAllListVO> collect = sysUsers.stream().map(sysUser -> {
SimpleUserAllListVO vo = new SimpleUserAllListVO();
vo.setId(sysUser.getUserId());
@@ -247,9 +247,15 @@
<if test="query.deptId != null and query.deptId != ''">
AND u.dept_id = #{query.deptId}
</if>
<if test="ids != null">
<if test="query.deptIds != null and query.deptIds.size() != 0">
AND u.dept_id in
<foreach collection="query.deptIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="query.ids != null and query.ids.size() != 0">
AND u.user_id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
<foreach collection="query.ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
@@ -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))
@@ -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))
@@ -16,4 +16,14 @@ public class WalletManageDto extends WalletManageEntity {
private LocalDateTime[] createTimeList;
/**
* 是否深度搜索deptId
*/
private Boolean isDeepDept;
/**
* 部门ids
*/
private List<Long> deptIds;
}
@@ -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;
}
@@ -52,4 +52,8 @@ public class WalletRechargeImportVo extends WalletRechargeImportEntity implement
private String walletTypeUniqueCode;
private String walletTypeIcon;
private String priceStr;
private String importTimeStr;
}
@@ -144,9 +144,9 @@ public class WalletManageController {
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page-join")
@PostMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_view')")
public R getWalletManagePageJoin(@ParameterObject Page page, @ParameterObject WalletManageDto dto) {
public R getWalletManagePageJoin(@ParameterObject Page page, @RequestBody WalletManageDto dto) {
return R.ok(walletManageService.scopePageList(page, dto, DataScope.of()));
}
@@ -180,10 +180,10 @@ public class WalletManageController {
public R removeById(@RequestBody Long[] ids) {
return R.ok(walletManageService.removeBatchByIds(CollUtil.toList(ids)));
}
@GetMapping("/export")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_export')")
public void export(HttpServletResponse response, @ParameterObject Page page, @ParameterObject WalletManageDto dto) {
public void export(HttpServletResponse response, @ParameterObject Page page, @RequestBody WalletManageDto dto) {
walletManageService.export(response, page, dto);
}
}
@@ -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));
}
@@ -161,28 +161,29 @@ public class WalletTransactionController {
@Operation(summary = "充值导出", description = "充值导出")
@PostMapping("/export-cz")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportCz(HttpServletResponse response, @ParameterObject Page page, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.RECHARGE.getCode()));
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
public void exportCz(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(WalletBizEnum.getTopUpCodes());
// dto.setType(WalletTransactionDto.TYPE_INCOME);
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人充值明细.xlsx", list);
}
@Operation(summary = "消费导出", description = "消费导出")
@PostMapping("/export-xf")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportXf(HttpServletResponse response, @ParameterObject Page page, @RequestBody WalletTransactionDto dto) {
public void exportXf(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人消费明细.xlsx", list);
}
@Operation(summary = "退款导出", description = "退款导出")
@PostMapping("/export-tk")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public void exportTk(HttpServletResponse response, @ParameterObject Page page, @RequestBody WalletTransactionDto dto) {
public void exportTk(HttpServletResponse response, @RequestBody WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
List<WalletTransactionVo> list = walletTransactionService.scopePageList(page, dto, DataScope.of()).getRecords();
List<WalletTransactionVo> list = walletTransactionService.scopeList(dto, DataScope.of());
walletTransactionService.exportByTemplate(response, dto, "file/个人退款明细.xlsx", list);
}
}
@@ -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);
}
}
}
@@ -105,10 +105,12 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
default Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope) {
LambdaQueryWrapper<WalletManageEntity> wrapper = new LambdaQueryWrapper<WalletManageEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletManageEntity::getUserId, dto.getUserId())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletManageEntity::getDeptId, dto.getDeptId())
.eq(ObjectUtil.isNotEmpty(dto.getWalletTypeId()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
.eq(ObjectUtil.isNotEmpty(dto.getIsFreeze()), WalletManageEntity::getIsFreeze, dto.getIsFreeze())
.in(ObjectUtil.isNotEmpty(dto.getWalletIds()), WalletManageEntity::getId, dto.getWalletIds())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletManageEntity::getDeptId, dto.getDeptIds())
.between(
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
WalletManageEntity::getCreateTime,
@@ -121,4 +123,24 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
return list;
}
default List<WalletManageVo> scopeList(WalletManageDto dto, DataScope dataScope) {
LambdaQueryWrapper<WalletManageEntity> wrapper = new LambdaQueryWrapper<WalletManageEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletManageEntity::getUserId, dto.getUserId())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletManageEntity::getDeptId, dto.getDeptId())
.eq(ObjectUtil.isNotEmpty(dto.getWalletTypeId()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
.eq(ObjectUtil.isNotEmpty(dto.getIsFreeze()), WalletManageEntity::getIsFreeze, dto.getIsFreeze())
.in(ObjectUtil.isNotEmpty(dto.getWalletIds()), WalletManageEntity::getId, dto.getWalletIds())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletManageEntity::getDeptId, dto.getDeptIds())
.between(
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
WalletManageEntity::getCreateTime,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
)
.orderByDesc(WalletManageEntity::getCreateTime);
List<WalletManageEntity> list = selectListByScope(wrapper, dataScope);
return BeanUtils.toBean(list, WalletManageVo.class);
}
}
@@ -24,33 +24,11 @@ import java.util.Objects;
@Mapper
public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransactionEntity> {
default List<WalletTransactionVo> pageList(WalletTransactionDto dto) {
MPJLambdaWrapper<WalletTransactionEntity> wrapper = new MPJLambdaWrapper<WalletTransactionEntity>()
.selectAll(WalletTransactionEntity.class)
.selectAs(WalletManageEntity::getUserId, WalletTransactionVo::getUserId)
.selectAs(WalletManageEntity::getDeptId, WalletTransactionVo::getDeptId)
.selectAs(WalletTypeEntity::getName, WalletTransactionVo::getWalletTypeName)
.selectAs(WalletTypeEntity::getUniqueCode, WalletTransactionVo::getWalletTypeUniqueCode)
.leftJoin(WalletManageEntity.class, WalletManageEntity::getId, WalletTransactionEntity::getWalletId)
.leftJoin(WalletTypeEntity.class, WalletTypeEntity::getId, WalletManageEntity::getWalletTypeId)
.eqIfExists(WalletTransactionEntity::getWalletId, dto.getWalletId())
.eqIfExists(WalletTransactionEntity::getBizType, dto.getBizType())
.eqIfExists(WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
.in(ObjectUtil.isNotEmpty(dto.getBizTypes()), WalletTransactionEntity::getBizType, dto.getBizTypes())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds())
.orderByDesc(WalletTransactionEntity::getCreateTime);
if (ObjectUtil.equals(dto.getType(), WalletTransactionDto.TYPE_INCOME)) {
wrapper.gt(WalletTransactionEntity::getPrice, 0);
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
return selectJoinList(WalletTransactionVo.class, wrapper);
}
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) {
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId())
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType())
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletTransactionEntity::getUserId, dto.getUserId())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletTransactionEntity::getDeptId, dto.getDeptId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, dto.getDeptIds())
@@ -72,6 +50,32 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
return list;
}
default List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope) {
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId())
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType())
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletTransactionEntity::getUserId, dto.getUserId())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletTransactionEntity::getDeptId, dto.getDeptId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletTransactionEntity::getDeptId, dto.getDeptIds())
.in(ObjectUtil.isNotEmpty(dto.getBizTypes()), WalletTransactionEntity::getBizType, dto.getBizTypes())
.between(
ObjectUtil.isNotEmpty(dto.getCreateTimeList()),
WalletTransactionEntity::getCreateTime,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
)
.orderByDesc(WalletTransactionEntity::getCreateTime);
if (ObjectUtil.equals(dto.getType(), WalletTransactionDto.TYPE_INCOME)) {
wrapper.gt(WalletTransactionEntity::getPrice, 0);
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
List<WalletTransactionEntity> list = selectListByScope(wrapper, dataScope);
return BeanUtils.toBean(list, WalletTransactionVo.class);
}
Integer getTransactionPriceCount(@Param("month") String importTimeStr, @Param("walletId") Long walletId, @Param("bizType") String bizType);
List<WalletRechargeApplySelectCompareVo> selectCompare(@Param("bizType") String bizType, @Param("dateTime") String monthTimeStr, @Param("userIdList") List<Long> userIdList);
@@ -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,7 +2,6 @@ package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
@@ -83,7 +82,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope);
List<WalletManageVo> joinList(WalletManageDto dto);
List<WalletManageVo> scopeList(WalletManageDto dto, DataScope dataScope);
WalletManageVo join(Long user, Long walletId);
@@ -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);
}
@@ -16,7 +16,7 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope);
List<WalletTransactionVo> pageList(WalletTransactionDto dto);
List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope);
/**
* 扣减钱包余额
@@ -39,7 +39,6 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo;
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
@@ -49,7 +48,6 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -61,6 +59,7 @@ import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
/**
* 钱包管理
@@ -219,51 +218,38 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
@Override
public List<WalletManageVo> joinList(WalletManageDto dto) {
List<WalletManageVo> list = baseMapper.joinList(dto);
if (ObjectUtil.isNotEmpty(list)) {
// 用户
List<Long> userIds = list.stream().map(WalletManageVo::getUserId).distinct().toList();
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
// 部门
List<Long> deptIds = list.stream().map(WalletManageVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(list, deptList.getData());
public List<WalletManageVo> scopeList(WalletManageDto dto, DataScope dataScope) {
// 查询部门
if (ObjectUtil.isNotEmpty(dto.getIsDeepDept()) && dto.getIsDeepDept() && ObjectUtil.isNotEmpty(dto.getDeptId())) {
List<SysDept> deptList = deptService.getDescendantList(dto.getDeptId()).getData();
dto.setDeptId(null);
if (ObjectUtil.isNotEmpty(deptList)) {
dto.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(dto.getDeptIds())) {
dto.setDeptId(null);
}
List<WalletManageVo> list = baseMapper.scopeList(dto, dataScope);
disposeList(list, dto);
return list;
}
@Override
public Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto, DataScope dataScope) {
Page<WalletManageVo> list = baseMapper.scopePageList(page, dto, dataScope);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(WalletManageVo::getUserId).distinct().toList();
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
// 部门
List<Long> deptIds = list.getRecords().stream().map(WalletManageVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
}
// 饭卡类型
List<Long> walletTypeId = list.getRecords().stream().map(WalletManageVo::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.getDeptId())) {
List<SysDept> deptList = deptService.getDescendantList(dto.getDeptId()).getData();
dto.setDeptId(null);
if (ObjectUtil.isNotEmpty(deptList)) {
dto.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(dto.getDeptIds())) {
dto.setDeptId(null);
}
Page<WalletManageVo> list = baseMapper.scopePageList(page, dto, dataScope);
disposeList(list.getRecords(), dto);
return list;
}
@@ -283,7 +269,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
@Override
public void export(HttpServletResponse response, Page page, WalletManageDto dto) {
String fileName = "file/账户余额.xlsx";
List<WalletManageVo> list = scopePageList(page, dto, DataScope.of()).getRecords();
List<WalletManageVo> list = scopeList(dto, DataScope.of());
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream(fileName)).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
@@ -323,6 +309,32 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
}
private void disposeList(List<WalletManageVo> list, WalletManageDto dto) {
if (ObjectUtil.isNotEmpty(list)) {
// 用户
List<Long> userIds = list.stream().map(WalletManageVo::getUserId).distinct().toList();
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
// 部门
List<Long> deptIds = list.stream().map(WalletManageVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(list, deptList.getData());
}
// 饭卡类型
List<Long> walletTypeId = list.stream().map(WalletManageVo::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));
}
}
}
}
private WalletManageServiceImpl getSelf() {
return SpringUtil.getBean(getClass());
}
@@ -17,11 +17,11 @@ 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.constant.CacheConstants;
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;
@@ -38,7 +38,6 @@ import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -179,54 +178,62 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
dto.setDeptId(null);
}
Page<WalletTransactionVo> list = baseMapper.scopePageList(page, dto, dataScope);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(WalletTransactionVo::getUserId).distinct().toList();
R<List<SysUser>> userList = userService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(list.getRecords(), CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
// 部门
List<Long> deptIds = list.getRecords().stream().map(WalletTransactionVo::getDeptId).distinct().toList();
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
if (ObjectUtil.isNotEmpty(deptList.getData())) {
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
}
// 饭卡
List<Long> walletIds = list.getRecords().stream().map(WalletTransactionVo::getWalletId).distinct().toList();
if (ObjectUtil.isNotEmpty(walletIds)) {
WalletManageDto walletManageDto = new WalletManageDto();
walletManageDto.setWalletIds(walletIds);
List<WalletManageEntity> walletList = walletManageMapper.list(walletManageDto);
if (ObjectUtil.isNotEmpty(walletList)) {
WalletDataUtil.convertWalletList(list.getRecords(), CollectionUtils.convertMap(walletList, WalletManageEntity::getId));
}
}
// 饭卡类型
List<Long> walletTypeIds = list.getRecords().stream().map(WalletTransactionVo::getWalletTypeId).distinct().toList();
if (ObjectUtil.isNotEmpty(walletTypeIds)) {
WalletTypeDto walletTypeDto = new WalletTypeDto();
walletTypeDto.setWalletTypeIds(walletTypeIds);
List<WalletTypeEntity> walletTypeList = walletTypeMapper.list(walletTypeDto);
if (ObjectUtil.isNotEmpty(walletTypeList)) {
WalletDataUtil.convertWalletTypeList(list.getRecords(), CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
}
}
// 订单
if (dto.getIsFindOrder()) {
list.getRecords().forEach(v -> {
if (ObjectUtil.isNotEmpty(v.getBizId())) {
v.setOrderId(Long.valueOf(v.getBizId()));
}
});
}
}
disposeList(list.getRecords(), dto);
return list;
}
@Override
public List<WalletTransactionVo> pageList(WalletTransactionDto dto) {
List<WalletTransactionVo> list = baseMapper.pageList(dto);
public List<WalletTransactionVo> scopeList(WalletTransactionDto dto, DataScope dataScope) {
// 查询部门
if (ObjectUtil.isNotEmpty(dto.getIsDeepDept()) && dto.getIsDeepDept() && ObjectUtil.isNotEmpty(dto.getDeptId())) {
List<SysDept> deptList = deptService.getDescendantList(dto.getDeptId()).getData();
dto.setDeptId(null);
if (ObjectUtil.isNotEmpty(deptList)) {
dto.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(dto.getDeptIds())) {
dto.setDeptId(null);
}
List<WalletTransactionVo> list = baseMapper.scopeList(dto, dataScope);
disposeList(list, dto);
return list;
}
@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()) {
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 priceTotal = BigDecimal.ZERO;
for (WalletTransactionVo v : list) {
if (ObjectUtil.isNotEmpty(v.getPrice())) {
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());
}
excelWriter.fill(map, writeSheet);
excelWriter.fill(list, fillConfig, writeSheet);
} catch (IOException e) {
e.printStackTrace();
log.error("|{}|导入错误,dto:|{}|,fileName:|{}|,error:|{}|", TAG, JSON.toJSONString(dto), fileName, e.getMessage());
}
}
private void disposeList(List<WalletTransactionVo> list, WalletTransactionDto dto) {
if (ObjectUtil.isNotEmpty(list)) {
// 用户
List<Long> userIds = list.stream().map(WalletTransactionVo::getUserId).distinct().toList();
@@ -260,36 +267,15 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
WalletDataUtil.convertWalletTypeList(list, CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId));
}
}
// 订单
if (dto.getIsFindOrder()) {
list.forEach(v -> {
if (ObjectUtil.isNotEmpty(v.getBizId())) {
v.setOrderId(Long.valueOf(v.getBizId()));
}
});
}
}
return list;
}
@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()) {
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 priceTotal = BigDecimal.ZERO;
for (WalletTransactionVo v : list) {
if (ObjectUtil.isNotEmpty(v.getPrice())) {
priceTotal = priceTotal.add(BigDecimal.valueOf(v.getPrice()));
v.setPriceStr(BigDecimal.valueOf(v.getPrice()).divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
}
}
map.put("computeTotalPayPrice", priceTotal.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString());
}
excelWriter.fill(map, writeSheet);
excelWriter.fill(list, fillConfig, writeSheet);
} catch (IOException e) {
e.printStackTrace();
log.error("|{}|导入错误,dto:|{}|,fileName:|{}|,error:|{}|", TAG, JSON.toJSONString(dto), fileName, e.getMessage());
}
}
}
@@ -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));
}
}
}
}
}
@@ -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>