| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.supersavedriving.driver.modular.system.util.MallBook.util.TrhRequest; |
| | | import com.supersavedriving.driver.modular.system.util.*; |
| | | 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.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.File; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | @Value("${qyt.admin_url}") |
| | | private String adminUrl; |
| | | |
| | | @Autowired |
| | | private IAppUserService appUserService; |
| | | |
| | |
| | | |
| | | @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"; |
| | | 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(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | | } |
| | | return execute.body(); |
| | | } |
| | | //司机下单二维码 |
| | | 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"; |
| | | 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(); |
| | | int status = execute.getStatus(); |
| | | if(200 != status){ |
| | | throw new RuntimeException("上传图片异常"); |
| | | } |
| | | return execute.body(); |
| | | } |
| | | |
| | | |
| | |
| | | if(null == driverWork){ |
| | | return ResultUtil.error("请先上班"); |
| | | } |
| | | String value = redisUtil.getValue("DRIVER" + uid); |
| | | String value = redisUtil.getValue("daijia:DRIVER" + uid); |
| | | List<String> list = new ArrayList<>(); |
| | | if(ToolUtil.isNotEmpty(value)){ |
| | | String[] split = value.split(","); |
| | |
| | | i = 3; |
| | | } |
| | | } |
| | | String value1 = redisUtil.getValue("DRIVER" + s.getDriverId()); |
| | | String value1 = redisUtil.getValue("daijia:DRIVER" + s.getDriverId()); |
| | | if(s.getDriverId().compareTo(uid) != 0 && ToolUtil.isNotEmpty(value1)){ |
| | | list.add(s.getLocation().getX() + "," + s.getLocation().getY()+","+i+","+driver.getName()); |
| | | } |
| | |
| | | .eq("state", 2).last(" and failureTime > now() order by failureTime limit 0, 1")); |
| | | if(null != youTuiDriver){ |
| | | driverInfo.setYouTuiEnd(youTuiDriver.getType() == 1 ? youTuiDriver.getFailureTime().getTime() : youTuiDriver.getEndTime().getTime()); |
| | | driverInfo.setType(youTuiDriver.getType()); |
| | | driverInfo.setSurplusQuantity(youTuiDriver.getSurplusQuantity()); |
| | | } |
| | | List<Integer> state = Arrays.asList(107, 108, 109); |
| | | int count = orderService.selectCount(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", state).last(" and DATE_FORMAT(createTime, '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d')")); |