| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @Autowired |
| | | private IDriverOnlineTimeService driverOnlineTimeService; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | |
| | | if(token.length() > 16){ |
| | | key = token.substring(token.length() - 16); |
| | | } |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 7 * 24 * 60 * 60);//7天 |
| | | redisUtil.setStrValue("DRIVER_" + phone, key, 7 * 24 * 60 * 60);//7天 |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 94608000);//7天 |
| | | redisUtil.setStrValue("DRIVER_" + phone, key, 94608000);//7天 |
| | | |
| | | //下线 |
| | | for (int i = 0; i < 5; i++) { |
| | |
| | | //找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(lon), Double.valueOf(lat)); |
| | | //构造半径 |
| | | Distance distanceR = new Distance(5D, Metrics.KILOMETERS); |
| | | Distance distanceR = new Distance(10D, Metrics.KILOMETERS); |
| | | //画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | // 构造query对象 |
| | |
| | | */ |
| | | public void addDurationCredits(Integer driverId) throws Exception { |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | String today = sdf1.format(new Date()); |
| | | String[] s = value.split("_"); |
| | | if(!today.equals(s[1])){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | Integer second = Integer.valueOf(s[0]) + 5; |
| | | Integer time = Integer.valueOf(s[2]); |
| | | |
| | | SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 4)); |
| | | if(null == systemConfig){ |
| | | return; |
| | |
| | | long end = sdf.parse(sdf1.format(new Date()) + " " + num2 + ":00").getTime(); |
| | | long l = System.currentTimeMillis(); |
| | | if(start <= l && end > l){ |
| | | Driver driver = this.selectById(driverId); |
| | | String value = redisUtil.getValue("ONLINE" + driverId); |
| | | if(ToolUtil.isEmpty(value)){ |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | String today = sdf1.format(new Date()); |
| | | String[] s = value.split("_"); |
| | | if(!today.equals(s[1])){ |
| | | //修改在线时长记录 |
| | | DriverOnlineTime driverOnlineTime = driverOnlineTimeService.selectOne(new EntityWrapper<DriverOnlineTime>().eq("driverId", driverId).eq("DATE_FORMAT(`day`, '%Y-%m-%d')", s[1])); |
| | | if(null != driverOnlineTime){ |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.updateById(driverOnlineTime); |
| | | }else{ |
| | | driverOnlineTime = new DriverOnlineTime(); |
| | | driverOnlineTime.setDriverId(driverId); |
| | | driverOnlineTime.setDay(sdf1.parse(s[1])); |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.insert(driverOnlineTime); |
| | | } |
| | | driver.setOnlineTime(new BigInteger(s[0])); |
| | | this.updateById(driver); |
| | | redisUtil.setStrValue("ONLINE" + driverId, "0_" + sdf1.format(new Date()) + "_0", 25 * 60 * 60); |
| | | return; |
| | | } |
| | | Integer second = Integer.valueOf(s[0]) + 5; |
| | | Integer time = Integer.valueOf(s[2]); |
| | | |
| | | int h = Double.valueOf(second / 3600).intValue(); |
| | | if(h > 0 && h > time){ |
| | | Driver driver = this.selectById(driverId); |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | |
| | | accountChangeDetail.setNewData(driver.getIntegral().doubleValue()); |
| | | accountChangeDetail.setExplain("在线时长奖励"); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | driver.setOnlineTime(new BigInteger(s[0])); |
| | | this.updateById(driver); |
| | | time++; |
| | | |
| | | //修改在线时长记录 |
| | | DriverOnlineTime driverOnlineTime = driverOnlineTimeService.selectOne(new EntityWrapper<DriverOnlineTime>().eq("driverId", driverId).eq("DATE_FORMAT(`day`, '%Y-%m-%d')", s[1])); |
| | | if(null != driverOnlineTime){ |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.updateById(driverOnlineTime); |
| | | }else{ |
| | | driverOnlineTime = new DriverOnlineTime(); |
| | | driverOnlineTime.setDriverId(driverId); |
| | | driverOnlineTime.setDay(sdf1.parse(s[1])); |
| | | driverOnlineTime.setOnlineTime(new BigInteger(s[0])); |
| | | driverOnlineTimeService.insert(driverOnlineTime); |
| | | } |
| | | } |
| | | redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time); |
| | | } |
| | | redisUtil.setStrValue("ONLINE" + driverId, second + "_" + s[1] + "_" + time); |
| | | |
| | | } |
| | | |
| | | |