| | |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.ID; |
| | | import com.doumee.dao.business.RefundMapper; |
| | | import com.doumee.dao.business.TransactionsMapper; |
| | |
| | | import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; |
| | | import com.github.binarywang.wxpay.bean.result.WxPayRefundResult; |
| | | import com.github.binarywang.wxpay.exception.WxPayException; |
| | | import io.netty.handler.codec.base64.Base64Decoder; |
| | | import io.netty.handler.codec.base64.Base64Encoder; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | | import okhttp3.Response; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import sun.misc.BASE64Decoder; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | |
| | | * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html |
| | | * @return |
| | | */ |
| | | public void generateWXMiniCode(Locks locks){ |
| | | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.ACCESS_TOKEN); |
| | | public void generateWXMiniCode(Locks locks,SystemDictData systemDictData,String prePath,String path){ |
| | | |
| | | if(Objects.isNull(systemDictData)){ |
| | | return; |
| | | } |
| | |
| | | body.put("env_version", "release"); |
| | | // 透明,根据你的场景自行设置body参数 |
| | | body.put("is_hyaline", false); |
| | | // body.put("page","pages/index/index"); |
| | | body.put("check_path", false); |
| | | body.put("page","pages/index/index"); |
| | | OkHttpClient client = new OkHttpClient().newBuilder().build(); |
| | | okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json"); |
| | | okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSONObject.toJSONString(body)); |
| | |
| | | Response response = client.newCall(request).execute(); |
| | | if (response.isSuccessful()) { |
| | | InputStream inputStream = new ByteArrayInputStream(response.body().bytes()); |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[1024]; |
| | | int len = -1; |
| | | while ((len = inputStream.read(buffer)) != -1) { |
| | | baos.write(buffer, 0, len); |
| | | } |
| | | |
| | | locks.setInfo("data:mediatype;base64," + Base64.getEncoder().encodeToString(baos.toByteArray())); |
| | | |
| | | // FileOutputStream out = new FileOutputStream("d:\\test.png"); |
| | | // byte[] buffer = new byte[8192]; |
| | | // int bytesRead = 0; |
| | | // while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) { |
| | | // out.write(buffer, 0, bytesRead); |
| | | // } |
| | | // out.flush(); |
| | | // inputStream.close(); |
| | | // out.close(); |
| | | String nowDate = DateUtil.getNowShortDate(); |
| | | File file = new File(prePath+path,locks.getSiteId()+"-"+locks.getCode()+"-"+nowDate+".png"); |
| | | FileUtils.copyInputStreamToFile(inputStream,file); |
| | | locks.setInfo(locks.getSiteId()+"-"+locks.getCode()+"-"+nowDate+".png"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |