Administrator il y a 2 ans
Parent
commit
d1e7d45cf9

+ 5 - 13
mhotel/src/com/happy/Model/Hotel.java

@@ -86,8 +86,7 @@ public class Hotel {
 	 */
 	private String hconfig;
 
-	private String hconfigName;
-	private String hconfigFileUrl;
+	private List hconfigList;
 	/**
 	 * 接单设置(1自动接单 2手动接单)
 	 */
@@ -362,19 +361,12 @@ public class Hotel {
 		this.hotelTownshipName = hotelTownshipName;
 	}
 
-	public String getHconfigName() {
-		return hconfigName;
-	}
-
-	public void setHconfigName(String hconfigName) {
-		this.hconfigName = hconfigName;
-	}
 
-	public String getHconfigFileUrl() {
-		return hconfigFileUrl;
+	public List getHconfigList() {
+		return hconfigList;
 	}
 
-	public void setHconfigFileUrl(String hconfigFileUrl) {
-		this.hconfigFileUrl = hconfigFileUrl;
+	public void setHconfigList(List hconfigList) {
+		this.hconfigList = hconfigList;
 	}
 }

+ 1 - 1
mhotel/src/com/happy/Model/HotelDict.java

@@ -12,7 +12,7 @@ public class HotelDict {
 	private Integer id;
 
     /**
-     * 编码
+     * 编码(1.民宿类型;2.民宿服务;3.房型名称;4.房型服务)
      */
     private Integer code;
 

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

@@ -46,6 +46,7 @@ public class House {
 	 */
 	private String hConfig;
 
+	private  List hConfigList;
 	/**
 	 * 备注
 	 */
@@ -189,4 +190,12 @@ public class House {
 	public void setRemainRooms(String remainRooms) {
 		this.remainRooms = remainRooms;
 	}
+
+	public List gethConfigList() {
+		return hConfigList;
+	}
+
+	public void sethConfigList(List hConfigList) {
+		this.hConfigList = hConfigList;
+	}
 }

+ 2 - 2
mhotel/src/com/happy/Model/weixin/WeiXinUtil.java

@@ -3,9 +3,9 @@ package com.happy.Model.weixin;
 public class WeiXinUtil {
 
     // 诚欣公众号
-    public static String appid_c = "wxa5cc2178ff34bc8e";
+    public static String appid_c = "wx2fc3f45732fae5d3";
     public static String ip = "171.34.223.11";
-    public static String screct_c = "7e6b036298b718da6d1afe4ae5364a1f";
+    public static String screct_c = "7eee4a49a4470a77f9222995e8511547";
     public static String key = "v2";
     // 诚欣测试号
     /*public static String appid_c = "wx5fcbd4d313aa4c15";

+ 1 - 1
mhotel/src/com/happy/Until/DateUtil.java

@@ -22,7 +22,7 @@ public class DateUtil
 
     }
 
-    public static String Time_Formatter_Day = "yyyy/MM/dd";
+    public static String Time_Formatter_Day = "yyyy-MM-dd";
     public static String Time_Formatter_Second = "yyyy-MM-dd HH:mm:ss";
 
     public static String getCurrentYear() {

+ 2 - 2
mhotel/src/com/happy/Until/Func.java

@@ -289,13 +289,13 @@ public class Func {
             return null;
         }
         try {
-            return new SimpleDateFormat("yyyy/MM/dd").parse(dateStr);
+            return new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
         } catch (ParseException e) {
             e.printStackTrace();
         }
 
         try {
-            return new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
+            return new SimpleDateFormat("yyyy/MM/dd").parse(dateStr);
         } catch (ParseException e) {
             e.printStackTrace();
         }

+ 3 - 1
mhotel/src/com/happy/action/AppBookingAction.java

@@ -161,7 +161,8 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
             return null;
         }
 
-        String mess = appBookService.createOrder(houseId, startDate, endDate, houseOrderNumber, userName, userPhone, userId);
+        String  bookingId= Func.parseStr(UUIDUtil.generateID());
+        String mess = appBookService.createOrder(bookingId, houseId, startDate, endDate, houseOrderNumber, userName, userPhone, userId);
         if (!Func.checkNull(mess)) {
             jsonObject.put(B.code, ResultStatusCode.BAD_REQUEST.getStatus());
             jsonObject.put(B.message, mess);
@@ -171,6 +172,7 @@ public class AppBookingAction extends ActionSupport implements ServletRequestAwa
 
         jsonObject.put(B.code, ResultStatusCode.OK.getStatus());
         jsonObject.put(B.message, ResultStatusCode.OK.getMsg());
+        jsonObject.put(B.data, bookingId);
         ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
         return null;
     }

+ 11 - 17
mhotel/src/com/happy/action/AppMePageAction.java

@@ -2,15 +2,15 @@ package com.happy.action;
 
 import com.baidubce.model.User;
 import com.google.gson.Gson;
-import com.happy.Model.weixin.Users;
-import com.happy.Model.weixin.Wechat_userinfo;
-import com.happy.Model.weixin.WeiXinUtil;
+import com.happy.Model.weixin.*;
 import com.happy.Until.*;
 import com.happy.Until.Enum.B;
 import com.happy.Until.Enum.DataType;
 import com.happy.common.http.HttpsClient;
+import com.happy.common.wx.WxUtil;
 import com.happy.constant.ResultStatusCode;
 import com.happy.dto.IPage;
+import com.happy.service.AppService;
 import com.happy.service.BookService;
 import com.happy.service.UserService;
 import com.opensymphony.xwork2.ActionSupport;
@@ -37,6 +37,8 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
     public BookService bookService;
     @Resource
     public UserService userService;
+    @Resource
+    public AppService appService;
 
     private String contactUserName; // 常用联系人姓名
     private String contactUserIdNum; // 常用联系人身份证
@@ -317,19 +319,9 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
 
         String OPEN_ID = "";
         JSONObject resultJson = new JSONObject();
-//        // 此处授权后的回调地址,主要获取token和openid TODO
-//        String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
-//                + WeiXinUtil.appid_c
-//                + "&secret="
-//                + WeiXinUtil.screct_c
-//                + "&code="
-//                + this.getCode() + "&grant_type=authorization_code";
-//
-//            // String json = HttpUtils.get(requestUrl);
-//            String json = HttpsClient.sendPost(requestUrl, "");
-//            Wechat_userinfo result = new Gson().fromJson(json, Wechat_userinfo.class);
-//            OPEN_ID = result.getOpenid();
-            OPEN_ID = code;
+        CodeEntity codeEntity = appService.getCodeInfo(code);
+        OPEN_ID = codeEntity.getOpenid();
+            System.out.println(OPEN_ID);
             if (Func.checkNull(OPEN_ID))
             {
                 resultJson.put(B.code,ResultStatusCode.BAD_REQUEST.getStatus());
@@ -345,8 +337,10 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
             if (users == null)
             {
                 users = new Users();
+                // 确定默认用户名,默认用户头像
+                String userName = "微信用户" + Func.parseStr(WxUtil.mchOrderNo());
                 users.setUser_name(userName);
-                users.setHeadPhoto(headPhoto);
+                users.setHeadPhoto("http://172.16.20.88:80/mhotel/download/orderS.png");
                 users.setOpenid(OPEN_ID);
                 users.setCreate_time(DateUtil.getFormatPaternDate(new Date()));
                 users.setDataType(DataType.游客数据.toString());

+ 1 - 1
mhotel/src/com/happy/service/AppBookService.java

@@ -19,7 +19,7 @@ public interface AppBookService {
      * @param userId
      * @return
      */
-    public String createOrder(String houseId,String startTime,String endTime,String houseOrderNumber,String userName,String userPhone, String userId);
+    public String createOrder(String bookingId, String houseId,String startTime,String endTime,String houseOrderNumber,String userName,String userPhone, String userId);
 
 
     /**

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

@@ -5,6 +5,7 @@ import com.happy.Model.HotelDict;
 import com.happy.dto.IPage;
 
 import java.util.List;
+import java.util.Map;
 
 public interface HotelService {
 
@@ -62,6 +63,11 @@ public interface HotelService {
     List<Hotel> queryList(String sqlx);
 
     /**
+     * 获取酒店配置字典map
+     * @return
+     */
+    public Map queryHotelDicMap();
+    /**
      * 描述:查询一条数据
      * @param sqlx
      * @return

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

@@ -11,6 +11,7 @@ import com.happy.Until.Enum.OrderEnum;
 import com.happy.Until.Enum.PayEnum;
 import com.happy.Until.Func;
 import com.happy.Until.TimeExchange;
+import com.happy.Until.UUIDUtil;
 import com.happy.common.wx.WxUtil;
 import com.happy.constant.ResultStatusCode;
 import com.happy.dao.BookDao;
@@ -39,7 +40,7 @@ public class AppBookImplService implements AppBookService {
     public AdminManagerService adminManagerService;
 
     @Override
-    public String createOrder(String houseId, String startTime, String endTime, String houseOrderNumber, String userName, String userPhone, String userId) {
+    public String createOrder(String bookingId, String houseId, String startTime, String endTime, String houseOrderNumber, String userName, String userPhone, String userId) {
         if (Func.checkNull(houseId) ||Func.checkNull(startTime) ||Func.checkNull(endTime)
                 ||Func.checkNull(houseOrderNumber) ||Func.checkNull(userName) ||Func.checkNull(userPhone) ||Func.checkNull(userId))
             return null;
@@ -95,6 +96,7 @@ public class AppBookImplService implements AppBookService {
         booking.setOrderStatus(Func.parseStr(PayEnum.ONE.getNum())); // 1待支付状态
         booking.setCreateTime(DateUtil.getFormatPaternDate(DateUtil.getCurrentDate()));
         booking.setCreateUserid(userId);
+        booking.setId(Func.parseInt(bookingId));
         int i = bookService.insertBooking(booking);
         if ( i == 0)
             return ResultStatusCode.CANNTBOOKING.CANNTBOOKING.getMsg();

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

@@ -1,6 +1,7 @@
 package com.happy.service.impl;
 
 import com.happy.Model.Booking;
+import com.happy.Model.FileInfo;
 import com.happy.Model.Hotel;
 import com.happy.Model.House;
 import com.happy.Until.DateUtil;
@@ -8,15 +9,13 @@ import com.happy.Until.Func;
 import com.happy.Until.TimeExchange;
 import com.happy.dao.BookDao;
 import com.happy.dao.HouseDao;
+import com.happy.dao.impl.FileImplInfoDao;
 import com.happy.dto.IPage;
 import com.happy.service.*;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service("AppHomePageService")
 public class AppHomePageImplService implements AppHomePageService {
@@ -33,6 +32,8 @@ public class AppHomePageImplService implements AppHomePageService {
     public BookService bookService;
     @Resource
     public AdminManagerService adminManagerService;
+    @Resource
+    public FileService fileService;
 
 
     @Override
@@ -65,6 +66,22 @@ public class AppHomePageImplService implements AppHomePageService {
         if (hotel == null || Func.checkNull(hotel.getManagerId()))
             return hotel;
 
+        // 数据字典写入hotel
+        Map dicMap = hotelService.queryHotelDicMap();
+        if (!Func.checkNull(hotel.getHconfig()))
+        {
+            List<String> list = Arrays.asList(hotel.getHconfig().split(","));
+            List hotelDicList = new ArrayList();
+            for (String hotelDicId:list) {
+                if (!dicMap.containsKey(Func.parseInt(hotelDicId)))
+                    continue;
+
+                hotelDicList.add(dicMap.get(Func.parseInt(hotelDicId)));
+            }
+            hotel.setHconfigList(hotelDicList);
+        }
+
+
         System.out.println(hotel.getManagerId());// 需求确定使用商户id关联房型
         StringBuffer strSql = new StringBuffer();
         strSql.append(" and manager_id = '").append(hotel.getManagerId()).append("' ");
@@ -72,13 +89,23 @@ public class AppHomePageImplService implements AppHomePageService {
         if (houseList == null )
             return hotel;
 
-//        Map<String, House> houseMap =  new HashMap();
-//        houseList.forEach((House house) ->{
-//            if (house.getId() == 0)
-//                return;
-//            houseMap.put(Func.parseStr(house.getId()),house);
-//        });
+        // 数据字典写入hotel
+        List<String> hlist = new ArrayList<>();
+        List houseDicList = new ArrayList();
+        for (House house:houseList) {
+            if (house == null || Func.checkNull(Func.parseStr(house.getNumber())))
+                continue;
+            // “,”号分逗开来
+            hlist = Arrays.asList(house.gethConfig().split(","));
+            houseDicList = new ArrayList();
+            for (String houseDicId:hlist) {
+                if (!dicMap.containsKey(Func.parseInt(houseDicId)))
+                    continue;
 
+                houseDicList.add(dicMap.get(Func.parseInt(houseDicId)));
+            }
+            house.sethConfigList(houseDicList);
+        }
 
         // 判断是否有房间,对每个房型进行标识
         StringBuffer strSqlBook = new StringBuffer();
@@ -109,15 +136,20 @@ public class AppHomePageImplService implements AppHomePageService {
             }
         }
 
+
         houseList.forEach((House house) ->{
             if (!houseBookingMap.containsKey(Func.parseStr(house.getId()))) {
                 house.setRemainRooms(Func.parseStr(house.getNumber()));
                 return;
             }
 
+            StringBuilder fileSqlx = new StringBuilder("");
+            fileSqlx.append("and link_id = '").append(house.getId()).append("'");
+            List<FileInfo> fileInfoList = fileService.queryList(fileSqlx.toString());
 
             int i = Func.parseInt(house.getNumber()) - Func.parseInt(houseBookingMap.get(house.getId()));
             house.setRemainRooms(Func.parseStr(i));
+            house.setFileInfoList(fileInfoList);
         });
 
 

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

@@ -134,7 +134,7 @@ public class BookImplService implements BookService {
         if (book == null)
             return "无此订单,请重新查询";
 
-        book.setIsDelete(1);
+        book.setIsDelete(0);
         book.setUpdateTime(DateUtil.getFormatPaternDate(new Date()));
         bookDao.updateBooking(book);
         return null;

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

@@ -1,19 +1,26 @@
 package com.happy.service.impl;
 
 import com.happy.Model.Hotel;
+import com.happy.Model.HotelDict;
+import com.happy.Until.Func;
 import com.happy.dao.HotelDao;
 import com.happy.dto.IPage;
+import com.happy.service.HotelDictService;
 import com.happy.service.HotelService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service("HotelService")
 public class HotelImplService implements HotelService {
 
     @Resource
     public HotelDao hotelDao;
+    @Resource
+    public HotelDictService hotelDictService;
 
     @Override
     public int insertHotel(Hotel hotel) {
@@ -61,6 +68,19 @@ public class HotelImplService implements HotelService {
         return iPage;
     }
 
+    public Map queryHotelDicMap()
+    {
+        Map map = new HashMap<>();
+        List<HotelDict> list = hotelDictService.queryList("and code in (1,2,3,4) ");
+        for (HotelDict h:list) {
+            if (h == null || Func.checkNull(Func.parseStr(h.getId())))
+                continue;
+
+                map.put(h.getId(),h);
+        }
+        return map;
+    }
+
     @Override
     public List<Hotel> queryList(String sqlx) {
         return hotelDao.queryList(sqlx);