pay : 会员电子钱包表结构

This commit is contained in:
jason 2023-06-30 10:24:36 +08:00
parent ef656cf762
commit 3a1e5c1b5f
7 changed files with 253 additions and 0 deletions

View File

@ -0,0 +1,44 @@
-- ----------------------------
-- 支付-会员钱包表
-- ----------------------------
DROP TABLE IF EXISTS `pay_member_wallet`;
CREATE TABLE `pay_member_wallet`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` bigint NOT NULL COMMENT '用户 id',
`balance` int NOT NULL DEFAULT 0 COMMENT '余额, 单位分',
`total_spending` int NOT NULL DEFAULT 0 COMMENT '累计支出, 单位分',
`total_top_up` int NOT NULL DEFAULT 0 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 COMMENT='会员钱包表';
-- ----------------------------
-- 支付-会员钱包明细表
-- ----------------------------
DROP TABLE IF EXISTS `pay_member_wallet_transaction`;
CREATE TABLE `pay_member_wallet_transaction`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`wallet_id` bigint NOT NULL COMMENT '会员钱包 id',
`user_id` bigint NOT NULL COMMENT '用户 id',
`trade_no` varchar(64) COMMENT '交易单号',
`category` tinyint NOT NULL COMMENT '交易大类',
`operate_type` tinyint NOT NULL COMMENT '操作分类',
`operate_desc` varchar(64) NOT NULL COMMENT '操作说明',
`amount` int NOT NULL COMMENT '交易金额, 单位分',
`balance` int NOT NULL COMMENT '余额, 单位分',
`mark` varchar(512) COMMENT '备注',
`transaction_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP 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 COMMENT='会员钱包明细表';

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.pay.enums.member;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 钱包操作类型枚举
*
* @author jason
*/
@AllArgsConstructor
@Getter
public enum WalletOperateTypeEnum {
TOP_UP_INC(1, "充值增加"),
ORDER_DEC(2, "订单消费扣除");
// TODO 其它类型
private final Integer type;
private final String desc;
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.pay.enums.member;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 钱包交易大类枚举
*
* @author jason
*/
@AllArgsConstructor
@Getter
public enum WalletTransactionGategoryEnum {
TOP_UP(1, "充值"),
SPENDING(2, "支出");
/**
* 分类
*/
private final Integer category;
/**
* 说明
*/
private final String desc;
}

View File

@ -0,0 +1,46 @@
package cn.iocoder.yudao.module.pay.dal.dataobject.member;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* 支付-会员钱包 DO
*
* @author jason
*/
@TableName(value ="pay_member_wallet")
@KeySequence("pay_member_wallet_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class MemberWalletDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 用户 id
*
* 关联 MemberUserDO id 编号
*/
private Long userId;
/**
* 余额, 单位分
*/
private Integer balance;
/**
* 累计支出, 单位分
*/
private Integer totalSpending;
/**
* 累计充值, 单位分
*/
private Integer totalTopUp;
}

View File

@ -0,0 +1,86 @@
package cn.iocoder.yudao.module.pay.dal.dataobject.member;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.pay.enums.member.WalletOperateTypeEnum;
import cn.iocoder.yudao.module.pay.enums.member.WalletTransactionGategoryEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 支付-会员钱包明细 DO
*
* @author jason
*/
@TableName(value ="pay_member_wallet_transaction")
@KeySequence("pay_member_wallet_transaction_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class MemberWalletTransactionDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 会员钱包 id
*
* 关联 {@link MemberWalletDO#getId()}
*/
private Long walletId;
/**
* 用户 id
*
* 关联 MemberUserDO id 编号
*/
private Long userId;
/**
* 交易单号 @芋艿 这里是关联交易单号, 还是订单号 , 退款单号! ??
*/
private String tradeNo;
/**
* 交易分类
*
* 枚举 {@link WalletTransactionGategoryEnum#getCategory()}
*/
private Integer category;
/**
* 操作分类
*
* 枚举 {@link WalletOperateTypeEnum#getType()}
*/
private Integer operateType;
/**
* 操作详情
*/
private String operateDesc;
/**
* 交易金额, 单位分
*/
private Integer amount;
/**
* 余额, 单位分
*/
private Integer balance;
/**
* 备注
*/
private String mark;
/**
* 交易时间
*/
private LocalDateTime transactionTime;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.pay.dal.mysql.member;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pay.dal.dataobject.member.MemberWalletDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MemberWalletMapper extends BaseMapperX<MemberWalletDO> {
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.pay.dal.mysql.member;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pay.dal.dataobject.member.MemberWalletTransactionDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MemberWalletTransactionMapper extends BaseMapperX<MemberWalletTransactionDO> {
}