jiangping
2023-10-12 d1c6020dc36ce118ce9f13ba81caa70d7117d94c
server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
@@ -57,6 +57,8 @@
import java.net.UnknownHostException;
import java.sql.Ref;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -243,7 +245,9 @@
        homeResponse.setLeaseVideoUrl(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_TIPS_VIDEO).getCode());
        homeResponse.setPricingRules(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PRICING_RULE).getCode());
        homeResponse.setStopServeTips(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_TIPS).getCode());
        homeResponse.setIsStopServe(Constants.ZERO);
        homeResponse.setIsStopServe(this.checkTemporaryStop()?1:0);
        homeResponse.setIsBusiness(this.checkBusiness()?0:1);
        homeResponse.setUnBusinessTips("营业时间为"+ systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_STARTTIME).getCode() +" ~ "+systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_ENDTIME).getCode()+",请在营业时间内使用本系统");
        homeResponse.setAdList(adMapper.selectList(new QueryWrapper<Ad>()
                .eq("isdeleted",Constants.ZERO)
                .eq("status",Constants.ZERO)
@@ -637,9 +641,13 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已支付过定金,无法重复该操作");
        }
        //是否处于小程序停止服务时间内
        this.checkTemporaryStop();
        if(this.checkTemporaryStop()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_TIPS).getCode());
        };
        //是否处于营业时间
        this.checkBusiness();
        if(this.checkBusiness()){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"营业时间为"+ systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_STARTTIME).getCode() +" ~ "+systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_ENDTIME).getCode()+",请在营业时间内使用本系统");
        };
        Goodsorder goodsorder = new Goodsorder();
        goodsorder.setId(Constants.getUUID());
        goodsorder.setCreateDate(new Date());
@@ -675,21 +683,24 @@
     * 验证营业时间
     */
    @Override
    public void checkBusiness(){
    public Boolean checkBusiness(){
        String businessStartTime = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_STARTTIME).getCode();
        String businessEndTime = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_ENDTIME).getCode();
        String nowTime = DateUtil.getDate(new Date(),"HH:mm");
        LocalTime currentTime = LocalTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
        String nowTime = currentTime.format(formatter);
        if(Integer.valueOf(nowTime.replace(":",""))<= Integer.valueOf(businessStartTime.replace(":",""))
                ||Integer.valueOf(nowTime.replace(":","")) > Integer.valueOf(businessEndTime.replace(":",""))){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"营业时间为06:00 ~ 23:59,请在营业时间内使用本系统");
            return true;
        }
        return false;
    }
    /**
     * 临时停止服务 未交押金的用户,无法扫车使用;已经交过押金的用户可以继续扫码骑行;
     */
    @Override
    public void checkTemporaryStop(){
    public Boolean checkTemporaryStop(){
        if(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.IS_STOP_SERVE).getCode().equals(Constants.ONE)){
            String stopServeStartTime = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_STARTTIME).getCode();
            String stopServeEndTime = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_ENDTIME).getCode();
@@ -697,9 +708,10 @@
            long s = DateUtil.StringToDate(stopServeStartTime).getTime();
            long e = DateUtil.StringToDate(stopServeEndTime).getTime();
            if(e>System.currentTimeMillis()&&s<=System.currentTimeMillis()){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.STOP_SERVE_TIPS).getCode());
                return true;
            }
        }
        return false;
    }