|
|
@@ -1,17 +1,30 @@
|
|
|
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;
|
|
|
+import com.happy.Until.Func;
|
|
|
+import com.happy.Until.ResponseUtil;
|
|
|
import com.happy.common.util.CommonResult;
|
|
|
+import com.happy.common.util.ResponseStatusEnum;
|
|
|
import com.happy.service.AppHomePageService;
|
|
|
import com.happy.service.BookService;
|
|
|
+import com.happy.service.UserService;
|
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
|
+import net.sf.json.JSON;
|
|
|
+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 java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * 首页进去Action请求交互
|
|
|
+ * 我的进去Action请求交互
|
|
|
*/
|
|
|
public class AppMePageAction extends ActionSupport implements ServletRequestAware {
|
|
|
|
|
|
@@ -21,11 +34,18 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
@Resource
|
|
|
public BookService bookService;
|
|
|
@Resource
|
|
|
- public AppHomePageService appHomePageService;
|
|
|
+ public UserService userService;
|
|
|
|
|
|
- public int page; // 当前页
|
|
|
- public int rows;// 每页显示的行数rows
|
|
|
- public Integer id;
|
|
|
+ private String contactUserName; // 常用联系人姓名
|
|
|
+ private String contactUserIdNum; // 常用联系人身份证
|
|
|
+ private String contactUserPhone; // 常用联系人电话
|
|
|
+
|
|
|
+
|
|
|
+ public int page = 1; // 当前页
|
|
|
+ public int rows = 5;// 每页显示的行数rows
|
|
|
+ private String userId; // 用户id
|
|
|
+ private String userName; // 用户姓名
|
|
|
+ private String contactId; // 相关联系人的id
|
|
|
public String status;
|
|
|
|
|
|
private String userCode; // 第一次进来获取用户的code
|
|
|
@@ -67,14 +87,6 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
this.rows = rows;
|
|
|
}
|
|
|
|
|
|
- public Integer getId() {
|
|
|
- return id;
|
|
|
- }
|
|
|
-
|
|
|
- public void setId(Integer id) {
|
|
|
- this.id = id;
|
|
|
- }
|
|
|
-
|
|
|
public String getStatus() {
|
|
|
return status;
|
|
|
}
|
|
|
@@ -86,20 +98,142 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 进入首页
|
|
|
+ * 进入我的,查询订单列表
|
|
|
* @return
|
|
|
*/
|
|
|
- public CommonResult homePage()
|
|
|
+ public String getBookingList()
|
|
|
{
|
|
|
- // 第一次进入首页,获取用户信息
|
|
|
- //getUserInfo();
|
|
|
-
|
|
|
- // 获取民宿列表
|
|
|
- appHomePageService.getHotelList(queryValue,rows,page);
|
|
|
+ if (Func.checkNull(userId))
|
|
|
+ return null;
|
|
|
+ // 通过用户id查询所有订单列表数据
|
|
|
|
|
|
+ StringBuilder querySql = new StringBuilder("");
|
|
|
+ if (!Func.checkNull(userId)){
|
|
|
+ querySql.append(" and create_userid = '").append(userId).append("' ");
|
|
|
+ }
|
|
|
+ int total = bookService.queryBookTotal(querySql.toString()); // 查询表中的总记录数
|
|
|
+ List<Booking> listPage = bookService.queryBookPage(querySql.toString(), page, rows); // 查询分页
|
|
|
+ ResponseUtil.writeJsonPageData(ServletActionContext.getResponse(),listPage,this.page,this.rows,total);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 进入我的页面,跳转常用旅客列表
|
|
|
+ */
|
|
|
+ public void getUserContact()
|
|
|
+ {
|
|
|
+// String userId = "15461"; // 用户id
|
|
|
+ // 通过用户id查询所有订单列表数据
|
|
|
+ if (Func.checkNull(userId))
|
|
|
+ return;
|
|
|
+
|
|
|
+ StringBuilder querySql = new StringBuilder("");
|
|
|
+ if (!Func.checkNull(userId)){
|
|
|
+ querySql.append(" and contact_id = '").append(userId).append("' ");
|
|
|
+ }
|
|
|
+ querySql.append(" and data_type = '").append(DataType.关联数据.toString()).append("' ");
|
|
|
+ int total = userService.queryUserTotal(querySql.toString()); // 查询表中的总记录数
|
|
|
+ List<Users> listPage = userService.queryUserPage(querySql.toString(), page, rows); // 查询分页
|
|
|
+ ResponseUtil.writeJsonPageData(ServletActionContext.getResponse(),listPage,this.page,this.rows,total);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击设置按钮,获取数据
|
|
|
+ */
|
|
|
+ public void queryUsers()
|
|
|
+ {
|
|
|
+ if (Func.checkNull(userId))
|
|
|
+ return;
|
|
|
+ Users users = userService.queryByUserId(userId);
|
|
|
+
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put(B.CODE,ResponseStatusEnum.SUCCESS.getStatus());
|
|
|
+ resultJson.put(B.MESSAGE,ResponseStatusEnum.SUCCESS.getMsg());
|
|
|
+ resultJson.put(B.DATA,users);
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过UserId进行更改或添加数据
|
|
|
+ */
|
|
|
+ public void updateContact()
|
|
|
+ {
|
|
|
+ if (Func.checkNull(userId))
|
|
|
+ return;
|
|
|
+
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ Users users = new Users();
|
|
|
+ users.setUser_name(contactUserName);
|
|
|
+
|
|
|
+// // 验证手机号码
|
|
|
+// if ( !Func.checkPhone(contactUserPhone))
|
|
|
+// {
|
|
|
+// resultJson.put(B.CODE,ResponseStatusEnum.FAILED.getStatus());
|
|
|
+// resultJson.put(B.MESSAGE,"请确认手机号码");
|
|
|
+// ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 验证身份证
|
|
|
+// if (!Func.isCard(contactUserIdNum))
|
|
|
+// {
|
|
|
+// resultJson.put(B.CODE,ResponseStatusEnum.FAILED.getStatus());
|
|
|
+// resultJson.put(B.MESSAGE,"请确认身份证");
|
|
|
+// ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
|
|
|
+// return;
|
|
|
+// }
|
|
|
+ users.setUser_phone(contactUserPhone);
|
|
|
+ users.setCard_number(contactUserIdNum);
|
|
|
+ userService.update(users);
|
|
|
+
|
|
|
+ resultJson.put(B.CODE,ResponseStatusEnum.SUCCESS.getStatus());
|
|
|
+ resultJson.put(B.MESSAGE,ResponseStatusEnum.SUCCESS.getMsg());
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加常用联系人数据
|
|
|
+ */
|
|
|
+ public void AddContact()
|
|
|
+ {
|
|
|
+ if (Func.checkNullOrEmpty(userId))
|
|
|
+ return;
|
|
|
+
|
|
|
+ // 相关联系人
|
|
|
+ Users users = new Users();
|
|
|
+ users.setContactId(Func.parseInt(userId));
|
|
|
+ users.setContactName(userName);
|
|
|
+ users.setCreate_time(Func.parseStr(new Date()));
|
|
|
+ users.setDataType(DataType.关联数据.toString());
|
|
|
+ users.setUser_name(contactUserName); // 相关联系人的名字
|
|
|
+ users.setUser_phone(contactUserPhone); // 相关联系人的手机号码
|
|
|
+ users.setCard_number(contactUserIdNum); // 相关联系人的身份证
|
|
|
+ userService.insert(users);
|
|
|
+
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ resultJson.put(B.CODE,ResponseStatusEnum.SUCCESS.getStatus());
|
|
|
+ resultJson.put(B.MESSAGE,ResponseStatusEnum.SUCCESS.getMsg());
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(),resultJson.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户可以删除自己相关联系人
|
|
|
+ */
|
|
|
+ public void delContact()
|
|
|
+ {
|
|
|
+ if (Func.checkNull(contactId))
|
|
|
+ return;
|
|
|
+
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ userService.del(Func.parseInt(contactId));
|
|
|
+
|
|
|
+ resultJson.put(B.CODE,ResponseStatusEnum.SUCCESS.getStatus());
|
|
|
+ resultJson.put(B.MESSAGE,ResponseStatusEnum.SUCCESS.getMsg());
|
|
|
+ ResponseUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public String getUserCode() {
|
|
|
return userCode;
|
|
|
@@ -116,4 +250,52 @@ public class AppMePageAction extends ActionSupport implements ServletRequestAwar
|
|
|
public void setQueryValue(String queryValue) {
|
|
|
this.queryValue = queryValue;
|
|
|
}
|
|
|
+
|
|
|
+ public String getContactUserName() {
|
|
|
+ return contactUserName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setContactUserName(String contactUserName) {
|
|
|
+ this.contactUserName = contactUserName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getContactUserIdNum() {
|
|
|
+ return contactUserIdNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setContactUserIdNum(String contactUserIdNum) {
|
|
|
+ this.contactUserIdNum = contactUserIdNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getContactUserPhone() {
|
|
|
+ return contactUserPhone;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setContactUserPhone(String contactUserPhone) {
|
|
|
+ this.contactUserPhone = contactUserPhone;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getUserId() {
|
|
|
+ return userId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUserId(String userId) {
|
|
|
+ this.userId = userId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getUserName() {
|
|
|
+ return userName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUserName(String userName) {
|
|
|
+ this.userName = userName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getContactId() {
|
|
|
+ return contactId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setContactId(String contactId) {
|
|
|
+ this.contactId = contactId;
|
|
|
+ }
|
|
|
}
|