| | |
| | | import com.supersavedriving.driver.modular.system.util.weChat.WeChatUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.model.Code2Session; |
| | | import com.supersavedriving.driver.modular.system.warpper.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.authc.SimpleAuthenticationInfo; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | |
| | | * @author pzb |
| | | * @Date 2023/2/8 18:52 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements IDriverService { |
| | | |
| | |
| | | String pictureName = "driver_" + driverId + ".png"; |
| | | File file = FileUtil.writeFromStream(release, new File(filePath + pictureName)); |
| | | HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image"); |
| | | HttpRequest form = post.form("file", file); |
| | | HttpResponse execute = form.execute(); |
| | | post.form("file", file); |
| | | HttpResponse execute = post.execute(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | |
| | | String pictureName = "driver_" + driverId + ".png"; |
| | | File file = FileUtil.writeFromStream(release, new File(filePath + pictureName)); |
| | | HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image"); |
| | | HttpRequest form = post.form("file", file); |
| | | HttpResponse execute = form.execute(); |
| | | post.form("file", file); |
| | | HttpResponse execute = post.execute(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | |
| | | tokenWarpper.setValidTime(7200L); |
| | | tokenWarpper.setIsSetPassword(ToolUtil.isEmpty(driver.getPassword()) ? 0 : 1); |
| | | |
| | | String RYToken = rongYunUtil.getToken(driver.getId().toString(), driver.getName(), driver.getAvatar()); |
| | | if(ToolUtil.isNotEmpty(RYToken)){ |
| | | JSONObject jsonObject = JSON.parseObject(RYToken); |
| | | Integer code1 = jsonObject.getInteger("code"); |
| | | if(200 == code1){ |
| | | tokenWarpper.setRytoken(jsonObject.getString("token")); |
| | | } |
| | | } |
| | | |
| | | if(ToolUtil.isEmpty(driver.getReferralCode())){ |
| | | String s = wechatMiniProgramORCode(driver.getId()); |
| | | driver.setReferralCode(s); |
| | | this.updateById(driver); |
| | | } |
| | | if(ToolUtil.isEmpty(driver.getOrderQRCode())){ |
| | | String s = wechatMiniOrderQRCode(driver.getId()); |
| | | driver.setOrderQRCode(s); |
| | | this.updateById(driver); |
| | | } |
| | | // String RYToken = rongYunUtil.getToken(driver.getId().toString(), driver.getName(), driver.getAvatar()); |
| | | // if(ToolUtil.isNotEmpty(RYToken)){ |
| | | // JSONObject jsonObject = JSON.parseObject(RYToken); |
| | | // Integer code1 = jsonObject.getInteger("code"); |
| | | // if(200 == code1){ |
| | | // tokenWarpper.setRytoken(jsonObject.getString("token")); |
| | | // } |
| | | // } |
| | | // todo 正式放开 |
| | | // if(ToolUtil.isEmpty(driver.getReferralCode())){ |
| | | // String s = wechatMiniProgramORCode(driver.getId()); |
| | | // driver.setReferralCode(s); |
| | | // this.updateById(driver); |
| | | // } |
| | | // if(ToolUtil.isEmpty(driver.getOrderQRCode())){ |
| | | // String s = wechatMiniOrderQRCode(driver.getId()); |
| | | // driver.setOrderQRCode(s); |
| | | // this.updateById(driver); |
| | | // } |
| | | return ResultUtil.success(tokenWarpper); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | String s = ShiroKit.md5(MD5AndKL.MD5("123456"), "i#sm4"); |
| | | System.out.println(s); |
| | | } |
| | | |
| | | /** |
| | | * 司机密码登录 |
| | |
| | | redisUtil.setStrValue(key, driver.getId().toString(), 94608000);//7天 |
| | | redisUtil.setStrValue("DRIVER_" + phone, key, 94608000);//7天 |
| | | |
| | | // todo 正式放开 |
| | | //下线 |
| | | for (int i = 0; i < 5; i++) { |
| | | Integer code = pushUtil.pushOffline(driver.getId(), 2); |
| | | if(200 == code){ |
| | | break; |
| | | } |
| | | } |
| | | // for (int i = 0; i < 5; i++) { |
| | | // Integer code = pushUtil.pushOffline(driver.getId(), 2); |
| | | // if(200 == code){ |
| | | // break; |
| | | // } |
| | | // } |
| | | return token; |
| | | } |
| | | return ""; |
| | |
| | | Double lat = driverPositionWarpper.getLat(); |
| | | Integer driverId = driverPositionWarpper.getDriverId(); |
| | | Integer orderId = driverPositionWarpper.getOrderId(); |
| | | log.info("存储地理空间:{}", driverPositionWarpper); |
| | | redisUtil.setStrValue("daijia:DRIVER" + driverId, lon + "," + lat, 30); |
| | | Query query = Query.query(Criteria.where("driverId").is(driverId)); |
| | | Location old = this.mongoTemplate.findOne(query, Location.class); |