feat:预定判断是否在时间段内
This commit is contained in:
1 parent
f4df20e5f0
commit
80cc00e2ec
2 files changed
+17
-4
No files matched your search
+17
-1
@@ -73,6 +73,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -268,9 +269,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
|||||||
// 查询用户
|
// 查询用户
|
||||||
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
|
UserInfo userDetail = userService.getInnerByUserId(dto.getUserId()).getData();
|
||||||
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
if (ObjectUtil.isEmpty(userDetail)) throw new RuntimeException("用户不存在不存在");
|
||||||
|
// 如果是预约判断是否在预约时间段内
|
||||||
|
boolean inReserveTime = isInReserveTime(dto.getApptId());
|
||||||
|
if (!inReserveTime) throw new RuntimeException("不在预约时间段内");
|
||||||
// 判断是否有重复的预约订单
|
// 判断是否有重复的预约订单
|
||||||
Long reserveCount = isHaveCanteenReserve(dto.getUserId());
|
Long reserveCount = isHaveCanteenReserve(dto.getUserId());
|
||||||
if (reserveCount > 100) throw new RuntimeException("您有" + reserveCount + "笔未核销的预约订单,请先核销");
|
if (reserveCount > 3) throw new RuntimeException("您有" + reserveCount + "笔未核销的预约订单,请先核销");
|
||||||
// 钱包
|
// 钱包
|
||||||
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
|
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
|
||||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||||
@@ -814,6 +818,18 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 是否在预约时间段内
|
||||||
|
private boolean isInReserveTime(Long apptId) {
|
||||||
|
if (ObjectUtil.isEmpty(apptId)) return true;
|
||||||
|
HardApptEntity apptDetail = hardApptService.getById(apptId);
|
||||||
|
if (ObjectUtil.isEmpty(apptDetail)) {
|
||||||
|
throw new RuntimeException("请先配置预约时间段");
|
||||||
|
}
|
||||||
|
LocalTime startTime = apptDetail.getStartTime();
|
||||||
|
LocalTime endTime = apptDetail.getEndTime();
|
||||||
|
return LocalTime.now().isAfter(startTime) && LocalTime.now().isBefore(endTime);
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************* end 支付相关 end ************************************* */
|
/* ************************************* end 支付相关 end ************************************* */
|
||||||
|
|
||||||
private HardOrderServiceImpl getSelf() {
|
private HardOrderServiceImpl getSelf() {
|
||||||
|
|||||||
-3
@@ -1,11 +1,8 @@
|
|||||||
package com.bsd.pjcloud.thirdparty.controller.pay;
|
package com.bsd.pjcloud.thirdparty.controller.pay;
|
||||||
|
|
||||||
|
|
||||||
import com.bsd.pjcloud.common.core.util.R;
|
|
||||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayGetWalletInfoDto;
|
|
||||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayApiService;
|
import com.bsd.pjcloud.thirdparty.service.ThirdPayApiService;
|
||||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
|
||||||
import com.bsd.pjcloud.thirdparty.vo.pay.*;
|
import com.bsd.pjcloud.thirdparty.vo.pay.*;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
|||||||
Reference in new issue
Block a user