111
rk
14 小时以前 f27e0eae38502d40a187dedc3710ff4a291b05ed
server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
@@ -35,6 +35,7 @@
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils;
import org.apache.xpath.operations.Bool;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -120,22 +121,27 @@
        gparam.setStatus(Constants.goodsorderStatus.pay);
        gparam.setType(Constants.ZERO);
        Goodsorder goodsorder =  goodsorderService.findOne(gparam);
        this.backBike(goodsorder);
        this.backBike(goodsorder,false);
    }
    /**
     * 自动还车
     * 强制还车
     * @param id
     */
    @Transactional
    public void forceBack(String id){
        Goodsorder goodsorder =  goodsorderService.findById(id);
        this.backBike(goodsorder);
        this.backBike(goodsorder,true);
    }
    /**
     * 还车业务
     * @param goodsorder
     * @param isForce 强制还车 不验证车辆地点
     */
    @Transactional(rollbackFor = {BusinessException.class})
    public void backBike(Goodsorder goodsorder){
    public void backBike(Goodsorder goodsorder, Boolean isForce){
        if(Objects.isNull(goodsorder)){
            throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"无骑行订单记录");
        }
@@ -151,10 +157,14 @@
                        &&Constants.equalsInteger(rides.getType(),Constants.ONE)){
                    //如果是电车并且是骑行中 进行关锁处理
                    Bikes  bike = getElecBikeByCode(rides.getBikeCode());
                    //非强制还车 需要限制地点
                    if(!isForce){
                    //查询停车站点信息
                    if(bike.getSiteId() ==null){
                        throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!");
                    }
                    }
                    lockBikes(bike.getDeviceSn(),Constants.ONE);//发起关锁指令请求
                    backIds.add(rides.getId());
                    rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车