Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

guojing vor 5 Jahren
Ursprung
Commit
14bf20442e

+ 25 - 0
whepi-ui/templates/home/tuangouHome.ftl

@@ -0,0 +1,25 @@
+<#assign title="我的团购"/>
+<#include "/home/frag.head.ftl" />
+
+<#include "/home/buy.ftl" />
+
+</body>
+
+<#include "/home/frag.foot.ftl" />
+<script>
+    (function ($) {
+
+        $(function () {
+            $('.weui-navbar__item').on('click', function () {
+                $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
+                //内容切换
+                var moduleClass = jQuery(this).attr("module");
+                var ss = ".weui-tab__panel ." + moduleClass + "_weui_tab_bd_item_active";
+                $(ss).removeClass(moduleClass + '_weui_tab_bd_item_active');
+                var data_toggle = jQuery(this).attr("target");
+                $(data_toggle).addClass(moduleClass + "_weui_tab_bd_item_active");
+            });
+        });
+    })(jQuery);
+
+</script>

+ 2 - 2
whepi-ui/templates/user/changeRole.ftl

@@ -72,8 +72,8 @@
             $.alert("请选择用户角色!")
             return false;
         }
-        <#if (type?? )&&(type = 1) >window.location.href = "/user/homeIndex.html?userId=" + $("#userId").val() + "&userType=" + userType;</#if>
-        <#if (type?? )&&(type = 2) >window.location.href = "/user/homeIndex.html?userId=" + $("#userId").val() + "&userType=" + userType;</#if>
+        <#if (type?? )&&(type = 1) >window.location.href = "/user/homeIndex.html?userId=" + $("#userId").val() + "&userType=" + userType + "&type=1";</#if>
+        <#if (type?? )&&(type = 2) >window.location.href = "/user/homeIndex.html?userId=" + $("#userId").val() + "&userType=" + userType + "&type=2";</#if>
 
     }
 </script>

+ 1 - 0
whepi-ui/templates/user/scanEstate.ftl

@@ -20,6 +20,7 @@
                     <br/>
                     <p class="user-title-long  ${collor!''}">${errorMsg!""}</p>
                     <br/>
+<#--                    <img id="qr" src="${img!''}"/>-->
                     <br/>
                 </header>
                 <br/>

+ 1 - 1
whepi-ui/templates/wuye/qiuzhu.ftl

@@ -5,7 +5,7 @@
                 用户求助
             </a>
             <a class="weui-navbar__item" target="#qz_nav2" module="qiu_zhu" id="qzMy_help" onclick="qzMy_help('')">
-                业委会任务
+                管理员任务
             </a>
         </div>
         <div class="weui-tab__panel">

+ 26 - 0
whepi-ui/templates/yeweihui/tuangouHome.ftl

@@ -0,0 +1,26 @@
+<#assign title="我的团购"/>
+<#include "/home/frag.head.ftl" />
+
+<#include "/yeweihui/tuangou.ftl" />
+
+</body>
+
+<#include "/home/frag.foot.ftl" />
+<script>
+    <#include "/yeweihui/tuangou.js" />
+    (function ($) {
+        $(function () {
+            $('.weui-navbar__item').on('click', function () {
+                $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
+                //内容切换
+                var moduleClass = jQuery(this).attr("module");
+                var ss = ".weui-tab__panel ." + moduleClass + "_weui_tab_bd_item_active";
+                $(ss).removeClass(moduleClass + '_weui_tab_bd_item_active');
+                var data_toggle = jQuery(this).attr("target");
+                $(data_toggle).addClass(moduleClass + "_weui_tab_bd_item_active");
+            });
+
+        });
+    })(jQuery);
+
+</script>

+ 5 - 0
whepi-web/src/main/java/com/bofeng/dao/UptownDoorMapper.java

@@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Mapper
 @Repository
 public interface UptownDoorMapper extends BaseMapper<UptownDoor> {
@@ -15,4 +17,7 @@ public interface UptownDoorMapper extends BaseMapper<UptownDoor> {
             "sys_uptown u ON u.uptown_id = ud.uptown_id WHERE ud.door_id = #{doorId} AND ud.STATUS = 1")
     UptownDoor getUptownDoorById(@Param("doorId") Long doorId);
 
+    @Select("SELECT * FROM sys_uptown_door WHERE STATUS = 1")
+    List<UptownDoor> getAllUptownDoor();
+
 }

+ 59 - 7
whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java

@@ -4,25 +4,31 @@ import com.bofeng.dao.*;
 import com.bofeng.entity.*;
 import com.bofeng.service.HomeService;
 import com.bofeng.service.ScanService;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.yvan.platform.JsonWapper;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageConfig;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.yvan.mvc.Pd;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import lombok.Cleanup;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
 import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
-import java.text.DateFormat;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -30,6 +36,14 @@ import java.util.List;
 @RestController
 public class ScanController {
 
+    // 获取code
+    private static final String oauth2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=";
+    private static final String moreUrl = "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
+    @Value("${yvan.wechat.appID}")
+    private String appId;
+    @Value("${yvan.wechat.domain}")
+    private String domain;
+
     @Autowired
     private HomeService homeService;
     @Autowired
@@ -53,6 +67,13 @@ public class ScanController {
     @Autowired
     private OutScanEstateMapper outScanEstateMapper;
 
+    /**
+     * @param doorId 小区大门ID
+     * @param inType 1进入;2外出
+     * @param request
+     * @param model
+     * @return
+     */
     @ApiOperation("进出扫码页面")
     @GetMapping("/user/scan.html")
     public ModelAndView scan(HttpServletRequest request, ModelMap model, @RequestParam(value = "doorId", required = false, defaultValue = "0") Long doorId,
@@ -138,6 +159,7 @@ public class ScanController {
                 model.put("errorMsg", "这是您今天第" + conut + "次出行,为了您的安全,请尽快回家。");
             }
             scanService.saveOutScanEstate(userOpen.getUserId());
+//            model.put("img", "/scan/scanEstate_qr.png");
             return new ModelAndView("/user/scanEstate.ftl", model);
         }
     }
@@ -164,4 +186,34 @@ public class ScanController {
         }
         return "";
     }
+
+    /**
+     * 生成进出门二维码
+     * @param doorId 小区大门ID
+     * @param inType 1进入;2外出
+     * @param response
+     * @throws IOException
+     * @throws WriterException
+     */
+    @GetMapping(value = "/scan/scan_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
+    public void scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType,
+                            HttpServletResponse response) throws IOException, WriterException {
+        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" + domain +
+                "/user/scan.html?doorId=" + doorId + "&inType=" + inType + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+    }
+
+    /**
+     * 生成校园巡逻二维码
+     * @throws IOException
+     * @throws WriterException
+     */
+    @GetMapping(value = "/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
+    public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
+        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" + domain +
+                "/user/scanEstate.html" + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+    }
 }

+ 55 - 6
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -64,10 +64,10 @@ public class UserOpenController {
                              @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType) throws JsonProcessingException {
         List<UserRole> list = new ArrayList<>();
         if (userId == 0) {
-//            UserOpen userOpen = homeService.getUserOpen();
-//            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
-            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
-            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
+            UserOpen userOpen = homeService.getUserOpen();
+            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
+//            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
+//            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
             userId = userOpen.getUserId();
             model.put("user", userOpen);
             model.put("user_id", "\"" + userOpen.getUserId() + "\"");
@@ -90,6 +90,7 @@ public class UserOpenController {
                 return new ModelAndView("/home/home.ftl", model);
             }
             if (list.size() == 2) {
+                model.put("type", 1);
                 return new ModelAndView("/user/changeRole.ftl", model);
             }
         } else {
@@ -100,6 +101,47 @@ public class UserOpenController {
                 model.put("msReport", new JsonWapper(msReport));
                 return new ModelAndView("/home/home.ftl", model);
             } else if (userType == 2) {
+                model.put("type", 1);
+                return new ModelAndView("/user/changeRole.ftl", model);
+            }
+        }
+        return null;
+    }
+
+
+    @ApiOperation("商品团购")
+    @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", required = false, dataType = "Long", paramType = "query"),
+            @ApiImplicitParam(name = "userType", value = "用户类型", required = false, dataType = "Integer", paramType = "query")
+    })
+    @GetMapping("/tuangou/home.html")
+    public ModelAndView tuangouHome(ModelMap model, @RequestParam(value = "userId", required = false, defaultValue = "0") Long userId,
+                             @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType) throws JsonProcessingException {
+        List<UserRole> list = new ArrayList<>();
+        if (userId == 0) {
+            UserOpen userOpen = homeService.getUserOpen();
+            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
+//            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
+//            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
+            userId = userOpen.getUserId();
+            model.put("user", userOpen);
+            model.put("user_id", "\"" + userOpen.getUserId() + "\"");
+            if (list.size() == 0) {
+                return new ModelAndView("/user/home.ftl", model);
+            }
+            if (list.size() == 1) {
+                return new ModelAndView("/tuangou/home.ftl", model);
+            }
+            if (list.size() == 2) {
+                model.put("type", 2);
+                return new ModelAndView("/user/changeRole.ftl", model);
+            }
+        } else {
+            model.put("user", userOpenMapper.selectByUserId(userId));
+            model.put("user_id", "\"" + userId + "\"");
+            if (userType == 1) {
+                return new ModelAndView("/tuangou/home.ftl", model);
+            } else if (userType == 2) {
+                model.put("type", 2);
                 return new ModelAndView("/user/changeRole.ftl", model);
             }
         }
@@ -108,7 +150,9 @@ public class UserOpenController {
 
     @GetMapping("/user/homeIndex.html")
     public ModelAndView homeIndex(ModelMap model, @RequestParam(value = "userId", required = false, defaultValue = "0") Long userId,
-                                  @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType, @RequestParam(value = "show", required = false, defaultValue = "-") String show) throws JsonProcessingException {
+                                  @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType,
+                                  @RequestParam(value = "type", required = false, defaultValue = "1") Integer type,
+                                  @RequestParam(value = "show", required = false, defaultValue = "-") String show) throws JsonProcessingException {
         if (userId != 0 && userType != 0) {
             model.put("user_id", "\"" + userId + "\"");
             List<Uptown> uptowns = rbMapper.selectUptown(userId);
@@ -122,13 +166,18 @@ public class UserOpenController {
                 MsReport msReport = msReportService.getReportByDateNow(userId);
                 model.put("msReport", new JsonWapper(msReport));
                 model.put("show", "\"" + show + "\"");
+                if (type == 2) {
+                    return new ModelAndView("/home/tuangouHome.ftl", model);
+                }
                 return new ModelAndView("/home/home.ftl", model);
             } else if (userType == 2) {
                 List<QzTask> taskList = qzTaskService.selectAll(userId);
                 model.put("taskList", YvanUtil.toJsonPretty(taskList));
                 List<sysUptownUnit> rbList = rbService.selectAll(userId);
                 model.put("rbList", YvanUtil.toJsonPretty(rbList));
-
+                if (type == 2) {
+                    return new ModelAndView("/yeweihui/tuangouHome.ftl", model);
+                }
                 return new ModelAndView("/yeweihui/home.ftl", model);
             }
         }