doum
3 天以前 7ec3683c8e41460f4bb0bd3a6677198742313e2b
新增智能电表、空调管理
已添加6个文件
已修改13个文件
497 ■■■■■ 文件已修改
admin/src/views/operation/category.vue 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/manifest.json 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/package-lock.json 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/package.json 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
h5/utils/config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/db/business.yw_customer.openid.sql 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/system_service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/admin_timer/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/admin_timer/src/main/resources/bootstrap.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/web/VisitorWebController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/web/YwCustomerWebController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_admin/src/main/resources/bootstrap.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwCustomer.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/MemberService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwCustomerH5AuthService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwCustomerH5AuthServiceImpl.java 135 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/operation/category.vue
@@ -8,7 +8,7 @@
            @click="exportExcel">导出</el-button></li>
      </ul>
      <el-table row-key="id" :tree-props="{ children: 'childCategoryList' }" v-loading="isWorking.search"
        :data="dataList" stripe @selection-change="handleSelectionChange">
        :data="tableData.list" stripe @selection-change="handleSelectionChange">
        <el-table-column prop="name" label="设备分类" min-width="100px"></el-table-column>
        <!-- <el-table-column prop="parentName" label="所属分类" min-width="100px"></el-table-column> -->
        <el-table-column prop="sortnum" label="排序码" min-width="100px"></el-table-column>
@@ -22,7 +22,7 @@
          </template>
        </el-table-column>
      </el-table>
      <pagination @size-change="handleSizeChange" @current-change="getList" :pagination="tableData.pagination">
      <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination">
      </pagination>
    </template>
    <!-- æ–°å»º/修改 -->
@@ -43,9 +43,10 @@
  data() {
    return {
      // æœç´¢
      filters: {
     /* filters: {
        parentId: ''
      },
      },*/
      searchForm:{ type: 5 ,parentId: ''},
      isShowEdit: false,
      loading: false,
      pagination: {
@@ -63,7 +64,7 @@
      'field.id': 'id',
      'field.main': 'id'
    })
    this.getList()
    this.search()
  },
  methods: {
    handleEdit(row) {
@@ -84,16 +85,15 @@
        type: 'warning'
      }).then(() => {
        deleteById(row.id).then(res => {
          this.getList()
          this.search()
        })
      })
    },
    getList() {
      const { pagination, filters } = this
      const { pagination } = this
      this.loading = true
      fetchList({
        model: { ...filters, type: 5 },
        model: this.searchForm,
        capacity: pagination.pageSize,
        page: pagination.page,
      }).then(res => {
h5/manifest.json
@@ -141,13 +141,10 @@
            "https" : false
        },
        "sdkConfigs" : {
            "maps" : {
                "amap" : {
                    "key" : "d9a554b1808ce10a12a932ed9b0db1d0",
                    "securityJsCode" : "",
                    "serviceHost" : ""
                }
            }
            "maps" : {}
        },
        "unipush" : {
            "enable" : false
        }
    }
}
h5/package-lock.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,167 @@
{
    "name": "图片裁剪 å››è§’拖动 å›¾ç‰‡ç¼©æ”¾ç§»åЍ",
    "version": "1.0.0",
    "lockfileVersion": 2,
    "requires": true,
    "packages": {
        "": {
            "name": "图片裁剪 å››è§’拖动 å›¾ç‰‡ç¼©æ”¾ç§»åЍ",
            "version": "1.0.0",
            "dependencies": {
                "dayjs": "^1.11.13",
                "dingtalk-jsapi": "^3.2.0",
                "html5-qrcode": "^2.3.8",
                "uniapp-qrcode": "^1.0.2",
                "uview-ui": "^2.0.37",
                "vconsole": "^3.15.1"
            }
        },
        "node_modules/@babel/runtime": {
            "version": "7.29.7",
            "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.29.7.tgz",
            "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",
            "engines": {
                "node": ">=6.9.0"
            }
        },
        "node_modules/copy-text-to-clipboard": {
            "version": "3.2.2",
            "resolved": "https://registry.npmmirror.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.2.tgz",
            "integrity": "sha512-T6SqyLd1iLuqPA90J5N4cTalrtovCySh58iiZDGJ6FGznbclKh4UI+FGacQSgFzwKG77W7XT5gwbVEbd9cIH1A==",
            "engines": {
                "node": ">=12"
            },
            "funding": {
                "url": "https://github.com/sponsors/sindresorhus"
            }
        },
        "node_modules/core-js": {
            "version": "3.49.0",
            "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.49.0.tgz",
            "integrity": "sha512-es1U2+YTtzpwkxVLwAFdSpaIMyQaq0PBgm3YD1W3Qpsn1NAmO3KSgZfu+oGSWVu6NvLHoHCV/aYcsE5wiB7ALg==",
            "hasInstallScript": true,
            "funding": {
                "type": "opencollective",
                "url": "https://opencollective.com/core-js"
            }
        },
        "node_modules/dayjs": {
            "version": "1.11.21",
            "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.21.tgz",
            "integrity": "sha512-98IT+HOahAisibz/yjKbzuOBwYcjJ7BCLPzARyHiyEBmRz4fatF+KPJszEHXsGYjUG234aH/cOjW1wwTbKUZlA=="
        },
        "node_modules/dingtalk-jsapi": {
            "version": "3.2.9",
            "resolved": "https://registry.npmmirror.com/dingtalk-jsapi/-/dingtalk-jsapi-3.2.9.tgz",
            "integrity": "sha512-VLt8co92z29bdguxUvJLnhpQn7WFjb5rJTODDczieS7I0yyWj5+KwF04sWfMvyIKX0MQPVL++Fyo6z2JucFpgQ==",
            "dependencies": {
                "promise-polyfill": "^7.1.0"
            }
        },
        "node_modules/html5-qrcode": {
            "version": "2.3.8",
            "resolved": "https://registry.npmmirror.com/html5-qrcode/-/html5-qrcode-2.3.8.tgz",
            "integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ=="
        },
        "node_modules/mutation-observer": {
            "version": "1.0.3",
            "resolved": "https://registry.npmmirror.com/mutation-observer/-/mutation-observer-1.0.3.tgz",
            "integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
        },
        "node_modules/promise-polyfill": {
            "version": "7.1.2",
            "resolved": "https://registry.npmmirror.com/promise-polyfill/-/promise-polyfill-7.1.2.tgz",
            "integrity": "sha512-FuEc12/eKqqoRYIGBrUptCBRhobL19PS2U31vMNTfyck1FxPyMfgsXyW4Mav85y/ZN1hop3hOwRlUDok23oYfQ=="
        },
        "node_modules/uniapp-qrcode": {
            "version": "1.0.2",
            "resolved": "https://registry.npmmirror.com/uniapp-qrcode/-/uniapp-qrcode-1.0.2.tgz",
            "integrity": "sha512-jcWwWz4yXsO7if/+78MMXj5VUdZTLu2D6L/IKb4mJkIw87oF11pO3WS/jS27SUcPCrX/BKcir5a2R1uvkaoR9g=="
        },
        "node_modules/uview-ui": {
            "version": "2.0.38",
            "resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-2.0.38.tgz",
            "integrity": "sha512-6egHDf9lXHKpG3hEjRE0vMx4+VWwKk/ReTf5x18KrIKqdvdPRqO3+B8Unh7vYYwrIxzAWIlmhZ9RJpKI/4UqPQ==",
            "engines": {
                "HBuilderX": "^3.1.0"
            }
        },
        "node_modules/vconsole": {
            "version": "3.15.1",
            "resolved": "https://registry.npmmirror.com/vconsole/-/vconsole-3.15.1.tgz",
            "integrity": "sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==",
            "dependencies": {
                "@babel/runtime": "^7.17.2",
                "copy-text-to-clipboard": "^3.0.1",
                "core-js": "^3.11.0",
                "mutation-observer": "^1.0.3"
            }
        }
    },
    "dependencies": {
        "@babel/runtime": {
            "version": "7.29.7",
            "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.29.7.tgz",
            "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw=="
        },
        "copy-text-to-clipboard": {
            "version": "3.2.2",
            "resolved": "https://registry.npmmirror.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.2.tgz",
            "integrity": "sha512-T6SqyLd1iLuqPA90J5N4cTalrtovCySh58iiZDGJ6FGznbclKh4UI+FGacQSgFzwKG77W7XT5gwbVEbd9cIH1A=="
        },
        "core-js": {
            "version": "3.49.0",
            "resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.49.0.tgz",
            "integrity": "sha512-es1U2+YTtzpwkxVLwAFdSpaIMyQaq0PBgm3YD1W3Qpsn1NAmO3KSgZfu+oGSWVu6NvLHoHCV/aYcsE5wiB7ALg=="
        },
        "dayjs": {
            "version": "1.11.21",
            "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.21.tgz",
            "integrity": "sha512-98IT+HOahAisibz/yjKbzuOBwYcjJ7BCLPzARyHiyEBmRz4fatF+KPJszEHXsGYjUG234aH/cOjW1wwTbKUZlA=="
        },
        "dingtalk-jsapi": {
            "version": "3.2.9",
            "resolved": "https://registry.npmmirror.com/dingtalk-jsapi/-/dingtalk-jsapi-3.2.9.tgz",
            "integrity": "sha512-VLt8co92z29bdguxUvJLnhpQn7WFjb5rJTODDczieS7I0yyWj5+KwF04sWfMvyIKX0MQPVL++Fyo6z2JucFpgQ==",
            "requires": {
                "promise-polyfill": "^7.1.0"
            }
        },
        "html5-qrcode": {
            "version": "2.3.8",
            "resolved": "https://registry.npmmirror.com/html5-qrcode/-/html5-qrcode-2.3.8.tgz",
            "integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ=="
        },
        "mutation-observer": {
            "version": "1.0.3",
            "resolved": "https://registry.npmmirror.com/mutation-observer/-/mutation-observer-1.0.3.tgz",
            "integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
        },
        "promise-polyfill": {
            "version": "7.1.2",
            "resolved": "https://registry.npmmirror.com/promise-polyfill/-/promise-polyfill-7.1.2.tgz",
            "integrity": "sha512-FuEc12/eKqqoRYIGBrUptCBRhobL19PS2U31vMNTfyck1FxPyMfgsXyW4Mav85y/ZN1hop3hOwRlUDok23oYfQ=="
        },
        "uniapp-qrcode": {
            "version": "1.0.2",
            "resolved": "https://registry.npmmirror.com/uniapp-qrcode/-/uniapp-qrcode-1.0.2.tgz",
            "integrity": "sha512-jcWwWz4yXsO7if/+78MMXj5VUdZTLu2D6L/IKb4mJkIw87oF11pO3WS/jS27SUcPCrX/BKcir5a2R1uvkaoR9g=="
        },
        "uview-ui": {
            "version": "2.0.38",
            "resolved": "https://registry.npmmirror.com/uview-ui/-/uview-ui-2.0.38.tgz",
            "integrity": "sha512-6egHDf9lXHKpG3hEjRE0vMx4+VWwKk/ReTf5x18KrIKqdvdPRqO3+B8Unh7vYYwrIxzAWIlmhZ9RJpKI/4UqPQ=="
        },
        "vconsole": {
            "version": "3.15.1",
            "resolved": "https://registry.npmmirror.com/vconsole/-/vconsole-3.15.1.tgz",
            "integrity": "sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==",
            "requires": {
                "@babel/runtime": "^7.17.2",
                "copy-text-to-clipboard": "^3.0.1",
                "core-js": "^3.11.0",
                "mutation-observer": "^1.0.3"
            }
        }
    }
}
h5/package.json
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
{
    "id": "tly-picture-cut",
    "name": "图片裁剪 å››è§’拖动 å›¾ç‰‡ç¼©æ”¾ç§»åЍ",
    "version": "1.0.0",
    "description": "图片裁剪组件 æ”¯æŒæ‹–动四角 å·²ä½¿ç”¨å¾®ä¿¡å°ç¨‹åºã€H5 å¹³å°",
    "keywords": [
        "图片裁剪"
    ],
    "dcloudext": {
        "category": [
            "前端组件",
            "通用组件"
        ]
    },
    "dependencies": {
        "dayjs": "^1.11.13",
        "dingtalk-jsapi": "^3.2.0",
        "html5-qrcode": "^2.3.8",
        "uniapp-qrcode": "^1.0.2",
        "uview-ui": "^2.0.37",
        "vconsole": "^3.15.1"
    }
}
h5/utils/config.js
@@ -1,7 +1,7 @@
 // export const baseUrl = 'gateway_interface/'
// export const baseUrl = 'http://192.168.0.173/gateway_interface/'
export const baseUrl = 'http://localhost:10010/gateway_interface/'
// export const baseUrl = 'https://zhcg.fnwtzx.com/gateway_interface/'
export const baseUrl = 'https://dmtest.ahapp.net/gateway_interface/'
//export const baseUrl = 'https://dmtest.ahapp.net/gateway_interface/'
export const uploadAvatar = `${baseUrl}visitsAdmin/cloudService/web/public/uploadFtp.do`
export const uploadUrl = `${baseUrl}visitsAdmin/cloudService/public/uploadBatch`
server/db/business.yw_customer.openid.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
-- å•†æˆ· H5 å¾®ä¿¡ openid
SET @db := DATABASE();
SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_customer' AND COLUMN_NAME = 'openid') = 0,
  'ALTER TABLE `yw_customer` ADD COLUMN `openid` varchar(64) DEFAULT NULL COMMENT ''微信openid'' AFTER `phone`',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.STATISTICS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_customer' AND INDEX_NAME = 'idx_openid') = 0,
  'ALTER TABLE `yw_customer` ADD INDEX `idx_openid` (`openid`)',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
server/system_service/src/main/java/com/doumee/core/model/LoginUserInfo.java
@@ -12,6 +12,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -52,6 +53,16 @@
    private List<Integer> companyIdList;
    private Company company;
    @ApiModelProperty("H5用户类型 0运维人员 1商户")
    private Integer h5UserType;
    @ApiModelProperty("商户ID(h5UserType=1时有值)")
    private Integer customerId;
    public static final int H5_USER_OPS = 0;
    public static final int H5_USER_CUSTOMER = 1;
    public static final int SOURCE_H5_CUSTOMER = 10;
    //jwt登录设置
    public static LoginUserInfo from(SystemUser user, List<SystemRole> roles, List<SystemPermission> permissions,Company company,String sessionId) {
        if (user == null) {
server/system_service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java
@@ -27,4 +27,7 @@
    @NotBlank(message = "验证码不能为空")
    @ApiModelProperty(value = "验证码")
    private String code;
    @ApiModelProperty(value = "0运维人员 1商户")
    private Integer userType;
}
server/system_service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java
@@ -273,6 +273,7 @@
        user.setCompanyIdList(systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user));
        LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,company,null);
        userInfo.setH5UserType(LoginUserInfo.H5_USER_OPS);
        return  userInfo;
    }
@@ -353,6 +354,7 @@
        user.setCompanyIdList(systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user));
        LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,company,null);
        userInfo.setH5UserType(LoginUserInfo.H5_USER_OPS);
        String token = jwtTokenUtil.generateToken(userInfo);
        return  token;
server/visits/admin_timer/src/main/resources/application.yml
@@ -64,7 +64,7 @@
  compression:
    enabled: true
    mime-types: application/json
  port: 10037
  port: 10010
  tomcat:
    max-swallow-size: -1
  servlet:
server/visits/admin_timer/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
spring:
  profiles:
    active: pro
    active: dev
  application:
    name: visitsTimer
    # å®‰å…¨é…ç½®
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/web/VisitorWebController.java
@@ -75,10 +75,11 @@
    @GetMapping("/ywWxAuthorize")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "授权码", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "source", value = "来源:0=司机;1=访客;2=内部员工", required = true)
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "userType", value = "用户类型:0=运维人员;1=商户", required = false)
    })
    public ApiResponse<WxAuthorizeVO> ywWxAuthorize(@RequestParam String code) {
        WxAuthorizeVO wxAuthorizeVO =  memberService.ywWxAuthorize(code);
    public ApiResponse<WxAuthorizeVO> ywWxAuthorize(@RequestParam String code,
                                                      @RequestParam(required = false, defaultValue = "0") Integer userType) {
        WxAuthorizeVO wxAuthorizeVO =  memberService.ywWxAuthorize(code, userType);
        return ApiResponse.success("查询成功",wxAuthorizeVO);
    }
server/visits/dmvisit_admin/src/main/java/com/doumee/cloud/web/YwCustomerWebController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
package com.doumee.cloud.web;
import com.doumee.api.BaseController;
import com.doumee.config.annotation.LoginNoRequired;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
import com.doumee.dao.system.dto.LoginPhoneDTO;
import com.doumee.service.business.YwCustomerH5AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@Api(tags = "【公众号】商户登录")
@RestController
@LoginNoRequired
@RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX + "/web/customer")
public class YwCustomerWebController extends BaseController {
    @Autowired
    private YwCustomerH5AuthService ywCustomerH5AuthService;
    @PreventRepeat
    @ApiOperation("商户短信验证码登录")
    @PostMapping("/loginByPhone")
    public ApiResponse<String> loginByPhone(@Validated @RequestBody LoginPhoneDTO dto) {
        try {
            return ApiResponse.success(ywCustomerH5AuthService.loginByPhone(dto));
        } catch (BusinessException e) {
            return ApiResponse.failed(e.getCode(), e.getMessage());
        } catch (Exception e) {
            return ApiResponse.failed(ResponseStatus.SERVER_ERROR);
        }
    }
    @ApiOperation("获取当前商户登录信息")
    @GetMapping("/getUserInfo")
    public ApiResponse<LoginUserInfo> getUserInfo(@RequestHeader(Constants.HEADER_USER_TOKEN) String token) {
        LoginUserInfo user = this.getLoginUser(token);
        if (user == null || !Constants.equalsInteger(user.getH5UserType(), LoginUserInfo.H5_USER_CUSTOMER)) {
            return ApiResponse.failed("登录已失效");
        }
        return ApiResponse.success(ywCustomerH5AuthService.buildLoginUserInfo(user.getCustomerId()));
    }
}
server/visits/dmvisit_admin/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
spring:
  profiles:
    active: pro
    active: dev
  application:
    name: visitsAdmin
    # å®‰å…¨é…ç½®
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwCustomer.java
@@ -69,6 +69,9 @@
    @ExcelColumn(name="手机号")
    private String phone;
    @ApiModelProperty(value = "微信openid")
    private String openid;
    @ApiModelProperty(value = "身份证号(加密)")
    @ExcelColumn(name="身份证号(加密)")
    private String idcardNo;
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/MemberService.java
@@ -178,6 +178,8 @@
    WxAuthorizeVO ywWxAuthorize(String code);
    WxAuthorizeVO ywWxAuthorize(String code, Integer userType);
    List<MemberVO> getVisitedMember(CheckVisitedDTO checkVisitedDTO);
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/YwCustomerH5AuthService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package com.doumee.service.business;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.dao.system.dto.LoginPhoneDTO;
public interface YwCustomerH5AuthService {
    String loginByPhone(LoginPhoneDTO dto);
    String loginByCustomerId(Integer customerId);
    String loginByOpenId(String openId);
    LoginUserInfo buildLoginUserInfo(Integer customerId);
}
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java
@@ -45,6 +45,7 @@
import com.doumee.dao.web.response.WxAuthorizeVO;
import com.doumee.service.business.MemberService;
import com.doumee.service.business.SmsEmailService;
import com.doumee.service.business.YwCustomerH5AuthService;
import com.doumee.service.business.impl.hksync.HkSyncEmpowerServiceImpl;
import com.doumee.service.business.impl.hksync.ferp.HkSyncOrgUserToHKServiceImpl;
import com.doumee.service.system.SystemLoginService;
@@ -127,6 +128,9 @@
    @Autowired
    private SystemLoginService systemLoginService; 
    @Autowired
    private YwCustomerH5AuthService ywCustomerH5AuthService;
    
    @Value("${debug_model}")
    private Boolean isDebug;
@@ -1773,6 +1777,11 @@
     */
    @Override
    public WxAuthorizeVO ywWxAuthorize(String code){
        return ywWxAuthorize(code, LoginUserInfo.H5_USER_OPS);
    }
    @Override
    public WxAuthorizeVO ywWxAuthorize(String code, Integer userType){
        if(StringUtils.isBlank(code)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
@@ -1793,7 +1802,14 @@
            }
        }
        wxAuthorizeVO.setOpenid(openId);
        //根据openId æŸ¥è¯¢ç”¨æˆ·ä¿¡æ¯
        if(Constants.equalsInteger(userType, LoginUserInfo.H5_USER_CUSTOMER)){
            String token = ywCustomerH5AuthService.loginByOpenId(openId);
            if(StringUtils.isNotBlank(token)){
                wxAuthorizeVO.setToken(token);
            }
            return wxAuthorizeVO;
        }
        //根据openId æŸ¥è¯¢è¿ç»´ç”¨æˆ·ä¿¡æ¯
        SystemUser user = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda()
                .eq(SystemUser::getOpenid,openId)
                .eq(SystemUser::getDeleted,Boolean.FALSE)
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwCustomerH5AuthServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,135 @@
package com.doumee.service.business.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.config.jwt.JwtTokenUtil;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.YwCustomerMapper;
import com.doumee.dao.business.model.YwCustomer;
import com.doumee.dao.system.dto.LoginPhoneDTO;
import com.doumee.service.business.YwCustomerH5AuthService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.Date;
@Service
public class YwCustomerH5AuthServiceImpl implements YwCustomerH5AuthService {
    @Autowired
    private YwCustomerMapper ywCustomerMapper;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String loginByPhone(LoginPhoneDTO dto) {
        YwCustomer customer = findActiveByPhone(dto.getPhone());
        bindOpenId(customer, dto.getOpenid());
        touchLogin(customer);
        return jwtTokenUtil.generateToken(toLoginUserInfo(customer));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String loginByCustomerId(Integer customerId) {
        YwCustomer customer = requireActiveCustomer(customerId);
        touchLogin(customer);
        return jwtTokenUtil.generateToken(toLoginUserInfo(customer));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String loginByOpenId(String openId) {
        if (StringUtils.isBlank(openId)) {
            return null;
        }
        YwCustomer customer = ywCustomerMapper.selectOne(new QueryWrapper<YwCustomer>().lambda()
                .eq(YwCustomer::getIsdeleted, Constants.ZERO)
                .eq(YwCustomer::getOpenid, openId.trim())
                .last(" limit 1 "));
        if (customer == null) {
            return null;
        }
        assertCustomerEnabled(customer);
        touchLogin(customer);
        return jwtTokenUtil.generateToken(toLoginUserInfo(customer));
    }
    @Override
    public LoginUserInfo buildLoginUserInfo(Integer customerId) {
        return toLoginUserInfo(requireActiveCustomer(customerId));
    }
    private YwCustomer findActiveByPhone(String phone) {
        if (StringUtils.isBlank(phone)) {
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "手机号不能为空");
        }
        YwCustomer customer = ywCustomerMapper.selectOne(new QueryWrapper<YwCustomer>().lambda()
                .eq(YwCustomer::getIsdeleted, Constants.ZERO)
                .eq(YwCustomer::getPhone, phone.trim())
                .last(" limit 1 "));
        if (customer == null) {
            throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), "商户不存在或未注册");
        }
        assertCustomerEnabled(customer);
        return customer;
    }
    private YwCustomer requireActiveCustomer(Integer customerId) {
        if (customerId == null) {
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        YwCustomer customer = ywCustomerMapper.selectById(customerId);
        if (customer == null || Constants.equalsInteger(customer.getIsdeleted(), Constants.ONE)) {
            throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), "商户不存在或未注册");
        }
        assertCustomerEnabled(customer);
        return customer;
    }
    private void assertCustomerEnabled(YwCustomer customer) {
        if (customer.getStatus() != null && Constants.equalsInteger(customer.getStatus(), Constants.ONE)) {
            throw new BusinessException(ResponseStatus.NO_ALLOW_LOGIN.getCode(), "商户账号已禁用");
        }
    }
    private void bindOpenId(YwCustomer customer, String openid) {
        if (StringUtils.isBlank(openid)) {
            return;
        }
        ywCustomerMapper.update(null, new UpdateWrapper<YwCustomer>().lambda()
                .set(YwCustomer::getOpenid, null)
                .eq(YwCustomer::getOpenid, openid.trim())
                .ne(YwCustomer::getId, customer.getId()));
        customer.setOpenid(openid.trim());
    }
    private void touchLogin(YwCustomer customer) {
        Date now = new Date();
        customer.setLastLoginDate(now);
        customer.setEditDate(now);
        customer.setLoginNum((customer.getLoginNum() == null ? 0 : customer.getLoginNum()) + 1);
        ywCustomerMapper.updateById(customer);
    }
    private LoginUserInfo toLoginUserInfo(YwCustomer customer) {
        LoginUserInfo loginUserInfo = new LoginUserInfo();
        loginUserInfo.setCustomerId(customer.getId());
        loginUserInfo.setId(customer.getId());
        loginUserInfo.setH5UserType(LoginUserInfo.H5_USER_CUSTOMER);
        loginUserInfo.setRealname(customer.getName());
        loginUserInfo.setMobile(customer.getPhone());
        loginUserInfo.setUsername("customer_" + customer.getId());
        loginUserInfo.setSource(LoginUserInfo.SOURCE_H5_CUSTOMER);
        loginUserInfo.setRoles(Collections.singletonList("h5_customer"));
        loginUserInfo.setPermissions(Collections.emptyList());
        return loginUserInfo;
    }
}