| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | 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; |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @Autowired |
| | | private IDriverOnlineTimeService driverOnlineTimeService; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | |
| | | //新账号 |
| | | if(null == driver){ |
| | | driver = new Driver(); |
| | | driver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | driver.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | try { |
| | | driver = setDriverParamete(driver, driverRegisterWarpper); |
| | | }catch (Exception e){ |
| | |
| | | Integer num7 = JSON.parseObject(systemConfig.getContent()).getInteger("num7"); |
| | | if(num7 > 0){ |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setType(2); |
| | |
| | | driver.setCityCode(branchOffice.getCityCode()); |
| | | driver.setAreaCode(branchOffice.getDistrictCode()); |
| | | driver.setAreaName(branchOffice.getDistrictName()); |
| | | driver.setInviterType(driverRegisterWarpper.getInviterType()); |
| | | driver.setInviterId(driverRegisterWarpper.getInviterId()); |
| | | if(null != driverRegisterWarpper.getInviterId()){ |
| | | driver.setInviterType(driverRegisterWarpper.getInviterType()); |
| | | driver.setInviterId(driverRegisterWarpper.getInviterId()); |
| | | } |
| | | driver.setApprovalStatus(1); |
| | | driver.setApprovalNotes(""); |
| | | driver.setApprovalTime(null); |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil<TokenWarpper> driverLogin(String receiver, String phone, String code) throws Exception { |
| | | if(ToolUtil.isEmpty(receiver)){ |
| | | receiver = "+86"; |
| | | } |
| | | String value = redisUtil.getValue(receiver + phone); |
| | | if(!"12345".equals(code) && ToolUtil.isEmpty(value)){ |
| | | return ResultUtil.error("短信验证码无效"); |
| | |
| | | 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(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driverId); |
| | | accountChangeDetail.setType(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); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | DriverInfoWarpper driverInfo = new DriverInfoWarpper(); |
| | | BeanUtils.copyProperties(driver, driverInfo); |
| | | driverInfo.setWithdrawBalance(driver.getBalance()); |
| | | driverInfo.setBalance(driver.getBalance() + driver.getBackgroundBalance());//司机充值+平台充值 |
| | | driverInfo.setCommission(driver.getCommission() + driver.getCouponBalance());//司机订单收入+司机佣金收入+司机优惠券收入+司机折扣收入 |
| | | driverInfo.setBalance(new BigDecimal(driver.getBalance()).add(new BigDecimal(driver.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());//司机充值+平台充值 |
| | | driverInfo.setCommission(new BigDecimal(driver.getCommission()).add(new BigDecimal(driver.getCouponBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue());//司机订单收入+司机佣金收入+司机优惠券收入+司机折扣收入 |
| | | YouTuiDriver youTuiDriver = youTuiDriverService.selectOne(new EntityWrapper<YouTuiDriver>().eq("driverId", uid) |
| | | .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1")); |
| | | if(null != youTuiDriver){ |
| | |
| | | List<AccountChangeDetail> list = new ArrayList<>(); |
| | | for (Driver driver : drivers) { |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver.getId()); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | |
| | | Driver driver = this.selectById(uid); |
| | | //调起微信 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3); |
| | | String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | RechargeRecord rechargeRecord = new RechargeRecord(); |
| | | rechargeRecord.setType(2); |
| | | rechargeRecord.setUserId(uid); |
| | |
| | | |
| | | PaymentOrder paymentOrder = new PaymentOrder(); |
| | | paymentOrder.setBizOrderId(out_trade_no); |
| | | paymentOrder.setAmount(String.valueOf(Double.valueOf(amount * 100).intValue())); |
| | | paymentOrder.setAmount(new BigDecimal(amount).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); |
| | | paymentOrder.setOrderName("账户充值"); |
| | | paymentOrder.setPayType("WX_MINI"); |
| | | paymentOrder.setTransferType("0"); |
| | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver1.getId()); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("账户充值"); |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance()); |
| | | driver1.setBalance(driver1.getBalance() + rechargeRecord1.getAmount()); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance()); |
| | | accountChangeDetail.setOldData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | driver1.setBalance(new BigDecimal(driver1.getBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | accountChangeDetail.setNewData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | DriverServiceImpl.this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(rechargeRecord1.getUserId()); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); |
| | | accountChangeDetail.setChangeType(3); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setCreateTime(new Date()); |
| | | accountChangeDetail.setExplain("账户充值"); |
| | | accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance()); |
| | | driver1.setBalance(driver1.getBalance() + rechargeRecord1.getAmount()); |
| | | accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance()); |
| | | accountChangeDetail.setOldData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | driver1.setBalance(new BigDecimal(driver1.getBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | accountChangeDetail.setNewData(new BigDecimal(driver1.getBalance()).add(new BigDecimal(driver1.getBackgroundBalance())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | this.updateById(driver1); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | |
| | | public ResultUtil microenterprise(Integer uid, String name, String number, String phone, String notifyUrl) throws Exception { |
| | | Driver driver = this.selectById(uid); |
| | | Register registerVO = new Register(); |
| | | registerVO.setMerUserId("driver_" + uid); |
| | | registerVO.setMerUserId(driver.getCode());//"driver_" + uid |
| | | registerVO.setPhone(phone); |
| | | registerVO.setUserType("0"); |
| | | registerVO.setUserName(name); |