Parcourir la source

添加积分管理菜单、网关、修改积分管理

asd123a20 il y a 2 ans
Parent
commit
3e01ab5213

+ 3 - 0
pm2-start-all.sh

@@ -57,5 +57,8 @@ pm2 start ./server.js --name service-wx --watch
 cd ..
 cd service-question-bank
 pm2 start ./server.js --name service-question-bank --watch
+cd ..
+cd service-integral
+pm2 start ./server.js --name service-integral --watch
 pm2 startup 
 pm2 save

+ 1 - 0
service-gateway/config/config.default.js

@@ -62,6 +62,7 @@ module.exports = appInfo => {
     importandexport: 'http://127.0.0.1:9016',
     reader: 'http://127.0.0.1:9017',
     question: 'http://127.0.0.1:9018',
+    integral: 'http://127.0.0.1:9019',
   };
   // 限制文件大小
   config.multipart = {

+ 91 - 0
service-gateway/config/integral.js

@@ -0,0 +1,91 @@
+'use strict';
+
+module.exports = [
+  // 积分
+//   {
+//     url: '/api/integral/integral/create',
+//     jwt: true,
+//     issuer: [ 'naf' ],
+//     log: true,
+//   },
+//   {
+//     url: '/api/integral/integral/update',
+//     jwt: true,
+//     issuer: [ 'naf' ],
+//     log: true,
+//   },
+  {
+    url: '/api/integral/integral/delete/:id',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integral/query',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: false,
+  },
+  {
+    url: '/api/integral/integral/increase',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integral/reduce',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: false,
+  },
+  // 积分日志
+  {
+    url: '/api/integral/integralLog/create',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralLog/update',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralLog/delete/:id',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralLog/query',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: false,
+  },
+  // 积分配置
+  {
+    url: '/api/integral/integralConfig/create',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralConfig/update',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralConfig/delete/:id',
+    jwt: true,
+    issuer: [ 'naf' ],
+    log: true,
+  },
+  {
+    url: '/api/integral/integralConfig/query',
+    jwt: false,
+    issuer: [ 'naf' ],
+    log: false,
+  },
+];

+ 12 - 5
service-integral/app/service/integral.js

@@ -59,27 +59,34 @@ class integralService extends Service {
       throw error;
     }
   }
-  async increase({ openid, integral }) {
+  async increase({ openid, name, integral }) {
     assert(openid, 'openid不存在');
+    assert(name, '姓名不存在');
+    assert(integral, '积分不存在');
     try {
+      await this.service.integralLog.create({ openid, name, integral });
       const one = await this.model.findOne({ openid });
       if (one) {
-        const total = integral + one.integral;
+        const total = Number(integral) + Number(one.integral);
         await this.model.updateOne({ openid }, { integral: total });
         return { errcode: 0, errmsg: 'ok', data: '' };
       }
-      return { errcode: -1001, errmsg: '未查询到用户', data: '' };
+      await this.model.create({ openid, name, integral });
+      return { errcode: 0, errmsg: 'ok', data: '' };
     } catch (error) {
       throw error;
     }
   }
-  async reduce({ openid, integral }) {
+  async reduce({ openid, name, integral }) {
     assert(openid, 'openid不存在');
+    assert(name, '姓名不存在');
+    assert(integral, '积分不存在');
     try {
       const one = await this.model.findOne({ openid });
       if (one) {
-        const total = one.integral - integral;
+        const total = Number(one.integral) - Number(integral);
         await this.model.updateOne({ openid }, { integral: total });
+        await this.service.integralLog.create({ openid, name, integral });
         return { errcode: 0, errmsg: 'ok', data: '' };
       }
       return { errcode: -1001, errmsg: '未查询到用户', data: '' };

+ 1 - 1
service-integral/config/config.default.js

@@ -30,7 +30,7 @@ module.exports = appInfo => {
   };
   config.cluster = {
     listen: {
-      port: 9018,
+      port: 9019,
     },
   };
   // 数据库配置

+ 27 - 0
service-naf/config/menu.js

@@ -282,5 +282,32 @@ const data = [
     parentCode: 'media',
     icon: 'el-icon-star-on',
   },
+  // 积分管理
+  {
+    module: 'integral',
+    path: '',
+    title: '积分管理',
+    code: 'integral',
+    parentCode: null,
+    icon: 'el-icon-star-on',
+  },
+  // 积分管理
+  {
+    module: 'integral',
+    path: '/integral/home',
+    title: '积分管理',
+    code: 'integralHome',
+    parentCode: 'integral',
+    icon: 'el-icon-star-on',
+  },
+  // 积分日志
+  {
+    module: 'integralog',
+    path: '/integrallog/home',
+    title: '积分日志',
+    code: 'integralloglHome',
+    parentCode: 'integral',
+    icon: 'el-icon-star-on',
+  },
 ];
 module.exports.data = data;

+ 2 - 2
start-all.sh

@@ -2,7 +2,7 @@ cd service-activity
 npm run start
 cd ..
 cd service-cms
-npm run start server.js --name service-cms --watch
+npm run start
 cd ..
 cd service-code
 npm run start
@@ -50,7 +50,7 @@ cd service-user
 npm run start
 cd ..
 cd service-vip
-npm run start server.js --name service-vip --watch
+npm run start
 cd ..
 cd service-wx
 npm run start