创建交易订单-单元测试

This commit is contained in:
ex_yang.li@ca-nio.com
2022-09-15 16:57:04 +08:00
parent 7bf20ec72e
commit 5889093a64
26 changed files with 566 additions and 41 deletions

View File

@@ -0,0 +1,53 @@
spring:
main:
lazy-initialization: true # 开启懒加载,加快速度
banner-mode: off # 单元测试,禁用 Banner
--- #################### 数据库相关配置 ####################
spring:
# 数据源配置项
datasource:
name: ruoyi-vue-pro
url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式DATABASE_TO_UPPER 配置表和字段使用小写
driver-class-name: org.h2.Driver
username: sa
password:
druid:
async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度
initial-size: 1 # 单元测试,配置为 1提升启动速度
sql:
init:
schema-locations: classpath:/sql/create_tables.sql
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
port: 16379 # 端口(单元测试,使用 16379 端口)
database: 0 # 数据库索引
mybatis:
lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试
--- #################### 定时任务相关配置 ####################
--- #################### 配置中心相关配置 ####################
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项(单元测试,禁用 Lock4j
# Resilience4j 配置项
--- #################### 监控相关配置 ####################
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
info:
base-package: cn.iocoder.yudao.module
trade:
order:
app-id: 1
merchant-order-id: 1

View File

@@ -0,0 +1,4 @@
<configuration>
<!-- 引用 Spring Boot 的 logback 基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
</configuration>

View File

@@ -0,0 +1,2 @@
DELETE FROM trade_order;
DELETE FROM trade_order_item;

View File

@@ -0,0 +1,78 @@
/**todo cancelType 设置默认值 0?*/
CREATE TABLE IF NOT EXISTS `trade_order`
(
`id` number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
`sn` varchar(32) NOT NULL,
`type` int NOT NULL,
`terminal` int NOT NULL,
`user_id` bigint unsigned NOT NULL,
`user_ip` varchar(30) NOT NULL,
`user_remark` varchar(200),
`status` int NOT NULL,
`product_count` int NOT NULL,
`cancel_type` int DEFAULT NULL,
`remark` varchar(200),
`payed` bit(1) NOT NULL DEFAULT FALSE,
`pay_time` datetime DEFAULT NULL,
`finish_time` datetime DEFAULT NULL,
`cancel_time` datetime DEFAULT NULL,
`sku_original_price` int NOT NULL DEFAULT '0',
`sku_promotion_price` int NOT NULL DEFAULT '0',
`order_promotion_price` int NOT NULL DEFAULT '0',
`delivery_price` int NOT NULL DEFAULT '0',
`pay_price` int DEFAULT '0',
`pay_order_id` int DEFAULT NULL,
`pay_channel` int DEFAULT NULL,
`delivery_type` int NOT NULL DEFAULT '1',
`actual_delivery_type` int NOT NULL DEFAULT '1',
`delivery_template_id` int DEFAULT NULL,
`express_no` int DEFAULT NULL,
`delivery_status` bit(1) NOT NULL DEFAULT FALSE,
`delivery_time` datetime DEFAULT NULL,
`receive_time` datetime DEFAULT NULL,
`receiver_name` varchar(20) DEFAULT NULL,
`receiver_mobile` varchar(20) DEFAULT NULL,
`receiver_area_id` int DEFAULT NULL,
`receiver_post_code` int DEFAULT NULL,
`receiver_detail_address` varchar(255) DEFAULT NULL,
`refund_status` int NOT NULL DEFAULT '0',
`refund_price` int NOT NULL DEFAULT '0',
`coupon_id` bigint unsigned DEFAULT NULL,
`creator` varchar(64) DEFAULT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updater` varchar(64) DEFAULT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` bit(1) NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
);
CREATE TABLE IF NOT EXISTS `trade_order_item`
(
`id` number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
`user_id` bigint unsigned NOT NULL,
`order_id` bigint unsigned NOT NULL,
`spu_id` bigint unsigned NOT NULL,
`sku_id` bigint unsigned NOT NULL,
`properties` json DEFAULT NULL,
`name` varchar(128) DEFAULT NULL,
`pic_url` varchar(200) DEFAULT NULL,
`count` int NOT NULL,
`commented` bit(1) DEFAULT NULL,
`original_price` int NOT NULL DEFAULT '0',
`total_original_price` int NOT NULL DEFAULT '0',
`total_promotion_price` int NOT NULL DEFAULT '0',
`present_price` int NOT NULL DEFAULT '0',
`total_present_price` int NOT NULL DEFAULT '0',
`total_pay_price` int NOT NULL DEFAULT '0',
`refund_status` int NOT NULL DEFAULT '0',
`refund_total` int NOT NULL DEFAULT '0',
`creator` varchar(64) DEFAULT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updater` varchar(64) DEFAULT '',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted` bit(1) DEFAULT FALSE,
PRIMARY KEY ("id")
);