Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mhotel/src/com/happy/action/appAction.java
Administrator 2 gadi atpakaļ
vecāks
revīzija
a5468e3102

+ 9 - 0
mhotel/src/com/happy/Model/Admin.java

@@ -65,6 +65,7 @@ public class Admin {
 	 * 数据状态
 	 * 数据状态
 	 */
 	 */
 	private Integer status;
 	private Integer status;
+    public String openid;
 
 
     public Integer getId() {
     public Integer getId() {
         return id;
         return id;
@@ -161,4 +162,12 @@ public class Admin {
     public void setStatus(Integer status) {
     public void setStatus(Integer status) {
         this.status = status;
         this.status = status;
     }
     }
+
+    public String getOpenid() {
+        return openid;
+    }
+
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
 }
 }

+ 9 - 0
mhotel/src/com/happy/Model/AdminManager.java

@@ -106,6 +106,7 @@ public class AdminManager {
 	 * 营业执照
 	 * 营业执照
 	 */
 	 */
 	private List<File> fileList;
 	private List<File> fileList;
+	public String openid;
 
 
 	public Integer getId() {
 	public Integer getId() {
 		return id;
 		return id;
@@ -258,4 +259,12 @@ public class AdminManager {
 	public void setFileList(List<File> fileList) {
 	public void setFileList(List<File> fileList) {
 		this.fileList = fileList;
 		this.fileList = fileList;
 	}
 	}
+
+	public String getOpenid() {
+		return openid;
+	}
+
+	public void setOpenid(String openid) {
+		this.openid = openid;
+	}
 }
 }

+ 11 - 12
mhotel/src/com/happy/Model/File.java

@@ -1,6 +1,6 @@
 package com.happy.Model;
 package com.happy.Model;
 
 
-public class File {
+public class FileInfo {
 
 
 
 
     /**
     /**
@@ -16,12 +16,12 @@ public class File {
     /**
     /**
      * 附件路径
      * 附件路径
      */
      */
-    private String fileUrl;
+    private String url;
 
 
     /**
     /**
      * 附件名称
      * 附件名称
      */
      */
-    private String fileName;
+    private String name;
 
 
 
 
 
 
@@ -41,20 +41,19 @@ public class File {
 		this.linkId = linkId;
 		this.linkId = linkId;
 	}
 	}
 
 
-	public String getFileUrl() {
-		return fileUrl;
+	public String getUrl() {
+		return url;
 	}
 	}
 
 
-	public void setFileUrl(String fileUrl) {
-		this.fileUrl = fileUrl;
+	public void setUrl(String url) {
+		this.url = url;
 	}
 	}
 
 
-	public String getFileName() {
-		return fileName;
+	public String getName() {
+		return name;
 	}
 	}
 
 
-	public void setFileName(String fileName) {
-		this.fileName = fileName;
+	public void setName(String name) {
+		this.name = name;
 	}
 	}
-
 }
 }

+ 5 - 5
mhotel/src/com/happy/Model/House.java

@@ -76,7 +76,7 @@ public class House {
 	/**
 	/**
 	 * 房型详细图
 	 * 房型详细图
 	 */
 	 */
-	private List<File> fileList;
+	private List<FileInfo> fileInfoList;
 
 
 	public Integer getId() {
 	public Integer getId() {
 		return id;
 		return id;
@@ -174,12 +174,12 @@ public class House {
 		this.status = status;
 		this.status = status;
 	}
 	}
 
 
-	public List<File> getFileList() {
-		return fileList;
+	public List<FileInfo> getFileInfoList() {
+		return fileInfoList;
 	}
 	}
 
 
-	public void setFileList(List<File> fileList) {
-		this.fileList = fileList;
+	public void setFileInfoList(List<FileInfo> fileInfoList) {
+		this.fileInfoList = fileInfoList;
 	}
 	}
 
 
 	public String getRemainRooms() {
 	public String getRemainRooms() {

+ 9 - 9
mhotel/src/com/happy/action/adminAction.java

@@ -169,13 +169,13 @@ public class adminAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            if (admin.getAdminName()==null || admin.getUserName()==null || admin.getLevel()==null || admin.getPhone()==null){
-                resultJson.put("message", "各参数不能为空");
-                resultJson.put("code", 500);
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
-            if (!PwdDefind.vertify(admin.getPassword())){
+//            if (admin.getAdminName()==null || admin.getUserName()==null || admin.getLevel()==null || admin.getPhone()==null){
+//                resultJson.put("message", "各参数不能为空");
+//                resultJson.put("code", 500);
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
+            if (admin.getPassword()!=null && !"".equals(admin.getPassword()) && !PwdDefind.vertify(admin.getPassword())){
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -251,7 +251,7 @@ public class adminAction extends ActionSupport implements ServletRequestAware {
         }
         }
         Admin admin = adminService.getById(id);
         Admin admin = adminService.getById(id);
         if (admin != null && !"".equals(admin)) {
         if (admin != null && !"".equals(admin)) {
-            admin.setPassword("Jams123456");
+            admin.setPassword("Jams_123456");
             int m = adminService.updateAdmin(admin);
             int m = adminService.updateAdmin(admin);
             if(m > 0){
             if(m > 0){
                 resultJson.put("message", "重置成功");
                 resultJson.put("message", "重置成功");
@@ -280,7 +280,7 @@ public class adminAction extends ActionSupport implements ServletRequestAware {
         JSONObject resultJson = new JSONObject();
         JSONObject resultJson = new JSONObject();
         StringBuilder s1 = new StringBuilder("");
         StringBuilder s1 = new StringBuilder("");
         if (adminName!=null){
         if (adminName!=null){
-            s1.append(" and admin_name like '%").append(adminName).append("'");
+            s1.append(" and admin_name like '%").append(adminName).append("%'");
         }
         }
         IPage<Admin> adminIPage = adminService.queryPage(s1.toString(),page,rows);
         IPage<Admin> adminIPage = adminService.queryPage(s1.toString(),page,rows);
         if(adminIPage!=null && !"".equals(adminIPage)){
         if(adminIPage!=null && !"".equals(adminIPage)){

+ 42 - 35
mhotel/src/com/happy/action/adminManagerAction.java

@@ -22,6 +22,7 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
 import java.util.List;
 import java.util.List;
 
 
 public class adminManagerAction extends ActionSupport implements ServletRequestAware{
 public class adminManagerAction extends ActionSupport implements ServletRequestAware{
@@ -49,7 +50,8 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     public String level;//权限
     public String level;//权限
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
-    private String fileListJson;
+
+    public List<FileInfo> fileList;//需上传的附件列表
 
 
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
@@ -155,18 +157,18 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
             }
             }
             admin.setId(Math.toIntExact(UUIDUtil.generateID()));
             admin.setId(Math.toIntExact(UUIDUtil.generateID()));
             admin.setManagerId(admin.getId());
             admin.setManagerId(admin.getId());
-            //保存详细图附件
-            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
-            if(fileList!=null && fileList.size()>0){
-                for(File file : fileList){
-                    file.setLinkId(admin.getId());
-                    fileService.insertFile(file);
-                }
-            }else{
-                resultJson.put("message", "请上传详细图");
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
+//            //保存详细图附件
+//            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+//            if(fileList!=null && fileList.size()>0){
+//                for(File file : fileList){
+//                    file.setLinkId(admin.getId());
+//                    fileService.insertFile(file);
+//                }
+//            }else{
+//                resultJson.put("message", "请上传详细图");
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
             int m = adminManagerService.insertAdmin(admin);
             int m = adminManagerService.insertAdmin(admin);
             if (m > 0) {
             if (m > 0) {
                 resultJson.put("message", "添加成功");
                 resultJson.put("message", "添加成功");
@@ -239,21 +241,21 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            //修改详细图附件
-            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
-            if(fileList!=null && fileList.size()>0){
-                if(admin.getId()!= null){
-                    fileService.delLinkFile(admin.getId());
-                }
-                for(File file : fileList){
-                    file.setLinkId(admin.getId());
-                    fileService.insertFile(file);
-                }
-            }else{
-                resultJson.put("message", "请上传详细图");
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
+//            //修改详细图附件
+//            List<FileInfo> fileInfoList = JSONArray.parseArray(fileListJson, File.class);
+//            if(fileList!=null && fileList.size()>0){
+//                if(admin.getId()!= null){
+//                    fileService.delLinkFile(admin.getId());
+//                }
+//                for(FileInfo fileInfo : fileInfoList){
+//                    fileInfo.setLinkId(admin.getId());
+//                    fileService.insertFile(fileInfo);
+//                }
+//            }else{
+//                resultJson.put("message", "请上传详细图");
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
             int m = adminManagerService.updateAdmin(admin);
             int m = adminManagerService.updateAdmin(admin);
             if (m > 0) {
             if (m > 0) {
                 resultJson.put("message", "修改成功");
                 resultJson.put("message", "修改成功");
@@ -304,6 +306,12 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            if(admin.getManagerId()==null){
+                resultJson.put("message", "民宿超级管理员Id不能为空");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
             if (!PwdDefind.vertify(admin.getPassword())){
             if (!PwdDefind.vertify(admin.getPassword())){
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
@@ -362,14 +370,13 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            if (admin.getAdminName()==null || admin.getCardName()==null || admin.getCorpnPhone()==null
-                    || admin.getLevel()==null || admin.getPassword()==null){
-                resultJson.put("message", "各参数不能为空");
+            if (admin.getId()==null){
+                resultJson.put("message", "用户主键不能为空");
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            if (!PwdDefind.vertify(admin.getPassword())){
+            if (admin.getPassword()!=null && !"".equals(admin.getPassword()) && !PwdDefind.vertify(admin.getPassword())){
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -445,7 +452,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
         }
         }
         AdminManager admin = adminManagerService.getById(id);
         AdminManager admin = adminManagerService.getById(id);
         if (admin != null && !"".equals(admin)) {
         if (admin != null && !"".equals(admin)) {
-            admin.setPassword("Jams123456");
+            admin.setPassword("Jams_123456");
             int m = adminManagerService.updateAdmin(admin);
             int m = adminManagerService.updateAdmin(admin);
             if(m > 0){
             if(m > 0){
                 resultJson.put("message", "重置成功");
                 resultJson.put("message", "重置成功");
@@ -578,8 +585,8 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
             return null;
             return null;
         }
         }
         AdminManager admin = adminManagerService.getById(id);
         AdminManager admin = adminManagerService.getById(id);
-        List<File> fileList = fileService.queryList("and link_id ='"+id+"'");
-        admin.setFileList(fileList);
+        List<FileInfo> fileInfoList = fileService.queryList("and link_id ='"+id+"'");
+        admin.setFileInfoList(fileInfoList);
         if (admin != null) {
         if (admin != null) {
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);

+ 265 - 495
mhotel/src/com/happy/action/appAction.java

@@ -1,495 +1,265 @@
-//package com.happy.action;
-//
-//import com.google.gson.Gson;
-//import com.google.gson.reflect.TypeToken;
-//import com.happy.Model.*;
-//import com.happy.Model.weixin.*;
-//import com.happy.Until.*;
-//import com.happy.Until.weixin.EndPay;
-//import com.happy.Until.weixin.JaxbUtil;
-//import com.happy.Until.weixin.PayWxUtil;
-//import com.happy.Until.weixin.TongYiReturn;
-//import com.happy.common.http.ClientCustomSSL;
-//import com.happy.common.http.HttpsClient;
-//import com.happy.common.http.RequestHandler;
-//import com.happy.common.wx.WxUtil;
-//import com.happy.service.*;
-//import com.opensymphony.xwork2.ActionSupport;
-//import net.sf.json.JSONObject;
-//import org.apache.struts2.ServletActionContext;
-//import org.apache.struts2.interceptor.ServletRequestAware;
-//
-//import javax.annotation.Resource;
-//import javax.servlet.http.HttpServletRequest;
-//import javax.servlet.http.HttpServletResponse;
-//import javax.servlet.http.HttpSession;
-//import java.io.BufferedReader;
-//import java.io.IOException;
-//import java.io.PrintWriter;
-//import java.io.UnsupportedEncodingException;
-//import java.net.URLEncoder;
-//import java.text.ParseException;
-//import java.text.SimpleDateFormat;
-//import java.util.*;
-//
-//public class appAction extends ActionSupport implements ServletRequestAware {
-//
-//    private HttpServletRequest request;
-//    public HttpServletResponse response;
-//
-//    @Resource
-//    public UserService userService;
-//    @Resource
-//    public BookService bookService;
-//    @Resource
-//    public HouseService houseService;
-//    @Resource
-//    public ConfigService configService;
-//
-//    public String wxcode;
-//    public String state;
-//    public String code;
-//    public String order_num;
-//    public String card_number;
-//    public String phone;
-//
-//    public HttpServletRequest getRequest() {
-//        return request;
-//    }
-//
-//    public void setRequest(HttpServletRequest request) {
-//        this.request = request;
-//    }
-//
-//    public void setServletRequest(HttpServletRequest request) {
-//        this.request = request;
-//    }
-//
-//    public HttpServletResponse getResponse() {
-//        return response;
-//    }
-//
-//    public void setResponse(HttpServletResponse response) {
-//        this.response = response;
-//    }
-//
-//    public String getState() {
-//        return state;
-//    }
-//
-//    public void setState(String state) {
-//        this.state = state;
-//    }
-//
-//    public String getWxcode() {
-//        return wxcode;
-//    }
-//
-//    public void setWxcode(String wxcode) {
-//        this.wxcode = wxcode;
-//    }
-//
-//    public String getCode() {
-//        return code;
-//    }
-//
-//    public void setCode(String code) {
-//        this.code = code;
-//    }
-//
-//    public String getOrder_num() {
-//        return order_num;
-//    }
-//
-//    public void setOrder_num(String order_num) {
-//        this.order_num = order_num;
-//    }
-//
-//    public String getCard_number() {
-//        return card_number;
-//    }
-//
-//    public void setCard_number(String card_number) {
-//        this.card_number = card_number;
-//    }
-//
-//    public String getPhone() {
-//        return phone;
-//    }
-//
-//    public void setPhone(String phone) {
-//        this.phone = phone;
-//    }
-//
-//    // 前端传入code和手机号,后端通过code拿openid和用户其他的信息
-//    public String index() throws Exception {
-//        String OPEN_ID = "";
-//        /** 获取code的目的,其实就是为了获取openid和token,
-//         获取openid和token的目的,其实是为了获取unionid和用户信息。
-//         **/
-//        // 此处授权后的回调地址,主要获取token和openid
-//        String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
-//                + WeiXinUtil.appid_c
-//                + "&secret="
-//                + WeiXinUtil.screct_c
-//                + "&code="
-//                + code + "&grant_type=authorization_code";
-//        if (code != null) {
-//            // String json = HttpUtils.get(requestUrl);
-//            String json = HttpsClient.sendPost(requestUrl, "");
-//            Wechat_userinfo result = new Gson().fromJson(json, Wechat_userinfo.class);
-//            OPEN_ID = result.getOpenid();
-//            /*
-//            *  手机号前端过来,昵称、省份、性别等其他信息已保存的result中,
-//            * 查询用户openid是否存在,存在就返回信息给前端,不存在就保存到数据库
-//            * */
-//            Users users = userService.queryByOpenid(OPEN_ID);
-//
-//        }
-//        ServletActionContext.getResponse().sendRedirect(
-//                WeiXinUtil.ip_q + "/#/pages/p404/p404/?message=" + URLEncoder.encode("code获取失败", "UTF-8"));
-//        return null;
-//    }
-//
-//    // 微信支付
-//    public String order_pay(){
-//        JSONObject resultjson = new JSONObject();
-//        Gson gson = new Gson();
-//        com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
-//        System.out.println(json);
-//        if (json == null) {
-//            resultjson.put("message", "请传入参数");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//            return null;
-//        }
-//        Ordering ordering = null;
-//        try {
-//            ordering = gson.fromJson(json.toString(), new TypeToken<Ordering>() {}.getType());
-//            if (ordering == null) {
-//                resultjson.put("message", "数据为空");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            if (ordering.getCard_number()==null || ordering.getLive_time()==null || ordering.getEnd_time()==null || ordering.getH_type()==null ){
-//                resultjson.put("message", "各参数不能为空");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            Users users = userService.queryByNum(ordering.getCard_number());
-//            if (users==null){
-//                resultjson.put("message", "获取用户信息失败");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            if (users.getOpenid()==null || users.getOpenid().equals("")){
-//                resultjson.put("message", "未授权,不可下单");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            // 查询是否有空房
-//            List<String> times = TimeExchange.getDays(ordering.getLive_time(),ordering.getEnd_time());
-//            boolean flag = bookService.querySpare(ordering.getH_type(),times);
-//            if (!flag){
-//                resultjson.put("message", "房间数不够,请重新选择日期");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            House house = houseService.queryByType(ordering.getH_type());
-//            if (house==null){
-//                resultjson.put("message", "获取房型信息失败");
-//                resultjson.put("code", 500);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            Config config = configService.queryConfig();
-//            String stop_book = config.getStop_book();
-//            if (!TimeExchange.CompareDate(TimeExchange.getDate(),stop_book)){
-//                resultjson.put("message", "预定时间已截止");
-//                resultjson.put("code", 503);
-//                ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                return null;
-//            }
-//            String open_id = users.getOpenid();
-//            String ip = "171.34.223.11";
-//            // 支付费用
-//            double money = house.getPrice()*times.size();
-//            int a = (int) (money * 100);
-//
-//            WechatUnifiedOrder w = new WechatUnifiedOrder();
-//            w.setAppid(WeiXinUtil.appid_c);
-//            w.setAttach("chuanghai");
-//            w.setBody("chuanghai");
-//            w.setMch_id(WeiXinUtil.account);
-//            w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-//            w.setNotify_url(WeiXinUtil.ip_h + "/apppayResulet.action");// 支付结果回调地址
-//            w.setOpenid(open_id);
-//            String orderNo = WxUtil.mchOrderNo();
-//            w.setOut_trade_no(orderNo);
-//            w.setSpbill_create_ip(ip);
-//            w.setTotal_fee(a);
-//            w.setTrade_type("JSAPI");
-//            Map<String, String> params = new HashMap<String, String>();
-//            params.put("attach", w.getAttach());
-//            params.put("appid", w.getAppid());
-//            params.put("mch_id", w.getMch_id());
-//            params.put("nonce_str", w.getNonce_str());
-//            params.put("body", w.getBody());
-//            params.put("out_trade_no", w.getOut_trade_no());
-//            params.put("total_fee", w.getTotal_fee() + "");
-//            params.put("spbill_create_ip", w.getSpbill_create_ip());
-//            params.put("notify_url", w.getNotify_url());
-//            params.put("trade_type", w.getTrade_type());
-//            params.put("openid", w.getOpenid());
-//            w.setSign(PayWxUtil.getSign(params, WeiXinUtil.key));
-//            params.put("sign", w.getSign());
-//            String retXml = JaxbUtil.getRequestXml(params);
-//            String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/unifiedorder", retXml);
-//            System.out.println(msg);
-//            if (msg.indexOf("FAIL") > -1) {
-//                resultjson.put("code","205");
-//                resultjson.put("message", "支付异常205");
-//                ResUtil.write(resultjson, ServletActionContext.getResponse());
-//                return null;
-//            } else {
-//                JaxbUtil requestBinder = new JaxbUtil(TongYiReturn.class, JaxbUtil.CollectionWrapper.class);
-//                TongYiReturn to = requestBinder.fromXml(msg);
-//                if (to.getReturn_code().equals("SUCCESS") && to.getResult_code().equals("SUCCESS")) {
-//                    EndPay pay = new EndPay();
-//                    pay.setAppId(WeiXinUtil.appid_c);
-//                    pay.setSignType("MD5");
-//                    pay.setTimeStamp(System.currentTimeMillis() / 1000 + "");
-//                    pay.setPrepay_id(to.getPrepay_id());
-//                    pay.setNonceStr(PayWxUtil.getNonceStr());
-//                    Map<String, String> requestMap = new HashMap<String, String>();
-//                    requestMap.put("appId", pay.getAppId());
-//                    requestMap.put("timeStamp", pay.getTimeStamp());
-//                    requestMap.put("nonceStr", pay.getNonceStr());
-//                    requestMap.put("package", "prepay_id=" + pay.getPrepay_id());
-//                    requestMap.put("signType", "MD5");
-//                    pay.setPaySign(PayWxUtil.getSign(requestMap, WeiXinUtil.key));
-//                    // 返回支付参数
-//                    resultjson.put("code", 200);
-//                    resultjson.put("message","返回成功");
-//                    resultjson.put("data", pay);
-//                    ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//                    // 保存支付信息
-//                    Booking pay1 = new Booking();
-//                    System.out.println("金额:"+ (double) a / 100);
-//                    pay1.setOrder_num(orderNo);
-//                    pay1.setStatus("1");
-//                    pay1.setCard_number(users.getCard_number());
-//                    pay1.setUser_name(users.getUser_name());
-//                    pay1.setPhone(users.getUser_phone());
-//                    pay1.setH_type(house.getH_type());
-//                    pay1.setPrice(house.getPrice());
-//                    pay1.setCreate_time(TimeExchange.getTime());
-//                    pay1.setLive_time(ordering.getLive_time());
-//                    pay1.setEnd_time(ordering.getEnd_time());
-//                    pay1.setPay_account((double) a / 100);
-//                    bookService.insert(pay1);
-//                    return null;
-//                }
-//            }
-//        } catch (Exception e) {
-//            resultjson.put("message", "支付异常206");
-//            resultjson.put("code", 206);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//            return null;
-//        }
-//        resultjson.put("message", "支付异常207");
-//        resultjson.put("code", 207);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//        return null;
-//    }
-//
-//    // 成功回调
-//    public String payResulet(){
-//        System.out.println("进入支付回调====");
-//        JSONObject resultjson = new JSONObject();
-//        try{
-//            BufferedReader reader = null;// BufferedReader 字符输入流
-//            reader = request.getReader();
-//            String line = "";
-//            String xmlString = null;
-//            StringBuilder inputString = new StringBuilder();
-//            while ((line = reader.readLine()) != null) {
-//                inputString.append(line);
-//            }
-//            xmlString = inputString.toString();
-//            request.getReader().close();
-//            JaxbUtil requestBinder = new JaxbUtil(PayResult.class, PayResult.class);
-//            PayResult result = requestBinder.fromXml(xmlString);// Xml到Java,用fromXML()方法
-//            String order_num = result.getOut_trade_no();
-//            System.out.println("支付成功回调,订单号:"+order_num);
-//            Booking booking = bookService.queryByOrder(order_num);
-//            // 支付成功
-//            if (result.getResult_code().equals("SUCCESS") && booking!=null && booking.getOrderStatus().equals("1")) {
-//                int m = bookService.update_pay("2", order_num);
-//                if (m>0){
-//                    String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
-//                    HttpServletResponse response = ServletActionContext.getResponse();
-//                    response.setContentType("text/html;charset=utf-8");
-//                    PrintWriter out = response.getWriter();
-//                    out.println(returnMsg);
-//                    out.flush();
-//                    out.close(); // 发送成功消息给商家
-//                }
-//                return null;
-//            }
-//        } catch (Exception e){
-//            resultjson.put("message", "支付失败");
-//            resultjson.put("code", 205);
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//            return null;
-//        }
-//        resultjson.put("message", "支付失败");
-//        resultjson.put("code", 205);
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
-//        return null;
-//    }
-//
-//    // 微信退款功能
-//    public String refund() throws Exception {
-//        JSONObject resultJson = new JSONObject();
-//        if (order_num==null){
-//            resultJson.put("code", 500);
-//            resultJson.put("message", "code和订单号不能为空");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        Booking booking = bookService.queryByOrder(order_num);
-//        if (booking==null){
-//            resultJson.put("code", 502);
-//            resultJson.put("message", "订单不存在");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (booking.getOrderStatus().equals("1")){
-//            resultJson.put("code", 503);
-//            resultJson.put("message", "订单未支付不可申请退款");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (booking.getOrderStatus().equals("3")){
-//            resultJson.put("code", 503);
-//            resultJson.put("message", "已入住,请往前台办理");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        if (booking.getOrderStatus().equals("4") || booking.getOrderStatus().equals("5") || booking.getOrderStatus().equals("6")){
-//            resultJson.put("code", 503);
-//            resultJson.put("message", "订单已完成,请往前台办理");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        Config config = configService.queryConfig();
-//        String[] sc = config.getFree_cancel().split("~");
-//        if (TimeExchange.CompareDate(TimeExchange.getDate(),sc[0]) || TimeExchange.CompareDate(sc[1],TimeExchange.getDate())){
-//            resultJson.put("code", 505);
-//            resultJson.put("message", "当前时间段,请前往前台办理");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        String open_id = "";
-//        //String ip = request.getParameter("ip");
-//        String ip = "171.34.223.11";
-//        double money = booking.getPay_account();
-//        int a = (int) (money * 100);
-//        WechatUnifiedOrder w = new WechatUnifiedOrder();
-//        w.setAppid(WeiXinUtil.appid_c);
-//        w.setAttach("chuanghai");
-//        w.setBody("chuanghai");
-//        w.setMch_id(WeiXinUtil.account);
-//        w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-//        w.setNotify_url(WeiXinUtil.ip_h + "/appquery_refund.action");// 支付结果回调地址
-//        w.setOpenid(open_id);
-//        w.setOut_trade_no(booking.getOrder_num());
-//        String refund_order = WxUtil.mchOrderNo();
-//        w.setOut_refund_no(refund_order);   // 退款单号
-//        w.setSpbill_create_ip(ip);
-//        w.setTotal_fee(a);
-//        w.setRefund_fee(a);   // 退款金额
-//        w.setTrade_type("JSAPI");
-//        SortedMap<String, String> params = new TreeMap<String, String>();
-//        params.put("appid", w.getAppid());
-//        params.put("mch_id", w.getMch_id());
-//        params.put("nonce_str", w.getNonce_str());
-//        params.put("notify_url", w.getNotify_url());
-//        params.put("out_refund_no", w.getOut_refund_no());   // 退款单号
-//        params.put("out_trade_no", w.getOut_trade_no());
-//        params.put("refund_fee",w.getRefund_fee()+"");  // 退款金额
-//        params.put("total_fee", w.getTotal_fee() + "");
-//
-//        w.setSign(PayWxUtil.getSign(params, WeiXinUtil.v2));
-//        params.put("sign", w.getSign());
-//        //String retXml = JaxbUtil.getRequestXml(params);
-//        String xml = "<xml>" +
-//                "<appid>" + w.getAppid() + "</appid>" +
-//                "<mch_id>" + w.getMch_id() + "</mch_id>" +
-//                "<nonce_str>" + w.getNonce_str() + "</nonce_str>" +
-//                "<notify_url>" + w.getNotify_url() + "</notify_url>" +
-//                "<out_refund_no>" + w.getOut_refund_no() + "</out_refund_no>" +
-//                "<out_trade_no>" + w.getOut_trade_no() + "</out_trade_no>"	+
-//                "<refund_fee>" + w.getRefund_fee()+"" + "</refund_fee>" +
-//                "<total_fee>" + w.getTotal_fee() + "" + "</total_fee>" +
-//                "<sign>" + w.getSign() + "</sign>"	+
-//                "</xml>";
-//        //String msg = HttpsClient.sendPost2("https://api.mch.weixin.qq.com/secapi/pay/refund", retXml);
-//        String msg = HttpUtils.post2("https://api.mch.weixin.qq.com/secapi/pay/refund", xml);
-//        if (msg.indexOf("FAIL") > -1) {
-//            resultJson.put("code", 507);
-//            resultJson.put("message", "退款失败");
-//            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//            return null;
-//        }
-//        bookService.update_pay("7", order_num);  // 退款中
-//        resultJson.put("code", 200);
-//        resultJson.put("message", "退款申请已提交,请稍候查询");
-//        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-//        return null;
-//    }
-//
-//    /* 退款回调 */
-//    public String query_refund() throws Exception {
-//        List<Booking> booking = bookService.queryRefunding("7");
-//        if (booking==null){
-//            return null;
-//        }
-//        for (int i = 0; i < booking.size(); i++) {
-//            WechatUnifiedOrder w = new WechatUnifiedOrder();
-//            w.setAppid(WeiXinUtil.appid_c);
-//            w.setAttach("chuanghai");
-//            w.setBody("chuanghai");
-//            w.setMch_id(WeiXinUtil.account);
-//            w.setNonce_str(PayWxUtil.getNonceStr());// 随机支付串
-//            w.setOut_trade_no(booking.get(i).getOrder_num());
-//            w.setTrade_type("JSAPI");
-//            Map<String, String> params = new HashMap<String, String>();
-//            params.put("appid", w.getAppid());
-//            params.put("mch_id", w.getMch_id());
-//            params.put("out_trade_no", w.getOut_trade_no());
-//            params.put("nonce_str", w.getNonce_str());
-//            w.setSign(PayWxUtil.getSign(params, WeiXinUtil.v2));
-//            params.put("sign", w.getSign());
-//            String retXml = JaxbUtil.getRequestXml(params);
-//            String msg = HttpUtils.post("https://api.mch.weixin.qq.com/pay/refundquery", retXml);
-//            if (msg.indexOf("<refund_status_0><![CDATA[SUCCESS]]></refund_status_0>")>0) { // 交易成功,支付结果转换为对象
-//                bookService.update_pay("4", booking.get(i).getOrder_num());
-//            }
-//        }
-//        String returnMsg = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
-//        HttpServletResponse response = ServletActionContext.getResponse();
-//        response.setContentType("text/html;charset=utf-8");
-//        PrintWriter out = response.getWriter();
-//        out.println(returnMsg);
-//        out.flush();
-//        out.close(); // 发送成功消息给商家
-//        return null;
-//    }
-//
-//}
+package com.happy.action;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.happy.Model.*;
+import com.happy.Model.weixin.*;
+import com.happy.Until.*;
+import com.happy.common.http.HttpsClient;
+import com.happy.common.util.WechatUtil;
+import com.happy.common.wx.WxUtil;
+import com.happy.service.*;
+import com.opensymphony.xwork2.ActionSupport;
+import net.sf.json.JSONObject;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.interceptor.ServletRequestAware;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class appAction extends ActionSupport implements ServletRequestAware {
+
+    private HttpServletRequest request;
+    public HttpServletResponse response;
+
+    @Resource
+    public UserService userService;
+    @Resource
+    public BookService bookService;
+    @Resource
+    public HouseService houseService;
+    @Resource
+    public ConfigService configService;
+    @Resource
+    public AppService appService;
+
+    public String wxcode;
+    public String state;
+    public String code;
+    public String order_num;
+    public String card_number;
+    public String phone;
+    public String admin_name;
+    public String password;
+
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    public void setServletRequest(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+
+    public void setResponse(HttpServletResponse response) {
+        this.response = response;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getWxcode() {
+        return wxcode;
+    }
+
+    public void setWxcode(String wxcode) {
+        this.wxcode = wxcode;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getOrder_num() {
+        return order_num;
+    }
+
+    public void setOrder_num(String order_num) {
+        this.order_num = order_num;
+    }
+
+    public String getCard_number() {
+        return card_number;
+    }
+
+    public void setCard_number(String card_number) {
+        this.card_number = card_number;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getAdmin_name() {
+        return admin_name;
+    }
+
+    public void setAdmin_name(String admin_name) {
+        this.admin_name = admin_name;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    // 获取code 微信支付第一步 通过code换取网页授权access_token
+    public String code() throws IOException {
+        JSONObject resultJson = new JSONObject();
+        if (code==null || admin_name==null || password==null){
+            resultJson.put("message", "参数不能为空");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        Admin login = appService.login(admin_name,password);
+        if (login==null){
+            resultJson.put("message", "账户或密码错误");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        CodeEntity codeEntity = appService.getCodeInfo(code);
+        Admin admin = appService.queryByNameAndOpenid(admin_name,codeEntity.getOpenid());
+        if (admin!=null){
+            resultJson.put("message", "已绑定");
+            resultJson.put("code", 200);
+            resultJson.put("data",admin);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        int m = appService.updateOpenid(codeEntity.getOpenid(),admin_name);
+        if (m>0){
+            admin = appService.queryByNameAndOpenid(admin_name,codeEntity.getOpenid());
+            resultJson.put("message", "绑定成功");
+            resultJson.put("code", 200);
+            resultJson.put("data",admin);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        return null;
+    }
+
+    public String getUser(){
+        JSONObject resultJson = new JSONObject();
+        if (code==null){
+            resultJson.put("message", "参数不能为空");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        CodeEntity codeEntity = appService.getCodeInfo(code);
+        Admin admin = appService.queryByOpenid(codeEntity.getOpenid());
+        if (admin==null){
+            resultJson.put("message", "未绑定信息");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        resultJson.put("message", "返回成功");
+        resultJson.put("code", 200);
+        resultJson.put("data", admin);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        return null;
+    }
+
+    /******************************商户绑定*******************************/
+    public String get_user_ma(){
+        JSONObject resultJson = new JSONObject();
+        if (code==null){
+            resultJson.put("message", "参数不能为空");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        CodeEntity codeEntity = appService.getCodeInfo(code);
+        AdminManager admin = appService.queryMaByOpenid(codeEntity.getOpenid());
+        if (admin==null){
+            resultJson.put("message", "未绑定信息");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        resultJson.put("message", "返回成功");
+        resultJson.put("code", 200);
+        resultJson.put("data", admin);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        return null;
+    }
+
+    public String manage_code(){
+        JSONObject resultJson = new JSONObject();
+        if (code==null || admin_name==null || password==null){
+            resultJson.put("message", "参数不能为空");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        AdminManager login = appService.login_ma(admin_name,password);
+        if (login==null){
+            resultJson.put("message", "账户或密码错误");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        if (login.getLevel().equals("2")){
+            resultJson.put("message", "管理员无权限绑定");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        CodeEntity codeEntity = appService.getCodeInfo(code);
+        AdminManager admin = appService.queryMaByNameAndOpenid(admin_name,codeEntity.getOpenid());
+        if (admin!=null){
+            resultJson.put("message", "已绑定");
+            resultJson.put("code", 200);
+            resultJson.put("data",admin);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+
+        int m = appService.updateMaOpenid(codeEntity.getOpenid(),admin_name);
+        if (m>0){
+            admin = appService.queryMaByNameAndOpenid(admin_name,codeEntity.getOpenid());
+            resultJson.put("message", "绑定成功");
+            resultJson.put("code", 200);
+            resultJson.put("data",admin);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        return null;
+    }
+}

+ 17 - 17
mhotel/src/com/happy/action/hotelAction.java

@@ -87,13 +87,13 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
             BeanUtils.copyProperties(hotelEto,hotel);
             BeanUtils.copyProperties(hotelEto,hotel);
             int hotelId = hotel.getId()!= null ? hotel.getId():Math.toIntExact(UUIDUtil.generateID());
             int hotelId = hotel.getId()!= null ? hotel.getId():Math.toIntExact(UUIDUtil.generateID());
             int m = 0;
             int m = 0;
-            //详细图附件
-            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
-            if(fileList==null){
-                resultJson.put("message", "请上传详细图");
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
+//            //详细图附件
+//            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+//            if(fileList==null){
+//                resultJson.put("message", "请上传详细图");
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
             //保存基本信息
             //保存基本信息
             if(hotel.getId()!= null){
             if(hotel.getId()!= null){
                 m = hotelService.updateHotel(hotel);
                 m = hotelService.updateHotel(hotel);
@@ -103,13 +103,13 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
             }
             }
 
 
             if (m > 0) {
             if (m > 0) {
-                if(hotel.getId()!= null){
-                    fileService.delLinkFile(hotel.getId());
-                }
-                for(File file : fileList){
-                    file.setLinkId(hotelId);
-                    fileService.insertFile(file);
-                }
+//                if(hotel.getId()!= null){
+//                    fileService.delLinkFile(hotel.getId());
+//                }
+//                for(File file : fileList){
+//                    file.setLinkId(hotelId);
+//                    fileService.insertFile(file);
+//                }
                 resultJson.put("message", "维护成功");
                 resultJson.put("message", "维护成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -156,8 +156,8 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
         }
         }
         StringBuilder fileSqlx = new StringBuilder("");
         StringBuilder fileSqlx = new StringBuilder("");
         fileSqlx.append("and link_id = '").append(id).append("'");
         fileSqlx.append("and link_id = '").append(id).append("'");
-        List<File> fileList = fileService.queryList(fileSqlx.toString());
-        hotelEto.setFileList(fileList);
+        List<FileInfo> fileList = fileService.queryList(fileSqlx.toString());
+        hotelEto.setFileInfoList(fileList);
         resultJson.put("message", "查询成功");
         resultJson.put("message", "查询成功");
         resultJson.put("code", 200);
         resultJson.put("code", 200);
         resultJson.put("data", hotelEto);
         resultJson.put("data", hotelEto);
@@ -365,7 +365,7 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
             List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
             List<HotelDict> list1 = hotelDictService.queryList(s1.toString());
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);
-            resultJson.put("data"+code, list1);
+            resultJson.put("data", list1);
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
             return null;
         }
         }

+ 27 - 27
mhotel/src/com/happy/action/houseAction.java

@@ -87,13 +87,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            //详细图附件
-            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
-            if(fileList==null){
-                resultJson.put("message", "请上传详细图");
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
+//            //详细图附件
+//            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+//            if(fileList==null){
+//                resultJson.put("message", "请上传详细图");
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             House listc = houseService.getOen(getOneSqlx.toString());
             House listc = houseService.getOen(getOneSqlx.toString());
@@ -106,10 +106,10 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             house.setId(Math.toIntExact(UUIDUtil.generateID()));
             house.setId(Math.toIntExact(UUIDUtil.generateID()));
             int m = houseService.insertHouse(house);
             int m = houseService.insertHouse(house);
             if (m > 0) {
             if (m > 0) {
-                for(File file : fileList){
-                    file.setLinkId(house.getId());
-                    fileService.insertFile(file);
-                }
+//                for(File file : fileList){
+//                    file.setLinkId(house.getId());
+//                    fileService.insertFile(file);
+//                }
                 resultJson.put("message", "新增成功");
                 resultJson.put("message", "新增成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -163,13 +163,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
-            //详细图附件
-            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
-            if(fileList==null){
-                resultJson.put("message", "请上传详细图");
-                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
-                return null;
-            }
+//            //详细图附件
+//            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+//            if(fileList==null){
+//                resultJson.put("message", "请上传详细图");
+//                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+//                return null;
+//            }
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and id != '").append(house.getId()).append("'");
             getOneSqlx.append(" and id != '").append(house.getId()).append("'");
@@ -182,13 +182,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             }
             }
             int m = houseService.updateHouse(house);
             int m = houseService.updateHouse(house);
             if (m > 0) {
             if (m > 0) {
-                if(house.getId()!= null){
-                    fileService.delLinkFile(house.getId());
-                }
-                for(File file : fileList){
-                    file.setLinkId(house.getId());
-                    fileService.insertFile(file);
-                }
+//                if(house.getId()!= null){
+//                    fileService.delLinkFile(house.getId());
+//                }
+//                for(File file : fileList){
+//                    file.setLinkId(house.getId());
+//                    fileService.insertFile(file);
+//                }
                 resultJson.put("message", "修改成功");
                 resultJson.put("message", "修改成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -248,8 +248,8 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
         House house = houseService.getById(id);
         House house = houseService.getById(id);
         StringBuilder fileSqlx = new StringBuilder("");
         StringBuilder fileSqlx = new StringBuilder("");
         fileSqlx.append("and link_id = '").append(id).append("'");
         fileSqlx.append("and link_id = '").append(id).append("'");
-        List<File> fileList = fileService.queryList(fileSqlx.toString());
-        house.setFileList(fileList);
+        List<FileInfo> fileInfoList = fileService.queryList(fileSqlx.toString());
+        house.setFileInfoList(fileInfoList);
         if (house != null) {
         if (house != null) {
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);

+ 4 - 1
mhotel/src/com/happy/action/uploadAction.java

@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
+import java.util.List;
 
 
 public class uploadAction extends ActionSupport implements ServletRequestAware {
 public class uploadAction extends ActionSupport implements ServletRequestAware {
 
 
@@ -24,6 +25,8 @@ public class uploadAction extends ActionSupport implements ServletRequestAware {
     public String url_name;
     public String url_name;
     public String url;
     public String url;
 
 
+    private List<File> fileList;
+
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
     }
     }
@@ -88,7 +91,7 @@ public class uploadAction extends ActionSupport implements ServletRequestAware {
             return null;
             return null;
         }
         }
         try{
         try{
-            if (!myFileFileName.endsWith("jpg") && !myFileFileName.endsWith("png")){
+            if (!filepath.endsWith("jpg") && !myFileFileName.endsWith("png")){
                 resultJson.put("code", 500);
                 resultJson.put("code", 500);
                 resultJson.put("message", "请上传jpg或png格式文件!");
                 resultJson.put("message", "请上传jpg或png格式文件!");
                 ResponseUtil.writeJson(ServletActionContext.getResponse(),
                 ResponseUtil.writeJson(ServletActionContext.getResponse(),

+ 30 - 0
mhotel/src/com/happy/dao/AppDao.java

@@ -0,0 +1,30 @@
+package com.happy.dao;
+
+import com.happy.Model.Admin;
+import com.happy.Model.AdminManager;
+
+import java.util.List;
+
+public interface AppDao {
+
+    // 登录
+    public Admin login(String admin_name, String password);
+
+    public Admin queryByOpenid(String openid);
+
+    public Admin queryByNameAndOpenid(String admin_name,String openid);
+
+    public int updateOpenid(String openid,String admin_name);
+
+    /**********************
+     * ********商户绑定**********
+     * ********************/
+    public AdminManager login_ma(String admin_name, String password);
+
+    public AdminManager queryMaByOpenid(String openid);
+
+    public AdminManager queryMaByNameAndOpenid(String admin_name,String openid);
+
+    public int updateMaOpenid(String openid,String admin_name);
+
+}

+ 7 - 7
mhotel/src/com/happy/dao/FileDao.java

@@ -1,24 +1,24 @@
 package com.happy.dao;
 package com.happy.dao;
 
 
-import com.happy.Model.File;
+import com.happy.Model.FileInfo;
 
 
 import java.util.List;
 import java.util.List;
 
 
-public interface FileDao {
+public interface FileInfoDao {
 
 
     /**
     /**
      * 描述:新增
      * 描述:新增
      * @param file
      * @param file
      * @return
      * @return
      */
      */
-    int insertFile(File file);
+    int insertFile(FileInfo file);
 
 
     /**
     /**
      * 描述:修改
      * 描述:修改
      * @param file
      * @param file
      * @return
      * @return
      */
      */
-    int updateFile(File file);
+    int updateFile(FileInfo file);
 
 
     /**
     /**
      * 描述:删除
      * 描述:删除
@@ -39,7 +39,7 @@ public interface FileDao {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
-    File getById(int id);
+    FileInfo getById(int id);
 
 
     /**
     /**
      * 描述:分页查询
      * 描述:分页查询
@@ -48,7 +48,7 @@ public interface FileDao {
      * @param rows
      * @param rows
      * @return
      * @return
      */
      */
-    List<File> queryPage(String sqlx, int page, int rows);
+    List<FileInfo> queryPage(String sqlx, int page, int rows);
 
 
 
 
     /**
     /**
@@ -63,6 +63,6 @@ public interface FileDao {
      * @param sqlx
      * @param sqlx
      * @return
      * @return
      */
      */
-    List<File> queryList(String sqlx);
+    List<FileInfo> queryList(String sqlx);
 
 
 }
 }

+ 44 - 11
mhotel/src/com/happy/dao/impl/AdminImplDao.java

@@ -2,6 +2,8 @@ package com.happy.dao.impl;
 
 
 import com.happy.Model.Admin;
 import com.happy.Model.Admin;
 import com.happy.Model.AdminPower;
 import com.happy.Model.AdminPower;
+import com.happy.Model.weixin.Users;
+import com.happy.Until.Func;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.AdminDao;
 import com.happy.dao.AdminDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -58,21 +60,15 @@ public class AdminImplDao implements AdminDao {
 
 
     @Override
     @Override
     public int updateAdmin(Admin admin){
     public int updateAdmin(Admin admin){
-        String sql = "update `admin` set user_name=:user_name,phone=:phone,password=:password,level=:level,admin_power=:admin_power,remark=:remark, create_id = :create_id, modify_date =:modify_date, status =:status where id=:id ";
+        StringBuffer stringBuffer =  new StringBuffer(" update `admin` set  ");
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("user_name",admin.getUserName());
-        sps.addValue("phone", admin.getPhone());
-        sps.addValue("password", admin.getPassword());
-        sps.addValue("level", admin.getLevel());
-        sps.addValue("admin_power",admin.getAdminPower());
-        sps.addValue("remark", admin.getRemark());
-        sps.addValue("create_id", admin.getCreateId());
-        sps.addValue("modify_date",admin.getModifyDate());
-        sps.addValue("status", admin.getStatus());
+        // 将要修改的数据填充到查询语句中
+        appendValue(admin,stringBuffer,sps);
+        stringBuffer.append("  where id=:id  ");
         sps.addValue("id", admin.getId());
         sps.addValue("id", admin.getId());
         int num = 0;
         int num = 0;
         try{
         try{
-            num = namedParameterJdbcTemplate.update(sql, sps);
+            num = namedParameterJdbcTemplate.update(stringBuffer.toString(), sps);
         }
         }
         catch(Exception e){
         catch(Exception e){
             e.printStackTrace();
             e.printStackTrace();
@@ -153,4 +149,41 @@ public class AdminImplDao implements AdminDao {
         }
         }
         return null;
         return null;
     }
     }
+
+    public void appendValue(Admin admin, StringBuffer stringBuffer, MapSqlParameterSource sps){
+        if (!Func.checkNull(admin.getAdminName())){
+            stringBuffer.append(" user_name=:user_name ,");
+            sps.addValue("user_name", admin.getAdminName());
+        }
+        if (!Func.checkNull(admin.getPassword())){
+            stringBuffer.append(" password=:password ,");
+            sps.addValue("password", admin.getPassword());
+        }
+        if (!Func.checkNull(admin.getUserName())){
+            stringBuffer.append(" user_name=:user_name ,");
+            sps.addValue("user_name", admin.getUserName());
+        }
+        if (!Func.checkNull(admin.getPhone())){
+            stringBuffer.append(" phone=:phone ,");
+            sps.addValue("phone", admin.getPhone());
+        }
+        if (!Func.checkNull(String.valueOf(admin.getLevel()))){
+            stringBuffer.append(" level=:level ,");
+            sps.addValue("level", admin.getLevel());
+        }
+        if (!Func.checkNull(admin.getAdminPower())){
+            stringBuffer.append(" admin_power=:admin_power ,");
+            sps.addValue("admin_power", admin.getAdminPower());
+        }
+        if (!Func.checkNull(admin.getRemark())){
+            stringBuffer.append(" remark=:remark ,");
+            sps.addValue("remark", admin.getRemark());
+        }
+        if (!Func.checkNull(String.valueOf(admin.getStatus()))){
+            stringBuffer.append(" status=:status ,");
+            sps.addValue("status", admin.getStatus());
+        }
+        stringBuffer.append(" modify_date=:modify_date ");
+        sps.addValue("modify_date", UUIDUtil.getNewDate());
+    }
 }
 }

+ 67 - 21
mhotel/src/com/happy/dao/impl/AdminManagerImplDao.java

@@ -1,6 +1,8 @@
 package com.happy.dao.impl;
 package com.happy.dao.impl;
 
 
+import com.happy.Model.Admin;
 import com.happy.Model.AdminManager;
 import com.happy.Model.AdminManager;
+import com.happy.Until.Func;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.AdminManagerDao;
 import com.happy.dao.AdminManagerDao;
 import org.apache.poi.ss.formula.functions.T;
 import org.apache.poi.ss.formula.functions.T;
@@ -30,10 +32,10 @@ public class AdminManagerImplDao implements AdminManagerDao {
     @Override
     @Override
     public int insertAdmin(AdminManager adminManager) {
     public int insertAdmin(AdminManager adminManager) {
 
 
-        String sql = "INSERT INTO admin_manager (id, manager_id, admin_name, password, hotel_name, hotel_township, corpn_name, corpn_phone, level, admin_power, bank_card, card_name, bank_name, create_id, create_date, status, remark) VALUES (:id, :admin_name, :password, :hotel_name, :hotel_township, :corpn_name, :corpn_phone, :level, :admin_power, :bank_card, :card_name, :bank_name, :create_id, :create_date, :status, :remark)";
+        String sql = "INSERT INTO admin_manager (id, manager_id, admin_name, password, hotel_name, hotel_township, corpn_name, corpn_phone, level, admin_power, bank_card, card_name, bank_name, create_id, create_date, status, remark) VALUES (:id, :manager_id ,:admin_name, :password, :hotel_name, :hotel_township, :corpn_name, :corpn_phone, :level, :admin_power, :bank_card, :card_name, :bank_name, :create_id, :create_date, :status, :remark)";
 
 
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("manager_id", adminManager.getAdminName());
+        sps.addValue("manager_id", adminManager.getManagerId());
         sps.addValue("admin_name", adminManager.getAdminName());
         sps.addValue("admin_name", adminManager.getAdminName());
         sps.addValue("password", adminManager.getPassword());
         sps.addValue("password", adminManager.getPassword());
         sps.addValue("hotel_name", adminManager.getHotelName());
         sps.addValue("hotel_name", adminManager.getHotelName());
@@ -67,28 +69,15 @@ public class AdminManagerImplDao implements AdminManagerDao {
     @Override
     @Override
     public int updateAdmin(AdminManager adminManager) {
     public int updateAdmin(AdminManager adminManager) {
 
 
-        String sql = "UPDATE admin_manager SET admin_name = :admin_name, password = :password, hotel_name = :hotel_name, hotel_township = :hotel_township, corpn_name = :corpn_name, corpn_phone = :corpn_phone, level = :level, admin_power = :admin_power, bank_card = :bank_card, card_name = :card_name, bank_name = :bank_name, create_id = :create_id, modify_date =:modify_date, status =:status, remark =:remark WHERE id = :id";
-
+        StringBuffer stringBuffer =  new StringBuffer(" update `admin_manager` set  ");
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("admin_name", adminManager.getAdminName());
-        sps.addValue("password", adminManager.getPassword());
-        sps.addValue("hotel_name", adminManager.getHotelName());
-        sps.addValue("hotel_township", adminManager.getHotelTownship());
-        sps.addValue("corpn_name", adminManager.getCorpnName());
-        sps.addValue("corpn_phone", adminManager.getCorpnPhone());
-        sps.addValue("level", adminManager.getLevel());
-        sps.addValue("admin_power", adminManager.getAdminPower());
-        sps.addValue("bank_card", adminManager.getBankCard());
-        sps.addValue("card_name", adminManager.getCardName());
-        sps.addValue("bank_name", adminManager.getBankName());
-        sps.addValue("create_id", adminManager.getCreateId());
-        sps.addValue("modify_date",adminManager.getModifyDate());
-        sps.addValue("status", adminManager.getStatus());
-        sps.addValue("remark", adminManager.getRemark());
-        sps.addValue("id",adminManager.getId());
+        // 将要修改的数据填充到查询语句中
+        appendValue(adminManager,stringBuffer,sps);
+        stringBuffer.append("  where id=:id  ");
+        sps.addValue("id", adminManager.getId());
         int num = 0;
         int num = 0;
         try{
         try{
-            num = namedParameterJdbcTemplate.update(sql, sps);
+            num = namedParameterJdbcTemplate.update(stringBuffer.toString(), sps);
         }
         }
         catch(Exception e){
         catch(Exception e){
             e.printStackTrace();
             e.printStackTrace();
@@ -159,4 +148,61 @@ public class AdminManagerImplDao implements AdminManagerDao {
         return null;
         return null;
     }
     }
 
 
+    public void appendValue(AdminManager adminManager, StringBuffer stringBuffer, MapSqlParameterSource sps){
+        if (!Func.checkNull(adminManager.getAdminName())){
+            stringBuffer.append(" admin_name=:admin_name ,");
+            sps.addValue("admin_name", adminManager.getAdminName());
+        }
+        if (!Func.checkNull(adminManager.getPassword())){
+            stringBuffer.append(" password=:password ,");
+            sps.addValue("password", adminManager.getPassword());
+        }
+        if (!Func.checkNull(adminManager.getHotelName())){
+            stringBuffer.append(" hotel_name=:hotel_name ,");
+            sps.addValue("hotel_name", adminManager.getHotelName());
+        }
+        if (!Func.checkNull(adminManager.getHotelTownship())){
+            stringBuffer.append(" hotel_township=:hotel_township ,");
+            sps.addValue("hotel_township", adminManager.getHotelTownship());
+        }
+        if (!Func.checkNull(adminManager.getCorpnName())){
+            stringBuffer.append(" corpn_name=:corpn_name ,");
+            sps.addValue("corpn_name", adminManager.getCorpnName());
+        }
+        if (!Func.checkNull(adminManager.getCorpnPhone())){
+            stringBuffer.append(" corpn_phone=:corpn_phone ,");
+            sps.addValue("corpn_phone", adminManager.getCorpnPhone());
+        }
+        if (!Func.checkNull(adminManager.getLevel())){
+            stringBuffer.append(" level=:level ,");
+            sps.addValue("level", adminManager.getLevel());
+        }
+        if (!Func.checkNull(adminManager.getAdminPower())){
+            stringBuffer.append(" admin_power=:admin_power ,");
+            sps.addValue("admin_power", adminManager.getAdminPower());
+        }
+        if (!Func.checkNull(String.valueOf(adminManager.getBankCard()))){
+            stringBuffer.append(" bank_card=:bank_card ,");
+            sps.addValue("bank_card", adminManager.getBankCard());
+        }
+        if (!Func.checkNull(adminManager.getCardName())){
+            stringBuffer.append(" card_name=:card_name ,");
+            sps.addValue("card_name", adminManager.getCardName());
+        }
+        if (!Func.checkNull(adminManager.getBankName())){
+            stringBuffer.append(" bank_name=:bank_name ,");
+            sps.addValue("bank_name", adminManager.getBankName());
+        }
+        if (!Func.checkNull(String.valueOf(adminManager.getStatus()))){
+            stringBuffer.append(" status=:status ,");
+            sps.addValue("status", adminManager.getStatus());
+        }
+        if (!Func.checkNull(adminManager.getRemark())){
+            stringBuffer.append(" remark=:remark ,");
+            sps.addValue("remark", adminManager.getRemark());
+        }
+        stringBuffer.append(" modify_date=:modify_date ");
+        sps.addValue("modify_date", UUIDUtil.getNewDate());
+    }
+
 }
 }

+ 138 - 0
mhotel/src/com/happy/dao/impl/AppImplDao.java

@@ -0,0 +1,138 @@
+package com.happy.dao.impl;
+
+import com.happy.Model.Admin;
+import com.happy.Model.AdminManager;
+import com.happy.dao.AppDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository("AppDao")
+public class AppImplDao implements AppDao {
+
+    @Autowired
+    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
+
+    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
+        return namedParameterJdbcTemplate;
+    }
+
+    public void setNamedParameterJdbcTemplate(
+            NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
+        this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
+    }
+
+    // 登录
+    public Admin login(String admin_name,String password) {
+        String sql = "select * from `admin` where admin_name=:admin_name and password=:password ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("admin_name",admin_name);
+        sps.addValue("password",password);
+        List<Admin> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(Admin.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public Admin queryByOpenid(String openid) {
+        String sql = "select * from `admin` where openid=:openid ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("openid",openid);
+        List<Admin> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(Admin.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public Admin queryByNameAndOpenid(String admin_name,String openid) {
+        String sql = "select * from `admin` where admin_name=:admin_name and openid=:openid ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("admin_name",admin_name);
+        sps.addValue("openid",openid);
+        List<Admin> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(Admin.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public int updateOpenid(String openid,String admin_name){
+        String sql = "update `admin` set openid=:openid where admin_name=:admin_name ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("openid",openid);
+        sps.addValue("admin_name",admin_name);
+        int num = 0;
+        try{
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        return num;
+    }
+
+    /**********************
+     * ********商户绑定**********
+     * ********************/
+    public AdminManager login_ma(String admin_name, String password) {
+        String sql = "select * from `admin_manager` where admin_name=:admin_name and password=:password ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("admin_name",admin_name);
+        sps.addValue("password",password);
+        List<AdminManager> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(AdminManager.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public AdminManager queryMaByOpenid(String openid) {
+        String sql = "select * from `admin_manager` where openid=:openid ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("openid",openid);
+        List<AdminManager> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(AdminManager.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public AdminManager queryMaByNameAndOpenid(String admin_name,String openid) {
+        String sql = "select * from `admin_manager` where admin_name=:admin_name and openid=:openid ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("admin_name",admin_name);
+        sps.addValue("openid",openid);
+        List<AdminManager> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(AdminManager.class));
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public int updateMaOpenid(String openid,String admin_name){
+        String sql = "update `admin_manager` set openid=:openid where admin_name=:admin_name ";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("openid",openid);
+        sps.addValue("admin_name",admin_name);
+        int num = 0;
+        try{
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        return num;
+    }
+}

+ 26 - 27
mhotel/src/com/happy/dao/impl/FileImplDao.java

@@ -1,9 +1,8 @@
 package com.happy.dao.impl;
 package com.happy.dao.impl;
 
 
-import com.happy.Model.AdminManager;
-import com.happy.Model.File;
+import com.happy.Model.FileInfo;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
-import com.happy.dao.FileDao;
+import com.happy.dao.FileInfoDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -13,7 +12,7 @@ import org.springframework.stereotype.Repository;
 import java.util.List;
 import java.util.List;
 
 
 @Repository("FileDao")
 @Repository("FileDao")
-public class FileImplDao implements FileDao {
+public class FileImplInfoDao implements FileInfoDao {
 
 
     @Autowired
     @Autowired
     private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
     private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@@ -28,12 +27,12 @@ public class FileImplDao implements FileDao {
     }
     }
 
 
     @Override
     @Override
-    public int insertFile(File file) {
-        String sql = "INSERT INTO file (id, link_id, file_url, file_name) VALUES (:id, :link_id, :file_url, :file_name)";
+    public int insertFile(FileInfo file) {
+        String sql = "INSERT INTO file_info (id, link_id, url, name) VALUES (:id, :link_id, :url, :name)";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("link_id",file.getLinkId());
         sps.addValue("link_id",file.getLinkId());
-        sps.addValue("file_url",file.getFileUrl());
-        sps.addValue("file_name",file.getFileName());
+        sps.addValue("url",file.getUrl());
+        sps.addValue("name",file.getName());
         if(file.getId()==null){
         if(file.getId()==null){
             sps.addValue("id", UUIDUtil.generateID());
             sps.addValue("id", UUIDUtil.generateID());
         }
         }
@@ -48,12 +47,12 @@ public class FileImplDao implements FileDao {
     }
     }
 
 
     @Override
     @Override
-    public int updateFile(File file) {
-        String sql = "UPDATE file SET id = :id, link_id = :link_id, file_url = :file_url, file_name = :file_name WHERE id = :id";
+    public int updateFile(FileInfo file) {
+        String sql = "UPDATE file_info SET id = :id, link_id = :link_id, url = :url, name = :name WHERE id = :id";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("link_id",file.getLinkId());
         sps.addValue("link_id",file.getLinkId());
-        sps.addValue("file_url",file.getFileUrl());
-        sps.addValue("file_name",file.getFileName());
+        sps.addValue("url",file.getUrl());
+        sps.addValue("name",file.getName());
         sps.addValue("id",file.getId());
         sps.addValue("id",file.getId());
         int num = 0;
         int num = 0;
         try{
         try{
@@ -67,7 +66,7 @@ public class FileImplDao implements FileDao {
 
 
     @Override
     @Override
     public int delFile(int id) {
     public int delFile(int id) {
-        String sql = "DELETE FROM `file` WHERE id = :id ";
+        String sql = "DELETE FROM `file_info` WHERE id = :id ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("id",id);
         sps.addValue("id",id);
         int num = 0;
         int num = 0;
@@ -81,7 +80,7 @@ public class FileImplDao implements FileDao {
 
 
     @Override
     @Override
     public int delLinkFile(int linkId) {
     public int delLinkFile(int linkId) {
-        String sql = "DELETE FROM `file` WHERE link_id = :link_id ";
+        String sql = "DELETE FROM `file_info` WHERE link_id = :link_id ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("link_id",linkId);
         sps.addValue("link_id",linkId);
         int num = 0;
         int num = 0;
@@ -94,14 +93,14 @@ public class FileImplDao implements FileDao {
     }
     }
 
 
     @Override
     @Override
-    public File getById(int id) {
-        String sql = "SELECT * FROM `file` WHERE id = :id ";
+    public FileInfo getById(int id) {
+        String sql = "SELECT * FROM `file_info` WHERE id = :id ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("id",id);
         sps.addValue("id",id);
-        List<File> list = null;
+        List<FileInfo> list = null;
         try{
         try{
             list = namedParameterJdbcTemplate.query(sql, sps,
             list = namedParameterJdbcTemplate.query(sql, sps,
-                    new BeanPropertyRowMapper<>(File.class));
+                    new BeanPropertyRowMapper<>(FileInfo.class));
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
         }
         }
@@ -110,31 +109,31 @@ public class FileImplDao implements FileDao {
     }
     }
 
 
     @Override
     @Override
-    public List<File> queryPage(String sqlx, int page, int rows) {
+    public List<FileInfo> queryPage(String sqlx, int page, int rows) {
         int start = (page - 1) * rows;// 每页的起始下标
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = "SELECT * FROM `file` WHERE 1=1 "+sqlx+" ORDER BY id DESC limit :start,:rows ";
+        String sql = "SELECT * FROM `file_info` WHERE 1=1 "+sqlx+" ORDER BY id DESC limit :start,:rows ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("start", start);
         sps.addValue("start", start);
         sps.addValue("rows", rows);
         sps.addValue("rows", rows);
-        List<File> list = namedParameterJdbcTemplate.query(sql, sps,
-                new BeanPropertyRowMapper<>(File.class));
+        List<FileInfo> list = namedParameterJdbcTemplate.query(sql, sps,
+                new BeanPropertyRowMapper<>(FileInfo.class));
         if (list != null && list.size() > 0) return list;
         if (list != null && list.size() > 0) return list;
         return null;
         return null;
     }
     }
 
 
     @Override
     @Override
     public int queryTotal(String sqlx) {
     public int queryTotal(String sqlx) {
-        String sql = "SELECT count(*) FROM`file` where 1=1 "+sqlx;
+        String sql = "SELECT count(*) FROM `file_info` where 1=1 "+sqlx;
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         return namedParameterJdbcTemplate.queryForInt(sql, sps);
         return namedParameterJdbcTemplate.queryForInt(sql, sps);
     }
     }
 
 
     @Override
     @Override
-    public List<File> queryList(String sqlx) {
-        String sql = "SELECT * FROM `file` WHERE 1=1 "+sqlx;
-        List<File> list = null;
+    public List<FileInfo> queryList(String sqlx) {
+        String sql = "SELECT * FROM `file_info` WHERE 1=1 "+sqlx;
+        List<FileInfo> list = null;
         try{
         try{
-            list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(File.class));
+            list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FileInfo.class));
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
         }
         }

+ 25 - 7
mhotel/src/com/happy/dao/impl/HotelDictImplDao.java

@@ -1,6 +1,8 @@
 package com.happy.dao.impl;
 package com.happy.dao.impl;
 
 
+import com.happy.Model.AdminManager;
 import com.happy.Model.HotelDict;
 import com.happy.Model.HotelDict;
+import com.happy.Until.Func;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.HotelDictDao;
 import com.happy.dao.HotelDictDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -55,17 +57,15 @@ public class HotelDictImplDao implements HotelDictDao {
 
 
     @Override
     @Override
     public int updateHotelDict(HotelDict hotelDict) {
     public int updateHotelDict(HotelDict hotelDict) {
-        String sql = "UPDATE hotel_dict SET code=:code, name=:name, file_url=:file_url, create_id=:create_id, modify_date=:modify_date WHERE id = :id";
+        StringBuffer stringBuffer =  new StringBuffer(" update `hotel_dict` set  ");
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("code",hotelDict.getCode());
-        sps.addValue("name",hotelDict.getName());
-        sps.addValue("file_url",hotelDict.getFileUrl());
-        sps.addValue("create_id",hotelDict.getCreateId());
-        sps.addValue("modify_date",UUIDUtil.getNewDate());
+        // 将要修改的数据填充到查询语句中
+        appendValue(hotelDict,stringBuffer,sps);
+        stringBuffer.append("  where id=:id  ");
         sps.addValue("id", hotelDict.getId());
         sps.addValue("id", hotelDict.getId());
         int num = 0;
         int num = 0;
         try{
         try{
-            num = namedParameterJdbcTemplate.update(sql, sps);
+            num = namedParameterJdbcTemplate.update(stringBuffer.toString(), sps);
         }
         }
         catch(Exception e){
         catch(Exception e){
             e.printStackTrace();
             e.printStackTrace();
@@ -135,4 +135,22 @@ public class HotelDictImplDao implements HotelDictDao {
         if(list != null && list.size()>0) return list;
         if(list != null && list.size()>0) return list;
         return null;
         return null;
     }
     }
+
+    public void appendValue(HotelDict hotelDict, StringBuffer stringBuffer, MapSqlParameterSource sps){
+        if (!Func.checkNull(String.valueOf(hotelDict.getCode()))){
+            stringBuffer.append(" code=:code ,");
+            sps.addValue("code",hotelDict.getCode());
+        }
+        if (!Func.checkNull(hotelDict.getName())){
+            stringBuffer.append(" name=:name ,");
+            sps.addValue("name",hotelDict.getName());
+        }
+        if (!Func.checkNull(hotelDict.getFileUrl())){
+            stringBuffer.append(" file_url=:file_url ,");
+            sps.addValue("file_url",hotelDict.getFileUrl());
+        }
+        stringBuffer.append(" modify_date=:modify_date ");
+        sps.addValue("modify_date", UUIDUtil.getNewDate());
+    }
+
 }
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 85 - 23
mhotel/src/com/happy/dao/impl/HotelImplDao.java


+ 45 - 11
mhotel/src/com/happy/dao/impl/HouseImplDao.java

@@ -1,8 +1,10 @@
 package com.happy.dao.impl;
 package com.happy.dao.impl;
 
 
 import com.happy.Model.Admin;
 import com.happy.Model.Admin;
+import com.happy.Model.Hotel;
 import com.happy.Model.House;
 import com.happy.Model.House;
 import com.happy.Model.House;
 import com.happy.Model.House;
+import com.happy.Until.Func;
 import com.happy.Until.UUIDUtil;
 import com.happy.Until.UUIDUtil;
 import com.happy.dao.HouseDao;
 import com.happy.dao.HouseDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,20 +61,15 @@ public class HouseImplDao implements HouseDao {
 
 
     @Override
     @Override
     public int updateHouse(House house) {
     public int updateHouse(House house) {
-        String sql = "UPDATE house SET h_name = :h_name, h_areas = :h_areas, price = :price, number = :number, h_config = :h_config, remark = :remark, modify_date = :modify_date, status = :status WHERE id = :id";
+        StringBuffer stringBuffer =  new StringBuffer(" update `house` set  ");
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
-        sps.addValue("h_name",house.gethName());
-        sps.addValue("h_areas",house.gethAreas());
-        sps.addValue("price",house.getPrice());
-        sps.addValue("number",house.getNumber());
-        sps.addValue("h_config",house.gethConfig());
-        sps.addValue("remark",house.getRemark());
-        sps.addValue("modify_date",house.getModifyDate());
-        sps.addValue("status",house.getStatus());
-        sps.addValue("id",house.getId());
+        // 将要修改的数据填充到查询语句中
+        appendValue(house,stringBuffer,sps);
+        stringBuffer.append("  where id=:id  ");
+        sps.addValue("id", house.getId());
         int num = 0;
         int num = 0;
         try{
         try{
-            num = namedParameterJdbcTemplate.update(sql, sps);
+            num = namedParameterJdbcTemplate.update(stringBuffer.toString(), sps);
         }
         }
         catch(Exception e){
         catch(Exception e){
             e.printStackTrace();
             e.printStackTrace();
@@ -142,4 +139,41 @@ public class HouseImplDao implements HouseDao {
         if(list != null && list.size()>0) return list;
         if(list != null && list.size()>0) return list;
         return null;
         return null;
     }
     }
+
+    public void appendValue(House house, StringBuffer stringBuffer, MapSqlParameterSource sps){
+        if (!Func.checkNull(house.getManagerId())){
+            stringBuffer.append(" manager_id=:manager_id ,");
+            sps.addValue("manager_id",house.getManagerId());
+        }
+        if (!Func.checkNull(house.gethName())){
+            stringBuffer.append(" h_name=:h_name ,");
+            sps.addValue("h_name",house.gethName());
+        }
+        if (!Func.checkNull(house.gethAreas())){
+            stringBuffer.append(" h_areas=:h_areas ,");
+            sps.addValue("h_areas",house.gethAreas());
+        }
+        if (!Func.checkNull(String.valueOf(house.getPrice()))){
+            stringBuffer.append(" price=:price ,");
+            sps.addValue("price",house.getPrice());
+        }
+        if (!Func.checkNull(String.valueOf(house.getNumber()))){
+            stringBuffer.append(" number=:number ,");
+            sps.addValue("number",house.getNumber());
+        }
+        if (!Func.checkNull(house.gethConfig())){
+            stringBuffer.append(" h_config=:h_config ,");
+            sps.addValue("h_config",house.gethConfig());
+        }
+        if (!Func.checkNull(house.getRemark())){
+            stringBuffer.append(" remark=:remark ,");
+            sps.addValue("remark",house.getRemark());
+        }
+        if (!Func.checkNull(String.valueOf(house.getStatus()))){
+            stringBuffer.append(" status=:status ,");
+            sps.addValue("status", house.getStatus());
+        }
+        stringBuffer.append(" modify_date=:modify_date ");
+        sps.addValue("modify_date", UUIDUtil.getNewDate());
+    }
 }
 }

+ 6 - 6
mhotel/src/com/happy/dto/HotelEto.java

@@ -1,6 +1,6 @@
 package com.happy.dto;
 package com.happy.dto;
 
 
-import com.happy.Model.File;
+import com.happy.Model.FileInfo;
 import com.happy.Model.Hotel;
 import com.happy.Model.Hotel;
 
 
 import java.util.List;
 import java.util.List;
@@ -17,7 +17,7 @@ public class HotelEto extends Hotel {
 
 
     private String bankCard;//银行卡号
     private String bankCard;//银行卡号
 
 
-    private List<File> fileList;//详细图列表
+    private List<FileInfo> fileInfoList;//详细图列表
 
 
     public String getHotelName() {
     public String getHotelName() {
         return hotelName;
         return hotelName;
@@ -59,11 +59,11 @@ public class HotelEto extends Hotel {
         this.bankCard = bankCard;
         this.bankCard = bankCard;
     }
     }
 
 
-    public List<File> getFileList() {
-        return fileList;
+    public List<FileInfo> getFileInfoList() {
+        return fileInfoList;
     }
     }
 
 
-    public void setFileList(List<File> fileList) {
-        this.fileList = fileList;
+    public void setFileInfoList(List<FileInfo> fileInfoList) {
+        this.fileInfoList = fileInfoList;
     }
     }
 }
 }

+ 24 - 0
mhotel/src/com/happy/service/AppService.java

@@ -1,8 +1,32 @@
 package com.happy.service;
 package com.happy.service;
 
 
+import com.happy.Model.Admin;
+import com.happy.Model.AdminManager;
 import com.happy.Model.weixin.CodeEntity;
 import com.happy.Model.weixin.CodeEntity;
 
 
+import java.util.List;
+
 public interface AppService {
 public interface AppService {
 
 
     public CodeEntity getCodeInfo(String code);
     public CodeEntity getCodeInfo(String code);
+
+    // 登录
+    public Admin login(String admin_name, String password);
+
+    public Admin queryByOpenid(String openid);
+
+    public Admin queryByNameAndOpenid(String admin_name,String openid);
+
+    public int updateOpenid(String openid,String admin_name);
+
+    /**********************
+     * ********商户绑定**********
+     * ********************/
+    public AdminManager login_ma(String admin_name, String password);
+
+    public AdminManager queryMaByOpenid(String openid);
+
+    public AdminManager queryMaByNameAndOpenid(String admin_name,String openid);
+
+    public int updateMaOpenid(String openid,String admin_name);
 }
 }

+ 15 - 7
mhotel/src/com/happy/service/FileService.java

@@ -1,8 +1,11 @@
 package com.happy.service;
 package com.happy.service;
 
 
-import com.happy.Model.File;
+import com.happy.Model.FileInfo;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
 
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.List;
 import java.util.List;
 
 
 public interface FileService {
 public interface FileService {
@@ -12,14 +15,14 @@ public interface FileService {
      * @param file
      * @param file
      * @return
      * @return
      */
      */
-    int insertFile(File file);
+    int insertFile(FileInfo file);
 
 
     /**
     /**
      * 描述:修改
      * 描述:修改
      * @param file
      * @param file
      * @return
      * @return
      */
      */
-    int updateFile(File file);
+    int updateFile(FileInfo file);
 
 
     /**
     /**
      * 描述:删除
      * 描述:删除
@@ -40,7 +43,7 @@ public interface FileService {
      * @param id
      * @param id
      * @return
      * @return
      */
      */
-    File getById(int id);
+    FileInfo getById(int id);
 
 
     /**
     /**
      * 描述:分页查询
      * 描述:分页查询
@@ -49,19 +52,24 @@ public interface FileService {
      * @param rows
      * @param rows
      * @return
      * @return
      */
      */
-    IPage<File> queryPage(String sqlx, int page, int rows);
+    IPage<FileInfo> queryPage(String sqlx, int page, int rows);
 
 
     /**
     /**
      * 描述:查询列表
      * 描述:查询列表
      * @param sqlx
      * @param sqlx
      * @return
      * @return
      */
      */
-    List<File> queryList(String sqlx);
+    List<FileInfo> queryList(String sqlx);
 
 
     /**
     /**
      * 描述:查询一条数据
      * 描述:查询一条数据
      * @param sqlx
      * @param sqlx
      * @return
      * @return
      */
      */
-    File getOen(String sqlx);
+    FileInfo getOen(String sqlx);
+
+    /**
+     * 描述:批量上传图片
+     */
+    void uploadImp(List<File> fileList, HttpServletRequest request);
 }
 }

+ 46 - 1
mhotel/src/com/happy/service/impl/AppImplService.java

@@ -1,14 +1,23 @@
 package com.happy.service.impl;
 package com.happy.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.happy.Model.Admin;
+import com.happy.Model.AdminManager;
 import com.happy.Model.weixin.CodeEntity;
 import com.happy.Model.weixin.CodeEntity;
 import com.happy.common.util.WechatUtil;
 import com.happy.common.util.WechatUtil;
+import com.happy.dao.AppDao;
 import com.happy.service.AppService;
 import com.happy.service.AppService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import javax.annotation.Resource;
+import java.util.List;
+
 @Service("AppService")
 @Service("AppService")
 public class AppImplService implements AppService {
 public class AppImplService implements AppService {
 
 
+    @Resource
+    public AppDao appDao;
+
     public CodeEntity getCodeInfo(String code){
     public CodeEntity getCodeInfo(String code){
         CodeEntity entity = new CodeEntity();
         CodeEntity entity = new CodeEntity();
         JSONObject wx = WechatUtil.getOpenId(code);
         JSONObject wx = WechatUtil.getOpenId(code);
@@ -26,8 +35,44 @@ public class AppImplService implements AppService {
         entity.setUnionid(unionId);
         entity.setUnionid(unionId);
         // 是否需要获取手机号,true需要
         // 是否需要获取手机号,true需要
         entity.setFlagPhone(true);
         entity.setFlagPhone(true);
-        System.out.println("openid:"+openid+",session_key:"+sessionkey+",unionid:"+unionId);
         // 返回参数
         // 返回参数
         return entity;
         return entity;
     }
     }
+
+    // 登录
+    public Admin login(String admin_name, String password){
+        return appDao.login(admin_name, password);
+    }
+
+    public Admin queryByOpenid(String openid){
+        return appDao.queryByOpenid(openid);
+    }
+
+    public Admin queryByNameAndOpenid(String admin_name,String openid){
+        return appDao.queryByNameAndOpenid(admin_name, openid);
+    }
+
+    public int updateOpenid(String openid,String admin_name){
+        return appDao.updateOpenid(openid, admin_name);
+    }
+
+    /**********************
+     * ********商户绑定**********
+     * ********************/
+    public AdminManager login_ma(String admin_name, String password){
+        return appDao.login_ma(admin_name, password);
+    }
+
+    public AdminManager queryMaByOpenid(String openid){
+        return appDao.queryMaByOpenid(openid);
+    }
+
+    public AdminManager queryMaByNameAndOpenid(String admin_name,String openid){
+        return appDao.queryMaByNameAndOpenid(admin_name, openid);
+    }
+
+    public int updateMaOpenid(String openid,String admin_name){
+        return appDao.updateMaOpenid(openid, admin_name);
+    }
+
 }
 }

+ 50 - 12
mhotel/src/com/happy/service/impl/FileImplService.java

@@ -1,27 +1,38 @@
 package com.happy.service.impl;
 package com.happy.service.impl;
 
 
-import com.happy.Model.File;
-import com.happy.dao.FileDao;
+import com.happy.Model.FileInfo;
+import com.happy.Until.ResponseUtil;
+import com.happy.dao.FileInfoDao;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
 import com.happy.service.FileService;
 import com.happy.service.FileService;
+import net.sf.json.JSONObject;
+import org.apache.commons.io.FileUtils;
+import org.apache.struts2.ServletActionContext;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.util.List;
 import java.util.List;
 
 
 @Service("FileService")
 @Service("FileService")
 public class FileImplService implements FileService {
 public class FileImplService implements FileService {
 
 
     @Resource
     @Resource
-    public FileDao fileDao;
+    public FileInfoDao fileDao;
 
 
     @Override
     @Override
-    public int insertFile(File file) {
+    public int insertFile(FileInfo file) {
         return fileDao.insertFile(file);
         return fileDao.insertFile(file);
     }
     }
 
 
     @Override
     @Override
-    public int updateFile(File file) {
+    public int updateFile(FileInfo file) {
         return fileDao.updateFile(file);
         return fileDao.updateFile(file);
     }
     }
 
 
@@ -36,14 +47,14 @@ public class FileImplService implements FileService {
     }
     }
 
 
     @Override
     @Override
-    public File getById(int id) {
+    public FileInfo getById(int id) {
         return fileDao.getById(id);
         return fileDao.getById(id);
     }
     }
 
 
     @Override
     @Override
-    public IPage<File> queryPage(String sqlx, int page, int rows) {
-        IPage<File> iPage = new IPage();
-        List<File> fileList = fileDao.queryPage(sqlx,page,rows);
+    public IPage<FileInfo> queryPage(String sqlx, int page, int rows) {
+        IPage<FileInfo> iPage = new IPage();
+        List<FileInfo> fileList = fileDao.queryPage(sqlx,page,rows);
         int total = fileDao.queryTotal(sqlx);
         int total = fileDao.queryTotal(sqlx);
         iPage.setPageList(fileList);
         iPage.setPageList(fileList);
         iPage.setPage(page);
         iPage.setPage(page);
@@ -54,14 +65,41 @@ public class FileImplService implements FileService {
     }
     }
 
 
     @Override
     @Override
-    public List<File> queryList(String sqlx) {
+    public List<FileInfo> queryList(String sqlx) {
         return fileDao.queryList(sqlx);
         return fileDao.queryList(sqlx);
     }
     }
 
 
     @Override
     @Override
-    public File getOen(String sqlx){
-        List<File> list = fileDao.queryList(sqlx);
+    public FileInfo getOen(String sqlx){
+        List<FileInfo> list = fileDao.queryList(sqlx);
         if(list!=null && list.size()>0) return list.get(0);
         if(list!=null && list.size()>0) return list.get(0);
         return null;
         return null;
     }
     }
+
+    @Override
+    public void uploadImp(List<File> fileList, HttpServletRequest request) {
+        String filepath=request.getServletContext().getRealPath("/download/");
+        if(fileList!=null && fileList.size()>0 && filepath!=null){
+            //遍历file
+            for(File file : fileList){
+                try {
+                    File destFile = new File(filepath, file.getName());
+                    // 获取图片大小
+                    long size = file.length();
+                    // 获取图片尺寸
+                    BufferedImage sourceImg = null;
+                    sourceImg = ImageIO.read(new FileInputStream(file));
+                    System.out.println(String.format("%.1f",file.length()/1024.0));// 源图大小
+                    System.out.println(sourceImg.getWidth()); // 源图宽度
+                    System.out.println(sourceImg.getHeight()); // 源图高度
+                    // 保存图片到指定位置
+                    FileUtils.copyFile(file, destFile);
+                    // 返回图片url路径
+                    String url = "http://192.168.57.1:8080/zhotel/download/" + file.getName();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }
 }