|
|
@ -27,10 +27,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author wangpengfei |
|
|
@ -52,8 +54,19 @@ public class VegeCellarReserveOrderService extends MybatisBaseService<VegeCellar |
|
|
|
public ResultBean submission(VegeCellarReserveOrderDto dto) { |
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
boolean b = isSatAndSun(dto.getReserveDate()); |
|
|
|
if (!b) { |
|
|
|
return rb.setMsg("当前提货时间不可预约提货"); |
|
|
|
// if (!b) {
|
|
|
|
// return rb.setMsg("当前提货时间不可预约提货");
|
|
|
|
// }
|
|
|
|
Date date=new Date(); |
|
|
|
//1>2 1 、1<2 -1 、1=2 0
|
|
|
|
//判断预约时间小于当前时间
|
|
|
|
int i =date.compareTo(DateUtil.parse(dto.getReserveDate())); |
|
|
|
if(i!=-1){ |
|
|
|
return rb.setMsg("预约时间有误,请重新选择"); |
|
|
|
} |
|
|
|
//判断三点前 还是三点后
|
|
|
|
if(!isReserve(dto.getReserveDate())){ |
|
|
|
return rb.setMsg("预约时间有误,请重新选择"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(dto.getCustomerSid())) { |
|
|
|
return rb.setMsg("参数不全"); |
|
|
@ -93,6 +106,34 @@ public class VegeCellarReserveOrderService extends MybatisBaseService<VegeCellar |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
public boolean isReserve(String reserveDate){ |
|
|
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
LocalDate today = LocalDate.now(); // 获取今天的日期
|
|
|
|
LocalTime timeOfDay = LocalTime.of(15, 0); // 设置下午3点的小时数为15,分钟数为0
|
|
|
|
LocalDateTime dateAndTime = LocalDateTime.of(today, timeOfDay); // 将日期和时间合并成完整的日期时间对象
|
|
|
|
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
Date date = Date.from(dateAndTime.atZone(zoneId).toInstant()); |
|
|
|
Date nowDate=new Date(); |
|
|
|
String start =""; |
|
|
|
//1>2 1 、1<2 -1 、1=2 0
|
|
|
|
int k= DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(nowDate)))).compareTo(DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(date))))); |
|
|
|
if(String.valueOf(k).equals("1")){ |
|
|
|
start=sdf.format(DateUtil.offsetDay(nowDate,+2)); |
|
|
|
int a =DateUtil.parse(reserveDate).compareTo(DateUtil.parse(start)); |
|
|
|
if(a==-1){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
start=sdf.format(DateUtil.offsetDay(nowDate,+1)); |
|
|
|
int a =DateUtil.parse(reserveDate).compareTo(DateUtil.parse(start)); |
|
|
|
if(a==-1){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// @Test
|
|
|
|
// public void isSatAndSun(){
|
|
|
|