diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionCzExcelVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionCzExcelVo.java new file mode 100644 index 000000000..9125ce278 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionCzExcelVo.java @@ -0,0 +1,37 @@ +package com.bsd.pjcloud.wallet.api.vo.recharge.excel; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) +@HeadRowHeight(40) +@ColumnWidth(50) +@ContentRowHeight(20) +@ExcelIgnoreUnannotated +public class WalletTransactionCzExcelVo { + + @ExcelProperty("姓名") + private String username; + + @ExcelProperty("部门") + private String userMobile; + + @ExcelProperty("充值金额") + private String userDeptName; + + @ExcelProperty("充值时间") + private String price; + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionTkExcelVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionTkExcelVo.java new file mode 100644 index 000000000..0a31f503e --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionTkExcelVo.java @@ -0,0 +1,37 @@ +package com.bsd.pjcloud.wallet.api.vo.recharge.excel; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) +@HeadRowHeight(40) +@ColumnWidth(50) +@ContentRowHeight(20) +@ExcelIgnoreUnannotated +public class WalletTransactionTkExcelVo { + + @ExcelProperty("姓名") + private String username; + + @ExcelProperty("部门") + private String userMobile; + + @ExcelProperty("用户部门") + private String userDeptName; + + @ExcelProperty("充值金额") + private String price; + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionXfExcelVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionXfExcelVo.java new file mode 100644 index 000000000..5ef879cad --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/excel/WalletTransactionXfExcelVo.java @@ -0,0 +1,37 @@ +package com.bsd.pjcloud.wallet.api.vo.recharge.excel; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) +@HeadRowHeight(40) +@ColumnWidth(50) +@ContentRowHeight(20) +@ExcelIgnoreUnannotated +public class WalletTransactionXfExcelVo { + + @ExcelProperty("姓名") + private String username; + + @ExcelProperty("部门") + private String userMobile; + + @ExcelProperty("充值金额") + private String userDeptName; + + @ExcelProperty("充值时间") + private String price; + +} diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java index e72c8d3ad..e120d97b7 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletTransactionController.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.common.core.util.R; import com.bsd.pjcloud.common.log.annotation.SysLog; import com.bsd.pjcloud.common.security.annotation.Inner; @@ -14,6 +15,10 @@ import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum; import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto; import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto; import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; +import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionCzExcelVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionTkExcelVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionXfExcelVo; +import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo; import com.bsd.pjcloud.wallet.service.WalletTransactionService; import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,6 +31,7 @@ import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; /** @@ -140,9 +146,33 @@ public class WalletTransactionController { } @ResponseExcel - @GetMapping("/export") + @Operation(summary = "充值导出", description = "充值导出") + @GetMapping("/export-cz") @PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')") - public List export(WalletTransactionEntity walletTransaction, Long[] ids) { - return walletTransactionService.list(Wrappers.lambdaQuery(walletTransaction).in(ArrayUtil.isNotEmpty(ids), WalletTransactionEntity::getId, ids)); + public List exportCz(WalletTransactionDto dto) { + dto.setBizTypes(List.of(WalletBizEnum.RECHARGE.getCode())); + List list = walletTransactionService.pageList(dto); + return BeanUtils.toBean(list, WalletTransactionCzExcelVo.class); + } + + @ResponseExcel + @Operation(summary = "消费导出", description = "消费导出") + @GetMapping("/export-xf") + @PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')") + public List exportXf(WalletTransactionDto dto) { + dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode())); + List list = walletTransactionService.pageList(dto); + return BeanUtils.toBean(list, WalletTransactionXfExcelVo.class); + } + + @ResponseExcel + @Operation(summary = "退款导出", description = "退款导出") + @GetMapping("/export-tk") + @PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')") + public List exportTk(WalletTransactionDto dto) { + dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode())); + dto.setIsFindOrder(true); + List list = walletTransactionService.pageList(dto); + return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class); } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java index 70b42da91..163f0db03 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletTransactionMapper.java @@ -44,6 +44,28 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper pageList(WalletTransactionDto dto) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper() + .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()); + 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 scopePageList(Page page, WalletTransactionDto dto) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId()) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletTransactionService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletTransactionService.java index d423a7009..deea35654 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletTransactionService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletTransactionService.java @@ -7,12 +7,16 @@ import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto; import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity; import com.bsd.pjcloud.wallet.api.vo.transaction.WalletTransactionVo; +import java.util.List; + public interface WalletTransactionService extends IService { Page scopePageList(Page page, WalletTransactionDto dto); Page pageJoin(Page page, WalletTransactionDto dto); + List pageList(WalletTransactionDto dto); + /** * 扣减钱包余额 * diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java index f2dafec47..a4f39a92d 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletTransactionServiceImpl.java @@ -246,4 +246,44 @@ public class WalletTransactionServiceImpl extends ServiceImpl pageList(WalletTransactionDto dto) { + List list = baseMapper.pageList(dto); + if (ObjectUtil.isNotEmpty(list)) { + // 用户 + List userIds = list.stream().map(WalletTransactionVo::getUserId).distinct().toList(); + R> userList = userService.getUserById(new ArrayList<>(userIds)); + if (ObjectUtil.isNotEmpty(userList.getData())) { + DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId)); + } + // 部门 + List deptIds = list.stream().map(WalletTransactionVo::getDeptId).distinct().toList(); + R> deptList = deptService.getDeptByDeptIds(deptIds); + if (ObjectUtil.isNotEmpty(deptList.getData())) { + DataUtil.convertDeptList(list, deptList.getData()); + } + // 饭卡 + List walletIds = list.stream().map(WalletTransactionVo::getWalletId).distinct().toList(); + if (ObjectUtil.isNotEmpty(walletIds)) { + WalletManageDto walletManageDto = new WalletManageDto(); + walletManageDto.setWalletIds(walletIds); + List walletList = walletManageMapper.list(walletManageDto); + if (ObjectUtil.isNotEmpty(walletList)) { + WalletDataUtil.convertWalletList(list, CollectionUtils.convertMap(walletList, WalletManageEntity::getId)); + } + } + // 饭卡类型 + List walletTypeIds = list.stream().map(WalletTransactionVo::getWalletTypeId).distinct().toList(); + if (ObjectUtil.isNotEmpty(walletTypeIds)) { + WalletTypeDto walletTypeDto = new WalletTypeDto(); + walletTypeDto.setWalletTypeIds(walletTypeIds); + List walletTypeList = walletTypeMapper.list(walletTypeDto); + if (ObjectUtil.isNotEmpty(walletTypeList)) { + WalletDataUtil.convertWalletTypeList(list, CollectionUtils.convertMap(walletTypeList, WalletTypeEntity::getId)); + } + } + } + return list; + } } \ No newline at end of file