mirror of https://gitee.com/stylefeng/roses
【7.6.0】【框架改造】移除seata
parent
13a0832da8
commit
c57b60c321
|
@ -1 +0,0 @@
|
|||
分布式事务Seata模块
|
|
@ -1,111 +0,0 @@
|
|||
|
||||
-- ----------------------------
|
||||
-- 订单库
|
||||
-- ----------------------------
|
||||
DROP DATABASE IF EXISTS `order`;
|
||||
CREATE DATABASE IF NOT EXISTS `order` DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
USE `order`;
|
||||
|
||||
DROP TABLE IF EXISTS `order_info`;
|
||||
CREATE TABLE `order_info` (
|
||||
`order_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '订单ID',
|
||||
`product_id` bigint(20) NOT NULL COMMENT '商品ID',
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`prod_price` double(8, 2) NOT NULL COMMENT '商品单价',
|
||||
`prod_number` int(11) NOT NULL COMMENT '商品数量',
|
||||
`total_amount` double(10, 2) NOT NULL COMMENT '总价',
|
||||
`pay_status` int(11) NOT NULL COMMENT '支付状态:1待支付,2已支付,3支付失败,已取消',
|
||||
`create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`order_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单表' ROW_FORMAT = Dynamic;
|
||||
|
||||
DROP TABLE IF EXISTS `undo_log`;
|
||||
CREATE TABLE `undo_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`branch_id` bigint(20) NOT NULL,
|
||||
`xid` varchar(100) NOT NULL,
|
||||
`context` varchar(128) NOT NULL,
|
||||
`rollback_info` longblob NOT NULL,
|
||||
`log_status` int(11) NOT NULL,
|
||||
`log_created` datetime NOT NULL,
|
||||
`log_modified` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT = 'seata事务记录';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 仓储库
|
||||
-- ----------------------------
|
||||
DROP DATABASE IF EXISTS `storage`;
|
||||
CREATE DATABASE IF NOT EXISTS `storage` DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
USE `storage`;
|
||||
|
||||
DROP TABLE IF EXISTS `product_info`;
|
||||
CREATE TABLE `product_info` (
|
||||
`prod_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '商品ID',
|
||||
`prod_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商品名称',
|
||||
`inventory` int(11) NOT NULL COMMENT '库存数量',
|
||||
`prod_price` double(8, 2) NOT NULL COMMENT '商品单价',
|
||||
`prod_status` int(11) NOT NULL COMMENT '上架状态:1上架,2下架',
|
||||
`create_user` bigint(20) NULL DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`prod_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品表' ROW_FORMAT = Dynamic;
|
||||
|
||||
DROP TABLE IF EXISTS `undo_log`;
|
||||
CREATE TABLE `undo_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`branch_id` bigint(20) NOT NULL,
|
||||
`xid` varchar(100) NOT NULL,
|
||||
`context` varchar(128) NOT NULL,
|
||||
`rollback_info` longblob NOT NULL,
|
||||
`log_status` int(11) NOT NULL,
|
||||
`log_created` datetime NOT NULL,
|
||||
`log_modified` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT = 'seata事务记录';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 用户库
|
||||
-- ----------------------------
|
||||
DROP DATABASE IF EXISTS `member`;
|
||||
CREATE DATABASE IF NOT EXISTS `member` DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
|
||||
USE `member`;
|
||||
|
||||
DROP TABLE IF EXISTS `member_wallet`;
|
||||
CREATE TABLE `member_wallet` (
|
||||
`member_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '会员ID',
|
||||
`member_balance` double(8, 2) DEFAULT '0.00' COMMENT '会员余额',
|
||||
`member_integral` double(8, 2) DEFAULT '0.00' COMMENT '会员积分',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`member_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户钱包' ROW_FORMAT = Dynamic;
|
||||
|
||||
DROP TABLE IF EXISTS `undo_log`;
|
||||
CREATE TABLE `undo_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`branch_id` bigint(20) NOT NULL,
|
||||
`xid` varchar(100) NOT NULL,
|
||||
`context` varchar(128) NOT NULL,
|
||||
`rollback_info` longblob NOT NULL,
|
||||
`log_status` int(11) NOT NULL,
|
||||
`log_created` datetime NOT NULL,
|
||||
`log_modified` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT = 'seata事务记录';
|
Binary file not shown.
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>roses-kernel</artifactId>
|
||||
<version>7.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>kernel-d-seata</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>seata-demo-wallet-api</module>
|
||||
<module>seata-demo-storage-api</module>
|
||||
<module>seata-demo-order</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 开发规则 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-a-rule</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,55 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-d-seata</artifactId>
|
||||
<version>7.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>seata-demo-order</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
|
||||
<!--feign远程调用-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
<version>${openfeign.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--demo业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>seata-demo-storage-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>seata-demo-wallet-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--seata分布式事务-->
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
<artifactId>seata-all</artifactId>
|
||||
<version>${seata.all.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--资源api模块-->
|
||||
<!--用在资源控制器,资源扫描上-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>scanner-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.consumer;
|
||||
|
||||
import cn.stylefeng.roses.kernel.seata.api.StorageApi;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
/**
|
||||
* 仓储 api
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/10 16:42
|
||||
*/
|
||||
@FeignClient(name = "seata-demo-storage")
|
||||
public interface StorageConsumer extends StorageApi {
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.consumer;
|
||||
|
||||
import cn.stylefeng.roses.kernel.seata.wallet.api.WalletApi;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
/**
|
||||
* 用户钱包 api
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/10 16:42
|
||||
*/
|
||||
@FeignClient(name = "seata-demo-wallet")
|
||||
public interface WalletConsumer extends WalletApi {
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.seata.order.entity.Order;
|
||||
import cn.stylefeng.roses.kernel.seata.order.service.OrderService;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 订单接口
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/10 16:42
|
||||
*/
|
||||
@ApiResource(name = "订单接口(测试seata)", resBizType = ResBizTypeEnum.SYSTEM)
|
||||
public class OrderController {
|
||||
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/4/20 20:11
|
||||
*/
|
||||
@GetResource(name = "创建订单", path = "/order/create", requiredPermission = false, requiredLogin = false)
|
||||
public Order create(@RequestParam("userId") String userId, @RequestParam("commodityCode") String commodityCode, @RequestParam("orderCount") Integer orderCount) {
|
||||
return orderService.create(userId, commodityCode, orderCount);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单 实体类
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/21 08:33
|
||||
*/
|
||||
public class Order implements Serializable {
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 商品单价
|
||||
*/
|
||||
private Integer prodPrice;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer prodNumber;
|
||||
|
||||
/**
|
||||
* 总价
|
||||
*/
|
||||
private Integer totalAmount;
|
||||
|
||||
/**
|
||||
* 支付状态:1待支付,2已支付,3支付失败,已取消
|
||||
*/
|
||||
private Integer payStatus;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long createUser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Long updateUser;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public Long getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(Long orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getProdPrice() {
|
||||
return prodPrice;
|
||||
}
|
||||
|
||||
public void setProdPrice(Integer prodPrice) {
|
||||
this.prodPrice = prodPrice;
|
||||
}
|
||||
|
||||
public Integer getProdNumber() {
|
||||
return prodNumber;
|
||||
}
|
||||
|
||||
public void setProdNumber(Integer prodNumber) {
|
||||
this.prodNumber = prodNumber;
|
||||
}
|
||||
|
||||
public Integer getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(Integer totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public Integer getPayStatus() {
|
||||
return payStatus;
|
||||
}
|
||||
|
||||
public void setPayStatus(Integer payStatus) {
|
||||
this.payStatus = payStatus;
|
||||
}
|
||||
|
||||
public Long getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Long createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getUpdateUser() {
|
||||
return updateUser;
|
||||
}
|
||||
|
||||
public void setUpdateUser(Long updateUser) {
|
||||
this.updateUser = updateUser;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.seata.order.entity.Order;
|
||||
|
||||
/**
|
||||
* 订单 数据层
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/21 08:33
|
||||
*/
|
||||
public interface OrderMapper {
|
||||
|
||||
/**
|
||||
* 新增订单
|
||||
*
|
||||
* @param order 订单
|
||||
* @author wangyl
|
||||
* @since 2021/4/21 9:43
|
||||
*/
|
||||
void insertOrder(Order order);
|
||||
|
||||
/**
|
||||
* 根据ID查询订单
|
||||
*
|
||||
* @param orderId 订单id
|
||||
* @author wangyl
|
||||
* @since 2021/4/21 9:43
|
||||
*/
|
||||
Order selectById(Long orderId);
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?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="cn.stylefeng.roses.kernel.seata.order.mapper.OrderMapper">
|
||||
|
||||
<!-- 新增订单 -->
|
||||
<insert id="insertOrder" parameterType="cn.stylefeng.roses.kernel.seata.order.entity.Order">
|
||||
insert into order(
|
||||
<if test="productId != null and productId != ''">product_id,</if>
|
||||
<if test="userId != null and userId != ''">user_id,</if>
|
||||
<if test="prodPrice != null and prodPrice != ''">prod_price,</if>
|
||||
<if test="prodNumber != null and prodNumber != ''">prod_number,</if>
|
||||
<if test="totalAmount != null and totalAmount != ''">total_amount,</if>
|
||||
<if test="payStatus != null and payStatus != ''">pay_status,</if>
|
||||
<if test="createUser != null and createUser != ''">create_user,</if>
|
||||
<if test="createTime != null and createTime != ''">create_time</if>
|
||||
<if test="updateUser != null and updateUser != ''">update_user,</if>
|
||||
<if test="updateTime != null and updateTime != ''">update_time,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
)values(
|
||||
<if test="productId != null and productId != ''">#{productId},</if>
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="prodPrice != null and prodPrice != ''">#{prodPrice},</if>
|
||||
<if test="prodNumber != null and prodNumber != ''">#{prodNumber},</if>
|
||||
<if test="totalAmount != null and totalAmount != ''">#{totalAmount},</if>
|
||||
<if test="payStatus != null and payStatus != ''">#{payStatus},</if>
|
||||
<if test="createUser != null and createUser != ''">#{createUser},</if>
|
||||
<if test="createTime != null and createTime != ''">#{createTime}</if>
|
||||
<if test="updateUser != null and updateUser != ''">#{updateUser},</if>
|
||||
<if test="updateTime != null and updateTime != ''">#{updateTime},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID查询订单 -->
|
||||
<select id="selectById" resultType="cn.stylefeng.roses.kernel.seata.order.entity.Order">
|
||||
select *
|
||||
from order
|
||||
where order_id = #{orderId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,24 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.seata.order.entity.Order;
|
||||
|
||||
/**
|
||||
* 订单 业务层
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/21 08:33
|
||||
*/
|
||||
public interface OrderService {
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param commodityCode 商品编码
|
||||
* @param orderCount 购买数量
|
||||
* @author wangyl
|
||||
* @since 2021/4/21 9:43
|
||||
*/
|
||||
Order create(String userId, String commodityCode, int orderCount);
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.order.service.impl;
|
||||
|
||||
import cn.stylefeng.roses.kernel.seata.order.consumer.StorageConsumer;
|
||||
import cn.stylefeng.roses.kernel.seata.order.consumer.WalletConsumer;
|
||||
import cn.stylefeng.roses.kernel.seata.order.entity.Order;
|
||||
import cn.stylefeng.roses.kernel.seata.order.mapper.OrderMapper;
|
||||
import cn.stylefeng.roses.kernel.seata.order.service.OrderService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 订单 业务层
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/21 08:33
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
|
||||
@Resource
|
||||
private StorageConsumer storageConsumer;
|
||||
|
||||
@Resource
|
||||
private WalletConsumer walletConsumer;
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Order create(String userId, String commodityCode, int orderCount) {
|
||||
Order order = new Order();
|
||||
|
||||
//保存订单
|
||||
orderMapper.insertOrder(order);
|
||||
|
||||
//扣减商品库存
|
||||
storageConsumer.deduct(commodityCode, orderCount);
|
||||
|
||||
//扣用户钱
|
||||
walletConsumer.debit(userId, order.getTotalAmount());
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-d-seata</artifactId>
|
||||
<version>7.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>seata-demo-storage-api</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
</project>
|
|
@ -1,21 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.api;
|
||||
|
||||
/**
|
||||
* 仓储 api
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/10 16:42
|
||||
*/
|
||||
public interface StorageApi {
|
||||
|
||||
/**
|
||||
* 扣除存储数量
|
||||
*
|
||||
* @param commodityCode 商品编码
|
||||
* @param count 购买数量
|
||||
* @author wangyl
|
||||
* @since 2021/4/21 9:44
|
||||
*/
|
||||
void deduct(String commodityCode, Integer count);
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>kernel-d-seata</artifactId>
|
||||
<version>7.6.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>seata-demo-wallet-api</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
</project>
|
|
@ -1,21 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.seata.wallet.api;
|
||||
|
||||
/**
|
||||
* 用户钱包 api
|
||||
*
|
||||
* @author wangyl
|
||||
* @since 2021/04/10 16:42
|
||||
*/
|
||||
public interface WalletApi {
|
||||
|
||||
/**
|
||||
* 从用户账户中扣除余额
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param money 消费金额
|
||||
* @author wangyl
|
||||
* @since 2021/4/21 9:44
|
||||
*/
|
||||
void debit(String userId, Integer money);
|
||||
|
||||
}
|
4
pom.xml
4
pom.xml
|
@ -106,9 +106,6 @@
|
|||
<!--系统管理基础业务-->
|
||||
<module>kernel-s-system</module>
|
||||
|
||||
<!-- 分布式事务seata -->
|
||||
<module>kernel-d-seata</module>
|
||||
|
||||
<!-- Socket模块 -->
|
||||
<module>kernel-d-socket</module>
|
||||
|
||||
|
@ -149,7 +146,6 @@
|
|||
<easy.excel.version>3.2.1</easy.excel.version>
|
||||
<pinyin4j.version>2.5.0</pinyin4j.version>
|
||||
<openfeign.version>2.2.6.RELEASE</openfeign.version>
|
||||
<seata.all.version>1.3.0</seata.all.version>
|
||||
<bcprov.version>1.68</bcprov.version>
|
||||
<springdoc.version>1.6.12</springdoc.version>
|
||||
</properties>
|
||||
|
|
Loading…
Reference in New Issue