فهرست منبع

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java
guojing 5 سال پیش
والد
کامیت
8b78b7937d

+ 86 - 0
admin-ui/app/whepi/ceshi.js

@@ -0,0 +1,86 @@
+define(function (require) {
+  return function (context) {
+
+    var $form, $form1;
+
+    //检查查询
+    function queryGrid1() {
+      var obj = $form.formGet();
+      if (obj.we == "") {
+        $.yvan.msg('请选择电话号码');
+        return false;
+      }
+      return true;
+    }
+
+    //检查查询
+    function queryGrid2() {
+      var obj = $form1.formGet();
+      if (obj.uptownId == "") {
+        $.yvan.msg('请选择小区');
+        return false;
+      }
+      if (obj.date == "") {
+        $.yvan.msg('请选择导出时间');
+        return false;
+      }
+      return true;
+    }
+
+    return {
+      center: {
+        border: false,
+        title: '数据处理',
+        items: [
+          {
+            onRender: function () {
+              $form = $(this);
+            },
+            xtype: 'formgroup',
+            title: '',
+            items: [
+              [
+                {
+                  xtype: 'textbox',
+                  label: '电话号码',
+                  name: 'we',
+                  prompt: '请输入要添加的电话号码',
+                  labelWidth: 'auto',
+                  id: 'we',
+                },
+              ]
+            ]
+          },
+          {
+            xtype: 'group',
+            title: '具体操作',
+            items: [
+              [{xtype: 'offset'},
+                {
+                  xtype: 'button', text: '授权测试', class: 'button-blue', onClick: function () {
+                    if (!queryGrid1()) {
+                      return;
+                    }
+                    var a = $form.formGet()
+
+                    $.yvan.ajax({
+                      method: 'post',
+                      url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa3991865de920847&redirect_uri=http://yuliang.ng.yvanui.com/userOpen/loginTest&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect',
+                      data: $form.formGet(),
+                      success: function (data) {
+                        $.yvan.msg('操作成功');
+                        return;
+                      }
+                    });
+
+
+                  }
+                },
+              ],
+            ]
+          }
+        ]
+      },
+    };
+  };
+});

+ 17 - 0
admin-ui/app/whepi/mock/menu.json

@@ -17,6 +17,23 @@
       "iconCls": "icon-blank fa fa-align-justify",
       "state": "close",
       "children": []
+    },
+    {
+      "id": "ENT10002",
+      "text": "小区进出信息",
+      "href": "",
+      "iconCls": "icon-blank fa fa-bars",
+      "state": "closed",
+      "children": [
+        {
+          "id": "ENT100021",
+          "text": "进出二维码",
+          "href": "/app/whepi/scan/qrImg.js",
+          "iconCls": "icon-blank fa fa-align-justify",
+          "state": "close",
+          "children": []
+        }
+      ]
     }
   ]
 }

+ 132 - 0
admin-ui/app/whepi/scan/qrImg.js

@@ -0,0 +1,132 @@
+define(function (require) {
+        return function (context) {
+
+            var $grid1, $form;
+
+
+            //查询小区
+            function queryGrid2() {
+                var _datas = [];
+                $.yvan.ajax({
+                    async: false,
+                    method: 'post',
+                    url: api('/getAllUptown'),
+                    data: {userId: 0},
+                    success: function (data) {
+                        if (data.data != null && data.data != undefined) {
+                            for (var i = 0; i < data.data.length; i++) {
+                                _datas.push({
+                                    "id": data.data[i].uptownId,
+                                    "text": data.data[i].uptownName
+                                })
+                            }
+                        }
+                    }
+                });
+                return _datas;
+            }
+
+            // 输入搜索文本后点击回车按钮查询列表
+            function enterQueryGrid1(e) {
+                if (e.keyCode === 13) {
+                    var tmp = $(this).val();
+                    $form.formSet({queryProperties: tmp});
+                    queryGrid1();
+                }
+            }
+
+            // 检索条件查询
+            function queryGrid1() {
+                var queryForm = $form.formGet();
+                $grid1.reload({
+                    mtype: 'POST',
+                    url: api('/qrImg/scanQrImg'),
+                    queryParams: queryForm
+                }, true);
+            }
+
+            // 搜索按钮
+            var queryToolbarTitle = '团购信息管理';// 自行替换此参数
+            var queryToolbar = {
+                xtype: 'toolbar', title: queryToolbarTitle, items: [
+                    {
+                        text: '查询', iconCls: 'fa fa-search', onClick: function () {
+                            queryGrid1();
+                        }
+                    }, {
+                        text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
+                            $form.formClear();
+                            queryGrid1();
+                        }
+                    }, {
+                        text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
+                            App.closeMe(this);
+                        }
+                    }
+                ]
+            };
+
+            var queryForm = {
+                onRender: function () {
+                    $form = $(this);
+                },
+                xtype: 'form',
+                items: [[
+                    {
+                        xtype: 'textbox',
+                        label: '检索条件',
+                        name: 'queryProperties',
+                        prompt: "小区名称",
+                        labelWidth: 'auto',
+                        events: {keydown: enterQueryGrid1}, width: 350
+                    },
+                ]]
+            };
+
+            return {
+                north: {
+                    height: 88,
+                    /* split: true,
+                     border: false,*///底框是否可变动
+                    items: [
+                        queryToolbar,
+                        queryForm
+                    ]
+                },
+                center: {
+                    height: '60%',
+                    split: true,
+                    items:
+                        {
+                            onRender: function () {
+                                $grid1 = $(this);
+                                queryGrid1()
+                            },
+                            xtype: 'grid',
+                            idField: 'doorId',
+                            autoSizeColumns: true,
+                            columns:
+                                [
+                                    [
+                                        {field: 'doorId', title: '大门ID', hidden: true},
+                                        {field: 'uptownName', title: '小区', maxWidth: 200, align: 'left',},
+                                        {field: 'doorName', title: '小区大门', maxWidth: 200, align: 'left',},
+                                        {
+                                            field: 'outImg', title: '外出二维码', minWidth: 300, maxWidth: 400,
+                                            formatter: function (value) {
+                                                return "<img  src='" + value + "'/>";
+                                            },
+                                        },
+                                        {field: 'inImg', title: '进入二维码', minWidth: 300, maxWidth: 400,
+                                            formatter: function (value) {
+                                                return "<img  src='" + value + "'/>";
+                                            },},
+                                        {field: 'timeUpdate', title: '修改时间', maxWidth: 200, formatter: $.fn.fmatter.ts},
+                                    ]
+                                ]
+                        }
+                }
+            };
+        };
+    }
+);

+ 1 - 1
whepi-ui/templates/groupBuying/groupBuyingXx.ftl

@@ -154,7 +154,7 @@
     });
 
     function goback() {
-        window.location.href = "/yeweihui/home.html?show=tuangou&userId=" + userId;
+        window.location.href = "/yeweihui/tuangouHome.html?show=tuangou&userId=" + userId;
     }
 
     function finish() {

+ 2 - 2
whepi-ui/templates/yeweihui/tgPublish.ftl

@@ -44,7 +44,7 @@
     $("#tg_input_deliver_time").datetimePicker();
 
     function goback() {
-        window.location.href = "/yeweihui/home.html?show=tuangou&userId=" + userId;
+        window.location.href = "/yeweihui/tuangouHome.html?show=tuangou&userId=" + userId;
     }
 
     $("#tg_publish").on('click', function () {
@@ -197,7 +197,7 @@
             success: function (data) {
                 // console.log(data);
                 if (data.success) {
-                    window.location.href = "/yeweihui/home.html?show=tuangou&userId=" + userId;
+                    window.location.href = "/yeweihui/tuangouHome.html?show=tuangou&userId=" + userId;
                 }
                 else  {
                     $.alert(data.data);

+ 22 - 3
whepi-ui/templates/yeweihui/tuangouHome.ftl

@@ -1,7 +1,24 @@
-<#assign title="我的团购"/>
+<#assign title="管理员"/>
 <#include "/home/frag.head.ftl" />
 
-<#include "/yeweihui/tuangou.ftl" />
+<div class="weui-tab">
+    <input id="userId" type="text" hidden="hidden" value=${user_id!}/>
+    <input id="uptownId" type="text" hidden="hidden" value=${uptown_id!}/>
+    <input id="uptownName" type="text" hidden="hidden" value=${uptown_name!}/>
+
+    <div class="weui-tab__bd">
+        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
+            <#include "/yeweihui/tuangou.ftl" />
+        </div>
+    </div>
+    <div class="weui-tabbar">
+        <a id="tab1a" href="#tab1" class="weui-tabbar__item weui-bar__item--on">
+            <div class="weui-tabbar__icon"><img src="/static/images/wx/customer_service.png" alt=""></div>
+            <p class="weui-tabbar__label">团购</p>
+        </a>
+    </div>
+</div>
+
 
 </body>
 
@@ -21,6 +38,8 @@
             });
 
         });
-    })(jQuery);
 
+        tuangou_init();
+
+    })(jQuery);
 </script>

+ 25 - 0
whepi-web/src/main/java/com/bofeng/controller/WxUserOpenController.java

@@ -8,10 +8,15 @@ import com.bofeng.entity.UserRole;
 import com.bofeng.service.HomeService;
 import com.bofeng.service.WxUserOpenService;
 import com.yvan.Model;
+import com.yvan.ModelOps;
 import com.yvan.platform.JsonWapper;
 import com.yvan.platform.StringUtils;
+import com.yvan.springmvc.HttpParameterParser;
+import com.yvan.springmvc.HttpUtils;
 import io.swagger.annotations.ApiOperation;
+import lombok.val;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -30,6 +35,26 @@ public class WxUserOpenController {
     @Autowired
     private WxUserOpenService wxUserOpenService;
 
+    @GetMapping("/userOpen/loginTest")
+    public Model<UserOpen> loginTest() {
+        val parser = HttpParameterParser.newInstance(HttpUtils.currentRequest());
+        String openId = parser.getString("openId");
+        String code = parser.getString("code");
+        if (StringUtils.isNullOrEmpty(code)) {
+            return Model.newFail("code为空");
+        }
+        UserOpen userOpen = homeService.getUserOpenByCode(code);
+        if (userOpen == null) {
+            return Model.newFail("微信登录失败");
+        }
+        //成功返回用户Id
+        try {
+            return Model.newSuccess(userOpen);
+        } catch (Exception e) {
+            return Model.newFail(e.getMessage());
+        }
+    }
+
     @ApiOperation("用户注册页面点登录")
     @PostMapping("/userOpen/login")
     public Model<UserOpen> login(JsonWapper jsonWapper) {

+ 3 - 2
whepi-web/src/main/java/com/bofeng/dao/UptownDoorMapper.java

@@ -2,12 +2,14 @@ package com.bofeng.dao;
 
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.bofeng.entity.UptownDoor;
+import com.yvan.PageDb;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 @Repository
@@ -17,7 +19,6 @@ 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();
+    List<UptownDoor> getAllUptownDoor(PageDb pagination, Map<String, Object> map);
 
 }

+ 7 - 0
whepi-web/src/main/java/com/bofeng/entity/UptownDoor.java

@@ -45,4 +45,11 @@ public class UptownDoor {
     @ApiModelProperty("出门间隔时间")
     @TableField(exist = false)
     private Integer goOutFre;
+
+    @TableField(exist = false)
+    private String inImg;
+
+    @TableField(exist = false)
+    private String outImg;
+
 }

+ 69 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/ScanAdminController.java

@@ -1,18 +1,35 @@
 package com.bofeng.wx.controller;
 
+import com.bofeng.dao.UptownDoorMapper;
 import com.bofeng.entity.SysUptownHouse;
+import com.bofeng.entity.UptownDoor;
 import com.bofeng.excel.ExcelUtils;
 import com.bofeng.service.SweepCodeService;
+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.Model;
+import com.yvan.PageDb;
+import com.yvan.mvc.Pd;
 import com.yvan.springmvc.HttpParameterParser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.Cleanup;
 import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
 import java.util.List;
 
 @Api("进出扫码后台信息")
@@ -22,6 +39,8 @@ public class ScanAdminController {
 
     @Autowired
     private SweepCodeService sweepCodeService;
+    @Autowired
+    private UptownDoorMapper uptownDoorMapper;
 
     @ApiOperation("出入查询")
     @GetMapping("/whepi/sweepCode/selectCode")
@@ -39,5 +58,55 @@ public class ScanAdminController {
         ExcelUtils.writeSheet(SysUptownHouse.class, sysUptownHouses).export(resp,"扫码导出");
     }
 
+    @ApiOperation("小区进出二维码")
+    @PostMapping("/whepi/qrImg/scanQrImg")
+    public Model<List<UptownDoor>> scanQrImg(HttpParameterParser parser, PageDb pagination) {
+        List<UptownDoor> list = uptownDoorMapper.getAllUptownDoor(pagination, parser.getMap());
+        for (UptownDoor door : list) {
+            door.setInImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=1");
+            door.setOutImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=2");
+        }
+        return Model.newSuccess(pagination, list);
+    }
+
+    // 获取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;
+
+    /**
+     * 生成进出门二维码
+     * @param doorId 小区大门ID
+     * @param inType 1进入;2外出
+     * @param response
+     * @throws IOException
+     * @throws WriterException
+     */
+    @GetMapping(value = "/whepi/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();
+        String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+    }
+
+    /**
+     * 生成校园巡逻二维码
+     * @throws IOException
+     * @throws WriterException
+     */
+    @GetMapping(value = "/whepi/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
+    public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
+        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
+        String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+    }
 
 }

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

@@ -28,6 +28,7 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -199,8 +200,9 @@ public class ScanController {
     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);
+        String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
         MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
     }
 
@@ -212,8 +214,9 @@ public class ScanController {
     @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);
+        String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
+        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
         MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
     }
 }

+ 6 - 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() + "\"");
@@ -120,8 +120,8 @@ public class UserOpenController {
         if (userId == 0) {
             UserOpen userOpen = homeService.getUserOpen();
             list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
-          /*  list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
-            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);*/
+//            list = userRoleMapper.getUserRoleByUserId(1225321682867105793L);
+//            UserOpen userOpen = userOpenMapper.selectByUserId(1225321682867105793L);
             userId = userOpen.getUserId();
             model.put("user", userOpen);
             model.put("user_id", "\"" + userOpen.getUserId() + "\"");

+ 9 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/YeWeiHuiController.java

@@ -69,6 +69,15 @@ public class YeWeiHuiController {
     return new ModelAndView("/yeweihui/home.ftl", model);
   }
 
+  @GetMapping("/yeweihui/tuangouHome.html")
+  public ModelAndView yeweihuiTuangouHome(ModelMap model, @RequestParam(value = "userId") Long userId, @RequestParam(value = "show", required = false, defaultValue = "-") String show) {
+
+    model.put("user_id", "\"" + userId + "\"");
+    model.put("show", "\"" + show + "\"");
+
+    return new ModelAndView("/yeweihui/tuangouHome.ftl", model);
+  }
+
   @GetMapping("/yeweihui/qiuzhuDetail.html")
   public ModelAndView qiuzhudetail(@Pd(name = "taskId") Long taskId, @Pd(name = "userId") Long userId, ModelMap model) throws JsonProcessingException {
 

+ 1 - 1
whepi-web/src/main/resources/application.yml

@@ -43,7 +43,7 @@ endpoints:
 #  whitelabel.enabled: false
 
 spring:
-  profiles.active: guojing
+  profiles.active: lll
 
   application:
     name: bofeng-web

+ 17 - 0
whepi-web/src/main/resources/mapper/UptownDoorMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bofeng.dao.UptownDoorMapper">
+
+    <select id="getAllUptownDoor" resultType="com.bofeng.entity.UptownDoor">
+        SELECT ud.*,u.uptown_name as uptownName FROM sys_uptown_door ud left join sys_uptown u on u.uptown_id =
+        ud.uptown_id
+        <where>
+            and ud.status = 1
+            <if test="queryProperties!=null and queryProperties!=''">
+                and u.uptown_name like concat('%',#{queryProperties},'%')
+            </if>
+        </where>
+        order by ud.time_update desc
+    </select>
+
+</mapper>