diff --git a/sql/mysql/optional/pay_temp.sql b/sql/mysql/optional/pay_temp.sql new file mode 100644 index 000000000..12ba4f68e --- /dev/null +++ b/sql/mysql/optional/pay_temp.sql @@ -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='会员钱包明细表'; \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletOperateTypeEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletOperateTypeEnum.java new file mode 100644 index 000000000..896e90ef9 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletOperateTypeEnum.java @@ -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; +} diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletTransactionGategoryEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletTransactionGategoryEnum.java new file mode 100644 index 000000000..fe950991d --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/member/WalletTransactionGategoryEnum.java @@ -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; +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletDO.java new file mode 100644 index 000000000..043481103 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; +} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletTransactionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletTransactionDO.java new file mode 100644 index 000000000..456ced9f0 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/member/MemberWalletTransactionDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; +} \ No newline at end of file diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletMapper.java new file mode 100644 index 000000000..46e80df8e --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletMapper.java @@ -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 { + +} + + + + diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletTransactionMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletTransactionMapper.java new file mode 100644 index 000000000..a6cb541d1 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/member/MemberWalletTransactionMapper.java @@ -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 { + +} + + + +