|
@@ -12,6 +12,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -40,6 +41,10 @@ public class ProxyDemandServiceImpl implements ProxyDemandService {
|
|
|
|
|
|
@Override
|
|
|
public BaseResult insert(ProxyVerifyDTO proxyVerifyDTO) {
|
|
|
+ int handleTotal = this.findTotalByTime(new Date());
|
|
|
+ if(handleTotal>=10){
|
|
|
+ throw new BusinessException("预约已满,请下周再提交!");
|
|
|
+ }
|
|
|
Object o = redisTemplate.opsForValue().get(proxyVerifyDTO.getImgKey());
|
|
|
if(o==null){
|
|
|
throw new BusinessException("验证码已过期");
|
|
@@ -60,6 +65,7 @@ public class ProxyDemandServiceImpl implements ProxyDemandService {
|
|
|
proxyDemand.setProxyName(proxyVerifyDTO.getProxyName());
|
|
|
proxyDemand.setProxyPhone(proxyVerifyDTO.getProxyPhone());
|
|
|
proxyDemand.setProxyMatters(proxyVerifyDTO.getProxyMatters());
|
|
|
+ proxyDemand.setHandleTotal(handleTotal+1);
|
|
|
proxyDemandDao.insert(proxyDemand);
|
|
|
return BaseResult.ok();
|
|
|
}
|
|
@@ -73,6 +79,37 @@ public class ProxyDemandServiceImpl implements ProxyDemandService {
|
|
|
public void deleteById(Long id) {
|
|
|
proxyDemandDao.deleteById(id);
|
|
|
}
|
|
|
+
|
|
|
+ //判断预约总数
|
|
|
+ @Override
|
|
|
+ public BaseResult findBylastTotal() {
|
|
|
+ int i=proxyDemandDao.findBylastTotal();
|
|
|
+ if(i<=9){
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ throw new BusinessException("预约已满,请下周再提交");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public int findTotalByTime(Date handleTime) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(handleTime);
|
|
|
+ // 设置为一周的开始时间(通常是周一的 00:00:00)
|
|
|
+ calendar.setFirstDayOfWeek(Calendar.MONDAY); // 设置每周的第一天为周一
|
|
|
+ calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // 设置为本周的周一
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0);
|
|
|
+ Date startTime = calendar.getTime();
|
|
|
+ // 设置为一周的结束时间(下周一的 00:00:00 前一秒)
|
|
|
+ calendar.add(Calendar.DAY_OF_WEEK, 7); // 向前移动7天,到达下周的周一
|
|
|
+ calendar.add(Calendar.MILLISECOND, -1); // 回退1毫秒,得到本周日的最后一刻
|
|
|
+ Date endTime = calendar.getTime();
|
|
|
+ return proxyDemandDao.findTotalByTime(startTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|