取消支付接口
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.eq(TbOrderInfo::getStatus, "paying")
|
||||
.set(TbOrderInfo::getStatus, "unpaid"));
|
||||
}
|
||||
|
||||
|
||||
// public Result returnOrder(){
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user