Pu Zhibing
14 小时以前 aa72a1d1d8c792b322281f5ab01996bc62820b13
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/DriverController.java
@@ -9,7 +9,6 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.config.properties.GunsProperties;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
@@ -24,7 +23,6 @@
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.WeChatUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.QianYunTongConfig;
import com.stylefeng.guns.modular.system.util.zhenglian.CallbackUtil;
import com.stylefeng.guns.modular.system.util.zhenglian.TokenUtil;
import com.stylefeng.guns.modular.system.util.zhenglian.model.MessageBody;
@@ -51,6 +49,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.MessageFormat;
@@ -103,9 +102,6 @@
    
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
    @Autowired
    private GunsProperties gunsProperties;
    @Autowired
    private ICompanyService companyService;
@@ -115,9 +111,6 @@
    @Autowired
    private TDriverPromotionActivityService driverPromotionActivityService;
    @Autowired
    private QianYunTongConfig qianYunTongConfig;
    
    @Value("${wx.url}")
    private String ACCESS_TOKEN_URL;
@@ -136,6 +129,12 @@
    
    @Autowired
    private WeChatUtil weChatUtil;
    @Value("${filePath}")
    private String filePath;
    @Value("${qyt.admin_url}")
    private String adminUrl;
    
    /**
     * 获取短信验证码
@@ -530,9 +529,11 @@
                return ResultUtil.tokenErr();
            }
            Driver driver = driverService.selectById(uid);
            String areaCode = driver.getAreaCode();
            String areaCode = driver.getPlaceOfEmployment();
            TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>()
                    .eq("districtCode", areaCode)
                            .eq("state", 1)
                            .eq("remove", 0)
                    .eq("status", 2)
                    .last("LIMIT 1"));
            if(tDriverPromotionActivity!=null){
@@ -565,13 +566,16 @@
                accessToken = getAccessToken();
            }
            int index=0;
            if(ToolUtil.isEmpty(img)) {
            String urlLink = driver.getShareLink();
            if(ToolUtil.isEmpty(img) || ToolUtil.isEmpty(urlLink)) {
                RestTemplate rest = new RestTemplate();
                String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken;
//                String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken;
                String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
                Map<String, Object> param = new HashMap<>();
                param.put("path", "pages/home/home?driverId=" + uid);
                param.put("page", "pages/home/home");
                param.put("width", 430); //二维码尺寸
                param.put("scene", "driverId=" + uid);
                param.put("env_version", "trial"); //正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
                HttpRequest post = HttpUtil.createPost(url);
                post.body(JSON.toJSONString(param));
@@ -581,7 +585,6 @@
                redisTemplate.opsForValue().set("DRIVER_WX_IMG" + uid, img,30, TimeUnit.DAYS);
            }
            String urlLink = driver.getShareLink();
            if(ToolUtil.isEmpty(urlLink)) {
                index=1;
                String url1 = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + accessToken;
@@ -746,6 +749,7 @@
            if(null == position){
                position = new DriverPosition();
            }
            position.setDriverId(orderPosition.getDriverId());
            position.setPoint(point);
            mongoTemplate.save(position);
            //处理业务上的功能
@@ -1605,7 +1609,7 @@
            if(companyCities.isEmpty()){
                return ResultUtil.success(companyVos);
            }
            Wrapper<Company> in = new EntityWrapper<Company>().ne("type", 1).ne("flag", 3).in("id", companyCities.stream().map(CompanyCity::getCompanyId).collect(Collectors.toList()));
            Wrapper<Company> in = new EntityWrapper<Company>().eq("type", 2).ne("flag", 3).in("id", companyCities.stream().map(CompanyCity::getCompanyId).collect(Collectors.toList()));
            if(ToolUtil.isNotEmpty( name)){
                in.like("name", name);
@@ -1765,17 +1769,19 @@
                if (fileName == null || "".equals(fileName)) {
                    String appletPath = "pages/home/scanPage/scanPage";
                    //HttpURLConnection httpURLConnection = weChatUtil.getwxacodeunlimit(appletPath, "d=" + driverId + "&k=" + 0, "release",driverId);
                    InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId, "release");
                    InputStream inputStream = weChatUtil.getwxacodeunlimit(appletPath, "driverId=" + driverId, "trial");
                    if (inputStream != null) {
                        // 上传文件目录
                        fileName = UUID.randomUUID().toString() + ".png";
                        String fileSavePath = gunsProperties.getFileUploadPath() + "img\\";
                        FileUtil.writeFromStream(inputStream, fileName);
                        String pictureName = gunsProperties.getPictureServerAddress() + "img/" + fileName;
//                     fileName = OssUploadUtil.ossUploadByStream(driverId, inputStream);
                        System.out.println(pictureName);
                        driver.setQrCode(pictureName);
                        File file = FileUtil.writeFromStream(inputStream, new File(filePath + "/" + UUID.randomUUID().toString() + ".png"));
                        HttpRequest post = HttpUtil.createPost(adminUrl + "/upload/image");
                        post.form("file", file);
                        HttpResponse execute = post.execute();
                        int status = execute.getStatus();
                        if(200 != status){
                            throw new RuntimeException("上传图片异常");
                        }
                        driver.setQrCode(execute.body());
                        driverService.updateById(driver);
                        fileName = driver.getQrCode();
                    }
                }
                return ResultUtil.success(fileName);
@@ -1809,13 +1815,13 @@
            driver.setAuthState(3);
            driverService.updateById(driver);
            //开始验证当前账号是否在别处登录
            String value = (String) redisTemplate.opsForValue().get("DRIVER_" + driverId);
            String value = (String) redisTemplate.opsForValue().get("dache:DRIVER_" + driverId);
            if (ToolUtil.isNotEmpty(value)) {//将另外设备上的强迫下线
                //开始清除redis中无效的数据
                String key = (String) redisTemplate.opsForValue().get("DRIVER_" + driver.getPhone());
                String key = (String) redisTemplate.opsForValue().get("dache:DRIVER_" + driver.getPhone());
                redisTemplate.delete(key);//删除个人信息数据
                redisTemplate.delete("DRIVER_" + driver.getPhone());//删除后台冻结相关缓存
                redisTemplate.delete("DRIVER_" + driverId);//清除存储的token
                redisTemplate.delete("dache:DRIVER_" + driver.getPhone());//删除后台冻结相关缓存
                redisTemplate.delete("dache:DRIVER_" + driverId);//清除存储的token
            }
            return ResultUtil.success();
        } catch (Exception e) {
@@ -1831,8 +1837,15 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "当前设备IP地址", name = "ip", required = true, dataType = "String"),
            @ApiImplicitParam(value = "当前设备mac地址", name = "mac", required = true, dataType = "String"),
            @ApiImplicitParam(value = "01 证联收银台支付\n" +
                    "\t 04 HOME 页\n" +
                    "\t 06 申请免密签约\n" +
                    "\t 07 商户收银台支付\n" +
                    "\t 08 开户(绑卡)\n" +
                    "\t 09 开通支付账户\n" +
                    "\t 10 打开付款码", name = "type", required = true, dataType = "String"),
    })
    public ResultUtil<String> getZLToken(String ip, String mac, HttpServletRequest request){
    public ResultUtil<String> getZLToken(String ip, String mac, String type, HttpServletRequest request){
        try {
            Integer driverId = driverService.getUserIdFormRedis(request);
            if (null == driverId) {
@@ -1849,6 +1862,7 @@
            tradeTerminalInfo.setTerminal("1");
            tradeTerminalInfo.setMac(mac);
            tokenRequest.setTradeTerminalInfo(tradeTerminalInfo);
            tokenRequest.setType(type);
            String token = TokenUtil.getToken(tokenRequest);
            return ResultUtil.success(token);
        }catch (Exception e){