| | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.dingding.DingDingNotice; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.PositionUtil; |
| | | import com.doumee.core.utils.StringTools; |
| | | import com.doumee.core.wx.SendWxMessage; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.core.wx.WxMiniUtilService; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.BikesJoinMapper; |
| | | import com.doumee.dao.business.join.GoodsorderJoinMapper; |
| | | import com.doumee.dao.business.join.MemberRidesJoinMapper; |
| | | import com.doumee.dao.business.join.RefundJoinMapper; |
| | |
| | | import com.doumee.service.business.GoodsorderService; |
| | | import com.doumee.service.business.PricingRuleService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Service |
| | | public class Jtt808Service { |
| | | @Value("${tencent.map.remoteHost:}") |
| | | @Value("${tencent.map.remoteHost}") |
| | | private String mapHost; |
| | | @Value("${tencent.map.appKey:}") |
| | | @Value("${tencent.map.appKey}") |
| | | private String mapKey; |
| | | @Autowired |
| | | private MessageManager messageManager; |
| | |
| | | private GoodsorderService goodsorderService; |
| | | @Autowired |
| | | private BikesMapper bikesMapper; |
| | | @Autowired |
| | | private BikesJoinMapper bikesJoinMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | |
| | | @Autowired |
| | | private HolidaysMapper holidaysMapper; |
| | | |
| | | @Autowired |
| | | private SendWxMessage sendWxMessage; |
| | | |
| | | |
| | | @Autowired |
| | | PricingRuleService pricingRuleService; |
| | |
| | | Goodsorder gparam = new Goodsorder(); |
| | | gparam.setMemberId(param.getMemberId()); |
| | | gparam.setStatus(Constants.goodsorderStatus.pay); |
| | | gparam.setType(Constants.ZERO); |
| | | Goodsorder goodsorder = goodsorderService.findOne(gparam); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"无骑行订单记录"); |
| | |
| | | if(Constants.equalsInteger(rides.getStatus(),Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey()) |
| | | &&Constants.equalsInteger(rides.getType(),Constants.ONE)){ |
| | | //如果是电车并且是骑行中 进行关锁处理 |
| | | Bikes bike = getElecBikeByCode(rides.getBikeCode()); |
| | | //查询停车站点信息 |
| | | if(bike.getSiteId() ==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!"); |
| | | } |
| | | lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 |
| | | // Bikes bike = getElecBikeByCode(rides.getBikeCode()); |
| | | // //查询停车站点信息 |
| | | // if(bike.getSiteId() ==null){ |
| | | // throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!"); |
| | | // } |
| | | // lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 |
| | | backIds.add(rides.getId()); |
| | | rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车 |
| | | rides.setBackSiteId(bike.getSiteId());//还车站点 |
| | | // rides.setBackSiteId(bike.getSiteId());//还车站点 |
| | | |
| | | rides.setBackDate(new Date()); |
| | | Integer freeRentTime = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.FREE_RENT_TIME).getCode()); |
| | | Integer rideTime = DateUtil.betweenMin(rides.getRentDate(), rides.getBackDate()); |
| | | //计算骑行计费时长 |
| | | rides.setDuration( rideTime > freeRentTime ? rideTime : 0 ); |
| | | rides.setEditDate(rides.getBackDate()); |
| | | memberRidesJoinMapper.updateById(rides);//更新骑行状态为已还车 |
| | | } |
| | |
| | | if(memberRides ==null || memberRides.getBikeCode() == null){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"对不起,未查询到您当前有骑行中记录"); |
| | | } |
| | | Bikes bike = getElecBikeByCode(memberRides.getBikeCode()); |
| | | //查询停车位置是否符合停车位置规范 |
| | | checkPausePostionBiz(bike); |
| | | // Bikes bike = getElecBikeByCode(memberRides.getBikeCode()); |
| | | // //查询停车位置是否符合停车位置规范 |
| | | // checkPausePostionBiz(bike); |
| | | memberRides.setPauseDate(new Date()); |
| | | memberRides.setEditDate(memberRides.getBackDate()); |
| | | memberRides.setStatus(Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()); |
| | |
| | | } |
| | | } |
| | | |
| | | public void updateBikesInfo(List<T0200> list) { |
| | | public void updateBikesInfo(List<T0200> list) throws Exception{ |
| | | Date date = new Date(); |
| | | BigDecimal lowVoltage = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.LOW_VOLTAGE).getCode()); |
| | | String ddToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_TOKEN).getCode(); |
| | | String ddRobotCode = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_ROBOTCODE).getCode(); |
| | | String ddChatToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_CHATTOKEN).getCode(); |
| | | for(T0200 m : list){ |
| | | Bikes bike = new Bikes(); |
| | | bike.setDeviceSn(m.getClientId()); |
| | |
| | | .set(Bikes::getSiteId,site ==null?null:site.getId()) |
| | | .set( Bikes::getHeartDate,date) |
| | | .eq(Bikes::getId,bikes.getId())); |
| | | |
| | | if(bikes.getVoltage().compareTo(lowVoltage)>=Constants.ZERO |
| | | && bike.getVoltage().compareTo(lowVoltage)<Constants.ZERO){ |
| | | //发送钉钉通知 |
| | | DingDingNotice.lowVoltageNotice(bikes.getCode(), |
| | | PositionUtil.getTxMapAddrByLatAndLng(Double.valueOf(bike.getLatitude().toString()),Double.valueOf(bike.getLongitude().toString()),mapHost,mapKey) |
| | | ,Objects.nonNull(site)?site.getName():null, |
| | | ddToken, |
| | | ddRobotCode, |
| | | ddChatToken); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | Goodsorder goodsorder = goodsorderService.findOneByWrapper(new QueryWrapper<Goodsorder>() |
| | | .eq("isdeleted", Constants.ZERO) |
| | | .eq("status", Constants.goodsorderStatus.pay) |
| | | .eq("type", Constants.ZERO) |
| | | .eq("member_id", member.getId()) |
| | | .orderByDesc("create_date") |
| | | .last("limit 1")); |
| | |
| | | //根据车型查询计价方案 |
| | | isValidePricingType(bike,memberRides) ; |
| | | MemberRidesDetailResponse memberRidesDetailResponse = new MemberRidesDetailResponse(); |
| | | this.lockBikes(bike.getDeviceSn(),1); |
| | | // this.lockBikes(bike.getDeviceSn(),1); |
| | | //存储骑行记录 |
| | | memberRides.setId(Constants.getUUID()); |
| | | memberRides.setIsdeleted(Constants.ZERO); |
| | |
| | | memberRides.setOrdreId(goodsorder.getId()); |
| | | memberRides.setBikeCode(bike.getCode()); |
| | | memberRides.setRentDate(new Date()); |
| | | memberRides.setType(Constants.ZERO); |
| | | memberRides.setType(Constants.ONE); |
| | | memberRides.setBalance(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode())); |
| | | memberRides.setStatus(Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey()); |
| | | memberRides.setCloseStatus(Constants.ZERO); |
| | |
| | | /** |
| | | * 临时停车超时 自动还车 |
| | | */ |
| | | public void autoBackBike(){ |
| | | public void autoBackBike() throws WxErrorException { |
| | | List<MemberRides> memberRidesList = memberRidesJoinMapper.selectJoinList(MemberRides.class,new MPJLambdaWrapper<MemberRides>() |
| | | .selectAll(MemberRides.class) |
| | | .leftJoin(Goodsorder.class,Goodsorder::getId,MemberRides::getOrdreId) |
| | | .eq(Goodsorder::getStatus,Constants.ONE) |
| | | .eq(MemberRides::getIsdeleted,Constants.ZERO) |
| | | .eq(MemberRides::getType,Constants.ONE) |
| | | .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING) |
| | | .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()) |
| | | .apply(" NOW() >= t.create_date + INTERVAL '2 hours' ") |
| | | ); |
| | | |
| | |
| | | goodsorder.setEditDate(date); |
| | | goodsorder.setEditor(null); |
| | | goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides); |
| | | //发送小程序通知 |
| | | Member member = memberMapper.selectById(goodsorder.getMemberId()); |
| | | if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getOpenid())){ |
| | | sendWxMessage.bookingsCancel(member.getOpenid(),goodsorder.getId(), WxMiniConfig.wxMaService.getAccessToken(),timeOutRides.getBikeCode(),goodsorder.getPayDate(),goodsorder.getEndDate()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |