|
@@ -3,11 +3,16 @@ package com.jeeplus.modules.wexintheorder.web;
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
import com.jeeplus.common.web.BaseController;
|
|
import com.jeeplus.common.web.BaseController;
|
|
import com.jeeplus.modules.sys.entity.User;
|
|
import com.jeeplus.modules.sys.entity.User;
|
|
|
|
+import com.jeeplus.modules.wexinpackage.access.entity.WeChatUser;
|
|
|
|
+import com.jeeplus.modules.wexinpackage.access.util.access.AccessTokenUtil;
|
|
|
|
+import com.jeeplus.modules.wexinpackage.access.util.access.AddressBookUtil;
|
|
|
|
+import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
|
|
import com.jeeplus.modules.wexintheorder.Utils.OrderUtils;
|
|
import com.jeeplus.modules.wexintheorder.Utils.OrderUtils;
|
|
import com.jeeplus.modules.wexintheorder.entity.TheLeadership;
|
|
import com.jeeplus.modules.wexintheorder.entity.TheLeadership;
|
|
import com.jeeplus.modules.wexintheorder.entity.TheOrder;
|
|
import com.jeeplus.modules.wexintheorder.entity.TheOrder;
|
|
import com.jeeplus.modules.wexintheorder.service.TheLeadershipService;
|
|
import com.jeeplus.modules.wexintheorder.service.TheLeadershipService;
|
|
import com.jeeplus.modules.wexintheorder.service.TheOrderService;
|
|
import com.jeeplus.modules.wexintheorder.service.TheOrderService;
|
|
|
|
+import net.sf.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
@@ -29,7 +34,27 @@ public class TheOrderController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private TheLeadershipService theLeadershipService;
|
|
private TheLeadershipService theLeadershipService;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @RequestMapping(value = "orderFromTest")
|
|
|
|
+ public String getOrderForm(Model model){
|
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String userId = "XuShuai";
|
|
|
|
+ WeChatUser weChatUser = new WeChatUser();
|
|
|
|
+ weChatUser.setName("张三");
|
|
|
|
+ //回显
|
|
|
|
+ TheOrder userOrderEcho = getUserOrderEcho("张三");
|
|
|
|
+ //验证今天是否预定过餐
|
|
|
|
+ //获取工作日 -- 第二天
|
|
|
|
+ String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
|
|
|
|
+ //验证是否存在订单 --true未为存在
|
|
|
|
+ boolean planOrder = getPlanOrder(userId, addOrMinusDayString);
|
|
|
|
+ if (planOrder){
|
|
|
|
+ userOrderEcho.setExits("0");//已经选择过了
|
|
|
|
+ }else {
|
|
|
|
+ userOrderEcho.setExits("1");//未预定
|
|
|
|
+ }
|
|
|
|
+ model.addAttribute("theOrder",userOrderEcho);
|
|
|
|
+ return "modules/weixin/theorder/orderMeal";//返回一个界面
|
|
|
|
+ }
|
|
//页面显示
|
|
//页面显示
|
|
@RequestMapping(value = "orderFrom")
|
|
@RequestMapping(value = "orderFrom")
|
|
public String getOrderFrom(Model model, HttpServletRequest request,@RequestParam String code){
|
|
public String getOrderFrom(Model model, HttpServletRequest request,@RequestParam String code){
|
|
@@ -38,7 +63,11 @@ public class TheOrderController extends BaseController {
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
String userId = OrderUtils.findUserId(code);//获取useerid
|
|
String userId = OrderUtils.findUserId(code);//获取useerid
|
|
//回显
|
|
//回显
|
|
- TheOrder userOrderEcho = getUserOrderEcho(userId);
|
|
|
|
|
|
+ //获取acton
|
|
|
|
+ String accessToken = AccessTokenUtil.getAccessToken(WeChatParamsUtil.corpId, WeChatParamsUtil.contactsSecret);
|
|
|
|
+ String user = AddressBookUtil.getUser(accessToken, userId);
|
|
|
|
+ String name = getMaps(user);
|
|
|
|
+ TheOrder userOrderEcho = getUserOrderEcho(name);
|
|
//验证今天是否预定过餐
|
|
//验证今天是否预定过餐
|
|
//获取工作日 -- 第二天
|
|
//获取工作日 -- 第二天
|
|
String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
|
|
String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
|
|
@@ -59,10 +88,10 @@ public class TheOrderController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
//获取部门以及分管领导信息--回显FROM
|
|
//获取部门以及分管领导信息--回显FROM
|
|
- public TheOrder getUserOrderEcho(String weChatUserId){
|
|
|
|
|
|
+ public TheOrder getUserOrderEcho(String name){
|
|
TheOrder theOrder = new TheOrder();
|
|
TheOrder theOrder = new TheOrder();
|
|
//查询用户
|
|
//查询用户
|
|
- User user = theLeadershipService.findUser(weChatUserId);
|
|
|
|
|
|
+ User user = theLeadershipService.findUser(name);
|
|
String userId = user.getId();//获取用户id
|
|
String userId = user.getId();//获取用户id
|
|
//获取用户user
|
|
//获取用户user
|
|
//添加回显对象
|
|
//添加回显对象
|
|
@@ -202,4 +231,15 @@ public class TheOrderController extends BaseController {
|
|
theOrder.setSpecific("");
|
|
theOrder.setSpecific("");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public String getMaps(String sMsg){
|
|
|
|
+ String name = "";
|
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(sMsg);
|
|
|
|
+ try {
|
|
|
|
+ name = jsonObject.getString("name");
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return name;
|
|
|
|
+ }
|
|
}
|
|
}
|