feat:二维码

This commit is contained in:
dzc committed 2025-01-09 20:51:02 +08:00
1 parent 872ebe235f
commit fdab8dfd7a
55 files changed
+854 -173

No files matched your search

@@ -11,6 +11,8 @@ import java.util.Arrays;
public enum WalletCodeBizEnum {
STRIDE("1", "跨单位"),
FOREIGN("2", "外来人员"),
CANTEEN_RESERVE("3", "食堂线上预订"),
SUPERMARKET_RESERVE("4", "超市线上预订"),
;
private final String code;
@@ -10,4 +10,6 @@ public class WalletManageDto extends WalletManageEntity {
private List<Long> userIds;
private List<Long> walletIds;
}
@@ -4,6 +4,7 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
@@ -32,4 +33,11 @@ public class WalletTransactionDto extends WalletTransactionEntity {
private List<String> bizTypes;
private LocalDate[] createTimeList;
/**
* 是否查询order
*/
private Boolean isFindOrder = false;
}
@@ -0,0 +1,13 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import lombok.Data;
import java.util.List;
@Data
public class WalletTypeDto extends WalletTypeEntity {
private List<Long> walletTypeIds;
}
@@ -94,7 +94,7 @@ public class WalletManageEntity extends Model<WalletManageEntity> {
* 饭卡绑定状态
*/
@Schema(description = "饭卡绑定状态")
private Integer activeBindStatus;
private String activeBindStatus;
/**
* 创建人
@@ -21,88 +21,100 @@ import java.time.LocalDateTime;
public class WalletTransactionEntity extends Model<WalletTransactionEntity> {
/**
* 编号
*/
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
@Schema(description = "编号")
private Long id;
/**
* 会员钱包 id
*/
@Schema(description="会员钱包 id")
/**
* 用户 id
*/
@Schema(description = "用户 id")
private Long userId;
/**
* 部门 id
*/
@Schema(description = "部门 id")
private Long deptId;
/**
* 会员钱包 id
*/
@Schema(description = "会员钱包 id")
private Long walletId;
/**
* 关联类型
*/
@Schema(description="关联类型")
/**
* 关联类型
*/
@Schema(description = "关联类型")
private String bizType;
/**
* 关联业务编号
*/
@Schema(description="关联业务编号")
/**
* 关联业务编号
*/
@Schema(description = "关联业务编号")
private String bizId;
/**
* 流水标题
*/
@Schema(description="流水标题")
/**
* 流水标题
*/
@Schema(description = "流水标题")
private String title;
/**
* 交易金额, 单位分
*/
@Schema(description="交易金额, 单位分")
/**
* 交易金额, 单位分
*/
@Schema(description = "交易金额, 单位分")
private Integer price;
/**
* 余额, 单位分
*/
@Schema(description="余额, 单位分")
/**
* 余额, 单位分
*/
@Schema(description = "余额, 单位分")
private Integer balance;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
private String updateBy;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
private LocalDateTime updateTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
private String delFlag;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
private Long tenantId;
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -3,12 +3,26 @@ package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(contextId = "remoteCodeUseService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteCodeUseService {
@NoToken
@GetMapping("/wallet-code-use/get-by-biz-ids")
R<List<WalletCodeUseEntity>> getByBizIds(@RequestParam List<Long> ids);
@NoToken
@GetMapping("/wallet-code-use/get-by-biz-id")
R<WalletCodeUseEntity> getByBizId(@RequestParam Long id);
/**
* 核销二维码
*
@@ -28,4 +42,17 @@ public interface RemoteCodeUseService {
@NoToken
@GetMapping("/wallet-code-use/is-cancel-code")
R<Boolean> isCancelCode(@RequestParam Long id);
/**
* 生成二维码
*
* @param id
* @param userId
* @param walletCodeBiz
* @param count
* @return
*/
@NoToken
@GetMapping("/wallet-code-use/generate-code")
R<Boolean> generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count);
}
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import org.springframework.cloud.openfeign.FeignClient;
@@ -1,28 +0,0 @@
package com.bsd.pjcloud.wallet.api.utils;
import cn.hutool.core.util.ObjectUtil;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import lombok.experimental.UtilityClass;
import java.util.List;
import java.util.Map;
@UtilityClass
public class MchDataUtil {
public <T extends BaseMchInterface> List<T> convertMchList(List<T> list, Map<Long, MchManageVo> map) {
return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId())));
}
public <T extends BaseMchInterface> T convertMch(T v, MchManageVo vo) {
if (ObjectUtil.isEmpty(vo)) return v;
v.setMerchantName(vo.getName());
v.setLogoPic(vo.getLogoPic());
return v;
}
}
@@ -0,0 +1,62 @@
package com.bsd.pjcloud.wallet.api.utils;
import cn.hutool.core.util.ObjectUtil;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface;
import lombok.experimental.UtilityClass;
import java.util.List;
import java.util.Map;
@UtilityClass
public class WalletDataUtil {
public <T extends BaseMchInterface> List<T> convertMchList(List<T> list, Map<Long, MchManageVo> map) {
return CollectionUtils.convertList(list, v -> convertMch(v, map.get(v.getMerchantId())));
}
public <T extends BaseMchInterface> T convertMch(T v, MchManageVo vo) {
if (ObjectUtil.isEmpty(vo)) return v;
v.setMerchantName(vo.getName());
v.setLogoPic(vo.getLogoPic());
return v;
}
public <T extends BaseWalletTypeInterface> List<T> convertWalletTYpeList(List<T> list, Map<Long, WalletTypeEntity> map) {
return CollectionUtils.convertList(list, v -> convertWalletType(v, map.get(v.getWalletTypeId())));
}
public <T extends BaseWalletTypeInterface> T convertWalletType(T v, WalletTypeEntity vo) {
if (ObjectUtil.isEmpty(vo)) return v;
v.setWalletTypeId(vo.getId());
v.setWalletTypeName(vo.getName());
v.setWalletTypeUniqueCode(vo.getUniqueCode());
v.setWalletTypeIcon(vo.getIcon());
return v;
}
public <T extends BaseWalletInterface> List<T> convertWalletList(List<T> list, Map<Long, WalletManageEntity> map) {
return CollectionUtils.convertList(list, v -> convertWallet(v, map.get(v.getWalletId())));
}
public <T extends BaseWalletInterface> T convertWallet(T v, WalletManageEntity vo) {
if (ObjectUtil.isEmpty(vo)) return v;
v.setWalletId(vo.getId());
v.setWalletTypeId(vo.getWalletTypeId());
v.setWalletCardNumber(vo.getCardNumber());
v.setWalletBalance(vo.getBalance());
v.setWalletTotalExpense(vo.getTotalExpense());
v.setWalletTotalRecharge(vo.getTotalRecharge());
v.setWalletFreezePrice(vo.getFreezePrice());
v.setWalletIsFreeze(vo.getIsFreeze());
v.setWalletActiveBindTime(vo.getActiveBindTime());
v.setWalletActiveBindStatus(vo.getActiveBindStatus());
return v;
}
}
@@ -3,10 +3,14 @@ package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class WalletTransactionVo extends WalletTransactionEntity implements BaseUserInterface, BaseDeptInterface {
public class WalletTransactionVo extends WalletTransactionEntity implements BaseUserInterface, BaseDeptInterface, BaseWalletTypeInterface, BaseWalletInterface {
/**
* 用户相关
@@ -28,11 +32,59 @@ public class WalletTransactionVo extends WalletTransactionEntity implements Base
private String deptName;
/**
* 钱包相关
*/
private Long walletId;
private String walletCardNumber;
private Integer walletBalance;
private Integer walletTotalExpense;
private Integer walletTotalRecharge;
private Integer walletFreezePrice;
private Boolean walletIsFreeze;
private LocalDateTime walletActiveBindTime;
private String walletActiveBindStatus;
/**
* 钱包类型相关
*/
private Long walletTypeId;
private String walletTypeName;
private String walletTypeUniqueCode;
private String walletTypeIcon;
/**
* 订单相关
*/
private Long orderHardId;
private Long orderId;
private Long orderDeptId;
private Long orderWalletId;
private Long orderParentCarId;
private Integer orderTotalPrice;
private Integer orderExtraPrice;
private Integer orderPayPrice;
private LocalDateTime orderPayTime;
}
@@ -0,0 +1,47 @@
package com.bsd.pjcloud.wallet.api.vo.base;
import java.time.LocalDateTime;
public interface BaseWalletInterface {
Long getWalletId();
void setWalletId(Long walletId);
Long getWalletTypeId();
void setWalletTypeId(Long walletTypeId);
String getWalletCardNumber();
void setWalletCardNumber(String walletCardNumber);
Integer getWalletBalance();
void setWalletBalance(Integer walletBalance);
Integer getWalletTotalExpense();
void setWalletTotalExpense(Integer walletTotalExpense);
Integer getWalletTotalRecharge();
void setWalletTotalRecharge(Integer walletTotalRecharge);
Integer getWalletFreezePrice();
void setWalletFreezePrice(Integer walletFreezePrice);
Boolean getWalletIsFreeze();
void setWalletIsFreeze(Boolean walletIsFreeze);
LocalDateTime getWalletActiveBindTime();
void setWalletActiveBindTime(LocalDateTime walletActiveBindTime);
String getWalletActiveBindStatus();
void setWalletActiveBindStatus(String walletActiveBindStatus);
}
@@ -0,0 +1,20 @@
package com.bsd.pjcloud.wallet.api.vo.base;
public interface BaseWalletTypeInterface {
Long getWalletTypeId();
void setWalletTypeId(Long walletTypeId);
String getWalletTypeName();
void setWalletTypeName(String walletTypeName);
String getWalletTypeUniqueCode();
void setWalletTypeUniqueCode(String walletTypeUniqueCode);
String getWalletTypeIcon();
void setWalletTypeIcon(String walletTypeIcon);
}
@@ -107,12 +107,6 @@
<groupId>com.bsd</groupId>
<artifactId>pjcloud-flow-task-api</artifactId>
</dependency>
<dependency>
<groupId>com.bsd</groupId>
<artifactId>pjcloud-hardware-api</artifactId>
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
@@ -1,10 +1,13 @@
package com.bsd.pjcloud.wallet.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletCodeUseDto;
import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo;
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -17,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequiredArgsConstructor
@@ -39,6 +44,31 @@ public class WalletCodeUseController {
public R<Boolean> isCancelCode(@RequestParam Long id) {
return R.ok(walletCodeUseService.isCancelCode(id));
}
@Inner
@GetMapping("/generate-code")
public R<Boolean> generateCode(@RequestParam Long id, @RequestParam Long userId, @RequestParam WalletCodeBizEnum walletCodeBiz, @RequestParam Integer count) {
walletCodeUseService.generate(id, userId, walletCodeBiz, count);
return R.ok(true);
}
@Inner
@GetMapping("/get-by-biz-ids")
public R<List<WalletCodeUseEntity>> getByBizIds(@RequestParam List<Long> ids) {
List<WalletCodeUseEntity> list = walletCodeUseService.list(new LambdaQueryWrapper<WalletCodeUseEntity>()
.in(WalletCodeUseEntity::getBizId, ids)
);
return R.ok(list);
}
@Inner
@GetMapping("/get-by-biz-id")
public R<WalletCodeUseEntity> getByBizId(@RequestParam Long id) {
WalletCodeUseEntity detail = walletCodeUseService.getOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
.eq(WalletCodeUseEntity::getBizId, id)
);
return R.ok(detail);
}
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@@ -14,6 +14,7 @@ import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
@@ -26,7 +27,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 钱包管理
@@ -43,6 +43,8 @@ public class WalletManageController {
private final WalletManageService walletManageService;
private final WalletCodeUseService walletCodeUseService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-or-create-wallet")
@@ -82,6 +84,7 @@ public class WalletManageController {
public R<Object> addPrice(@RequestParam("userIds") List<Long> userIds) {
return R.ok(walletManageService.delWalletByUserIds(userIds));
}
/* ************************************* end 远程调用 end ************************************* */
@@ -89,6 +89,7 @@ public class WalletTransactionController {
@GetMapping("/page-xf")
public R pageXf(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.PAYMENT.getCode()));
dto.setIsFindOrder(true);
return R.ok(walletTransactionService.pageJoin(page, dto));
}
@@ -96,6 +97,7 @@ public class WalletTransactionController {
@GetMapping("/page-tk")
public R pageTk(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
dto.setBizTypes(List.of(WalletBizEnum.REFUND.getCode()));
dto.setIsFindOrder(true);
return R.ok(walletTransactionService.pageJoin(page, dto));
}
@@ -12,6 +12,8 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity> {
/**
@@ -69,6 +71,16 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
return selectJoinPage(page, WalletManageVo.class, wrapper);
}
default List<WalletManageEntity> list(WalletManageDto dto) {
LambdaUpdateWrapper<WalletManageEntity> wrapper = new LambdaUpdateWrapper<WalletManageEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getUserId()), WalletManageEntity::getUserId, dto.getUserId())
.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());
return selectList(wrapper);
}
default WalletManageVo join(Long id) {
MPJLambdaWrapper<WalletManageEntity> wrapper = new MPJLambdaWrapper<WalletManageEntity>()
.selectAll(WalletManageEntity.class)
@@ -1,15 +1,15 @@
package com.bsd.pjcloud.wallet.mapper;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
@@ -38,7 +38,23 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
return selectJoinPage(page, WalletTransactionVo.class, wrapper);
}
default Page<WalletTransactionVo> scopePageList(Page page, WalletTransactionDto dto) {
LambdaQueryWrapper<WalletTransactionEntity> wrapper = new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(ObjectUtil.isNotEmpty(dto.getWalletId()), WalletTransactionEntity::getWalletId, dto.getWalletId())
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), WalletTransactionEntity::getBizType, dto.getBizType())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletTransactionEntity::getUserId, dto.getUserIds())
.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
);
Page list = selectPageByScope(page, wrapper, DataScope.of());
list.setRecords(BeanUtils.toBean(list.getRecords(), WalletTransactionVo.class));
return list;
}
}
@@ -1,11 +1,19 @@
package com.bsd.pjcloud.wallet.mapper;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface WalletTypeMapper extends PjcloudBaseMapper<WalletTypeEntity> {
default List<WalletTypeEntity> list(WalletTypeDto dto) {
LambdaUpdateWrapper<WalletTypeEntity> wrapper = new LambdaUpdateWrapper<WalletTypeEntity>()
.in(ObjectUtil.isNotEmpty(dto.getWalletTypeIds()), WalletTypeEntity::getId, dto.getWalletTypeIds());
return selectList(wrapper);
}
}
@@ -27,4 +27,5 @@ public interface WalletCodeUseService extends IService<WalletCodeUseEntity> {
* @return
*/
Boolean isCancelCode(Long id);
}
@@ -20,7 +20,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.MchDataUtil;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.mapper.WalletActiveMapper;
@@ -104,7 +104,7 @@ public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, Wal
List<Long> mchIds = list.getRecords().stream().map(WalletActiveVo::getMerchantId).distinct().toList();
List<MchManageVo> mchList = mchManageService.list(MchManageDto.builder().ids(mchIds).build());
if (ObjectUtil.isNotEmpty(mchList)) {
MchDataUtil.convertMchList(page.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId));
WalletDataUtil.convertMchList(page.getRecords(), CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
return list;
@@ -25,6 +25,7 @@ import com.bsd.pjcloud.hard.api.utils.HardUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -55,6 +56,7 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
private final RemoteFileService remoteFileService;
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public void generate(Long id, Long userId, WalletCodeBizEnum biz, Integer count) {
if (count == 0) return;
@@ -102,6 +104,8 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
}
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Boolean cancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(codeUse)) return false;
@@ -111,6 +115,8 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
}
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Boolean isCancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(codeUse)) return false;
@@ -3,7 +3,6 @@ package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
@@ -15,20 +14,29 @@ import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.exception.CheckedException;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.WalletTransactionVo;
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -54,6 +62,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
private final WalletManageService walletManageService;
private final WalletManageMapper walletManageMapper;
private final WalletTypeMapper walletTypeMapper;
private final RemoteUserService userService;
private final RemoteDeptService deptService;
@@ -65,6 +74,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
@@ -80,6 +90,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
Integer afterBalance = wallet.getBalance() - price;
WalletTransactionEntity insetObj = new WalletTransactionEntity();
insetObj.setUserId(wallet.getUserId());
insetObj.setDeptId(wallet.getDeptId());
insetObj.setWalletId(walletId);
insetObj.setPrice(-price);
insetObj.setBalance(afterBalance);
@@ -91,7 +103,9 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
public WalletTransactionEntity addWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
WalletManageEntity wallet = walletManageService.getById(walletId);
if (ObjectUtil.isEmpty(wallet)) {
@@ -107,6 +121,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
case REFUND: {
walletManageMapper.updateWhenConsumptionRefund(wallet.getId(), price);
break;
}
default: {
log.error("|{}|,钱包id({})使用未实现的增加钱包余额的类型({}).", TAG, walletId, bizType.getDesc());
@@ -114,6 +129,8 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
}
WalletTransactionEntity insetObj = new WalletTransactionEntity();
insetObj.setUserId(wallet.getUserId());
insetObj.setDeptId(wallet.getDeptId());
insetObj.setWalletId(walletId);
insetObj.setPrice(price);
insetObj.setBalance(wallet.getBalance() + price);
@@ -146,7 +163,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
@Override
public Page<WalletTransactionVo> pageJoin(Page page, WalletTransactionDto dto) {
Page<WalletTransactionVo> list = baseMapper.pageJoin(page, dto);
Page<WalletTransactionVo> list = baseMapper.scopePageList(page, dto);
if (ObjectUtil.isNotEmpty(list.getRecords())) {
// 用户
List<Long> userIds = list.getRecords().stream().map(WalletTransactionVo::getUserId).distinct().toList();
@@ -160,6 +177,34 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
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;
}
@@ -21,6 +21,7 @@ import com.bsd.pjcloud.wallet.service.WalletRechargeService;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -81,6 +82,7 @@ public class WalletRechargeServiceImpl extends ServiceImpl<WalletRechargeMapper,
}
@Override
@GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public WalletRechargeVo refund(WalletRechargeRefundDto dto) {
// 查询钱包
@@ -101,7 +103,7 @@ public class WalletRechargeServiceImpl extends ServiceImpl<WalletRechargeMapper,
.build();
baseMapper.insert(recharge);
// 增加金额
walletTransactionService.addWalletBalance(wallet.getId(), recharge.getTotalPrice(), String.valueOf(dto.getAfterSaleId()), WalletBizEnum.REFUND);
walletTransactionService.addWalletBalance(wallet.getId(), dto.getPrice(), String.valueOf(dto.getAfterSaleId()), WalletBizEnum.REFUND);
return BeanUtils.toBean(recharge, WalletRechargeVo.class);
}
}