feat:钱包数据库

This commit is contained in:
dzc committed 2024-12-27 18:43:20 +08:00
1 parent cfdc06d880
commit d684f1bc97
8 files changed
+424

No files matched your search

File renamed without changes.
+108
View File
@@ -0,0 +1,108 @@
create database `pjcloudx_wallet` default character set utf8mb4 collate utf8mb4_general_ci;
-- ----------------------------
-- Table structure for wallet_manage
-- ----------------------------
DROP TABLE IF EXISTS wallet_manage;
CREATE TABLE wallet_manage
(
id bigint NOT NULL COMMENT '主键',
user_id bigint NOT NULL COMMENT '饭卡绑定的用户id',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型id',
card_number varchar(64) COMMENT '饭卡卡号',
code varchar(1024) COMMENT '钱包二维码',
balance int DEFAULT 0 NOT NULL COMMENT '余额,单位分',
total_expense int DEFAULT 0 NOT NULL COMMENT '累计支出,单位分',
total_recharge int DEFAULT 0 NOT NULL COMMENT '累计充值,单位分',
freeze_price int DEFAULT 0 NOT NULL COMMENT '冻结金额,单位分',
is_freeze tinyint DEFAULT '0' NOT NULL COMMENT '是否冻结饭卡',
active_bind_time timestamp COMMENT '绑定饭卡时间',
active_bind_status tinyint COMMENT '饭卡绑定状态',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT ='商户管理';
CREATE INDEX idx_dept_id ON wallet_manage (user_id);
-- ----------------------------
-- Table structure for wallet_manage
-- ----------------------------
DROP TABLE IF EXISTS wallet_type;
CREATE TABLE wallet_type
(
id bigint NOT NULL COMMENT '主键',
name varchar(64) NOT NULL COMMENT '钱包名',
icon varchar(256) NOT NULL COMMENT '钱包图标',
unique_code varchar(16) COMMENT '饭卡code',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='钱包类型';
-- ----------------------------
-- Table structure for wallet_active
-- ----------------------------
CREATE TABLE wallet_active
(
id bigint NOT NULL COMMENT '主键',
user_id bigint NOT NULL COMMENT '用户编号',
wallet_id bigint NOT NULL COMMENT '钱包编号',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型',
dept_id BIGINT NOT NULL COMMENT '部门id',
merchant_id BIGINT NOT NULL COMMENT '商户id',
card_number varchar(128) NOT NULL COMMENT '用户卡号',
active_hardware_status TINYINT DEFAULT 0 COMMENT '是否在硬件上激活',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='钱包开卡';
CREATE INDEX idx_dept_id ON wallet_active (user_id);
CREATE INDEX idx_dept_id ON wallet_active (wallet_id);
CREATE INDEX idx_dept_id ON wallet_active (wallet_type_id);
-- ----------------------------
-- Table structure for wallet_freeze
-- ----------------------------
CREATE TABLE wallet_freeze
(
id bigint NOT NULL COMMENT '编号',
wallet_id bigint NOT NULL COMMENT '钱包id',
user_id bigint NOT NULL COMMENT '用户id',
flow_id bigint DEFAULT NULL COMMENT '流程id',
username varchar(128) COMMENT '用户名',
status TINYINT NOT NULL COMMENT '审核状态',
remark varchar(1024) COMMENT '备注',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='饭卡冻结记录表';
-- ----------------------------
-- Table structure for wallet_transaction
-- ----------------------------
CREATE TABLE wallet_transaction
(
id bigint NOT NULL COMMENT '编号',
wallet_id bigint NOT NULL COMMENT '会员钱包 id',
biz_type tinyint NOT NULL COMMENT '关联类型',
biz_id varchar(64) NOT NULL COMMENT '关联业务编号',
no varchar(64) NOT NULL COMMENT '流水号',
title varchar(128) NOT NULL COMMENT '流水标题',
price int NOT NULL COMMENT '交易金额, 单位分',
balance int NOT NULL COMMENT '余额, 单位分',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='会员钱包流水表';
CREATE INDEX idx_dept_id ON wallet_transaction (wallet_id);
@@ -0,0 +1,133 @@
package merchant.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
*/
@Data
@TenantTable
@TableName("mch_manage")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商户管理")
public class MchManageEntity extends Model<MchManageEntity> {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键")
private Long id;
/**
* 绑定的部门id
*/
@Schema(description="绑定的部门id")
private Long deptId;
/**
* 商户名
*/
@Schema(description="商户名")
private String name;
/**
* 店铺类型,逗号分隔
*/
@Schema(description="店铺类型,逗号分隔")
private String types;
/**
* 商户logo图片
*/
@Schema(description="商户logo图片")
private String logoPic;
/**
* 商户收款码,自动生成
*/
@Schema(description="商户收款码,自动生成")
private String collectionCode;
/**
* 商户轮播图,逗号分隔
*/
@Schema(description="商户轮播图,逗号分隔")
private String swiperPic;
/**
* 商户手机号
*/
@Schema(description="商户手机号")
private String phone;
/**
* 商户开始营业时间
*/
@Schema(description="商户开始营业时间")
private LocalDateTime jobStartTime;
/**
* 商户结束营业时间
*/
@Schema(description="商户结束营业时间")
private LocalDateTime jobEndTime;
/**
* 商户地址
*/
@Schema(description="商户地址")
private String addressDes;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@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 LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
private Long tenantId;
}
@@ -0,0 +1,124 @@
package merchant.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import merchant.entity.MchManageEntity;
import merchant.service.MchManageService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/mchManage")
@Tag(description = "mchManage", name = "商户管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MchManageController {
private final MchManageService mchManageService;
/**
* 分页查询
*
* @param page 分页对象
* @param mchManage 商户管理
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
public R getMchManagePage(@ParameterObject Page page, @ParameterObject MchManageEntity mchManage) {
LambdaQueryWrapper<MchManageEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(mchManageService.page(page, wrapper));
}
/**
* 通过id查询商户管理
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('mch_mchManage_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(mchManageService.getById(id));
}
/**
* 新增商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "新增商户管理", description = "新增商户管理")
@SysLog("新增商户管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_add')")
public R save(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.save(mchManage));
}
/**
* 修改商户管理
*
* @param mchManage 商户管理
* @return R
*/
@Operation(summary = "修改商户管理", description = "修改商户管理")
@SysLog("修改商户管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_edit')")
public R updateById(@RequestBody MchManageEntity mchManage) {
return R.ok(mchManageService.updateById(mchManage));
}
/**
* 通过id删除商户管理
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
@SysLog("通过id删除商户管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('mch_mchManage_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(mchManageService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param mchManage 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('mch_mchManage_export')")
public List<MchManageEntity> export(MchManageEntity mchManage, Long[] ids) {
return mchManageService.list(Wrappers.lambdaQuery(mchManage).in(ArrayUtil.isNotEmpty(ids), MchManageEntity::getId, ids));
}
}
@@ -0,0 +1,10 @@
package merchant.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import merchant.entity.MchManageEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
}
@@ -0,0 +1,8 @@
package merchant.service;
import com.baomidou.mybatisplus.extension.service.IService;
import merchant.entity.MchManageEntity;
public interface MchManageService extends IService<MchManageEntity> {
}
@@ -0,0 +1,16 @@
package merchant.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import merchant.entity.MchManageEntity;
import merchant.mapper.MchManageMapper;
import merchant.service.MchManageService;
import org.springframework.stereotype.Service;
/**
* 商户管理
*
* @author pjcloud
* @date 2024-12-27 17:25:08
*/
@Service
public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManageEntity> implements MchManageService {
}
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="merchant.mapper.MchManageMapper">
<resultMap id="mchManageMap" type="merchant.entity.MchManageEntity">
<id property="id" column="id"/>
<result property="deptId" column="dept_id"/>
<result property="name" column="name"/>
<result property="types" column="types"/>
<result property="logoPic" column="logo_pic"/>
<result property="collectionCode" column="collection_code"/>
<result property="swiperPic" column="swiper_pic"/>
<result property="phone" column="phone"/>
<result property="jobStartTime" column="job_start_time"/>
<result property="jobEndTime" column="job_end_time"/>
<result property="addressDes" column="address_des"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>