feat:钱包转账记录
This commit is contained in:
1 parent
96e12a1549
commit
d0c9628bea
29 files changed
+860
-26
No files matched your search
@@ -214,16 +214,17 @@ CREATE TABLE `member_open_type_user`
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for trade_gift
|
||||
-- Table structure for product_gift
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `trade_gift`;
|
||||
CREATE TABLE `trade_gift`
|
||||
DROP TABLE IF EXISTS `product_gift`;
|
||||
CREATE TABLE `product_gift`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '礼物商品id',
|
||||
`title` bigint NOT NULL COMMENT '礼物标题',
|
||||
`title` varchar(256) NOT NULL COMMENT '礼物标题',
|
||||
`price` int NOT NULL COMMENT '礼物价格(分)',
|
||||
`image` varchar(256) NOT NULL COMMENT '礼物图片',
|
||||
`status` char(32) NOT NULL COMMENT '礼物状态',
|
||||
`sort` int DEFAULT 0 NOT NULL COMMENT '礼物排序',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
@@ -231,4 +232,30 @@ CREATE TABLE `trade_gift`
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '礼物商品';
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '礼物商品';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pay_wallet_user_transition
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pay_wallet_user_transition`;
|
||||
CREATE TABLE `pay_wallet_user_transition`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '礼物商品id',
|
||||
`biz_type` varchar(32) NOT NULL COMMENT '转账类型',
|
||||
`biz_id` bigint DEFAULT NULL COMMENT '转账id',
|
||||
`send_user_id` bigint NOT NULL COMMENT '赠送人id',
|
||||
`send_before_balance` int NOT NULL COMMENT '赠送人转账钱的余额(分)',
|
||||
`send_after_balance` int NOT NULL COMMENT '赠送人转账后的余额(分)',
|
||||
`target_user_id` bigint NOT NULL COMMENT '被赠送人id',
|
||||
`target_before_balance` int NOT NULL COMMENT '被赠送人转账钱的余额(分)',
|
||||
`target_after_balance` int NOT NULL COMMENT '被赠送人转账后的余额(分)',
|
||||
`price` int NOT NULL COMMENT '交易金额(分)',
|
||||
`title` varchar(256) DEFAULT NULL COMMENT '金额赠送标题',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '钱包(用户之间的相互转账、赠送)';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.product.api.gift;
|
||||
|
||||
import cn.iocoder.yudao.module.product.api.gift.dto.ProductGiftRespDTO;
|
||||
|
||||
/**
|
||||
* 礼物商品 API
|
||||
*/
|
||||
public interface ProductGiftApi {
|
||||
|
||||
/**
|
||||
* 查询礼物商品
|
||||
*/
|
||||
ProductGiftRespDTO getGift(Long id);
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.product.api.gift.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ProductGiftRespDTO {
|
||||
|
||||
/**
|
||||
* 礼物标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 礼物价格(分)
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 礼物图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 礼物状态"
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 礼物状态
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+2
-1
@@ -54,6 +54,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在");
|
||||
|
||||
// ========== 礼物 商品 1-008-009-000 ==========
|
||||
ErrorCode GIFT_NOT_EXISTS = new ErrorCode(1_008_009_001, "礼物不存在");
|
||||
ErrorCode GIFT_NOT_EXISTS = new ErrorCode(1_008_009_000, "礼物不存在");
|
||||
ErrorCode GIFT_TARGET_USER_NOT_EXISTS = new ErrorCode(1_008_009_001, "送礼目标人,不存在");
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.product.enums.gift;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 礼物商品状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProductGiftStatusEnum {
|
||||
|
||||
DISABLE("1", "下架"),
|
||||
ENABLE("2", "上架");
|
||||
|
||||
private final String status;
|
||||
private final String name;
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.product.api.gift;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.api.gift.dto.ProductGiftRespDTO;
|
||||
import cn.iocoder.yudao.module.product.service.gift.GiftService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 礼物商品 API
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductGiftApiImpl implements ProductGiftApi {
|
||||
|
||||
@Resource
|
||||
private GiftService giftService;
|
||||
|
||||
/**
|
||||
* 查询礼物商品
|
||||
*/
|
||||
@Override
|
||||
public ProductGiftRespDTO getGift(Long id) {
|
||||
return BeanUtils.toBean(giftService.getGift(id), ProductGiftRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -1,10 +1,13 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.gift.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@@ -16,7 +19,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class GiftPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "礼物标题")
|
||||
private Long title;
|
||||
private String title;
|
||||
|
||||
@Schema(description = "礼物价格(分)", example = "31512")
|
||||
private Integer price;
|
||||
@@ -27,6 +30,9 @@ public class GiftPageReqVO extends PageParam {
|
||||
@Schema(description = "礼物状态", example = "2")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "礼物状态", example = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
+10
-2
@@ -2,11 +2,17 @@ package cn.iocoder.yudao.module.product.controller.admin.gift.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Schema(description = "管理后台 - 礼物商品 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@@ -17,8 +23,7 @@ public class GiftRespVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "礼物标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("礼物标题")
|
||||
private Long title;
|
||||
private String title;
|
||||
|
||||
@Schema(description = "礼物价格(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "31512")
|
||||
@ExcelProperty("礼物价格(分)")
|
||||
@@ -32,6 +37,9 @@ public class GiftRespVO {
|
||||
@ExcelProperty("礼物状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "礼物状态", example = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
+6
-2
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.controller.admin.gift.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@@ -13,8 +14,8 @@ public class GiftSaveReqVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "礼物标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "礼物标题不能为空")
|
||||
private Long title;
|
||||
@NotEmpty(message = "礼物标题不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "礼物价格(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "31512")
|
||||
@NotNull(message = "礼物价格(分)不能为空")
|
||||
@@ -28,4 +29,7 @@ public class GiftSaveReqVO {
|
||||
@NotEmpty(message = "礼物状态不能为空")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "礼物状态", example = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.product.controller.app.gift;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.gift.GiftDO;
|
||||
import cn.iocoder.yudao.module.product.service.gift.GiftService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 APP - 礼物商品")
|
||||
@RestController
|
||||
@RequestMapping("/trade/gift")
|
||||
@Validated
|
||||
public class AppGiftController {
|
||||
|
||||
@Resource
|
||||
private GiftService giftService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得礼物商品列表")
|
||||
public CommonResult<List<GiftRespVO>> getGiftPage(@Valid GiftPageReqVO pageReqVO) {
|
||||
List<GiftDO> pageResult = giftService.getGiftList(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, GiftRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得礼物商品详情")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<GiftRespVO> getGift(@RequestParam("id") Long id) {
|
||||
GiftDO gift = giftService.getGift(id);
|
||||
return success(BeanUtils.toBean(gift, GiftRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+14
-3
@@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.product.dal.dataobject.gift;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
@@ -12,8 +14,8 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@TableName("trade_gift")
|
||||
@KeySequence("trade_gift_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@TableName("product_gift")
|
||||
@KeySequence("product_gift_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@@ -27,21 +29,30 @@ public class GiftDO extends BaseDO {
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 礼物标题
|
||||
*/
|
||||
private Long title;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 礼物价格(分)
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 礼物图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 礼物状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+14
-1
@@ -17,12 +17,25 @@ public interface GiftMapper extends BaseMapperX<GiftDO> {
|
||||
|
||||
default PageResult<GiftDO> selectPage(GiftPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<GiftDO>()
|
||||
.eqIfPresent(GiftDO::getTitle, reqVO.getTitle())
|
||||
.likeIfPresent(GiftDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(GiftDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(GiftDO::getImage, reqVO.getImage())
|
||||
.eqIfPresent(GiftDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(GiftDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(GiftDO::getSort)
|
||||
.orderByDesc(GiftDO::getId));
|
||||
}
|
||||
|
||||
default List<GiftDO> selectList(GiftPageReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<GiftDO>()
|
||||
.likeIfPresent(GiftDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(GiftDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(GiftDO::getImage, reqVO.getImage())
|
||||
.eqIfPresent(GiftDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(GiftDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(GiftDO::getSort)
|
||||
.orderByDesc(GiftDO::getId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+5
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.gift;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftSaveReqVO;
|
||||
@@ -37,4 +38,8 @@ public interface GiftService {
|
||||
*/
|
||||
PageResult<GiftDO> getGiftPage(GiftPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得礼物商品列表
|
||||
*/
|
||||
List<GiftDO> getGiftList(@Valid GiftPageReqVO pageReqVO);
|
||||
}
|
||||
+13
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.service.gift;
|
||||
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.gift.vo.GiftSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.gift.GiftDO;
|
||||
@@ -18,6 +19,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.GIFT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.GIFT_TARGET_USER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 礼物商品 Service 实现类
|
||||
@@ -31,6 +33,9 @@ public class GiftServiceImpl implements GiftService {
|
||||
@Resource
|
||||
private GiftMapper giftMapper;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
|
||||
/**
|
||||
* 创建礼物商品
|
||||
*/
|
||||
@@ -82,6 +87,14 @@ public class GiftServiceImpl implements GiftService {
|
||||
return giftMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得礼物商品列表
|
||||
*/
|
||||
@Override
|
||||
public List<GiftDO> getGiftList(GiftPageReqVO pageReqVO) {
|
||||
return giftMapper.selectList(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateGiftExists(Long id) {
|
||||
if (giftMapper.selectById(id) == null) {
|
||||
throw exception(GIFT_NOT_EXISTS);
|
||||
|
||||
+8
-3
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* Pay 错误码 Core 枚举类
|
||||
*
|
||||
* <p>
|
||||
* pay 系统,使用 1-007-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
@@ -12,8 +12,8 @@ public interface ErrorCodeConstants {
|
||||
// ========== APP 模块 1-007-000-000 ==========
|
||||
ErrorCode APP_NOT_FOUND = new ErrorCode(1_007_000_000, "App 不存在");
|
||||
ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用");
|
||||
ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除");
|
||||
ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除");
|
||||
ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除");
|
||||
ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除");
|
||||
ErrorCode APP_KEY_EXISTS = new ErrorCode(1_007_000_005, "支付应用标识已经存在");
|
||||
|
||||
// ========== CHANNEL 模块 1-007-001-000 ==========
|
||||
@@ -47,6 +47,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1_007_007_002, "未找到对应的钱包交易");
|
||||
ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款");
|
||||
ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足");
|
||||
ErrorCode WALLET_TARGET_NOT_FOUND = new ErrorCode(1_007_007_000, "目标用户钱包不存在");
|
||||
|
||||
// ========== 钱包充值模块 1-007-008-000 ==========
|
||||
ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在");
|
||||
@@ -63,6 +64,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在");
|
||||
ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用");
|
||||
ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在");
|
||||
ErrorCode WALLET_RECHARGE_GIFT_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_008_014, "钱包发起送礼失败,钱包余额不足");
|
||||
|
||||
// ========== 转账模块 1-007-009-000 ==========
|
||||
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");
|
||||
@@ -73,6 +75,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账");
|
||||
ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中");
|
||||
|
||||
// ========== 钱包用户转账模块 1-007-010-000 ==========
|
||||
ErrorCode WALLET_USER_TRANSFER_NOT_FOUND = new ErrorCode(1_007_010_000, "用户转账单不存在");
|
||||
|
||||
// ========== 示例订单 1-007-900-000 ==========
|
||||
ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在");
|
||||
ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_900_001, "示例订单更新支付状态失败,订单不是【未支付】状态");
|
||||
|
||||
+3
-2
@@ -20,7 +20,8 @@ public enum PayWalletBizTypeEnum implements ArrayValuable<Integer> {
|
||||
PAYMENT(3, "支付"),
|
||||
PAYMENT_REFUND(4, "支付退款"),
|
||||
UPDATE_BALANCE(5, "更新余额"),
|
||||
BROKERAGE_WITHDRAW(6, "分佣提现");
|
||||
BROKERAGE_WITHDRAW(6, "分佣提现"),
|
||||
GIFT(7, "送礼物");
|
||||
|
||||
/**
|
||||
* 业务分类
|
||||
@@ -35,7 +36,7 @@ public enum PayWalletBizTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static PayWalletBizTypeEnum valueOf(Integer type) {
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-product-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionRespVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.WalletUserTransitionDO;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.WalletUserTransitionService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 钱包(用户之间的相互转账、赠送)")
|
||||
@RestController
|
||||
@RequestMapping("/pay/wallet-user-transition")
|
||||
@Validated
|
||||
public class PayWalletUserTransactionController {
|
||||
|
||||
@Resource
|
||||
private WalletUserTransitionService walletUserTransitionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建钱包(用户之间的相互转账、赠送)")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:create')")
|
||||
public CommonResult<Long> createWalletUserTransition(@Valid @RequestBody WalletUserTransitionSaveReqVO createReqVO) {
|
||||
return success(walletUserTransitionService.createWalletUserTransition(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新钱包(用户之间的相互转账、赠送)")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:update')")
|
||||
public CommonResult<Boolean> updateWalletUserTransition(@Valid @RequestBody WalletUserTransitionSaveReqVO updateReqVO) {
|
||||
walletUserTransitionService.updateWalletUserTransition(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除钱包(用户之间的相互转账、赠送)")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:delete')")
|
||||
public CommonResult<Boolean> deleteWalletUserTransition(@RequestParam("id") Long id) {
|
||||
walletUserTransitionService.deleteWalletUserTransition(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得钱包(用户之间的相互转账、赠送)")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:query')")
|
||||
public CommonResult<WalletUserTransitionRespVO> getWalletUserTransition(@RequestParam("id") Long id) {
|
||||
WalletUserTransitionDO walletUserTransition = walletUserTransitionService.getWalletUserTransition(id);
|
||||
return success(BeanUtils.toBean(walletUserTransition, WalletUserTransitionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得钱包(用户之间的相互转账、赠送)分页")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:query')")
|
||||
public CommonResult<PageResult<WalletUserTransitionRespVO>> getWalletUserTransitionPage(@Valid WalletUserTransitionPageReqVO pageReqVO) {
|
||||
PageResult<WalletUserTransitionDO> pageResult = walletUserTransitionService.getWalletUserTransitionPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, WalletUserTransitionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出钱包(用户之间的相互转账、赠送) Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pay:wallet-user-transition:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportWalletUserTransitionExcel(@Valid WalletUserTransitionPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<WalletUserTransitionDO> list = walletUserTransitionService.getWalletUserTransitionPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "钱包(用户之间的相互转账、赠送).xls", "数据", WalletUserTransitionRespVO.class, BeanUtils.toBean(list, WalletUserTransitionRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 钱包(用户之间的相互转账、赠送)分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class WalletUserTransitionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "转账类型", example = "1")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "转账id", example = "1541")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "赠送人id", example = "29738")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(description = "赠送人转账钱的余额(分)")
|
||||
private Integer sendBeforeBalance;
|
||||
|
||||
@Schema(description = "赠送人转账后的余额(分)")
|
||||
private Integer sendAfterBalance;
|
||||
|
||||
@Schema(description = "被赠送人id", example = "26766")
|
||||
private Long targetUserId;
|
||||
|
||||
@Schema(description = "被赠送人转账钱的余额(分)")
|
||||
private Integer targetBeforeBalance;
|
||||
|
||||
@Schema(description = "被赠送人转账后的余额(分)")
|
||||
private Integer targetAfterBalance;
|
||||
|
||||
@Schema(description = "交易金额(分)", example = "28209")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "金额赠送标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 钱包(用户之间的相互转账、赠送) Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class WalletUserTransitionRespVO {
|
||||
|
||||
@Schema(description = "礼物商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20417")
|
||||
@ExcelProperty("礼物商品id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("转账类型")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "转账id", example = "1541")
|
||||
@ExcelProperty("转账id")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "赠送人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29738")
|
||||
@ExcelProperty("赠送人id")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(description = "赠送人转账钱的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("赠送人转账钱的余额(分)")
|
||||
private Integer sendBeforeBalance;
|
||||
|
||||
@Schema(description = "赠送人转账后的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("赠送人转账后的余额(分)")
|
||||
private Integer sendAfterBalance;
|
||||
|
||||
@Schema(description = "被赠送人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26766")
|
||||
@ExcelProperty("被赠送人id")
|
||||
private Long targetUserId;
|
||||
|
||||
@Schema(description = "被赠送人转账钱的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("被赠送人转账钱的余额(分)")
|
||||
private Integer targetBeforeBalance;
|
||||
|
||||
@Schema(description = "被赠送人转账后的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("被赠送人转账后的余额(分)")
|
||||
private Integer targetAfterBalance;
|
||||
|
||||
@Schema(description = "交易金额(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "28209")
|
||||
@ExcelProperty("交易金额(分)")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "金额赠送标题")
|
||||
@ExcelProperty("金额赠送标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 钱包(用户之间的相互转账、赠送)新增/修改 Request VO")
|
||||
@Data
|
||||
public class WalletUserTransitionSaveReqVO {
|
||||
|
||||
@Schema(description = "礼物商品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20417")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "转账类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "转账类型不能为空")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "转账id", example = "1541")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "赠送人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29738")
|
||||
@NotNull(message = "赠送人id不能为空")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(description = "赠送人转账钱的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "赠送人转账钱的余额(分)不能为空")
|
||||
private Integer sendBeforeBalance;
|
||||
|
||||
@Schema(description = "赠送人转账后的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "赠送人转账后的余额(分)不能为空")
|
||||
private Integer sendAfterBalance;
|
||||
|
||||
@Schema(description = "被赠送人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26766")
|
||||
@NotNull(message = "被赠送人id不能为空")
|
||||
private Long targetUserId;
|
||||
|
||||
@Schema(description = "被赠送人转账钱的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "被赠送人转账钱的余额(分)不能为空")
|
||||
private Integer targetBeforeBalance;
|
||||
|
||||
@Schema(description = "被赠送人转账后的余额(分)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "被赠送人转账后的余额(分)不能为空")
|
||||
private Integer targetAfterBalance;
|
||||
|
||||
@Schema(description = "交易金额(分)", requiredMode = Schema.RequiredMode.REQUIRED, example = "28209")
|
||||
@NotNull(message = "交易金额(分)不能为空")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "金额赠送标题")
|
||||
private String title;
|
||||
|
||||
}
|
||||
+11
-1
@@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletGiftSendReqVo;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeRespVO;
|
||||
@@ -49,12 +51,20 @@ public class AppPayWalletRechargeController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建钱包充值记录(发起充值)")
|
||||
public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge(
|
||||
@Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) {
|
||||
@Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) {
|
||||
PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge(
|
||||
getLoginUserId(), getLoginUserType(), getClientIP(), reqVO);
|
||||
return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge));
|
||||
}
|
||||
|
||||
@PostMapping("/send-gift")
|
||||
@Operation(summary = "钱包送出礼物")
|
||||
public CommonResult<Boolean> sendGift(@Valid @RequestBody AppPayWalletGiftSendReqVo dto) {
|
||||
dto.setOperationMemberId(getLoginUserId());
|
||||
dto.setOperationUserType(getLoginUserType());
|
||||
return success(walletRechargeService.sendGift(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得钱包充值记录分页")
|
||||
public CommonResult<PageResult<AppPayWalletRechargeRespVO>> getWalletRechargePage(@Valid PageParam pageReqVO) {
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "用户 APP - 送出礼物")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class AppPayWalletGiftSendReqVo {
|
||||
|
||||
@Schema(description = "操作人用户id")
|
||||
private Long operationMemberId;
|
||||
|
||||
@Schema(description = "用户类型")
|
||||
private Integer operationUserType;
|
||||
|
||||
@Schema(description = "目标用户id")
|
||||
@NotNull(message = "目标用户id不能为空")
|
||||
private Long targetMemberId;
|
||||
|
||||
@Schema(description = "礼物id")
|
||||
@NotNull(message = "礼物id不能为空")
|
||||
private Long giftId;
|
||||
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.wallet;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 钱包(用户之间的相互转账、赠送) DO
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@TableName("pay_wallet_user_transition")
|
||||
@KeySequence("pay_wallet_user_transition_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WalletUserTransitionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 礼物商品id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 转账类型
|
||||
*/
|
||||
private String bizType;
|
||||
/**
|
||||
* 转账id
|
||||
*/
|
||||
private Long bizId;
|
||||
/**
|
||||
* 赠送人id
|
||||
*/
|
||||
private Long sendUserId;
|
||||
/**
|
||||
* 赠送人转账钱的余额(分)
|
||||
*/
|
||||
private Integer sendBeforeBalance;
|
||||
/**
|
||||
* 赠送人转账后的余额(分)
|
||||
*/
|
||||
private Integer sendAfterBalance;
|
||||
/**
|
||||
* 被赠送人id
|
||||
*/
|
||||
private Long targetUserId;
|
||||
/**
|
||||
* 被赠送人转账钱的余额(分)
|
||||
*/
|
||||
private Integer targetBeforeBalance;
|
||||
/**
|
||||
* 被赠送人转账后的余额(分)
|
||||
*/
|
||||
private Integer targetAfterBalance;
|
||||
/**
|
||||
* 交易金额(分)
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 金额赠送标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.WalletUserTransitionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 钱包(用户之间的相互转账、赠送)Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface WalletUserTransitionMapper extends BaseMapperX<WalletUserTransitionDO> {
|
||||
|
||||
default PageResult<WalletUserTransitionDO> selectPage(WalletUserTransitionPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<WalletUserTransitionDO>()
|
||||
.eqIfPresent(WalletUserTransitionDO::getBizType, reqVO.getBizType())
|
||||
.eqIfPresent(WalletUserTransitionDO::getBizId, reqVO.getBizId())
|
||||
.eqIfPresent(WalletUserTransitionDO::getSendUserId, reqVO.getSendUserId())
|
||||
.eqIfPresent(WalletUserTransitionDO::getSendBeforeBalance, reqVO.getSendBeforeBalance())
|
||||
.eqIfPresent(WalletUserTransitionDO::getSendAfterBalance, reqVO.getSendAfterBalance())
|
||||
.eqIfPresent(WalletUserTransitionDO::getTargetUserId, reqVO.getTargetUserId())
|
||||
.eqIfPresent(WalletUserTransitionDO::getTargetBeforeBalance, reqVO.getTargetBeforeBalance())
|
||||
.eqIfPresent(WalletUserTransitionDO::getTargetAfterBalance, reqVO.getTargetAfterBalance())
|
||||
.eqIfPresent(WalletUserTransitionDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(WalletUserTransitionDO::getTitle, reqVO.getTitle())
|
||||
.betweenIfPresent(WalletUserTransitionDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(WalletUserTransitionDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+11
-4
@@ -2,10 +2,13 @@ package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletGiftSendReqVo;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 钱包充值 Service 接口
|
||||
*
|
||||
@@ -19,17 +22,22 @@ public interface PayWalletRechargeService {
|
||||
* @param userId 用户 id
|
||||
* @param userType 用户类型
|
||||
* @param createReqVO 钱包充值请求 VO
|
||||
* @param userIp 用户Ip
|
||||
* @param userIp 用户Ip
|
||||
* @return 钱包充值记录
|
||||
*/
|
||||
PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
|
||||
AppPayWalletRechargeCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 钱包送出礼物
|
||||
*/
|
||||
Boolean sendGift(@Valid AppPayWalletGiftSendReqVo dto);
|
||||
|
||||
/**
|
||||
* 获得钱包充值记录分页
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
* @param userId 用户编号
|
||||
* @param userType 用户类型
|
||||
* @param pageReqVO 分页请求
|
||||
* @param payStatus 是否支付
|
||||
* @return 钱包充值记录分页
|
||||
@@ -60,5 +68,4 @@ public interface PayWalletRechargeService {
|
||||
* @param payRefundId 退款单id
|
||||
*/
|
||||
void updateWalletRechargeRefunded(Long id, Long payRefundId);
|
||||
|
||||
}
|
||||
+37
-1
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletGiftSendReqVo;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
|
||||
@@ -22,6 +23,8 @@ import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties;
|
||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
||||
import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
|
||||
import cn.iocoder.yudao.module.product.api.gift.ProductGiftApi;
|
||||
import cn.iocoder.yudao.module.product.api.gift.dto.ProductGiftRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -43,6 +46,7 @@ import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConver
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WXA_WALLET_RECHARGER_PAID;
|
||||
import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.GIFT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 钱包充值 Service 实现类
|
||||
@@ -68,6 +72,8 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
|
||||
@Resource
|
||||
public SocialClientApi socialClientApi;
|
||||
@Resource
|
||||
private ProductGiftApi productGiftApi;
|
||||
|
||||
@Resource
|
||||
private PayProperties payProperties;
|
||||
@@ -104,6 +110,36 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
return recharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包送出礼物
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean sendGift(AppPayWalletGiftSendReqVo dto) {
|
||||
// 查询目标用户钱包
|
||||
PayWalletDO targetWallet = payWalletService.getOrCreateWallet(dto.getTargetMemberId(), dto.getOperationUserType());
|
||||
if (ObjectUtil.isEmpty(targetWallet)) throw exception(WALLET_TARGET_NOT_FOUND);
|
||||
// 查询当前用户钱包
|
||||
PayWalletDO wallet = payWalletService.getOrCreateWallet(dto.getOperationMemberId(), dto.getOperationUserType());
|
||||
if (ObjectUtil.isEmpty(wallet)) throw exception(WALLET_NOT_FOUND);
|
||||
// 查询礼物
|
||||
ProductGiftRespDTO gift = productGiftApi.getGift(dto.getGiftId());
|
||||
if (ObjectUtil.isEmpty(gift)) throw exception(GIFT_NOT_EXISTS);
|
||||
|
||||
// 判断当前用于余额是否够
|
||||
if (wallet.getBalance() < gift.getPrice()) throw exception(WALLET_RECHARGE_GIFT_BALANCE_NOT_ENOUGH);
|
||||
|
||||
// 添加转账记录
|
||||
|
||||
// 扣除用户余额
|
||||
payWalletService.reduceWalletBalance(wallet.getId(), 1L, PayWalletBizTypeEnum.GIFT, gift.getPrice());
|
||||
|
||||
// 添加目标用户余额
|
||||
payWalletService.addWalletBalance(targetWallet.getId(), String.valueOf(1L), PayWalletBizTypeEnum.GIFT, gift.getPrice());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayWalletRechargeDO> getWalletRechargePackagePage(Long userId, Integer userType,
|
||||
PageParam pageReqVO, Boolean payStatus) {
|
||||
@@ -282,7 +318,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
/**
|
||||
* 校验支付订单的合法性
|
||||
*
|
||||
* @param recharge 充值订单
|
||||
* @param recharge 充值订单
|
||||
* @param payOrderId 支付订单编号
|
||||
* @return 支付订单
|
||||
*/
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.WalletUserTransitionDO;
|
||||
|
||||
/**
|
||||
* 钱包(用户之间的相互转账、赠送) Service 接口
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
public interface WalletUserTransitionService {
|
||||
|
||||
/**
|
||||
* 创建钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
Long createWalletUserTransition(@Valid WalletUserTransitionSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
void updateWalletUserTransition(@Valid WalletUserTransitionSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
void deleteWalletUserTransition(Long id);
|
||||
|
||||
/**
|
||||
* 获得钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
WalletUserTransitionDO getWalletUserTransition(Long id);
|
||||
|
||||
/**
|
||||
* 获得钱包(用户之间的相互转账、赠送)分页
|
||||
*/
|
||||
PageResult<WalletUserTransitionDO> getWalletUserTransitionPage(WalletUserTransitionPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionPageReqVO;
|
||||
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.usertransaction.WalletUserTransitionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.WalletUserTransitionDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.mysql.wallet.WalletUserTransitionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_USER_TRANSFER_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* 钱包(用户之间的相互转账、赠送) Service 实现类
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class WalletUserTransitionServiceImpl implements WalletUserTransitionService {
|
||||
|
||||
@Resource
|
||||
private WalletUserTransitionMapper walletUserTransitionMapper;
|
||||
|
||||
/**
|
||||
* 创建钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
@Override
|
||||
public Long createWalletUserTransition(WalletUserTransitionSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
WalletUserTransitionDO walletUserTransition = BeanUtils.toBean(createReqVO, WalletUserTransitionDO.class);
|
||||
walletUserTransitionMapper.insert(walletUserTransition);
|
||||
// 返回
|
||||
return walletUserTransition.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
@Override
|
||||
public void updateWalletUserTransition(WalletUserTransitionSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateWalletUserTransitionExists(updateReqVO.getId());
|
||||
// 更新
|
||||
WalletUserTransitionDO updateObj = BeanUtils.toBean(updateReqVO, WalletUserTransitionDO.class);
|
||||
walletUserTransitionMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
@Override
|
||||
public void deleteWalletUserTransition(Long id) {
|
||||
// 校验存在
|
||||
validateWalletUserTransitionExists(id);
|
||||
// 删除
|
||||
walletUserTransitionMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得钱包(用户之间的相互转账、赠送)
|
||||
*/
|
||||
@Override
|
||||
public WalletUserTransitionDO getWalletUserTransition(Long id) {
|
||||
return walletUserTransitionMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得钱包(用户之间的相互转账、赠送)分页
|
||||
*/
|
||||
@Override
|
||||
public PageResult<WalletUserTransitionDO> getWalletUserTransitionPage(WalletUserTransitionPageReqVO pageReqVO) {
|
||||
return walletUserTransitionMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateWalletUserTransitionExists(Long id) {
|
||||
if (walletUserTransitionMapper.selectById(id) == null) {
|
||||
throw exception(WALLET_USER_TRANSFER_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user