Enford 5 lat temu
rodzic
commit
84bd3fd97e

+ 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

+ 52 - 0
src/main/java/com/jeeplus/modules/wexintheorder/Utils/OrderUtils.java

@@ -103,4 +103,56 @@ public class OrderUtils {
         }
         return string;
     }
+    //超出预定时间判断
+    public static boolean isforDate(){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        DateFormat ft = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
+        try {
+            String addOrMinusDayString = getAddOrMinusDayString(0, dateFormat);
+            String add1 = addOrMinusDayString+" "+"15:59:59";
+            String add2 = addOrMinusDayString+" "+"00:00:00";
+            Date startTime = ft.parse(add2);
+            Date endTime = ft.parse(add1);
+            Date nowTime = new Date();
+            boolean effectiveDate = isEffectiveDate(nowTime, startTime, endTime);
+            if (effectiveDate) {
+               return false;
+            }else {
+                return true;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    /**
+     *
+     * @param nowTime   当前时间
+     * @param startTime	开始时间
+     * @param endTime   结束时间
+     * @return
+     * @author sunran   判断当前时间在时间区间内
+     */
+    public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
+        if (nowTime.getTime() == startTime.getTime()
+                || nowTime.getTime() == endTime.getTime()) {
+            return true;
+        }
+
+        Calendar date = Calendar.getInstance();
+        date.setTime(nowTime);
+
+        Calendar begin = Calendar.getInstance();
+        begin.setTime(startTime);
+
+        Calendar end = Calendar.getInstance();
+        end.setTime(endTime);
+
+        if (date.after(begin) && date.before(end)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 }

+ 2 - 2
src/main/java/com/jeeplus/modules/wexintheorder/web/SimpleOAuth2Controller.java

@@ -27,8 +27,8 @@ public class SimpleOAuth2Controller {
         String requestUrl = request.getServerName();
         String contextPath = request.getContextPath();
         logger.info("domain name: " + requestUrl + " project name: " + contextPath);
-        //拼接微信回调地址
-        String backUrl ="http://121.196.48.88:18081/weXin/theOrder/orderFrom";
+        //拼接微信回调地址Global.getConfig("")
+        String backUrl ="http://total2.viphk.ngrok.org/weXin/theOrder/orderFrom";
         String redirect_uri = "";
         try {
             redirect_uri = URLEncoder.encode(backUrl, "utf-8");

+ 39 - 9
src/main/java/com/jeeplus/modules/wexintheorder/web/TheOrderController.java

@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -58,10 +59,17 @@ public class TheOrderController extends BaseController {
     //页面显示
     @RequestMapping(value = "orderFrom")
     public String getOrderFrom(Model model, HttpServletRequest request,@RequestParam String code){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         try {
             if(null!=code){
-                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String userId = OrderUtils.findUserId(code);//获取useerid
+                String userId = "";
+                Boolean session = getSession(request, code);
+                if (session){
+                    userId = (String)request.getSession().getAttribute("userId");
+                }else {
+                    userId = OrderUtils.findUserId(code);//获取useerid
+                    request.getSession().setAttribute("userId",userId);
+                }
                 //回显
                 //获取acton
                 String accessToken = AccessTokenUtil.getAccessToken(WeChatParamsUtil.corpId, WeChatParamsUtil.contactsSecret);
@@ -119,20 +127,26 @@ public class TheOrderController extends BaseController {
     //获取--预定餐
     @ResponseBody
     @RequestMapping(value = "noSureTem")
-    public AjaxJson getReservation(TheOrder theOrder) throws Exception{
+    public AjaxJson getReservation(TheOrder theOrder){
+        AjaxJson ajaxJson = new AjaxJson();
         getTheOrder(theOrder);//判空
         DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();//当前时间
-        AjaxJson ajaxJson = new AjaxJson();
         try {
+            boolean isforDate = OrderUtils.isforDate();
+            if (isforDate){
+                ajaxJson.setSuccess(false);
+                ajaxJson.setMsg("超出预订时间!");
+                return ajaxJson;
+            }
             //获取工作日 -- 第二天
             String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
             //验证是否存在订单  --true未为存在
             boolean planOrder = getPlanOrder(theOrder.getCorrelationId(), addOrMinusDayString);
             if (planOrder){
                 ajaxJson.setSuccess(true);
-                ajaxJson.setMsg("您已经预过餐");
+                ajaxJson.setMsg("您已经预过餐");
                 return ajaxJson;
             }
             //保存团队信息,如果status为1,说明是回显信息,无需保存
@@ -144,13 +158,13 @@ public class TheOrderController extends BaseController {
             theOrder.setScheduled(parse);//添加预定时间
             theOrderService.insertOrder(theOrder);//保存订单信息
             ajaxJson.setSuccess(true);
-            ajaxJson.setMsg("预餐成功");
+            ajaxJson.setMsg("预餐成功");
             return ajaxJson;
         }catch (Exception e){
             e.printStackTrace();
         }
         ajaxJson.setSuccess(false);
-        ajaxJson.setMsg("预失败,请重新预定");
+        ajaxJson.setMsg("预失败,请重新预定");
         return ajaxJson;
     }
 
@@ -210,8 +224,10 @@ public class TheOrderController extends BaseController {
            toOrderDate.setDateStart(addOrMinusDayString);//开始时间
            toOrderDate.setCorrelationId(userId);
            List<TheOrder> list = theOrderService.findList(toOrderDate);//查询上个工作日时间范围内容
-           if(null!=list&&list.size()>0){
-               flag = true;
+           for (TheOrder theOrder:list){
+               if (theOrder.getCorrelationId().equals(userId)){
+                   flag = true;
+               }
            }
        }catch (Exception e){
            e.printStackTrace();
@@ -242,4 +258,18 @@ public class TheOrderController extends BaseController {
         }
         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;
+    }
 }

+ 2 - 0
src/main/resources/mappings/modules/wexintheorder/TheLeadershipDao.xml

@@ -75,6 +75,7 @@
 			update_by,
 			update_date,
 			remarks,
+			del_flag,
 			team,
 			department,
 			`specific`,
@@ -86,6 +87,7 @@
 			#{updateBy.id},
 			#{updateDate},
 			#{remarks},
+			#{delFlag},
 			#{team},
 			#{department},
 			#{specific},

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

@@ -27,7 +27,7 @@
 				AND a.scheduled LIKE CONCAT(CONCAT(#{dateStart},'%'))
 			</if>
 			<if test="correlationId != null and correlationId != '' ">
-				AND a.correlationId = correlationId
+				AND a.correlationId = #{correlationId}
 			</if>
 		</where>
 		<choose>

+ 2 - 2
src/main/webapp/webpage/modules/weixin/theorder/error.jsp

@@ -3,7 +3,7 @@
 <html lang="en">
 <head>
     <meta charset="UTF-8">
-    <title>失败页面</title>
+    <title>失败</title>
     <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
     <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
     <meta content="yes" name="apple-mobile-web-app-capable">
@@ -17,6 +17,6 @@
     <link rel="stylesheet" href="${ctx}/static/weixin/example/example.css"/>
 </head>
 <body>
-请求失败,请重新访问
+请在企业微信中打开
 </body>
 </html>

+ 49 - 16
src/main/webapp/webpage/modules/weixin/theorder/orderMeal.jsp

@@ -2,7 +2,7 @@
 <%@ include file="/webpage/include/taglib.jsp"%>
 <html>
 <head>
-    <title>订餐</title>
+    <title>订餐</title>
     <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
     <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
     <meta content="yes" name="apple-mobile-web-app-capable">
@@ -47,7 +47,7 @@
                 <div class="weui-cell">
                     <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
                     <div class="weui-cell__bd">
-                        <input class="weui-input" name="name" value="${theOrder.name}" placeholder="姓名">
+                        <input class="weui-input" style="color: #999999" name="name" readonly value="${theOrder.name}" placeholder="姓名">
                     </div>
                 </div>
                 <c:if test="${theOrder.status == '0'}">
@@ -57,10 +57,22 @@
                             <a href="javascript:;" onclick="updateStatus()" style="font-size: 12px;padding: 5px;color: green;">修改</a>
                         </div>
                         <div class="weui-cell__bd">
-                            <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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-                            <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>
-                            <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>&nbsp;&nbsp;&nbsp;
-                            <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>
+                            <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>
+                                </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>
+                                    </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>
+                                    </td>
+                                </tr>
+                                </thead>
+                            </table>
                             <%--<label><input type="button" onclick="updateStatus()" value="修改"></label>--%>
                         </div>
                     </div>
@@ -71,10 +83,18 @@
                             <label class="weui-label">团队</label>
                         </div>
                         <div class="weui-cell__bd">
-                            <label><input type="radio" id="isAdmin"  onchange="teamFirstCg()" name="team" value="潘中"/> &nbsp;潘   中 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-                            <label><input type="radio" name="team" onchange="teamFirstCg()" value="盛小兰" />盛小兰</label><br>
-                            <label><input type="radio" name="team" onchange="teamFirstCg()" value="王春生" />王春生</label>&nbsp;&nbsp;
-                            <label><input type="radio" name="team" onchange="teamFirstCg()" value="其他"  checked />其 他</label>
+                            <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" name="team" onchange="teamFirstCg()" value="盛小兰" />盛小兰</label></td>
+                                </tr>
+                                <tr>
+                                    <td style="width: 40%"><label><input type="radio" name="team" onchange="teamFirstCg()" value="王春生" />王春生</label></td>
+                                    <td style="width: 40%"><label><input type="radio" name="team" onchange="teamFirstCg()" value="其他"/>其 他</label></td>
+                                </tr>
+                                </thead>
+                            </table>
                         </div>
                     </div>
                 </c:if>
@@ -98,17 +118,17 @@
                         </div>
                     </div>
                     <input type="text" value="" name="specific" id="specific" hidden>
-            <input type="text" value="${theOrder.status}" hidden name="status"/>
+            <input type="text" value="${theOrder.status}" hidden name="status" id="orderStatus"/>
             <input type="text" value="${theOrder.correlationId}" hidden name="correlationId"/>
             </div>
             <%--<input class="weui-input" type="text" name="team" id='team' value="${theOrder.team}" onChange="teamChange()"/>--%>
         </form>
     </div>
         <div class="" style="text-align: center;border-radius: 50%;">
-            <div class="weui-cells__title"><h4 style="font-weight: 100;">预<span id="currentDate" style="color:#666;"></span>工作餐</h4></div>
+            <div class="weui-cells__title"><h4 style="font-weight: 100;">预<span id="currentDate" style="color:#666;"></span>工作餐</h4></div>
                     <c:if test="${theOrder.exits == '1'}">
                         <div class="button-2 blue" id="buttonPlan" onclick="plan()">
-                            <div class="btn_div_list" style="line-height: 90px;height:90px;padding-top: 55px;">
+                            <div class="btn_div_list" id="inDate" style="line-height: 90px;height:90px;padding-top: 55px;">
                                 <span class="btn_span_list" id="plan">预订</span><br><span class="btn_span_list" id="spantime"></span>
                             </div>
                         </div>
@@ -150,6 +170,9 @@
             --maxtime;
         } else{
             clearInterval(timer);
+            $("#plan").text("未预订");
+            $("#plan").attr("style","color: #0b61a4");
+            $("#inDate").attr("style","padding-top: 65px");
             changeStatus();
             $.toast("订餐时间已结束!", "text");
         }
@@ -166,6 +189,7 @@
         $.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);
@@ -194,9 +218,12 @@
         title: "选择级联部门(工程)",
         items: ["工程一部", "工程二部", "工程三部","其他"]
     });
-
     function teamCg() {
         if ($("#isAdmin").is(":checked")) {
+            var department = $("#department").val();
+            if (null== department || department == ""){
+                $("#department").val("财务");
+            }
             $("#divDepartment").attr("style","display:''");
             departmentChange();
         }else {
@@ -205,10 +232,9 @@
             $("#spc2").attr("style","display: none");
         }
     }
-    teamCg();
     function teamFirstCg() {
         if ($("#isAdmin").is(":checked")) {
-            $("#department").val("其他");
+            $("#department").val("财务");
             $("#divDepartment").attr("style","display:''");
             $("#divDepartment").removeClass("notclick");
             $("#spc1").removeClass("notclick");
@@ -220,6 +246,12 @@
             $("#spc2").attr("style","display: none");
         }
     }
+    var orderStatus = $("#orderStatus").val();
+    if (orderStatus == '1'){
+        teamFirstCg();
+    }else {
+        teamCg();
+    }
     //联动效果
     function teamChange() {
        var team =  $("#team").val();
@@ -252,6 +284,7 @@
     }
 
     function updateStatus() {
+        $.toptip('允许修改', 'success');
         $("input[name='team']").attr("disabled",false);
         $("#divDepartment").removeClass("notclick");
         $("#spc1").removeClass("notclick");