|
@@ -8,6 +8,7 @@ import com.yonge.cooleshow.portal.domain.ConfirmOrderResult;
|
|
|
import com.yonge.cooleshow.portal.domain.OmsOrderDetail;
|
|
|
import com.yonge.cooleshow.portal.domain.OrderParam;
|
|
|
import com.yonge.cooleshow.portal.service.OmsPortalOrderService;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
|
import com.yonge.toolset.payment.util.DistributedLock;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -159,15 +160,39 @@ public class OmsPortalOrderController {
|
|
|
@RequestMapping(value = "/paySuccess/test", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public CommonResult paySuccessTest(@RequestParam Long orderId,@RequestParam Integer payType) {
|
|
|
- Integer count = portalOrderService.paySuccess(orderId,payType);
|
|
|
- return CommonResult.success(count, "支付成功");
|
|
|
+ OmsOrder omsOrder = portalOrderService.getOrderById(orderId);
|
|
|
+ if (omsOrder == null) {
|
|
|
+ return CommonResult.failed("未找到订单");
|
|
|
+ }
|
|
|
+
|
|
|
+ DistributedLock.of(redissonClient)
|
|
|
+ .runIfLockCanGet(OrderCacheEnum.LOCK_ORDER_NO_MALL.getRedisKey(omsOrder.getOrderSn())
|
|
|
+ , () -> {
|
|
|
+ if (omsOrder.getStatus() == 0 || omsOrder.getStatus() == 6) {
|
|
|
+ portalOrderService.paySuccess(orderId, payType);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new BizException("订单已支付或已取消");
|
|
|
+ }
|
|
|
+ }, 60L, TimeUnit.SECONDS);
|
|
|
+ return CommonResult.success("支付成功");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("用户取消订单")
|
|
|
@GetMapping(value = "/cancelUserOrder/test")
|
|
|
@ResponseBody
|
|
|
public CommonResult cancelUserOrderTest(@RequestParam Long orderId) {
|
|
|
- portalOrderService.cancelOrder(orderId, "用户取消订单", null);
|
|
|
+
|
|
|
+ OmsOrder omsOrder = portalOrderService.getOrderById(orderId);
|
|
|
+ if (omsOrder == null) {
|
|
|
+ return CommonResult.failed("未找到订单");
|
|
|
+ }
|
|
|
+
|
|
|
+ DistributedLock.of(redissonClient)
|
|
|
+ .runIfLockCanGet(OrderCacheEnum.LOCK_ORDER_NO_MALL.getRedisKey(omsOrder.getOrderSn())
|
|
|
+ , () -> {
|
|
|
+ portalOrderService.cancelOrder(orderId, "用户取消订单", null);
|
|
|
+ }, 60L, TimeUnit.SECONDS);
|
|
|
return CommonResult.success(null);
|
|
|
}
|
|
|
}
|