Pārlūkot izejas kodu

停用提示展示及sql

ellisran 1 gadu atpakaļ
vecāks
revīzija
09e2956c9b

+ 20 - 6
app/controller/login_controller.js

@@ -142,7 +142,9 @@ module.exports = app => {
                     throw '该微信号未绑定此项目';
                 }
                 if (pa.enable !== 1) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
                 // 设置项目和用户session记录
                 const result = await ctx.service.projectAccount.accountLogin({ project: projectData, accountData: pa }, 3);
@@ -176,7 +178,11 @@ module.exports = app => {
                 }
 
                 if (result === 2) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 查找项目数据
+                    const projectData = await this.ctx.service.project.getProjectByCode(ctx.request.body.project.toString().trim());
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
 
                 // 调用 rotateCsrfSecret 刷新用户的 CSRF token
@@ -320,7 +326,9 @@ module.exports = app => {
                     throw '';
                 } else {
                     if (pa.enable !== 1) {
-                        throw '该账号已被停用,请联系销售人员';
+                        // 判断是否有设置停用提示,有则展示
+                        const msg = await ctx.service.projectStopmsg.getMsg(ctx.projectData.id);
+                        throw msg;
                     }
                     const result = await ctx.service.projectAccount.accountLogin({ project: ctx.projectData, accountData: pa }, 3);
                     if (!result) {
@@ -373,7 +381,9 @@ module.exports = app => {
                     }
 
                     if (pa.enable !== 1) {
-                        throw '该账号已被停用,请联系销售人员';
+                        // 判断是否有设置停用提示,有则展示
+                        const msg = await ctx.service.projectStopmsg.getMsg(pa.project_id);
+                        throw msg;
                     }
                     const updateData = {
                         bind: 1,
@@ -544,7 +554,9 @@ module.exports = app => {
                   throw '您无权限登录系统。';
               }
               if (account.enable !== 1) {
-                throw '该账号已被停用,请联系销售人员';
+                  // 判断是否有设置停用提示,有则展示
+                  const msg = await ctx.service.projectStopmsg.getMsg(project.id);
+                  throw msg;
             }
             const result = await ctx.service.projectAccount.accountLogin({ project, accountData: account }, 3);
             if (!result) {
@@ -612,7 +624,9 @@ module.exports = app => {
               throw '用户名或密码错误';
             }
             if (result === 2) {
-                throw '该账号已被停用,请联系销售人员';
+                // 判断是否有设置停用提示,有则展示
+                const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                throw msg;
             }
           } catch (error) {
             response.code = -1;

+ 3 - 1
app/controller/wap_controller.js

@@ -73,7 +73,9 @@ module.exports = app => {
                 }
 
                 if (result === 2) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(ctx.session.sessionProject.id);
+                    throw msg;
                 }
 
                 // 调用 rotateCsrfSecret 刷新用户的 CSRF token

+ 16 - 4
app/controller/wechat_controller.js

@@ -98,7 +98,11 @@ module.exports = app => {
                 }
 
                 if (result === 2) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 查找项目数据
+                    const projectData = await this.ctx.service.project.getProjectByCode(ctx.request.body.project.toString().trim());
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
                 const accountData = result;
                 if (accountData.wx_openid || ctx.session.wechatToken.openid === accountData.wx_openid) {
@@ -168,7 +172,9 @@ module.exports = app => {
                     throw '该微信号未绑定此项目';
                 }
                 if (pa.enable !== 1) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
                 // 设置项目和用户session记录
                 const result = await ctx.service.projectAccount.accountLogin({ project: projectData, accountData: pa }, 3);
@@ -379,7 +385,11 @@ module.exports = app => {
                 }
 
                 if (result === 2) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 查找项目数据
+                    const projectData = await this.ctx.service.project.getProjectByCode(ctx.request.body.project.toString().trim());
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
                 const accountData = result;
                 const qywx_userid = ctx.request.body.userid;
@@ -464,7 +474,9 @@ module.exports = app => {
                     throw '该企业微信号未绑定此项目';
                 }
                 if (pa.enable !== 1) {
-                    throw '该账号已被停用,请联系销售人员';
+                    // 判断是否有设置停用提示,有则展示
+                    const msg = await ctx.service.projectStopmsg.getMsg(projectData.id);
+                    throw msg;
                 }
                 // 设置项目和用户session记录
                 const result = await ctx.service.projectAccount.accountLogin({ project: projectData, accountData: pa }, 3);

+ 32 - 0
app/service/project_stopmsg.js

@@ -0,0 +1,32 @@
+'use strict';
+
+/**
+ * 系统维护数据模型
+ *
+ * @author CaiAoLin
+ * @date 2017/10/25
+ * @version
+ */
+module.exports = app => {
+
+    class ProjectStopMsg extends app.BaseService {
+
+        /**
+         * 构造函数
+         *
+         * @param {Object} ctx - egg全局变量
+         * @return {void}
+         */
+        constructor(ctx) {
+            super(ctx);
+            this.tableName = 'project_stopmsg';
+        }
+
+        async getMsg(pid) {
+            const info = await this.getDataByCondition({ pid, is_checked: 1 });
+            return info ? info.msg : '该账号已被停用,请联系销售人员';
+        }
+    }
+
+    return ProjectStopMsg;
+};

+ 9 - 0
sql/update.sql

@@ -39,3 +39,12 @@ ADD COLUMN `type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1为本期不参与调
 
 ALTER TABLE `zh_stage_bills_pc`
 MODIFY COLUMN `lid` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '项目节id' AFTER `sorder`;
+
+CREATE TABLE `calculation`.`zh_project_stopmsg`  (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `pid` int NOT NULL COMMENT '项目id',
+  `msg` varchar(255) NULL COMMENT '停用信息',
+  `is_checked` tinyint(1) NULL DEFAULT 0 COMMENT '是否选中',
+  `in_time` datetime NULL COMMENT '创建时间',
+  PRIMARY KEY (`id`)
+) ENGINE = InnoDB CHARACTER SET = utf8 COMMENT = '用户账号停用提示表';