高内聚,低耦合
并行开发,提高开发的效率
如何划分?
业务层次
功能划分
重复使用
构建工具:gradle
管理端
产品表
订单表
create table product(
id VARCHAR(50) not null comment '产品编号',
name VARCHAR(50) not null comment '产品名称',
threshold_amount DECIMAL(15,3) not null comment '起步金额',
step_amount DECIMAL(15,3) not null comment '投资步长',
lock_term SMALLINT not null comment '锁定期',
reward_rate DECIMAL(15,3) not null comment '收益率,0-100 百分比值',
status VARCHAR(20) not null comment '状态,AUDINTING:审核中,IN_SELL:销售 中,LOCKED:暂停销售,FINISHED:已结束',
memo VARCHAR(200) comment '备注',
create_at datetime comment '创建时间',
create_user VARCHAR(20) comment '创建者',
update_at datetime comment '更新时间',
update_user VARCHAR(20) comment '更新者',
PRIMARY KEY(id)
)ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
create table order_t(
order_id VARCHAR(50) not null comment '订单编号',
chan_id VARCHAR(50) not null comment '渠道编号',
product_id VARCHAR(50) not null comment '产品编号',
chan_user_id VARCHAR(50) not null comment '渠道用户编号',
order_type VARCHAR(50) not null comment '类型,APPLY:申购,REDEEM:赎回',
order_status VARCHAR(50) not null comment '状态,INIT:初始化,PROCESS:处理 中,SUCCESS:成功,FAIL:失败',
outer_order_id VARCHAR(50) not null comment '外部订单编号',
amount DECIMAL(15,3) not null comment '金额',
memo VARCHAR(200) comment '备注',
create_at datetime comment '创建时间',
update_at datetime comment '更新时间',
PRIMARY KEY(order_id)
)ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
package com.qwl.entity;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;
/**
* 产品
*/
@Entity
public class Product {
@Id
private String id;
private String name;
private String status;
//起投金额
private BigDecimal threshouldAmount;
//投资步长
private BigDecimal stepAmount;
//锁定期
private Integer lockTerm;
//收益率
private BigDecimal rewardRate;
private String memo;
private Date createAt;
private Date updateAt;
private String createUser;
private String updateUser;
//get set toString
}
package com.qwl.entity;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;
/**
* 订单
*/
@Entity(name = "order_t")
public class Order {
@Id
private String orderId;
//渠道id
private String chanId;
private String chanUserId;
private String orderType;
private String productId;
private BigDecimal amount;
private String outerOrderId;
private String orderStatus;
private String memo;
private Date createAt;
private Date updateAt;
//get set toString
}
package com.qwl.entity.enums;
/**
* 订单状态
*/
public enum OrderStatus {
INIT("初始化"),
PROCESS("处理中"),
SUCCESS("成功"),
FAIL("失败");
private String desc;
OrderStatus(String desc) {
this.desc = desc;
}
public String getDesc() {
return desc;
}
}
package com.qwl.entity.enums;
/**
* 订单状态
*/
public enum OrderType {
APPLY("申购"),
REDEEM("赎回");
private String desc;
OrderType(String desc) {
this.desc = desc;
}
public String getDesc() {
return desc;
}
}
package com.qwl.entity.enums;
/**
* 产品状态
*/
public enum ProductStatus {
AUDITING("审核中"),
IN_SELL("销售中"),
LOCKED("暂停销售"),
FINISHED("已结束");
private String desc;
ProductStatus(String desc){
this.desc = desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}