| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.heredata.hos.model.bucket.Bucket; |
| | | import com.supersavedriving.driver.core.common.constant.JwtConstants; |
| | | import com.supersavedriving.driver.core.shiro.ShiroKit; |
| | | import com.supersavedriving.driver.core.shiro.ShiroUser; |
| | |
| | | import com.supersavedriving.driver.modular.system.util.MiniPay.MiniAppPay; |
| | | import com.supersavedriving.driver.modular.system.util.huawei.OBSUtil; |
| | | import com.supersavedriving.driver.modular.system.util.mongodb.model.Location; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.NCOSSUtil; |
| | | import com.supersavedriving.driver.modular.system.util.qianyuntong.QianYunTongConfig; |
| | | import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.WeChatUtil; |
| | | import com.supersavedriving.driver.modular.system.util.weChat.model.Code2Session; |
| | |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @Resource |
| | | private QianYunTongConfig qianYunTongConfig; |
| | | |
| | | @Autowired |
| | | private IDriverOnlineTimeService driverOnlineTimeService; |
| | |
| | | //生成小程序二维码 |
| | | public String wechatMiniProgramORCode(Integer driverId) throws Exception{ |
| | | InputStream release = weChatUtil.getwxacodeunlimit("pages/index/index", "driverId=" + driverId, "release"); |
| | | String s = OssUploadUtil.ossUpload(release, "driver_" + driverId + "_" + UUIDUtil.getNumberRandom(5) + ".jpg"); |
| | | return s; |
| | | String pictureName = "driver_" + driverId + ".png"; |
| | | QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig(); |
| | | String bucketName = qianYunTongConfig1.getBucketName(); |
| | | Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName); |
| | | if (null == grjyTest) { |
| | | //创建桶 |
| | | Boolean bucket = NCOSSUtil.createBucket(bucketName); |
| | | if (!bucket) { |
| | | throw new RuntimeException("创建存储桶失败"); |
| | | } |
| | | //设置桶策略 |
| | | String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}"; |
| | | Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText); |
| | | if (!bucketPolicy) { |
| | | throw new RuntimeException("设置桶策略失败"); |
| | | } |
| | | } |
| | | //上传对象 |
| | | String key = "imgs/daijia/driver/" + pictureName; |
| | | String object = NCOSSUtil.putObject(bucketName, key, release); |
| | | if (null == object) { |
| | | throw new RuntimeException("上传图片失败"); |
| | | } |
| | | |
| | | return "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key; |
| | | } |
| | | //司机下单二维码 |
| | | public String wechatMiniOrderQRCode(Integer driverId) throws Exception{ |
| | | InputStream release = weChatUtil.getwxacodeunlimitOrder("pages/index/index", "driverIds=" + driverId, "release"); |
| | | String s = OssUploadUtil.ossUpload(release, "driverOrder_" + driverId + "_" + UUIDUtil.getNumberRandom(5) + ".jpg"); |
| | | return s; |
| | | String pictureName = "driver_" + driverId + ".png"; |
| | | QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig(); |
| | | String bucketName = qianYunTongConfig1.getBucketName(); |
| | | Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName); |
| | | if (null == grjyTest) { |
| | | //创建桶 |
| | | Boolean bucket = NCOSSUtil.createBucket(bucketName); |
| | | if (!bucket) { |
| | | throw new RuntimeException("创建存储桶失败"); |
| | | } |
| | | //设置桶策略 |
| | | String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}"; |
| | | Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText); |
| | | if (!bucketPolicy) { |
| | | throw new RuntimeException("设置桶策略失败"); |
| | | } |
| | | } |
| | | //上传对象 |
| | | String key = "imgs/daijia/driver/" + pictureName; |
| | | String object = NCOSSUtil.putObject(bucketName, key, release); |
| | | if (null == object) { |
| | | throw new RuntimeException("上传图片失败"); |
| | | } |
| | | |
| | | return "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key; |
| | | } |
| | | |
| | | |
| | |
| | | Double lat = driverPositionWarpper.getLat(); |
| | | Integer driverId = driverPositionWarpper.getDriverId(); |
| | | Integer orderId = driverPositionWarpper.getOrderId(); |
| | | redisUtil.setStrValue("DRIVER" + driverId, lon + "," + lat, 30); |
| | | 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); |
| | | if (Objects.isNull(old)) { |