diff --git a/laboratory/src/main/java/com/youlai/laboratory/seata/service/impl/SeataServiceImpl.java b/laboratory/src/main/java/com/youlai/laboratory/seata/service/impl/SeataServiceImpl.java index 8e78e2686..b65dc0711 100644 --- a/laboratory/src/main/java/com/youlai/laboratory/seata/service/impl/SeataServiceImpl.java +++ b/laboratory/src/main/java/com/youlai/laboratory/seata/service/impl/SeataServiceImpl.java @@ -36,49 +36,6 @@ public class SeataServiceImpl implements SeataService { private static Long memberId = 1l; // 会员ID private static Long orderId = 1l; // 订单ID - /** - * 模拟订单支付 - * - * @return - */ - @Override - public boolean payOrder(SeataForm seataForm) { - - log.info("========扣减商品库存========"); - skuFeignClient.deductStock(skuId, 1); // 扣减库存 - - log.info("========扣减账户余额========"); - memberFeignClient.deductBalance(memberId, 1000 * 100l); // 扣款1000 - - log.info("========修改订单状态========"); - orderFeignClient.updateOrderStatus(orderId, 201, seataForm.isOrderEx()); // 已支付 - - return true; - } - - /** - * 模拟订单支付(分布式事务) - * - * @param seataForm - * @return - */ - @Override - @GlobalTransactional - public boolean payOrderWithGlobalTx(SeataForm seataForm) { - log.info("========扣减商品库存(Seata)========"); - skuFeignClient.deductStock(skuId, 1); // 扣减库存 - - log.info("========修改订单状态(Seata)========"); - orderFeignClient.createOrder(orderId, 201, seataForm.isOrderEx()); // 已支付 - - log.info("========修改订单状态(Seata)========"); - orderFeignClient.updateOrderStatus(orderId, 201, seataForm.isOrderEx()); // 已支付 - - log.info("========扣减账户余额(Seata)========"); - memberFeignClient.deductBalance(memberId, 1000 * 100l); // 扣款1000 - return true; - } - /** * 获取模拟数据 * @@ -115,7 +72,6 @@ public class SeataServiceImpl implements SeataService { @Override public boolean resetData() { skuFeignClient.updateStock(skuId, 999); // 还原库存 - memberFeignClient.updateBalance(memberId, 10000000 * 100); // 还原余额 orderFeignClient.updateOrderStatus(orderId, 101, false); // 待支付 return true; diff --git a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/api/OrderFeignClient.java b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/api/OrderFeignClient.java index dad4bd133..8bef780a6 100644 --- a/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/api/OrderFeignClient.java +++ b/mall-oms/oms-api/src/main/java/com/youlai/mall/oms/api/OrderFeignClient.java @@ -44,5 +44,5 @@ public interface OrderFeignClient { * @return */ @PostMapping("/api/v1/orders") - Result createOrder(SeataOrderDTO orderDTO, boolean openEx); + Result createOrder(@RequestBody SeataOrderDTO orderDTO, @RequestParam boolean openEx); } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OmsOrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OmsOrderController.java index e1f390d8d..cb03946d2 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OmsOrderController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/admin/OmsOrderController.java @@ -23,8 +23,9 @@ import java.util.List; import java.util.Optional; /** + * 订单控制层 + * * @author huawei - * @email huawei_code@163.com * @date 2020/12/30 */ @Api(tags = "「管理端」订单管理")