jiangping
2025-02-19 b7d7bb82334af8574ad2510b9fa2220581e3f9f2
server/services/src/main/java/com/doumee/core/wx/WxMiniUtilService.java
@@ -11,6 +11,7 @@
import com.doumee.core.utils.ImageDesignerUtil;
import com.doumee.dao.business.RefundMapper;
import com.doumee.dao.business.TransactionsMapper;
import com.doumee.dao.business.model.Bikes;
import com.doumee.dao.business.model.Locks;
import com.doumee.dao.business.model.Refund;
import com.doumee.dao.business.model.Transactions;
@@ -290,6 +291,41 @@
            e.printStackTrace();
        }
    }
    public void generateEbikeWXMiniCode(Bikes bikes, String token, String prePath, String path){
        if(Objects.isNull(token)){
            return;
        }
         String url =  "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+ token;
        String release =   systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.MINI_PROGRAMME_REALEASE).getCode();
        //生成图片上传OSS
        Map<String,Object> body = new HashMap<>();
        // 场景码,与前端约定,最终是需要前端解析
        body.put("scene",  Constants.EBIKE_PREFIX +bikes.getCode() );
        // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
//        body.put("env_version", "release");
        body.put("env_version", StringUtils.defaultString(release, "release"));
        // 透明,根据你的场景自行设置body参数
        body.put("is_hyaline", false);
        body.put("check_path", false);
        body.put("width", 290);
        body.put("page","pages/index/index");
        log.info("=========================================="+url+"\n"+JSONObject.toJSONString(body));
        try {
            InputStream inputStream  =HttpsUtil.postJson(url,JSONObject.toJSONString(body));;
            if (inputStream !=null) {
                String nowDate = DateUtil.getNowShortDate();
                String name =Constants.EBIKE_PREFIX+bikes.getCode()+"-"+nowDate+".png";
                String fileName =prePath+path+"/"+name;
//                File file = new File(prePath+path,locks.getSiteId()+"-"+locks.getCode()+"-"+nowDate+".png");
//                FileUtils.copyInputStreamToFile(inputStream,file);
                if(ImageDesignerUtil.graphicsGenerationIs(bikes.getCode(),inputStream,fileName)){
                    bikes.setImgurl(name);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 生成小程序码
     * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html