Browse Source

H5管理员

xubh 4 năm trước cách đây
mục cha
commit
4b011626f2

+ 149 - 0
src/main/java/com/minpay/common/util/UpLoadFile.java

@@ -0,0 +1,149 @@
+package com.minpay.common.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.net.ftp.FTPClient;
+
+import com.min.util.DateUtil;
+import com.minpay.common.service.IPropertiesService;
+import com.minpay.db.table.mapper.PubSysparMapper;
+import com.minpay.db.table.model.PubSyspar;
+import com.minpay.db.table.model.PubSysparExample;
+import com.startup.minpay.frame.exception.MINBusinessException;
+import com.startup.minpay.frame.service.base.IMINDataBaseService;
+import com.startup.minpay.frame.service.base.Service;
+import com.startup.minpay.util.RandomUtil;
+
+public class UpLoadFile {
+	/**
+	 * 上传文件方法
+	 * @throws MINBusinessException,FileNotFoundException 
+	 * fileType  		00图片
+	 * size				缓冲区
+	 * renameFlag		是否重命名
+	 * 
+	 */
+	public static String uploadImg(InputStream in,String fileNameSuffix,String channel, String fileType) throws MINBusinessException,FileNotFoundException{
+//		获取根路径(nginx文件服务器路径)
+     	String basePath = Service.lookup(IPropertiesService.class)
+     				.getSystemProperties().get(channel+"_FILE_SERVER_BASE_PATH").getKey();// 为nginx根路径
+		String nowDate = DateUtil.format(new Date(), "yyyyMMdd");
+		// 获取web服务器访问路径
+		String baseUrl = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FILE_SERVER_URL").getKey(); // 为nginx访问路径
+				
+		// 文件类型存放路径
+		String filePath = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FILE_PATH_" + fileType).getKey();
+		String fileTypePath = basePath+filePath;//"/home/ftp_file/img/btxzs/";
+		//获取ftp 参数
+		String ftpIp = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FTP_IP").getKey(); // 上传IP
+		String ftpPort = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FTP_PORT").getKey(); // 上传端口
+		String ftpName = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FTP_USERNAME").getKey(); // 上传用户名
+		String ftpPwd = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_FTP_PASSWORD").getKey(); // 上传密码
+				
+		/*List<String> gauth = new ArrayList<String>();
+		gauth.add(channel+"_FTP_IP");
+		gauth.add(channel+"_FTP_PORT");
+		gauth.add(channel+"_FTP_USERNAME");
+		gauth.add(channel+"_FTP_PASSWORD");
+		PubSysparExample examples = new PubSysparExample();
+		examples.createCriteria().andCodeIn(gauth);
+//		查询ftp需要参数
+		List<PubSyspar> productRel = Service.lookup(IMINDataBaseService.class)
+				.getMybatisMapper(PubSysparMapper.class).selectByExample(examples);
+		String logoCode = null;
+		String ftpIP = null;
+		String ftpP = null;
+		String ftpUserName = null;
+		String ftpPassword = null;
+		int ftpPorti = 0;
+		for (int i = 0; i < productRel.size(); i++) {
+			logoCode = productRel.get(i).getCode();
+			if (logoCode.equals(FTPIP)){
+				ftpIP = productRel.get(i).getValue();
+			}else if (logoCode.equals(FTPPORT)){
+				ftpPort = productRel.get(i).getValue();
+			}else if (logoCode.equals(FTPUSERNAME)){
+				ftpUserName = productRel.get(i).getValue();
+			}else if (logoCode.equals(FTPPASSWORD)){
+				ftpPassword = productRel.get(i).getValue();
+			}
+		}
+		ftpPorti = Integer.parseInt(ftpPort);*/
+		byte[] buffer = new byte[512];// 缓冲区
+//		InputStream in = null;
+		File file = new File(basePath);
+		FileOutputStream out = null;
+		String saveFileName = "";
+		String subDir = "";
+		try {
+			/*String fileName = file.getName();
+			if (fileName.indexOf("\\") != -1) {
+				int le = fileName.lastIndexOf("\\");
+				fileName = fileName.substring(le + 1, fileName.length());
+			}
+			if (fileName.indexOf(".") == -1) {
+				throw new MINBusinessException("文件名称格式异常,请检查");
+			}
+			// 文件名后缀
+			String fileNameSuffix = fileName.split("\\.")[fileName.split("\\.").length - 1];*/
+			// 文件重命名
+//			if (renameFlag) {
+				String random = RandomUtil.generateNumber(6);// 获取6位随机数字 防止重复
+				saveFileName = new Date().getTime() + random + "."
+						+ fileNameSuffix;
+//			} else {
+//				saveFileName = fileTypePath + fileName;
+//			}
+//			in = new FileInputStream(file);
+
+			//subDir = "baotuan/img/" + nowDate +"/";
+			subDir = filePath + nowDate +"/";
+
+			FtpClientEntity a = new FtpClientEntity();
+			int ftpP = 21;
+			if(!StringUtils.isEmpty(ftpPort)){
+				ftpP = Integer.valueOf(ftpPort);
+			}
+			FTPClient ftp = a.getConnectionFTP(ftpIp, ftpP, ftpName,ftpPwd);
+//			FTPClient ftp = a.getConnectionFTP(ftpIP, ftpPorti, ftpUserName,
+//					ftpPassword);
+			a.uploadFile(ftp, basePath, subDir, saveFileName, in);
+			a.closeFTP(ftp);
+		}finally{
+			try {
+				in.close();
+			} catch (IOException e2) {
+				e2.printStackTrace();
+			}
+		}
+//		String url = "https://baotuan.keao.tech/".concat(subDir).concat(saveFileName);
+		String url = baseUrl.concat(subDir).concat(saveFileName);
+		return url;
+	}
+	/**
+	 * 获取文件名后缀
+	 * @throws MINBusinessException 
+	 * @throws FileNotFoundException 
+	 */
+	public static String uploadImg(InputStream in, String channel) throws FileNotFoundException, MINBusinessException{
+		String fileNameSuffix = "png";
+		return uploadImg(in,fileNameSuffix, channel,"00");
+	}
+	
+}
+	

+ 109 - 0
src/main/java/com/minpay/huicai/util/EquCodeCreateUtil.java

@@ -0,0 +1,109 @@
+package com.minpay.huicai.util;
+
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Hashtable;
+
+import javax.imageio.ImageIO;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.BinaryBitmap;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.LuminanceSource;
+import com.google.zxing.ReaderException;
+import com.google.zxing.Result;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.HybridBinarizer;
+import com.google.zxing.qrcode.QRCodeReader;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import com.itextpdf.text.pdf.qrcode.*;
+
+/**
+ * 二维码生成和读的工具类
+ *
+ */
+public class EquCodeCreateUtil {
+    
+    /**
+     * 生成包含字符串信息的二维码图片
+     * @param outputStream 文件输出流路径
+     * @param content 二维码携带信息
+     * @param qrCodeSize 二维码图片大小
+     * @param imageFormat 二维码的格式
+     * @throws WriterException 
+     * @throws IOException 
+     */
+    public static boolean createQrCode(OutputStream outputStream, String content, int qrCodeSize, String imageFormat) throws WriterException, IOException{  
+            //设置二维码纠错级别MAP
+            Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
+            hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);  // 矫错级别  
+            QRCodeWriter qrCodeWriter = new QRCodeWriter();
+            //创建比特矩阵(位矩阵)的QR码编码的字符串  
+            BitMatrix byteMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize, hintMap);
+            // 使BufferedImage勾画QRCode  (matrixWidth 是行二维码像素点)
+            int matrixWidth = byteMatrix.getWidth();  
+            BufferedImage image = new BufferedImage(matrixWidth-200, matrixWidth-200, BufferedImage.TYPE_INT_RGB);
+            image.createGraphics();  
+            Graphics2D graphics = (Graphics2D) image.getGraphics();  
+            graphics.setColor(Color.WHITE);  
+            graphics.fillRect(0, 0, matrixWidth, matrixWidth);  
+            // 使用比特矩阵画并保存图像
+            graphics.setColor(Color.BLACK);  
+            for (int i = 0; i < matrixWidth; i++){
+                for (int j = 0; j < matrixWidth; j++){
+                    if (byteMatrix.get(i, j)){
+                        graphics.fillRect(i-100, j-100, 1, 1);  
+                    }
+                }
+            }
+            return ImageIO.write(image, imageFormat, outputStream);  
+    }  
+      
+    /**
+     * 读二维码并输出携带的信息
+     */
+    public static void readQrCode(InputStream inputStream) throws IOException{  
+        //从输入流中获取字符串信息
+        BufferedImage image = ImageIO.read(inputStream);  
+        //将图像转换为二进制位图源
+        LuminanceSource source = new BufferedImageLuminanceSource(image);  
+        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));  
+        QRCodeReader reader = new QRCodeReader();  
+        Result result = null ;
+        try {
+         result = reader.decode(bitmap);  
+        } catch (ReaderException e) {
+            e.printStackTrace();  
+        }
+        System.out.println(result.getText());  
+    }
+    
+    
+    
+    
+    /**
+     * 测试代码
+     * @throws WriterException 
+     */
+    public static void main(String[] args) throws IOException, WriterException {
+        
+        createQrCode(new FileOutputStream(new File("d:\\qrcode.jpg")),"xiaoxue",900,"JPEG");
+        readQrCode(new FileInputStream(new File("d:\\qrcode.jpg")));  
+		// 去掉字母的客户号
+		/*String ofAfter = OffSetUtil.enScanCode("123456789");
+		System.out.println("加密后:" + ofAfter);
+		System.out.println("解密后:" + OffSetUtil.deScanCode(ofAfter));*/
+    }  
+  
+}

+ 31 - 5
src/main/java/com/minpay/shouhuo/PersManageAction.java

@@ -3,6 +3,7 @@ package com.minpay.shouhuo;
 import com.google.zxing.WriterException;
 import com.min.util.OffSetUtil;
 import com.minpay.common.bean.User;
+import com.minpay.common.constant.Constant;
 import com.minpay.common.constant.ServConstant;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.ILogService;
@@ -33,6 +34,7 @@ import net.sf.json.JSONObject;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -86,9 +88,13 @@ public class PersManageAction implements IMINAction {
 		// 创建查询条件
 		Map<String, String> p = new HashMap<String, String>();
 		User u = session.getUser();
+
 		p.put("dates", dates);     		// 创建日期
 		p.put("perName", perName); 		//用户名称
 		p.put("state", state);     		//状态
+		if(!u.getBranchId().equals(Constant.ADMINISTRATION_SYSTEM_NUMBER)){
+			p.put("branchId", u.getBranchId());
+		}
 		p.put("channel", u.getChannel());//渠道
 		p.put("roleid", roleid);
 		MINRowBounds rows = new MINRowBounds(page, limit);
@@ -162,13 +168,13 @@ public class PersManageAction implements IMINAction {
 	}
 
 
-	@MINAction(value = PERSON_ADD)
+	@MINAction(value = PERSON_ADD,session = false)
 	public MINActionResult personAdd(
 			@MINParam(key = "code") String code,
 			@MINParam(key = "type") String type,
 			@MINParam(key = "channel") String channel,
-			@MINParam(key = "equNo") String equNo,
-			@MINParam(key = "version") String version,
+			@MINParam(key = "role") String role,
+			@MINParam(key = "branchId") String branchId,
 			HttpServletResponse response,
 			MINHttpServletRequestContext request
 	) throws MINBusinessException {
@@ -187,7 +193,7 @@ public class PersManageAction implements IMINAction {
 		VmPersonInfExample personex = new VmPersonInfExample();
 		personex.createCriteria().andChannelEqualTo(channel).andTypeEqualTo(type).andOpenidEqualTo((String) result.get("openId"));
 		List<VmPersonInf> perLst = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonInfMapper.class).selectByExample(personex);
-		if(perLst.size() > 1 ){
+		if(perLst.size() > 0 ){
 			throw new MINBusinessException("用户已存在!");
 		}
 
@@ -207,6 +213,8 @@ public class PersManageAction implements IMINAction {
 			person.setCreateTime(nowTime);
 			person.setModifyUser(perId);
 			person.setModifyTime(nowTime);
+			person.setRole(role);
+			person.setUserId(branchId);
 			Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonInfMapper.class).insertSelective(person);
 		}else{
 			VmPersonInf vmPersonInf = perLst.get(0);
@@ -310,9 +318,27 @@ public class PersManageAction implements IMINAction {
 				.getSystemProperties().get(channel+"_TO_MACHINE_ERWERMA").getKey();// 为nginx根路径
 		// 加密客户号
 		OutputStream outputStream = new FileOutputStream(file);
+		String openUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?";
+		String redirect_uri = "http://xubing2.minpay.cc/adm/admin/wxuserManage/addUserTransfer.html?role=".concat(role).concat("&branchId=").concat(userId);
+		//在微信的appId
+		String appId = Service.lookup(IPublicService.class).getSysParValue(channel + "_APP_ID");
+		//配置参数
+		StringBuffer paramStr = new StringBuffer();
+		paramStr.append(openUrl);
+		paramStr.append("appid=");
+		paramStr.append(appId);
+		paramStr.append("&redirect_uri=");
+		paramStr.append(redirect_uri);
+		paramStr.append("&response_type=code&scope=snsapi_userinfo&state=STATE");
+		//String urlString = URLEncoder.encode(paramStr.toString(), "GBK");
+		String admUrl = Service.lookup(IPropertiesService.class)
+				.getSystemProperties().get(channel+"_ADM_URl").getKey();
+		admUrl = admUrl.concat("/admin/h5AddUser.html?role=").concat(role).concat("&branchId=").concat(userId);;
+		//String urlString = URLEncoder.encode(, "GBK");
+
 		// 生成二维码图片到本地
 		try {
-			EquCodeCreateUtil.createQrCode(outputStream,address+"/"+userId+"/"+role,900,"JPEG");
+			EquCodeCreateUtil.createQrCode(outputStream,admUrl,900,"JPEG");
 		} catch (com.google.zxing.WriterException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();

+ 9 - 2
src/main/resources/com/minpay/db/table/own/mapper/PersonManageMapper.xml

@@ -14,13 +14,20 @@
 			         per.VCI_MODIFY_TIME    "modifyTime",
 			         u.USR_NAME             "createUser",
 			         e.USR_NAME             "modifyUser",
-					per.VCI_ROLE             "role"
+					per.VCI_ROLE             "role",
+					per.VCI_USER_ID          "branchId",
+					ib.BRH_NAME			 "branchName"
 		  FROM  vm_person_inf  per
 		  left  join im_user    u
 		  on    u.USR_ID = per.VCI_CREATE_USER
 		  left  join im_user    e
 		  on    e.USR_ID = per.VCI_MODIFY_USER
-		  where 1=1 
+		left  join im_branch    ib
+		on    ib.BRH_ID = per.VCI_USER_ID
+		  where 1=1 and per.VCI_IS_USER ='1'
+		<if test="branchId!=null  and branchId != ''">
+			and   (per.VCI_USER_ID   =  #{branchId,jdbcType=VARCHAR})
+		</if>
 		  <if test="perName!=null  and perName != ''">
 	     	and   (per.VCI_NAME  like  concat('%', #{perName,jdbcType=VARCHAR},'%'))
 	   		</if>

+ 1 - 1
src/main/webapp/admin/wxuserManage/addUserwx.html

@@ -23,7 +23,7 @@
 				</div>
 			</div>
 
-            <img style="margin: 30px;" id="equCode" height="200px" width="200px" src="">
+            <img style="margin: 30px;" id="equCode" height="400px" width="400px" src="">
 		</div>
     </form>
     <script src="../../js/min-loader-next.js"></script>

+ 3 - 0
src/main/webapp/admin/wxuserManage/wxuserManage.html

@@ -200,6 +200,9 @@
  		      ,{field: 'channelDesc', title: '渠道'}
  		      ,{field: 'createTime', title: '创建日期'}
  		      ,{field: 'stateDesc', title: '状态'}
+			  ,{field: 'openId', title: 'openId'}
+			 ,{field: 'branchName', title: '所属商户'}
+
     	                 ];
 		// 寄存当前数据
 		setNowRowData(data, params);

+ 37 - 0
src/main/webapp/h5AddUser.html

@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>增加操作员</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+</head>
+<script>
+</script>
+<body class="content">
+    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+    </fieldset>
+    <form class="layui-form" action="">
+    </form>
+    <script src="../../js/min-loader-next.js"></script>
+    <script>
+		layui.use(['form', 'layedit', 'laydate'], function() {
+
+			var form = layui.form
+					, layer = layui.layer
+					, layedit = layui.layedit
+					, laydate = layui.laydate;
+            var url = document.location.toString();//获取url地址
+            var urlParmStr = url.slice(url.indexOf('?')+1);//获取问号后所有的字符串
+            var arr = urlParmStr.split('&');//通过&符号将字符串分割转成数组
+            var role = arr[0].split("=")[1];//获取数组中第一个参数
+            var branchId = arr[1].split("=")[1];//第二个参数
+
+
+        })
+
+
+    </script>
+</body>
+</html>