交易模块的实现
创建模型 OrderModel
@Data
public class OrderModel {
private String id;
private Integer userId;
private Integer itemId;
private BigDecimal itemPrice;
private Integer amount;
private BigDecimal orderPrice;
}
mybatis-generator.xml 添加下列代码,生成DO类
<table tableName="order_info" domainObjectName="OrderDO"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="sequence_info" domainObjectName="SequenceDO"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
创建 OrderService、OrderServiceImpl
public interface OrderService {
// 创建订单
OrderModel createOrder(Integer userId, Integer itemId, Integer promoId, Integer amount) throws BusinessException;
}
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private ItemService itemService;
@Autowired
private UserService userService;
@Autowired
private OrderDOMapper orderDOMapper;
@Autowired
private Sequen