Browse Source

更新实销相关业务

z332406259 4 years ago
parent
commit
9276a6ff4d

+ 3 - 0
app/model/local/tRbacUserModel.js

@@ -86,6 +86,9 @@ module.exports = app => {
 
     newAppSaledTotal: { type: Number }, // 新增app实销,
     newIviSaledTotal: { type: Number }, // 新增ivi实销
+    saledTotal: { type: Number }, // 实销,
+    saledAppTotal: { type: Number }, // app实销,
+    saledIviTotal: { type: Number }, // ivi实销,
 
   });
 

+ 5 - 0
app/service/tRbacUserService.js

@@ -66,6 +66,10 @@ class TRbacUserService extends Service {
     const activeAppSexAndAgeTotal = await this.activeAppSex2Age(timeRangData);
     const activeIviTotal = await this.activeIviTotal(timeRangData);
     const activeIviSexAndAgeTotal = await this.activeIviSex2Age(timeRangData);
+
+    const saledTotal = await this.total({ role_id: ctx.helper.saledRoleId });
+    const saledAppTotal = await this.total({ user_orgin: 'APP', role_id: ctx.helper.saledRoleId });
+    const saledIviTotal = await this.total({ user_orgin: 'IVI', role_id: ctx.helper.saledRoleId });
     initData.end_time = new Date();
     await ctx.service.statisticsService.save(ctx.model.Local.TRbacUserModel,
       { ...initData, total, sexAndAgeTotal,
@@ -76,6 +80,7 @@ class TRbacUserService extends Service {
         newIviTotal, newIviSexAndAgeTotal,
         activeIviTotal, activeIviSexAndAgeTotal,
         newAppSaledTotal, newIviSaledTotal,
+        saledTotal, saledAppTotal, saledIviTotal,
       }, isForceUpdate);
   }
 

+ 9 - 7
app/service/tRegisterInfoService.js

@@ -35,14 +35,10 @@ class TRegisterInfoService extends Service {
     if (result && result.length > 0) {
       maxMonth = result[0].data;
     }
-    const saledTotal = await ctx.model.TRbacUserModel.find(
-      { role_id: ctx.helper.saledRoleId }).countDocuments();
-    const saledAppTotal = await ctx.model.TRbacUserModel.find(
-      { user_orgin: 'APP', role_id: ctx.helper.saledRoleId }).countDocuments();
-    const saledIviTotal = await ctx.model.TRbacUserModel.find(
-      { user_orgin: 'IVI', role_id: ctx.helper.saledRoleId }).countDocuments();
     const user = await ctx.model.Local.TRbacUserModel.find({}, { appTotal: 1, newAppTotal: 1, activeAppTotal: 1,
-      iviTotal: 1, newIviTotal: 1, activeIviTotal: 1, newAppSaledTotal: 1, newIviSaledTotal: 1 }).sort({ create_date: -1 });
+      iviTotal: 1, newIviTotal: 1, activeIviTotal: 1, newAppSaledTotal: 1, newIviSaledTotal: 1,
+      saledTotal: 1, saledAppTotal: 1, saledIviTotal: 1,
+    }).sort({ create_date: -1 });
     let appTotal = 0;
     let newAppTotal = 0;
     let activeAppTotal = 0;
@@ -51,6 +47,9 @@ class TRegisterInfoService extends Service {
     let activeIviTotal = 0;
     let newAppSaledTotal = 0;
     let newIviSaledTotal = 0;
+    let saledTotal = 0;
+    let saledAppTotal = 0;
+    let saledIviTotal = 0;
     if (user) {
       appTotal = user.appTotal;
       newAppTotal = user.newAppTotal;
@@ -60,6 +59,9 @@ class TRegisterInfoService extends Service {
       activeIviTotal = user.activeIviTotal;
       newAppSaledTotal = user.newAppSaledTotal;
       newIviSaledTotal = user.newIviSaledTotal;
+      saledTotal = user.saledTotal;
+      saledAppTotal = user.saledAppTotal;
+      saledIviTotal = user.saledIviTotal;
     }
     return { maxDay, maxMonth, saledTotal, saledAppTotal, saledIviTotal,
       appTotal, newAppTotal, activeAppTotal,

+ 4 - 4
config/config.default.js

@@ -51,19 +51,19 @@ module.exports = appInfo => {
     },
     clients: {
       etlDB: {// 原始数据库
-        url: 'mongodb://127.0.0.1/faw-etl', //
+        // url: 'mongodb://127.0.0.1/faw-etl', //
         // url: 'mongodb://faw-etl-readonly:faw-etl-readonly@10.6.222.37:27017/faw-etl',//dev
         // url: 'mongodb://faw-etl-admin:faw-etl-admin%40123@10.112.16.11:27017/faw-etl', // sit
-        // url: 'mongodb://faw-etl:faw-etl123@uat.dbaas.private:27028/faw-etl', // uat
+        url: 'mongodb://faw-etl:faw-etl123@uat.dbaas.private:27028/faw-etl', // uat
         options: {
           useUnifiedTopology: true,
         },
       },
       etlLocalDB: {// 本地清洗后的数据库
-        url: 'mongodb://127.0.0.1/faw-etl-local', //
+        // url: 'mongodb://127.0.0.1/faw-etl-local', //
         // url: 'mongodb://faw-etl-local:faw-etl-local%40123@10.6.222.37:27017/faw-etl-local', // dev
         // url: 'mongodb://faw-etl-local:faw-etl-local%40123@10.112.16.11:27017/faw-etl-local', // sit
-        // url: 'mongodb://local3:local3%40123@uat.dbaas.private:27028/faw-etl-local3', // uat
+        url: 'mongodb://local3:local3%40123@uat.dbaas.private:27028/faw-etl-local3', // uat
         options: {
           useUnifiedTopology: true,
         },