Enford 5 年之前
父节点
当前提交
7b0e25a3f6

+ 4 - 4
src/main/java/com/jeeplus/modules/wexinpackage/access/util/access/WeChatParamsUtil.java

@@ -7,13 +7,13 @@ public class WeChatParamsUtil {
     //token
     public final static String token ="9ZmhR1CRrGIOSMxCcznVccQN8f3XX2w4GMoacioSkovFuJdCwMBvTHsJpGf67bUVtkHEqLzYIyaamn9dEyPJKcVxgIeERJpAwa9uNtW68EXYwOBvR2blpiQ3aM9l7ndqMJThfEWlcUz8oBzOh6XZPQqTcLwb95yHhwQO14KdIXj6Q1nko9rjp-9c-LsrzoS_SNu4TxTqTqoYj5ztp3J9Wg";
     //企业id
-    public final static String corpId ="ww24ca7e7771df9148";
+    public final static String corpId ="wwb8c36b4b35675fe9";
     //应用的凭证密钥
-    public final static String agentSecret = "alO4uidZ2hKK3p5HdrWxIKz5YgvT0vvNiMb9r_1vS7s";
+    public final static String agentSecret = "kekm2UtL_82xFr6tMi4N2cWQFMHNKhLD-0bwIIaUQP0";
     //通讯录秘钥 (获取tokenid)
-    public final static String contactsSecret ="rXEUF9kGCLZKyWs4WQie_F1Ix3g5dP_e3X2Yls5tiuA";
+    public final static String contactsSecret ="X67oIAoM8_SR9VhW7exd4_JKaeW5st8DKxvNluTZfi4";
     //企业应用的id,整型。可在应用的设置页面查看
-    public final static int agentId = 1000005;
+    public final static int agentId = 1000002;
     //通讯录token
     public final static String contacts_token = "AT84tGkhkt09pSYTxi3NoCQcn7F6o";
     // encodingAESKey

+ 65 - 1
src/main/java/com/jeeplus/modules/wexintheorder/Utils/OrderUtils.java

@@ -3,11 +3,14 @@ package com.jeeplus.modules.wexintheorder.Utils;
 import com.jeeplus.modules.wexinpackage.access.util.access.AccessTokenUtil;
 import com.jeeplus.modules.wexinpackage.access.util.access.RequestAccess;
 import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
+import com.jeeplus.modules.wexintheorder.entity.TheOrder;
 import net.sf.json.JSONObject;
 import org.junit.Test;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.RestTemplate;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -139,7 +142,6 @@ public class OrderUtils {
                 || nowTime.getTime() == endTime.getTime()) {
             return true;
         }
-
         Calendar date = Calendar.getInstance();
         date.setTime(nowTime);
 
@@ -155,4 +157,66 @@ public class OrderUtils {
             return false;
         }
     }
+
+    //判断code是否相同
+    public static Boolean getSession(HttpServletRequest request, String code){
+        boolean flag = false;
+        HttpSession session = request.getSession();
+        String attribute = (String) session.getAttribute("code");
+        if (null==attribute||attribute==""){
+            session.setAttribute("code",code);
+        }else if (!attribute.equals(code)){
+            session.setAttribute("code",code);
+        }else{
+            flag = true;
+        }
+        return flag;
+    }
+
+    //判断theorder
+    public static void getTheOrder(TheOrder theOrder){
+        if (null == theOrder.getName()){
+            theOrder.setName("");
+        }
+        if (null == theOrder.getTeam()){
+            theOrder.setTeam("");
+        }
+        if (null == theOrder.getDepartment()){
+            theOrder.setDepartment("");
+        }
+        if (null == theOrder.getSpecific()){
+            theOrder.setSpecific("");
+        }
+    }
+    //获取用户名
+    public static String getMaps(String sMsg){
+        String name = "";
+        JSONObject jsonObject = JSONObject.fromObject(sMsg);
+        try {
+            name = jsonObject.getString("name");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return name;
+    }
+
+    //提示拼接
+    public static String getMsg(TheOrder theOrder,String addOrMinusDayString){
+        String msg1 = "预订("+addOrMinusDayString+")工作餐成功。";
+        String msg4 = "("+theOrder.getTeam()+")团队,";
+        String msg5 = "("+theOrder.getDepartment()+")部门";
+        String msg2 = "("+theOrder.getDepartment()+"/"+theOrder.getSpecific()+")部门。";
+        String msg3 = "提示:团队部门可取消预订后</br>重新修改,再次预订";
+        String msg = "";
+        if (null!=theOrder.getDepartment()&&!"".equals(theOrder.getDepartment())){
+            if (!theOrder.getDepartment().equals("其他")){
+                msg = msg1+"</br>"+msg4+msg2+"</br>"+msg3;
+            }else {
+                msg = msg1+"</br>"+msg4+msg5+"</br>"+msg3;
+            }
+        }else {
+            msg = msg1+"</br>"+msg4+"</br>"+msg3;
+        }
+        return msg;
+    }
 }

+ 5 - 2
src/main/java/com/jeeplus/modules/wexintheorder/dao/TheOrderDao.java

@@ -11,10 +11,13 @@ import java.util.List;
 public interface TheOrderDao extends CrudDao<TheOrder> {
     public Integer insertOrder(TheOrder theOrder);
 
-    public Integer updateOrder(TheOrder theOrder);
-
     public List<TheOrder> findListPlan(TheOrder theOrder);
 
     public List<TheOrder> findListSure(TheOrder theOrder);
 
+    //取消订餐
+    public Integer deleteOrder(TheOrder theOrder);
+    //修改操作
+    public Integer updateOrder(TheOrder theOrder);
+
 }

+ 11 - 8
src/main/java/com/jeeplus/modules/wexintheorder/service/TheOrderService.java

@@ -34,13 +34,6 @@ public class TheOrderService extends CrudService<TheOrderDao,TheOrder>{
         theOrderDao.insertOrder(theOrder);
     };
 
-    //修改操作
-    @Transactional
-    public void updateOrder(TheOrder theOrder){
-        theOrder.preUpdate();
-        theOrderDao.updateOrder(theOrder);
-    }
-
     public List<TheOrder> findListPlan(TheOrder theOrder){
         return theOrderDao.findListPlan(theOrder);
     };
@@ -49,6 +42,16 @@ public class TheOrderService extends CrudService<TheOrderDao,TheOrder>{
         return theOrderDao.findListSure(theOrder);
     };
 
-
+    //删除操作
+    @Transactional
+    public Integer deleteOrder(TheOrder theOrder){
+        return theOrderDao.deleteOrder(theOrder);
+    }
+    //修改操作
+    @Transactional
+    public Integer updateOrder(TheOrder theOrder){
+        theOrder.preUpdate();
+        return theOrderDao.updateOrder(theOrder);
+    }
 
 }

+ 74 - 53
src/main/java/com/jeeplus/modules/wexintheorder/web/TheOrderController.java

@@ -34,13 +34,14 @@ public class TheOrderController extends BaseController {
     @Autowired
     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("许帅");
-        //回显
+        //回显 姓名-userId - 是否未第一次订餐
         TheOrder userOrderEcho = getUserOrderEcho(userId,"许帅");
         //验证今天是否预定过餐
         //获取工作日 -- 第二天
@@ -55,14 +56,15 @@ public class TheOrderController extends BaseController {
         model.addAttribute("theOrder",userOrderEcho);
         return "modules/weixin/theorder/orderMeal";//返回一个界面
     }
-    //页面显示
+
+    //页面显示--企业微信端
     @RequestMapping(value = "orderFrom")
     public String getOrderFrom(Model model, HttpServletRequest request,@RequestParam String code){
         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         try {
             if(null!=code){
                 String userId = "";
-                Boolean session = getSession(request, code);
+                Boolean session = OrderUtils.getSession(request, code);
                 if (session){
                     userId = (String)request.getSession().getAttribute("userId");
                 }else {
@@ -76,7 +78,8 @@ public class TheOrderController extends BaseController {
                 if (user.equals("flagOrder")){
                     return "modules/weixin/theorder/requestError";
                 }
-                String name = getMaps(user);
+                String name = OrderUtils.getMaps(user);
+                //回显 :姓名-userId - 是否未第一次订餐
                 TheOrder userOrderEcho = getUserOrderEcho(userId,name);
                 //验证今天是否预定过餐
                 //获取工作日 -- 第二天
@@ -88,11 +91,12 @@ public class TheOrderController extends BaseController {
                 }else {
                     userOrderEcho.setExits("1");//未预定
                 }
+                //验证是否超过预定时间
                 boolean isforDate = OrderUtils.isforDate();
                 if (isforDate){
-                    userOrderEcho.setDateStart("0");//未预定
+                    userOrderEcho.setDateStart("0");//未超过
                 }else {
-                    userOrderEcho.setDateStart("1");//以预定
+                    userOrderEcho.setDateStart("1");//已经超过
                 }
                 model.addAttribute("theOrder",userOrderEcho);
                 return "modules/weixin/theorder/orderMeal";//返回一个界面
@@ -106,10 +110,6 @@ public class TheOrderController extends BaseController {
     //获取部门以及分管领导信息--回显FROM
     public TheOrder getUserOrderEcho(String userId,String username){
         TheOrder theOrder = new TheOrder();
-        //查询用户
-//        User user = theLeadershipService.findUser(name);
-//        String userId = user.getId();//获取用户id
-        //获取用户user
         //添加回显对象
         theOrder.setName(username);//姓名
         theOrder.setCorrelationId(userId);//添加用户id
@@ -137,19 +137,20 @@ public class TheOrderController extends BaseController {
     @RequestMapping(value = "noSureTem")
     public AjaxJson getReservation(TheOrder theOrder){
         AjaxJson ajaxJson = new AjaxJson();
-        getTheOrder(theOrder);//判空
+        OrderUtils.getTheOrder(theOrder);//判空
         DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();//当前时间
         try {
-//            boolean isforDate = OrderUtils.isforDate();
-//            if (isforDate){
-//                ajaxJson.setSuccess(false);
-//                ajaxJson.setMsg("超出预订时间!");
-//                return ajaxJson;
-//            }
+            boolean isforDate = OrderUtils.isforDate();
+            if (isforDate){
+                ajaxJson.setSuccess(false);
+                ajaxJson.setMsg("超出预订时间!");
+                return ajaxJson;
+            }
             //获取工作日 -- 第二天
             String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
+            String addMsg = addOrMinusDayString;
             //验证是否存在订单  --true未为存在
             boolean planOrder = getPlanOrder(theOrder.getCorrelationId(), addOrMinusDayString);
             if (planOrder){
@@ -165,8 +166,9 @@ public class TheOrderController extends BaseController {
             Date parse = dateFormat1.parse(addOrMinusDayString);
             theOrder.setScheduled(parse);//添加预定时间
             theOrderService.insertOrder(theOrder);//保存订单信息
+            String msg = OrderUtils.getMsg(theOrder, addMsg);
             ajaxJson.setSuccess(true);
-            ajaxJson.setMsg("预订餐成功");
+            ajaxJson.setMsg(msg);
             return ajaxJson;
         }catch (Exception e){
             e.printStackTrace();
@@ -248,44 +250,63 @@ public class TheOrderController extends BaseController {
        return flag;
     }
 
-    //判断theorder
-    public void getTheOrder(TheOrder theOrder){
-        if (null == theOrder.getName()){
-            theOrder.setName("");
-        }
-        if (null == theOrder.getTeam()){
-            theOrder.setTeam("");
-        }
-        if (null == theOrder.getDepartment()){
-            theOrder.setDepartment("");
-        }
-        if (null == theOrder.getSpecific()){
-            theOrder.setSpecific("");
-        }
-    }
-    //获取用户名
-    public String getMaps(String sMsg){
-        String name = "";
-        JSONObject jsonObject = JSONObject.fromObject(sMsg);
+    //取消订单
+    @ResponseBody
+    @RequestMapping(value = "cancelTem")
+    public AjaxJson cancelOrder(TheOrder theOrder){
+        AjaxJson ajaxJson = new AjaxJson();
         try {
-            name = jsonObject.getString("name");
+            DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            //获取工作日 -- 第二天
+            String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
+            addOrMinusDayString = addOrMinusDayString+" 12:00:00";
+            theOrder.setScheduled(dateFormat1.parse(addOrMinusDayString));
+            boolean isforDate = OrderUtils.isforDate();
+            if (isforDate){
+                ajaxJson.setSuccess(false);
+                ajaxJson.setMsg("超出取消时间,如果取消订餐,请联系相关人员!");
+                return ajaxJson;
+            }
+            //删除操作
+            if (null!=theOrder.getCorrelationId()&&!"".equals(theOrder.getCorrelationId())){
+                theOrderService.deleteOrder(theOrder);
+            }
+            ajaxJson.setMsg("取消订餐成功");
+            ajaxJson.setSuccess(true);
+            return  ajaxJson;
         }catch (Exception e){
             e.printStackTrace();
         }
-        return name;
-    }
-    //判断code是否相同
-    public Boolean getSession(HttpServletRequest request,String code){
-        boolean flag = false;
-        HttpSession session = request.getSession();
-        String attribute = (String) session.getAttribute("code");
-        if (null==attribute||attribute==""){
-            session.setAttribute("code",code);
-        }else if (!attribute.equals(code)){
-            session.setAttribute("code",code);
-        }else{
-            flag = true;
-        }
-        return flag;
+        ajaxJson.setSuccess(false);
+        ajaxJson.setMsg("取消订餐失败");
+        return ajaxJson;
     }
+
+//    //修改团队-部门-级联部门
+//    @ResponseBody
+//    @RequestMapping(value = "updateOrder")
+//    public AjaxJson getUpdateTheOrder(TheOrder theOrder){
+//        AjaxJson ajaxJson = new AjaxJson();
+//        try{
+//            DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+//            //获取工作日 -- 第二天
+//            String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
+//            addOrMinusDayString = addOrMinusDayString+" 12:00:00";
+//            theOrder.setScheduled(dateFormat1.parse(addOrMinusDayString));
+//            theOrderService.updateOrder(theOrder);
+//            OrderUtils.getTheOrder(theOrder);//判空
+//            updateLeader(theOrder);
+//            ajaxJson.setSuccess(true);
+//            ajaxJson.setMsg("修改成功");
+//            return ajaxJson;
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }
+//        ajaxJson.setSuccess(false);
+//        ajaxJson.setMsg("修改失败");
+//        return ajaxJson;
+//    }
+
 }

+ 14 - 0
src/main/resources/mappings/modules/wexintheorder/TheOrderDao.xml

@@ -71,4 +71,18 @@
 			#{correlationId}
 		)
 	</insert>
+
+	<delete id="deleteOrder">
+		DELETE FROM the_order WHERE correlationId = #{correlationId} AND scheduled = #{scheduled}
+	</delete>
+
+	<update id="updateOrder">
+		UPDATE the_order SET
+			update_date = #{updateDate},
+			name = #{name},
+			team = #{team},
+			department = #{department},
+			`specific` = #{specific}
+		WHERE correlationId = #{correlationId} AND scheduled = #{scheduled}
+	</update>
 </mapper>

+ 10 - 1
src/main/webapp/static/wechat/wechat-btn.css

@@ -27,7 +27,16 @@
 			box-shadow: 0 1px 2px rgba(0,0,0,.2);
 			margin: 10px
 		}
-
+		.btn-yellow {
+			color: #d9eef7;
+			/*border: solid 1px #0076a3;*/
+			height: 150px;
+			width:150px;
+			background:#dab844;
+			background: -webkit-gradient(linear, left top, left bottom, from(#dab844), to(#DAA520));
+			background: -moz-linear-gradient(top,#dab844,#DAA520);
+			filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
+		}
 
 
 

+ 107 - 54
src/main/webapp/webpage/modules/weixin/theorder/orderMeal.jsp

@@ -44,36 +44,35 @@
       <div class=" weui-cells_form">
         <form id="subForm" method="post">
             <div class="weui-cells" style="margin: 0;">
-                <div class="weui-cell">
-                    <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
-                    <div class="weui-cell__bd">
-                        <input class="weui-input" style="color: #999999" name="name" readonly value="${theOrder.name}" placeholder="姓名">
+                    <div class="weui-cell">
+                        <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
+                        <div class="weui-cell__bd">
+                            <input class="weui-input" style="color: #999999" name="name" readonly value="${theOrder.name}" placeholder="姓名">
+                        </div>
                     </div>
-                </div>
                 <c:if test="${theOrder.status == '0'}">
                     <div class="weui-cell" id="divTeam">
                         <div class="weui-cell__hd">
                             <label class="weui-label">团队</label>
-                            <a href="javascript:;" onclick="updateStatus()" style="font-size: 12px;padding: 5px;color: green;">修改</a>
+                            <%--<a href="javascript:;" onclick="updateStatus()" style="font-size: 12px;padding: 5px;color: green;">修改</a>--%>
                         </div>
                         <div class="weui-cell__bd">
                             <table>
                                 <thead>
                                 <tr>
-                                    <td style="width: 40%"><label><input type="radio" id="isAdmin"  onchange="teamCg()" name="team" value="潘中"   <c:if test="${theOrder.team != '潘中'}">disabled</c:if>  <c:if test="${theOrder.team == '潘中'}">checked</c:if> />潘  中</label></td>
-                                    <td style="width: 40%"><label><input type="radio" name="team" onchange="teamCg()" value="盛小兰" <c:if test="${theOrder.team != '盛小兰'}">disabled</c:if> <c:if test="${theOrder.team == '盛小兰'}">checked</c:if> />盛小兰</label><br></td>
+                                    <td style="width: 40%"><label><input type="radio" id="isAdmin"  onchange="teamCg()" name="team" value="潘中" <c:if test="${theOrder.team == '潘中'}">checked</c:if> />潘中</label></td>
+                                    <td style="width: 40%"><label><input type="radio" name="team" onchange="teamCg()" value="盛小兰"  <c:if test="${theOrder.team == '盛小兰'}">checked</c:if> />盛小兰</label><br></td>
                                 </tr>
                                 <tr>
                                     <td style="width: 40%">
-                                        <label><input type="radio" name="team" onchange="teamCg()" value="王春生" <c:if test="${theOrder.team != '王春生'}">disabled</c:if> <c:if test="${theOrder.team == '王春生'}">checked</c:if> />王春生</label>
+                                        <label><input type="radio" name="team" onchange="teamCg()" value="王春生"  <c:if test="${theOrder.team == '王春生'}">checked</c:if> />王春生</label>
                                     </td>
                                     <td style="width: 40%">
-                                        <label><input type="radio" name="team" onchange="teamCg()" value="其他" <c:if test="${theOrder.team != '其他'}">disabled</c:if>  <c:if test="${theOrder.team == '其他'}">checked</c:if> />其  他</label>
+                                        <label><input type="radio" name="team" onchange="teamCg()" value="其他"  <c:if test="${theOrder.team == '其他'}">checked</c:if> />其  他</label>
                                     </td>
                                 </tr>
                                 </thead>
                             </table>
-                            <%--<label><input type="button" onclick="updateStatus()" value="修改"></label>--%>
                         </div>
                     </div>
                 </c:if>
@@ -86,7 +85,7 @@
                             <table>
                                 <thead>
                                 <tr>
-                                    <td style="width: 40%"><label><input type="radio" id="isAdmin"  onchange="teamFirstCg()" name="team" checked  value="潘中"/> &nbsp;    </label></td>
+                                    <td style="width: 40%"><label><input type="radio" id="isAdmin"  onchange="teamFirstCg()" name="team" checked  value="潘中"/>潘中</label></td>
                                     <td style="width: 40%"><label><input type="radio" name="team" onchange="teamFirstCg()" value="盛小兰" />盛小兰</label></td>
                                 </tr>
                                 <tr>
@@ -98,20 +97,20 @@
                         </div>
                     </div>
                 </c:if>
-                    <div class="weui-cell notclick" id="divDepartment">
+                    <div class="weui-cell" id="divDepartment">
                         <div class="weui-cell__hd"><label class="weui-label">部门</label></div>
                         <div class="weui-cell__bd">
                             <input class="weui-input" onChange="departmentChange()" type="text"  id='department' value="${theOrder.department}"/>
                         </div>
                     </div>
                     <input type="text" value="" name="department" id="departmentSure" hidden>
-                    <div class="weui-cell notclick" id="spc1">
+                    <div class="weui-cell" id="spc1">
                         <div class="weui-cell__hd"><label class="weui-label">工程部门</label></div>
                         <div class="weui-cell__bd">
                             <input class="weui-input" type="text" name="specific1" id='specific1' value="${theOrder.specific}"/>
                         </div>
                     </div>
-                    <div class="weui-cell notclick" id="spc2">
+                    <div class="weui-cell" id="spc2">
                         <div class="weui-cell__hd"><label class="weui-label">财务部门</label></div>
                         <div class="weui-cell__bd">
                             <input class="weui-input" type="text" name="specific2" id='specific2' value="${theOrder.specific}"/>
@@ -143,16 +142,26 @@
                         </c:if>
                     </c:if>
                     <c:if test="${theOrder.exits == '0'}">
-                        <div class="button-2 blue notclick" id="buttonPlan" style="background:#dcdbdb;">
-                            <div style="line-height: 130px;height:130px;padding-top: 65px">
-                                <span class="btn_span_list" style="color: #0b61a4">已订餐</span>
+                        <c:if test="${theOrder.dateStart == '0'}">
+                            <div class="button-2 blue notclick" id="buttonPlan" style="background:#dcdbdb;">
+                                <div style="line-height: 130px;height:130px;padding-top: 65px">
+                                    <span class="btn_span_list" style="color: #0b61a4">已订餐</span>
+                                </div>
                             </div>
-                        </div>
+                        </c:if>
+                        <c:if test="${theOrder.dateStart == '1'}">
+                            <div class="button-2 btn-yellow" id="cancelPlanDiv" onclick="cancelPlan();">
+                                <div style="line-height: 90px;height:90px;padding-top: 55px" id="cancelDate">
+                                    <span class="btn_span_list" id="cancelPlan2">取消订餐</span><br><span class="btn_span_list" id="spantime"></span>
+                                </div>
+                            </div>
+                        </c:if>
                     </c:if>
                 </div>
             <div class="" style="width: 100%;text-align: center;font-size: 14px;color: #666666;">请在0:00-16:00前预订第二天的用餐</div>
         </div>
-    <div class="bottem_div">兴光信息技术支持</div>
+        <div id="loadDiv" style="display: none;" class="weui-toast weui_loading_toast weui-toast--visible"><div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div><p class="weui-toast_content">请稍后...</p></div>
+        <div class="bottem_div">兴光信息技术支持</div>
 </body>
 <script type="text/javascript">
     var d=new Date();
@@ -166,42 +175,49 @@
     function CountDown() {
         if (maxtime >= 0) {
             hours = Math.floor(maxtime /60 /60 % 24);
+            if (hours < 10){
+                hours = '0'+ hours;
+            }
             minutes = Math.floor(maxtime / 60 % 60);
+            if (minutes < 10){
+               minutes = '0'+ minutes;
+            }
             seconds = Math.floor(maxtime % 60);
+            if (seconds < 10){
+                seconds = '0'+seconds;
+            }
             msg = hours + ":" +minutes + ":" + seconds;
             document.all["spantime"].innerHTML = msg;
             if (maxtime <= 5 * 60){
                 if (flag){
-                    $.toast("距离预结束不到5分钟!", "text");
+                    $.toast("距离预结束不到5分钟!", "text");
                     flag = false;
                 }
             };
             --maxtime;
         } else{
             clearInterval(timer);
-            $("#plan").text("未订餐");
-            $("#plan").attr("style","color: #0b61a4");
-            $("#inDate").attr("style","padding-top: 65px");
-            changeStatus();
+            $("#spantime").text("");
+            //预定
+            baDatePlan();
+            //取消
+            baCeCalDatePlan();
             $.toast("订餐时间已结束!", "text");
         }
     }
     timer = setInterval("CountDown()", 1000);
 </script>
 <script>
-    var currDate = GetDate();
-    $("#currentDate").html(currDate);
 //订餐方法
     function plan() {
         changeStatus();
         sureDepart();
         $.post("/weXin/theOrder/noSureTem",$('#subForm').serialize(),function(data){
             if(data.success){
-                $("#plan").text("已订餐");
-                $("#inDate").attr("style","padding-top: 65px")
-                $("#plan").attr("style","color: #0b61a4");
-                $("#spantime").attr("style","display: none");
-                $.toast(data.msg);
+                $.alert(data.msg, "订餐成功", function() {
+                    $("#loadDiv").show();
+                    window.location.reload();
+                });
             }else{
                 $.toast(data.msg, "cancel");
                 $("#buttonPlan").removeClass("notclick");
@@ -216,25 +232,26 @@
     });
     $("#department").select({
         title: "选择部门",
-        items: ["财务", "工程","管理咨询","资产评估"]
+        items: ["财务", "工程","管理咨询","资产评估","其他"]
     });
     $("#specific2").select({
         title: "选择级联部门(财务)",
-        items: ["审计部", "证券一部", "证券二部","证券三部","其他"]
+        items: ["审计部","审计一部","证券一部", "证券二部","证券三部","其他"],
     });
 
     $("#specific1").select({
         title: "选择级联部门(工程)",
-        items: ["工程一部", "工程二部", "工程三部","其他"]
+        items: ["工程一部", "工程二部", "工程三部","招标代理","其他"]
     });
+
     function teamCg() {
         if ($("#isAdmin").is(":checked")) {
+            $("#divDepartment").attr("style","display:''");
             var department = $("#department").val();
             if (null== department || department == ""){
                 $("#department").val("财务");
             }
-            $("#divDepartment").attr("style","display:''");
-            departmentChange();
+            departmentMany();
         }else {
             $("#divDepartment").attr("style","display: none");
             $("#spc1").attr("style","display: none");
@@ -272,12 +289,13 @@
            $("#spc2").attr("style","display: none");
        }
     }
+    //第一次以及选中后的
     function departmentChange(){
         var department = $("#department").val();
         if (department == '财务'){
             $("#spc1").attr("style","display: none");
             $("#spc2").attr("style","display: ''");
-            $("#specific2").val("审计部")
+            $("#specific2").val("审计部");
         }else if (department == '工程') {
             $("#spc2").attr("style","display: none");
             $("#spc1").attr("style","display: ''");
@@ -287,18 +305,34 @@
             $("#spc2").attr("style","display: none");
         }
     }
+    function departmentMany(){
+        var department = $("#department").val();
+        if (department == '财务'){
+            $("#spc1").attr("style","display: none");
+            $("#spc2").attr("style","display: ''");
+            if ($("#specific2").val()==""){
+                $("#specific2").val("审计部");
+            }
+        }else if (department == '工程') {
+            $("#spc2").attr("style","display: none");
+            $("#spc1").attr("style","display: ''");
+            if ($("#specific1").val()==""){
+                $("#specific1").val("工程一部")
+            }
+        }else {
+            $("#spc1").attr("style","display: none");
+            $("#spc2").attr("style","display: none");
+            $.toast(data.msg);
+        }
+    }
+
+
     function changeStatus() {
         $("#buttonPlan").addClass("notclick");
         $("#buttonPlan").attr("style","background:#dcdbdb");
     }
 
-    function updateStatus() {
-        $.toptip('允许修改', 'success');
-        $("input[name='team']").attr("disabled",false);
-        $("#divDepartment").removeClass("notclick");
-        $("#spc1").removeClass("notclick");
-        $("#spc2").removeClass("notclick");
-    }
+    //提交时数据更新
     function sureDepart() {
         if ($("#isAdmin").is(":checked")){
             var department = $("#department").val();
@@ -315,15 +349,34 @@
             $("#specific").val("");
         }
     }
-    //获取年月日
-    function GetDate(){
-        var currDate = new Date();
-        var now = new Date();
-        now.setTime(currDate.getTime()+24*60*60*1000)
-        var year = now.getFullYear();         //年
-        var month = now.getMonth() + 1;     //月
-        var day = now.getDate();              //日
-        return year+"年"+month+"月"+day+"日";
+
+    //取消订餐
+    function cancelPlan() {
+        $.post("/weXin/theOrder/cancelTem",$('#subForm').serialize(),function(data){
+            if(data.success){
+                $.toast(data.msg);
+                window.location.reload();
+            }else{
+                $.toast(data.msg, "cancel");
+            }
+        })
+    }
+    //时间预定方法
+    function baDatePlan(){
+        //预定
+        $("#plan").text("未订餐");
+        $("#plan").attr("style","color: #0b61a4");
+        $("#inDate").attr("style","padding-top: 65px");
+        changeStatus();
+    }
+    //取消
+    function baCeCalDatePlan(){
+        //预定
+        $("#cancelPlan2").text("已订餐");
+        $("#cancelDate").attr("style","padding-top: 65px");
+        $("#cancelPlan2").attr("style","color: #0b61a4");
+        $("#cancelPlanDiv").addClass("notclick");
+        $("#cancelPlanDiv").attr("style","background:#dcdbdb");
     }
 </script>
 </html>