Browse Source

Merge remote-tracking branch 'origin/master'

raojiaolong@163.com 2 years ago
parent
commit
0c3bf13164

+ 3 - 1
mhotel/src/com/happy/Model/Hotel.java

@@ -127,7 +127,6 @@ public class Hotel {
 	private Integer status;
 
 	private String min_price;
-
 	private List<House> houseList;
 
 	public Integer getId() {
@@ -322,6 +321,9 @@ public class Hotel {
 		this.houseList = houseList;
 	}
 
+	/**
+	 * 酒店最低价
+	 */
 	public String getMin_price() {
 		return min_price;
 	}

+ 3 - 3
mhotel/src/com/happy/Model/weixin/Users.java

@@ -14,7 +14,7 @@ public class Users {
     public String create_time;
     public String remark;   // 备注
     public int identity_type;   // 用户分类
-    private int contactId;   // 关联人id(用于常联系人关联)
+    private String contactId;   // 关联人id(用于常联系人关联)
     private String contactName;   // 关联人姓名(用于常联系人关联)
     private String dataType; // 数据类型
     private String headPhoto; // 用户头像地址
@@ -91,11 +91,11 @@ public class Users {
         this.identity_type = identity_type;
     }
 
-    public int getContactId() {
+    public String getContactId() {
         return contactId;
     }
 
-    public void setContactId(int contactId) {
+    public void setContactId(String contactId) {
         this.contactId = contactId;
     }
 

+ 49 - 2
mhotel/src/com/happy/Until/GetHttpParam.java

@@ -75,11 +75,58 @@ public class GetHttpParam {
             String value=arr[i].substring( arr[i].indexOf("=")+1);
             map.put(key, value);
         }
+        return JSON.parseObject(mapToJson(map));
+    }
+
+    /**
+     *  获取request中参数
+     * @param request 页面请求
+     */
+    public static String getRequestStringParameters(HttpServletRequest request) {
+        String parameters="";//请求参数
+        if("GET".equals(request.getMethod())){//GET请求时的参数
+            String urlParameter=request.getQueryString();//网址中的参数
+            if(urlParameter!=null&&!"".equals(urlParameter)){
+                try {
+                    urlParameter= URLDecoder.decode(urlParameter,"UTF-8");
+                } catch (UnsupportedEncodingException e) {
+                    e.printStackTrace();
+                }
+            }else {
+                urlParameter="";
+            }
+            parameters=urlParameter;
+        }else if("POST".equals(request.getMethod())){//POST请求时的参数
+            String totalParameter="";//表单及网址中全部参数
+            Map<String, String[]> params = request.getParameterMap();
+            int parametersNum=request.getParameterMap().size();//参数个数
+            int flag=1;
+            for (String key : params.keySet()) {
+
+                String[] values = params.get(key);
+                for (int i = 0; i < values.length; i++) {
+                    String value = values[i];
+                    totalParameter+= key + "=" + value;
+                }
+                if(flag<parametersNum){
+                    totalParameter+="&";
+                }
+                flag+=1;
+            }
+            parameters=totalParameter;
+        }
+        Map<String, Object> map=new HashMap<String, Object>();
+        String[] arr=parameters.split("&");
+        for (int i = 0; i <arr.length; i++) {
+            String key=arr[i].substring(0, arr[i].indexOf("="));
+            String value=arr[i].substring( arr[i].indexOf("=")+1);
+            map.put(key, value);
+        }
         return mapToJson(map);
     }
 
-    public static JSONObject mapToJson(Map<String, Object> map) {
+    public static String mapToJson(Map<String, Object> map) {
         String data = JSON.toJSONString(map);
-        return JSON.parseObject(data);
+        return data;
     }
 }

+ 4 - 1
mhotel/src/com/happy/Until/ResponseUtil.java

@@ -38,7 +38,7 @@ public class ResponseUtil {
 			resultJson.put("total", 0);
 		} else {
 			resultJson.put("code", 200);
-			resultJson.put("rows", listPage);
+			resultJson.put("rows", rows);
 			// int total = listAll.size();
 			resultJson.put("total", total);// 总记录数
 			int totalPage = total % rows == 0 ? (total / rows) : (total / rows) + 1;// 总页数
@@ -51,6 +51,8 @@ public class ResponseUtil {
 			resultJson.put("hasNextPage", true);// 有下一页
 			resultJson.put("firstPage", true);// 首页
 			resultJson.put("lastPage", true);// 尾页
+			resultJson.put("listPage", listPage);
+
 		}
 
 		PrintWriter out;
@@ -86,6 +88,7 @@ public class ResponseUtil {
 			resultJson.put("hasNextPage", true);// 有下一页
 			resultJson.put("firstPage", true);// 首页
 			resultJson.put("lastPage", true);// 尾页
+			resultJson.put("pageList",iPage.getPageList()); // 分页数据
 		}
 
 		PrintWriter out;

+ 1 - 12
mhotel/src/com/happy/action/AppHomePageAction.java

@@ -115,24 +115,13 @@ public class AppHomePageAction extends ActionSupport implements ServletRequestAw
         //getUserInfo();
 
         // 获取民宿列表
-        IPage iPage = appHomePageService.getHotelList(queryValue,rows,page);
+        IPage iPage = appHomePageService.getHotelList(queryValue,page,rows);
         ResponseUtil.writeJsonIPage(ServletActionContext.getResponse(),iPage);
 
         return null;
     }
 
     /**
-     * 微信授权,进入页面
-     * @return
-     */
-    public String Authorization()
-    {
-        // TODO 微信授权,进入页面
-        return null;
-    }
-
-
-    /**
      * 通过酒店的id获取到房间信息
      * @return
      */

+ 31 - 3
mhotel/src/com/happy/action/AppMePageAction.java

@@ -1,6 +1,5 @@
 package com.happy.action;
 
-import com.happy.Model.Booking;
 import com.happy.Model.weixin.Users;
 import com.happy.Until.Enum.B;
 import com.happy.Until.Enum.DataType;
@@ -18,7 +17,6 @@ import org.apache.struts2.interceptor.ServletRequestAware;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -43,6 +41,7 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
     public int rows = 5;// 每页显示的行数rows
     private String userId; // 用户id
     private String userName; // 用户姓名
+    private String headPhoto; // 用户头像地址
     private String contactId; // 相关联系人的id
     public String status;
 
@@ -96,6 +95,7 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
 
 
     /**
+     * userId
      * 进入我的,查询订单列表
      * @return
      */
@@ -199,7 +199,7 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
 
         // 相关联系人
         Users users = new Users();
-        users.setContactId(Func.parseInt(userId));
+        users.setContactId(Func.parseStr(userId));
         users.setContactName(userName);
         users.setCreate_time(TimeExchange.getDate());
         users.setDataType(DataType.关联数据.toString());
@@ -215,6 +215,26 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
     }
 
     /**
+     * 用户点击保存,更新用户信息
+     */
+    public void updateUserInfo()
+    {
+        if (Func.checkNullOrEmpty(userId))
+            return;
+        Users users = userService.queryByUserId(userId);
+        users.setHeadPhoto(headPhoto);
+        users.setUser_name(userName);
+        users.setDataType(DataType.游客数据.toString());
+
+        userService.update(users);
+        JSONObject resultJson = new JSONObject();
+        resultJson.put(B.CODE,ResultStatusCode.OK.getStatus());
+        resultJson.put(B.MESSAGE,ResultStatusCode.OK.getMsg());
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
+    }
+
+    /**
+     * contactId
      * 用户可以删除自己相关联系人
      */
     public void delContact()
@@ -296,4 +316,12 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
     public void setContactId(String contactId) {
         this.contactId = contactId;
     }
+
+    public String getHeadPhoto() {
+        return headPhoto;
+    }
+
+    public void setHeadPhoto(String headPhoto) {
+        this.headPhoto = headPhoto;
+    }
 }

+ 4 - 12
mhotel/src/com/happy/action/appAction.java

@@ -45,8 +45,6 @@
 //    public HouseService houseService;
 //    @Resource
 //    public ConfigService configService;
-//    @Resource
-//    public LogsService logsService;
 //
 //    public String wxcode;
 //    public String state;
@@ -330,7 +328,7 @@
 //            System.out.println("支付成功回调,订单号:"+order_num);
 //            Booking booking = bookService.queryByOrder(order_num);
 //            // 支付成功
-//            if (result.getResult_code().equals("SUCCESS") && booking!=null && booking.getStatus().equals("1")) {
+//            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>";
@@ -371,19 +369,19 @@
 //            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //            return null;
 //        }
-//        if (booking.getStatus().equals("1")){
+//        if (booking.getOrderStatus().equals("1")){
 //            resultJson.put("code", 503);
 //            resultJson.put("message", "订单未支付不可申请退款");
 //            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //            return null;
 //        }
-//        if (booking.getStatus().equals("3")){
+//        if (booking.getOrderStatus().equals("3")){
 //            resultJson.put("code", 503);
 //            resultJson.put("message", "已入住,请往前台办理");
 //            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
 //            return null;
 //        }
-//        if (booking.getStatus().equals("4") || booking.getStatus().equals("5") || booking.getStatus().equals("6")){
+//        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());
@@ -450,12 +448,6 @@
 //            return null;
 //        }
 //        bookService.update_pay("7", order_num);  // 退款中
-//        Logs logs = new Logs();
-//        logs.setAdmin_name(booking.getUser_name());
-//        logs.setOrder_num(booking.getOrder_num());
-//        logs.setCreate_time(TimeExchange.getTime());
-//        logs.setRecord1("用户自己申请退款,时间:"+TimeExchange.getTime());
-//        logsService.insert(logs);
 //        resultJson.put("code", 200);
 //        resultJson.put("message", "退款申请已提交,请稍候查询");
 //        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());

+ 9 - 10
mhotel/src/com/happy/dao/HotelDao.java

@@ -45,16 +45,6 @@ public interface HotelDao {
 
 
     /**
-     * 描述:分页查询,加最低价格
-     * @param sqlx
-     * @param page
-     * @param rows
-     * @return
-     */
-    List<Hotel> queryPagePrice(String sqlx, int page, int rows);
-
-
-    /**
      * 描述:获取总条数
      * @param sqlx
      * @return
@@ -68,4 +58,13 @@ public interface HotelDao {
      */
     List<Hotel> queryList(String sqlx);
 
+    /**
+     * 查询列表,加最底房价
+     * @param sqlx
+     * @param page
+     * @param rows
+     * @return
+     * 00
+     */
+    public List<Hotel> queryPagePrice(String sqlx, int page, int rows);
 }

+ 9 - 0
mhotel/src/com/happy/service/HotelService.java

@@ -46,6 +46,15 @@ public interface HotelService {
     IPage<Hotel> queryPage(String sqlx, int page, int rows);
 
     /**
+     * 描述:分页查询带最低价
+     * @param sqlx
+     * @param page
+     * @param rows
+     * @return
+     */
+    IPage<Hotel> queryPagePrice(String sqlx, int page, int rows);
+
+    /**
      * 描述:查询列表
      * @param sqlx
      * @return

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

@@ -44,7 +44,7 @@ public class AppHomePageImplService implements AppHomePageService {
             strSql.append(" and hname like '%").append(queryValue).append("%' ");
         }
 
-        return hotelService.queryPage(strSql.toString(),page,rows);
+        return hotelService.queryPagePrice(strSql.toString(),page,rows);
     }
 
     @Override

+ 13 - 0
mhotel/src/com/happy/service/impl/HotelImplService.java

@@ -49,6 +49,19 @@ public class HotelImplService implements HotelService {
     }
 
     @Override
+    public IPage<Hotel> queryPagePrice(String sqlx, int page, int rows) {
+        IPage<Hotel> iPage = new IPage();
+        List<Hotel> hotelList = hotelDao.queryPagePrice(sqlx,page,rows);
+        int total = hotelDao.queryTotal(sqlx);
+        iPage.setPageList(hotelList);
+        iPage.setPage(page);
+        iPage.setTotalPage( (int)Math.ceil((double)total/rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        return iPage;
+    }
+
+    @Override
     public List<Hotel> queryList(String sqlx) {
         return hotelDao.queryList(sqlx);
     }