From bd9aecf5746b566dbe02b149f4cb5225e91fd501 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 9 Oct 2024 16:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=94=AF=E4=BB=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/NotifyController.java | 11 +++++++++++ .../system/cashierservice/service/PayService.java | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java index 67a425e..93d197c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/NotifyController.java @@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil; import com.chaozhanggui.system.cashierservice.entity.Enum.PayTypeConstant; import com.chaozhanggui.system.cashierservice.interceptor.RequestWrapper; import com.chaozhanggui.system.cashierservice.service.PayService; +import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.DateUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -86,6 +87,16 @@ public class NotifyController { return null; } + /** + * 支付取消 + * @param orderId 订单id + * @return 影响数量 + */ + @PostMapping("cancel") + public Result notifyCancel(@RequestParam Integer orderId) { + return Result.successWithData(payService.cancelOrder(orderId)); + } + @RequestMapping("notifyfstCallBack") public String notifyfstCallBack(HttpServletRequest request){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 69e87e4..51ca21b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; +import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo; @@ -211,7 +212,7 @@ public class PayService { if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) { return Result.fail("订单状态异常,不允许支付"); } - if (System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) { + if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType()) && System.currentTimeMillis() - orderInfo.getCreatedAt() > 60 * 15 * 1000) { return Result.fail("订单十五分钟内有效,当前已超时,请重新下单。"); } @@ -1488,6 +1489,13 @@ public class PayService { .set(TbOrderInfo::getStatus, "unpaid")); } + public int cancelOrder(Integer orderId) { + return mpOrderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .eq(TbOrderInfo::getStatus, "paying") + .set(TbOrderInfo::getStatus, "unpaid")); + } + // public Result returnOrder(){ //