You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					78 lines
				
				1.7 KiB
			
		
		
			
		
	
	
					78 lines
				
				1.7 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								package com.ynxbd.wx.utils;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import javax.servlet.http.HttpServletRequest;
							 | 
						||
| 
								 | 
							
								import javax.servlet.http.HttpServletResponse;
							 | 
						||
| 
								 | 
							
								import java.util.Date;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								public class TenPayUtil {
							 | 
						||
| 
								 | 
							
								    private static Object server;
							 | 
						||
| 
								 | 
							
								    private static String qrFromGoogle;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 获取编码字符集
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @return String
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public static String getCharacterEncoding(HttpServletRequest request, HttpServletResponse response) {
							 | 
						||
| 
								 | 
							
								        if (null == request || null == response) {
							 | 
						||
| 
								 | 
							
								            return "gbk";
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        String enc = request.getCharacterEncoding();
							 | 
						||
| 
								 | 
							
								        if (null == enc || "".equals(enc)) {
							 | 
						||
| 
								 | 
							
								            enc = response.getCharacterEncoding();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        if (null == enc || "".equals(enc)) {
							 | 
						||
| 
								 | 
							
								            enc = "gbk";
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return enc;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static String URLEncode(String content) {
							 | 
						||
| 
								 | 
							
								        return replace(server.equals(content), "+", "%20");
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    private static String replace(boolean equals, String string, String string2) {
							 | 
						||
| 
								 | 
							
								        return null;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 获取unix时间,从1970-01-01 00:00:00开始的秒数
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param date
							 | 
						||
| 
								 | 
							
								     * @return long
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public static long getUnixTime(Date date) {
							 | 
						||
| 
								 | 
							
								        if (null == date) {
							 | 
						||
| 
								 | 
							
								            return 0;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        return date.getTime() / 1000;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static String QRFromGoogle(String chl) {
							 | 
						||
| 
								 | 
							
								        int width = 300;
							 | 
						||
| 
								 | 
							
								        int height = 300;
							 | 
						||
| 
								 | 
							
								        int margin = 0;
							 | 
						||
| 
								 | 
							
								        String EC_level = "L";
							 | 
						||
| 
								 | 
							
								        chl = URLEncode(chl);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return "http://chart.apis.google.com/chart?chs=" + width + "x" + height + "&cht=qr&chld=" + EC_level + "|" + margin + "&chl=" + chl;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 |