设备交易记录、商户交易记录

This commit is contained in:
dzc committed 2025-01-22 11:50:03 +08:00
1 parent d3926e63ad
commit 83d91ae763
14 files changed
+464 -88

No files matched your search

@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
/**
* 订单状态
@@ -22,6 +23,13 @@ public enum HardOrderStatusEnum {
private final String type;
private final String description;
public static List<String> getPaySuccessCodes() {
return List.of(
HardOrderStatusEnum.PAY.type,
HardOrderStatusEnum.CANCEL.type
);
}
public static HardOrderStatusEnum valueOfByType(Integer type) {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
@@ -26,6 +26,8 @@ public class HardOrderDto extends HardOrderEntity {
private List<Long> mchIds;
private List<String> orderStatusCodes;
private LocalDate[] createTimeList;
private LocalDate[] payTimeList;
@@ -0,0 +1,50 @@
package com.bsd.pjcloud.hard.api.vo.order;
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 com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
@HeadRowHeight(40)
@ColumnWidth(50)
@ContentRowHeight(20)
@ExcelIgnoreUnannotated
public class HardOrderCsVo implements BaseMchInterface, BaseHardInterface {
@ExcelProperty("设备名称")
@Schema(description = "设备id")
private Long hardId;
@ExcelProperty("设备名称")
private String hardName;
@Schema(description = "设备类型")
private String hardType;
@ExcelProperty("所属商户")
@Schema(description = "商户名")
private String merchantName;
@Schema(description = "商户logo")
private String logoPic;
@Schema(description = "商户id")
private Long merchantId;
@ExcelProperty("总消费金额")
@Schema(description = "总消费金额")
private BigDecimal totalPayPrice;
@ExcelProperty("总消费次数")
@Schema(description = "总消费次数")
private BigDecimal totalPayCount;
}
@@ -0,0 +1,47 @@
package com.bsd.pjcloud.hard.api.vo.order;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
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 com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
@HeadRowHeight(40)
@ColumnWidth(50)
@ContentRowHeight(20)
@ExcelIgnoreUnannotated
public class HardOrderSbVo implements BaseMchInterface, BaseHardInterface {
@Schema(description = "设备id")
private Long hardId;
@Schema(description = "商户id")
private Long merchantId;
@Schema(description = "总消费金额")
private BigDecimal totalPayPrice;
@Schema(description = "总消费次数")
private BigDecimal totalPayCount;
/**
* 商户相关
*/
private String merchantName;
private String logoPic;
/**
* 设备相关
*/
private String hardName;
private String hardType;
}
@@ -0,0 +1,67 @@
package com.bsd.pjcloud.hard.controller.order;
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.excel.annotation.ResponseExcel;
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletTransactionTkExcelVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-total")
@Tag(description = "hard-total", name = "统计")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardOrderTotalController {
private final HardOrderTotalService HardOrderTotalService;
@GetMapping("/page-list-sb")
@Operation(summary = "设备交易记录")
public R<Page<HardOrderSbVo>> pageListSb(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return R.ok(HardOrderTotalService.pageListSb(page, dto));
}
@GetMapping("/page-list-cs")
@Operation(summary = "商户交易记录")
public R<Page<HardOrderCsVo>> pageListCs(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return R.ok(HardOrderTotalService.pageListCs(page, dto));
}
@ResponseExcel
@Operation(summary = "设备交易记录导出", description = "退款导出")
@GetMapping("/export-sb")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_sb')")
public List<WalletTransactionTkExcelVo> exportSb(HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
List<HardOrderSbVo> list = HardOrderTotalService.listSb(dto);
return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
}
@ResponseExcel
@Operation(summary = "商户交易记录导出", description = "退款导出")
@GetMapping("/export-cs")
@PreAuthorize("@pms.hasPermission('hard_hardTotal_export_cs')")
public List<WalletTransactionTkExcelVo> exportTk(HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
List<HardOrderCsVo> list = HardOrderTotalService.listCs(dto);
return BeanUtils.toBean(list, WalletTransactionTkExcelVo.class);
}
}
@@ -10,9 +10,12 @@ import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardAfterSaleEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -74,4 +77,12 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
.in(ObjectUtil.isNotEmpty(dto.getOrderIds()), HardOrderEntity::getId, dto.getOrderIds());
return selectListByScope(wrapper, DataScope.of());
}
Page<HardOrderSbVo> pageListSb(Page page, @Param("dto") HardOrderDto dto);
List<HardOrderSbVo> listSb(@Param("dto") HardOrderDto dto);
Page<HardOrderCsVo> pageListCs(Page page, @Param("dto") HardOrderDto dto);
List<HardOrderCsVo> listCs(@Param("dto") HardOrderDto dto);
}
@@ -0,0 +1,19 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import java.util.List;
public interface HardOrderTotalService {
Page<HardOrderSbVo> pageListSb(Page page, HardOrderDto dto);
List<HardOrderSbVo> listSb(HardOrderDto dto);
Page<HardOrderCsVo> pageListCs(Page page, HardOrderDto dto);
List<HardOrderCsVo> listCs(HardOrderDto dto);
}
@@ -0,0 +1,120 @@
package com.bsd.pjcloud.hard.service.impl.order;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
import com.bsd.pjcloud.hard.mapper.order.HardOrderMapper;
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardOrderTotalServiceImpl implements HardOrderTotalService {
private final HardOrderMapper hardOrderMapper;
private final HardManagerMapper hardManagerMapper;
private final RemoteMchService remoteMchService;
@Override
public Page<HardOrderSbVo> pageListSb(Page page, HardOrderDto dto) {
Page<HardOrderSbVo> list = hardOrderMapper.pageListSb(page, dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.getRecords().stream().map(HardOrderSbVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
// 设备
List<Long> hardIds = list.getRecords().stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
HardManagerDto hardManagerDto = new HardManagerDto();
hardManagerDto.setIds(hardIds);
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
if (ObjectUtil.isNotEmpty(hardList)) {
HardUtil.convertHardList(list.getRecords(), CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
}
}
}
return list;
}
@Override
public List<HardOrderSbVo> listSb(HardOrderDto dto) {
List<HardOrderSbVo> list = hardOrderMapper.listSb(dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.stream().map(HardOrderSbVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
// 设备
List<Long> hardIds = list.stream().map(HardOrderSbVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
HardManagerDto hardManagerDto = new HardManagerDto();
hardManagerDto.setIds(hardIds);
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
if (ObjectUtil.isNotEmpty(hardList)) {
HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
}
}
}
return list;
}
@Override
public Page<HardOrderCsVo> pageListCs(Page page, HardOrderDto dto) {
Page<HardOrderCsVo> list = hardOrderMapper.pageListCs(page, dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.getRecords().stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
}
return list;
}
@Override
public List<HardOrderCsVo> listCs(HardOrderDto dto) {
List<HardOrderCsVo> list = hardOrderMapper.listCs(dto);
if (ObjectUtil.isNotEmpty(list)) {
// 商户
List<Long> mchIds = list.stream().map(HardOrderCsVo::getMerchantId).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
}
return list;
}
}
@@ -2,8 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.hard.mapper.order.HardOrderMapper">
<resultMap id="hardwareOrderMap" type="com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity">
<resultMap id="hardwareOrderMap" type="com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="merchantId" column="merchant_id"/>
@@ -36,5 +35,106 @@
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</resultMap>
<sql id="selectA">
select a.id,
a.user_id,
a.merchant_id,
a.hard_id,
a.dept_id,
a.wallet_id,
a.parent_car_id,
a.order_source_type_id,
a.order_type,
a.order_status,
a.pay_type,
a.hour_type,
a.sys_type,
a.total_price,
a.extra_price,
a.pay_price,
a.pay_time,
a.pay_refund_id,
a.refund_price,
a.refund_time,
a.refund_status,
a.apply_cancel_time,
a.android_order_code,
a.is_offline_order,
a.product_desc,
a.offline_pay_success,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.orderStatusCodes != null and dto.orderStatusCodes.size() != 0">
and a.order_status in
<foreach collection="dto.orderStatusCodes" 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.payTimeList != null and dto.payTimeList.length == 2">
and a.pay_time between #{dto.payTimeList[0]} and #{dto.payTimeList[1]}
</if>
</sql>
<select id="pageListSb" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo">
select
a.hard_id,
a.merchant_id,
sum(a.pay_price) as totalPayPrice,
count(0) as totalPayCount
from hard_order a
<where>
<include refid="whereA"/>
</where>
group by a.hard_id
</select>
<select id="listSb" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo">
select
a.hard_id,
a.merchant_id,
sum(a.pay_price) as totalPayPrice,
count(0) as totalPayCount
from hard_order a
<where>
<include refid="whereA"/>
</where>
group by a.hard_id
</select>
<select id="pageListCs" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
select
a.merchant_id,
sum(a.pay_price) as totalPayPrice,
count(0) as totalPayCount
from hard_order a
<where>
<include refid="whereA"/>
</where>
group by a.merchant_id
</select>
<select id="listCs" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
select
a.merchant_id,
sum(a.pay_price) as totalPayPrice,
count(0) as totalPayCount
from hard_order a
<where>
<include refid="whereA"/>
</where>
group by a.merchant_id
</select>
</mapper>
@@ -11,6 +11,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
@Data
@Builder
@AllArgsConstructor
@@ -25,13 +27,19 @@ public class WalletTransactionCzExcelVo {
@ExcelProperty("姓名")
private String username;
@ExcelProperty("部门")
@ExcelProperty("手机号")
private String userMobile;
@ExcelProperty("充值金额")
@ExcelProperty("部门")
private String userDeptName;
@ExcelProperty("充值时间")
@ExcelProperty("充值类型")
private String title;
@ExcelProperty("充值金额")
private String price;
@ExcelProperty("充值时间")
private LocalDateTime createTime;
}
@@ -7,6 +7,8 @@ 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.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -73,7 +75,9 @@ public class WalletTransactionController {
public R appGetAll(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(walletTransactionService.pageJoin(page, dto));
DataScope dataScope = new DataScope();
dataScope.func(DataScopeFuncEnum.ALL);
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
/* ************************************* end app end ************************************* */
@@ -88,7 +92,8 @@ public class WalletTransactionController {
@GetMapping("/page-cz")
public R pageCz(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.RECHARGE.getCode()));
return R.ok(walletTransactionService.scopePageList(page, dto));
DataScope dataScope = new DataScope();
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
@Operation(summary = "后台消费分页", description = "后台消费分页")
@@ -96,7 +101,8 @@ public class WalletTransactionController {
public R pageXf(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
dto.setIsFindOrder(true);
return R.ok(walletTransactionService.scopePageList(page, dto));
DataScope dataScope = new DataScope();
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
@Operation(summary = "后台退款分页", description = "后台退款分页")
@@ -104,14 +110,16 @@ public class WalletTransactionController {
public R pageTk(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
return R.ok(walletTransactionService.scopePageList(page, dto));
DataScope dataScope = new DataScope();
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
@Operation(summary = "分页查询复杂查询", description = "分页查询复杂查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_view')")
public R getWalletTransactionPageJoin(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
return R.ok(walletTransactionService.scopePageList(page, dto));
DataScope dataScope = new DataScope();
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@@ -22,28 +22,6 @@ import java.util.Objects;
@Mapper
public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransactionEntity> {
default Page<WalletTransactionVo> pageJoin(Page page, 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());
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 selectJoinPage(page, WalletTransactionVo.class, wrapper);
}
default List<WalletTransactionVo> pageList(WalletTransactionDto dto) {
MPJLambdaWrapper<WalletTransactionEntity> wrapper = new MPJLambdaWrapper<WalletTransactionEntity>()
.selectAll(WalletTransactionEntity.class)
@@ -66,7 +44,7 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
return selectJoinList(WalletTransactionVo.class, wrapper);
}
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto) {
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())
@@ -78,7 +56,12 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null,
ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null
);
Page list = selectPageByScope(page, wrapper, DataScope.of());
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);
}
Page list = selectPageByScope(page, wrapper, dataScope);
list.setRecords(BeanUtils.toBean(list.getRecords(), WalletTransactionVo.class));
return list;
}
@@ -2,6 +2,7 @@ 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.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;
@@ -11,9 +12,7 @@ import java.util.List;
public interface WalletTransactionService extends IService<WalletTransactionEntity> {
Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto);
Page<WalletTransactionVo> pageJoin(Page page, WalletTransactionDto dto);
Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope);
List<WalletTransactionVo> pageList(WalletTransactionDto dto);
@@ -42,6 +41,7 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
/**
* 更新会员用户余额
*
* @param dto
* @return
*/
@@ -13,6 +13,7 @@ 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.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
@@ -152,56 +153,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
@Override
public Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto) {
Page<WalletTransactionVo> list = baseMapper.scopePageList(page, dto);
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()));
}
});
}
}
return list;
}
@Override
public Page<WalletTransactionVo> pageJoin(Page page, WalletTransactionDto dto) {
Page<WalletTransactionVo> list = baseMapper.pageJoin(page, dto);
public Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto, DataScope dataScope) {
Page<WalletTransactionVo> list = baseMapper.scopePageList(page, dto, dataScope);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(WalletTransactionVo::getUserId).distinct().toList();