mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
fix: Seata实验室错误修复
This commit is contained in:
parent
a46173d3c1
commit
1fb89c4434
@ -39,18 +39,18 @@ public class SeataController {
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("购买商品")
|
||||
@PostMapping("/_purchase")
|
||||
@ApiOperation("订单支付")
|
||||
@PostMapping("/_pay")
|
||||
public Result payOrder(@RequestBody SeataForm seataForm) {
|
||||
boolean openTx = seataForm.isOpenTx();
|
||||
|
||||
String orderSn = null;
|
||||
boolean result;
|
||||
if (openTx) {
|
||||
// 开启全局事务
|
||||
orderSn = seataService.payOrderWithGlobalTx(seataForm);
|
||||
result = seataService.payOrderWithGlobalTx(seataForm);
|
||||
} else {
|
||||
orderSn = seataService.payOrder(seataForm);
|
||||
result = seataService.payOrder(seataForm);
|
||||
}
|
||||
return Result.success(orderSn);
|
||||
return Result.success(result);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import com.youlai.laboratory.seata.pojo.form.SeataForm;
|
||||
import com.youlai.laboratory.seata.pojo.vo.SeataVO;
|
||||
|
||||
/**
|
||||
* Seata 实验室接口层
|
||||
*
|
||||
* @author haoxr
|
||||
* @date 2022/4/16 20:49
|
||||
*/
|
||||
@ -24,16 +26,12 @@ public interface SeataService {
|
||||
boolean resetData();
|
||||
|
||||
/**
|
||||
* 购买商品
|
||||
*
|
||||
* @return 订单号
|
||||
* 订单支付
|
||||
*/
|
||||
String payOrder(SeataForm seataForm);
|
||||
boolean payOrder(SeataForm seataForm);
|
||||
|
||||
/**
|
||||
* 购买商品(全局事务)
|
||||
*
|
||||
* @return 订单号
|
||||
* 订单支付(全局事务)
|
||||
*/
|
||||
boolean payOrderWithGlobalTx(SeataForm seataForm);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Seata实验室业务类接口
|
||||
* Seata 实验室业务类接口
|
||||
*
|
||||
* @author haoxr
|
||||
* @date 2022/4/16 20:49
|
||||
@ -86,7 +86,7 @@ public class SeataServiceImpl implements SeataService {
|
||||
* 订单支付
|
||||
*/
|
||||
@Override
|
||||
public String payOrder(SeataForm seataForm) {
|
||||
public boolean payOrder(SeataForm seataForm) {
|
||||
log.info("========扣减商品库存(全局事务)========");
|
||||
skuFeignClient.deductStock(skuId, 1); // 扣减库存
|
||||
|
||||
@ -97,10 +97,9 @@ public class SeataServiceImpl implements SeataService {
|
||||
seataForm.getAmount(),
|
||||
seataForm.isOpenEx()
|
||||
);
|
||||
Result<String> result = orderFeignClient.payOrder(orderId, seataOrderDTO);
|
||||
String orderSn = result.getData();
|
||||
orderFeignClient.payOrder(orderId, seataOrderDTO);
|
||||
|
||||
return orderSn;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user