lrf402788946 4 år sedan
förälder
incheckning
0f3b83db19
50 ändrade filer med 768 tillägg och 345 borttagningar
  1. 41 36
      app/controller/cysci/.policy_order.js
  2. 0 3
      app/controller/cysci/.policy.js
  3. 6 4
      app/controller/cysci/.policy_apply.js
  4. 2 4
      app/controller/cysci/.ticket.js
  5. 24 4
      app/controller/cysci/.ticket_record.js
  6. 65 0
      app/controller/cysci/.reward.js
  7. 80 0
      app/controller/cysci/.reward_order.js
  8. 13 0
      app/controller/cysci/cashing.js
  9. 13 0
      app/controller/cysci/coupons.js
  10. 13 0
      app/controller/cysci/coupons_apply.js
  11. 17 0
      app/controller/cysci/declare.js
  12. 13 0
      app/controller/cysci/declare_order.js
  13. 0 13
      app/controller/cysci/policy.js
  14. 0 13
      app/controller/cysci/policy_apply.js
  15. 0 13
      app/controller/cysci/policy_order.js
  16. 13 0
      app/controller/cysci/reward.js
  17. 13 0
      app/controller/cysci/reward_order.js
  18. 0 17
      app/controller/cysci/ticket.js
  19. 0 13
      app/controller/cysci/ticket_record.js
  20. 2 2
      app/controller/statistics/index.js
  21. 9 10
      app/middleware/policy_apply.js
  22. 35 0
      app/middleware/declare_order.js
  23. 49 0
      app/model/cashing.js
  24. 4 5
      app/model/policy.js
  25. 8 6
      app/model/policy_apply.js
  26. 4 4
      app/model/ticket.js
  27. 29 0
      app/model/declare_order.js
  28. 0 43
      app/model/policy_order.js
  29. 31 0
      app/model/reward.js
  30. 41 0
      app/model/reward_order.js
  31. 0 24
      app/model/ticket_record.js
  32. 7 5
      app/router.js
  33. 12 12
      app/router/cysci/policy.js
  34. 12 0
      app/router/cysci/coupons.js
  35. 13 13
      app/router/cysci/policy_apply.js
  36. 1 1
      app/router/cysci/policy_order.js
  37. 13 0
      app/router/cysci/declare_order.js
  38. 12 13
      app/router/cysci/ticket.js
  39. 12 12
      app/router/cysci/ticket_record.js
  40. 1 1
      app/router/statistics/index.js
  41. 22 0
      app/service/cysci/cashing.js
  42. 5 5
      app/service/cysci/policy.js
  43. 5 5
      app/service/cysci/ticket_record.js
  44. 19 10
      app/service/cysci/ticket.js
  45. 5 5
      app/service/cysci/policy_apply.js
  46. 0 22
      app/service/cysci/policy_order.js
  47. 25 0
      app/service/cysci/reward.js
  48. 23 0
      app/service/cysci/reward_order.js
  49. 55 27
      app/service/statistics/index.js
  50. 1 0
      config/config.default.js

+ 41 - 36
app/controller/cysci/.policy_order.js

@@ -1,26 +1,27 @@
 module.exports = {
   create: {
     requestBody: [
-      "user_id",
-      "policy_id",
-      "apply_id",
-      "policy_user_type",
-      "req_desc",
-      "name",
-      "no",
-      "person",
-      "phone",
-      "email",
+      "cashing_no",
+      "coupons_id",
+      "coupons_type",
+      "coupons_name",
+      "company_id",
+      "company_name",
+      "create_time",
+      "end_time",
       "mechanism_id",
-      "mechanism_person",
-      "mechanism_mobile",
+      "mechanism_name",
       "money",
       "allowance",
       "total",
-      "remark",
-      "user_name",
-      "mechanism_name",
       "status",
+      "remark",
+      "contract",
+      "accept",
+      "cost",
+      "result",
+      "result_else",
+      "record",
     ],
   },
   destroy: {
@@ -30,26 +31,27 @@ module.exports = {
   update: {
     params: ["!id"],
     requestBody: [
-      "user_id",
-      "policy_id",
-      "apply_id",
-      "policy_user_type",
-      "req_desc",
-      "name",
-      "no",
-      "person",
-      "phone",
-      "email",
+      "cashing_no",
+      "coupons_id",
+      "coupons_type",
+      "coupons_name",
+      "company_id",
+      "company_name",
+      "create_time",
+      "end_time",
       "mechanism_id",
-      "mechanism_person",
-      "mechanism_mobile",
+      "mechanism_name",
       "money",
       "allowance",
       "total",
-      "remark",
-      "user_name",
-      "mechanism_name",
       "status",
+      "remark",
+      "contract",
+      "accept",
+      "cost",
+      "result",
+      "result_else",
+      "record",
     ],
   },
   show: {
@@ -61,14 +63,17 @@ module.exports = {
   index: {
     parameters: {
       query: {
-        user_id: "user_id",
-        policy_id: "policy_id",
-        apply_id: "apply_id",
-        person: "person",
-        name: "name",
+        cashing_no: "cashing_no",
+        coupons_id: "coupons_id",
+        coupons_type: "coupons_type",
+        coupons_name: "coupons_name",
+        company_id: "company_id",
+        company_name: "company_name",
+        create_time: "create_time",
+        end_time: "end_time",
         mechanism_id: "mechanism_id",
-        user_name: "user_name",
         mechanism_name: "mechanism_name",
+        status: "status",
         "create_time@start": "create_time@start",
         "create_time@end": "create_time@end",
       },

+ 0 - 3
app/controller/cysci/.policy.js

@@ -2,7 +2,6 @@ module.exports = {
   create: {
     requestBody: [
       "user_id",
-      "type",
       "name",
       "discount_type",
       "use_type",
@@ -25,7 +24,6 @@ module.exports = {
     params: ["!id"],
     requestBody: [
       "user_id",
-      "type",
       "name",
       "discount_type",
       "use_type",
@@ -51,7 +49,6 @@ module.exports = {
       query: {
         user_id: "user_id",
         name: "name",
-        type: "type",
         discount_type: "discount_type",
         use_type: "use_type",
         classify: "classify",

+ 6 - 4
app/controller/cysci/.policy_apply.js

@@ -2,7 +2,7 @@ module.exports = {
   create: {
     requestBody: [
       "user_id",
-      "policy_id",
+      "coupons_id",
       "company",
       "apply_personal",
       "phone",
@@ -11,6 +11,7 @@ module.exports = {
       "qylr",
       "record",
       "status",
+      "is_use",
       "remark",
     ],
   },
@@ -22,7 +23,7 @@ module.exports = {
     params: ["!id"],
     requestBody: [
       "user_id",
-      "policy_id",
+      "coupons_id",
       "company",
       "apply_personal",
       "phone",
@@ -31,7 +32,7 @@ module.exports = {
       "qylr",
       "record",
       "status",
-
+      "is_use",
       "remark",
     ],
   },
@@ -45,11 +46,12 @@ module.exports = {
     parameters: {
       query: {
         user_id: "user_id",
-        policy_id: "policy_id",
+        coupons_id: "coupons_id",
         company: "company",
         apply_personal: "apply_personal",
         phone: "phone",
         status: "status",
+        is_use: "is_use",
         "create_time@start": "meta.createdAt@start",
         "create_time@end": "meta.createdAt@end",
       },

+ 2 - 4
app/controller/cysci/.ticket.js

@@ -20,7 +20,9 @@ module.exports = {
       "material",
       "medium_material",
       "contract",
+      'record',
       "status",
+      "name",
     ],
   },
   show: {
@@ -51,8 +53,4 @@ module.exports = {
       count: true,
     },
   },
-  status: {
-    params: ["!id"],
-    requestBody: ["status", "desc", "opera_id"],
-  },
 };

+ 24 - 4
app/controller/cysci/.ticket_record.js

@@ -1,6 +1,14 @@
 module.exports = {
   create: {
-    requestBody: ["ticket_id", "status", "desc", "opera_id"],
+    requestBody: [
+      "user_id",
+      "name",
+      "mechanism_id",
+      "no",
+      "is_pay",
+      "time",
+      "remark",
+    ],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +16,15 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["ticket_id", "status", "desc", "opera_id"],
+    requestBody: [
+      "user_id",
+      "name",
+      "mechanism_id",
+      "no",
+      "is_pay",
+      "time",
+      "remark",
+    ],
   },
   show: {
     parameters: {
@@ -19,8 +35,12 @@ module.exports = {
   index: {
     parameters: {
       query: {
-        ticket_id: "ticket_id",
-        status: "status",
+        user_id: "user_id",
+        name: "name",
+        mechanism_id: "mechanism_id",
+        no: "no",
+        is_pay: "is_pay",
+        time: "time",
         "create_time@start": "create_time@start",
         "create_time@end": "create_time@end",
       },

+ 65 - 0
app/controller/cysci/.reward.js

@@ -0,0 +1,65 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "type",
+      "company",
+      "apply_personal",
+      "phone",
+      "qyfr",
+      "yyzz",
+      "qylr",
+      "user_id",
+      "status",
+      "remark",
+      "record",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "type",
+      "company",
+      "apply_personal",
+      "phone",
+      "qyfr",
+      "yyzz",
+      "qylr",
+      "user_id",
+      "status",
+      "remark",
+      "record",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        type: "type",
+        company: "company",
+        user_id: "user_id",
+        status: "status",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 80 - 0
app/controller/cysci/.reward_order.js

@@ -0,0 +1,80 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "no",
+      "company_id",
+      "company_name",
+      "create_time",
+      "end_time",
+      "money",
+      "allowance",
+      "total",
+      "status",
+      "remark",
+      "contract",
+      "accept",
+      "cost",
+      "result",
+      "result_else",
+      "record",
+      "type",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "no",
+      "company_id",
+      "company_name",
+      "create_time",
+      "end_time",
+      "money",
+      "allowance",
+      "total",
+      "status",
+      "remark",
+      "contract",
+      "accept",
+      "cost",
+      "result",
+      "result_else",
+      "record",
+      "type",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        no: "no",
+        company_id: "company_id",
+        company_name: "company_name",
+        create_time: "create_time",
+        end_time: "end_time",
+        status: "status",
+        type: "type",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/cysci/cashing.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.cashing.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 高企申报兑换
+class CashingController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.cashing;
+  }
+}
+module.exports = CrudController(CashingController, meta);

+ 13 - 0
app/controller/cysci/coupons.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.coupons.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 创新券
+class CouponsController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.coupons;
+  }
+}
+module.exports = CrudController(CouponsController, meta);

+ 13 - 0
app/controller/cysci/coupons_apply.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.coupons_apply.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 创新券申领
+class Coupons_applyController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.couponsApply;
+  }
+}
+module.exports = CrudController(Coupons_applyController, meta);

+ 17 - 0
app/controller/cysci/declare.js

@@ -0,0 +1,17 @@
+'use strict';
+const meta = require('./.declare.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 高企申报
+class DeclareController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.declare;
+  }
+  async index() {
+    const data = await this.service.query(this.ctx.query);
+    this.ctx.ok(data);
+  }
+}
+module.exports = CrudController(DeclareController, meta);

+ 13 - 0
app/controller/cysci/declare_order.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.declare_order.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 高企申报订单
+class Declare_orderController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.declareOrder;
+  }
+}
+module.exports = CrudController(Declare_orderController, meta);

+ 0 - 13
app/controller/cysci/policy.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./.policy.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 高企政策服务
-class PolicyController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.cysci.policy;
-  }
-}
-module.exports = CrudController(PolicyController, meta);

+ 0 - 13
app/controller/cysci/policy_apply.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./.policy_apply.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 高企服务政策申请
-class Policy_applyController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.cysci.policyApply;
-  }
-}
-module.exports = CrudController(Policy_applyController, meta);

+ 0 - 13
app/controller/cysci/policy_order.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./.policy_order.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 高企政策服务订单
-class Policy_orderController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.cysci.policyOrder;
-  }
-}
-module.exports = CrudController(Policy_orderController, meta);

+ 13 - 0
app/controller/cysci/reward.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.reward.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 研发补贴,奖励兑换申领
+class RewardController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.reward;
+  }
+}
+module.exports = CrudController(RewardController, meta);

+ 13 - 0
app/controller/cysci/reward_order.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.reward_order.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 研发补贴,奖励兑换订单
+class Reward_orderController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.cysci.rewardOrder;
+  }
+}
+module.exports = CrudController(Reward_orderController, meta);

+ 0 - 17
app/controller/cysci/ticket.js

@@ -1,17 +0,0 @@
-'use strict';
-const meta = require('./.ticket.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 高企申报
-class TicketController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.cysci.ticket;
-  }
-  async index() {
-    const { data, total } = await this.service.query(this.ctx.query);
-    this.ctx.ok({ data, total });
-  }
-}
-module.exports = CrudController(TicketController, meta);

+ 0 - 13
app/controller/cysci/ticket_record.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./.ticket_record.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 创新券记录表
-class Ticket_recordController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.cysci.ticketRecord;
-  }
-}
-module.exports = CrudController(Ticket_recordController, meta);

+ 2 - 2
app/controller/statistics/index.js

@@ -71,8 +71,8 @@ class IndexController extends Controller {
   /**
    * 高企申报个步骤统计
    */
-  async ticketCount() {
-    const data = await this.service.ticket();
+  async declare() {
+    const data = await this.service.declare();
     this.ctx.ok({ data });
   }
 }

+ 9 - 10
app/middleware/policy_apply.js

@@ -2,7 +2,7 @@
 const _ = require('lodash');
 
 const idToData = async (ctx, id) => {
-  let res = await ctx.service.cysci.policy.fetch({ id });
+  let res = await ctx.service.cysci.coupons.fetch({ id });
   if (res) {
     res = JSON.parse(JSON.stringify(res));
     const { user_id } = res;
@@ -15,27 +15,26 @@ const idToData = async (ctx, id) => {
 };
 
 module.exports = options => {
-  return async function policyApply(ctx, next) {
-    console.log('function in policy_apply middleware');
+  return async function couponsApply(ctx, next) {
     const request = ctx.request;
     await next();
     const { method } = request;
     if (method === 'GET') {
-      // 处理get的时policy_id换成对应的数据
+      // 处理get的时coupons_id换成对应的数据
       let { data } = ctx.body;
       data = JSON.parse(JSON.stringify(data));
       if (_.isArray(data)) {
         // 数组,多个,循环查
         for (const i of data) {
-          const { policy_id } = i;
-          const res = await idToData(ctx, policy_id);
-          if (res)i.policy = res;
+          const { coupons_id } = i;
+          const res = await idToData(ctx, coupons_id);
+          if (res)i.coupons = res;
         }
       } else if (_.isObject(data)) {
         // 一个,找完就完事
-        const { policy_id } = data;
-        const res = await idToData(ctx, policy_id);
-        if (res) data.policy = res;
+        const { coupons_id } = data;
+        const res = await idToData(ctx, coupons_id);
+        if (res) data.coupons = res;
       }
       ctx.body.data = data;
     }

+ 35 - 0
app/middleware/declare_order.js

@@ -0,0 +1,35 @@
+'use strict';
+const _ = require('lodash');
+const idToData = async (ctx, id) => {
+  // 需要请求获取
+  const res = await ctx.service.util.httpUtil.cget(`/mechanism/${id}`, 'hnhmain');
+  if (res) {
+    return res;
+  }
+};
+module.exports = options => {
+  return async function declare_order(ctx, next) {
+    const request = ctx.request;
+    await next();
+    const { method } = request;
+    if (method === 'GET') {
+      // 处理get的时mechanism_id换成对应的数据
+      let { data } = ctx.body;
+      data = JSON.parse(JSON.stringify(data));
+      if (_.isArray(data)) {
+        // 数组,多个,循环查
+        for (const i of data) {
+          const { mechanism_id } = i;
+          const res = await idToData(ctx, mechanism_id);
+          if (res)i.mechanism = res;
+        }
+      } else if (_.isObject(data)) {
+        // 一个,找完就完事
+        const { mechanism_id } = data;
+        const res = await idToData(ctx, mechanism_id);
+        if (res) data.mechanism = res;
+      }
+      ctx.body.data = data;
+    }
+  };
+};

+ 49 - 0
app/model/cashing.js

@@ -0,0 +1,49 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 兑付申请表
+const cashing = {
+  cashing_no: { type: String }, // 兑付申请号(自动生成)
+  coupons_id: { type: ObjectId }, // 券的id
+  coupons_type: { type: String }, // 券的类别
+  coupons_name: { type: String }, // 券的名称
+  company_id: { type: ObjectId }, // 使用单位id
+  company_name: { type: String }, // 使用单位
+  create_time: { type: String }, // 提交时间,服务端生成
+  end_time: { type: String }, // 最后审核时间
+  mechanism_id: { type: ObjectId }, // 服务提供商_id
+  mechanism_name: { type: String }, // 服务提供商
+  money: { type: Number }, // 订单金额
+  allowance: { type: Number }, // 抵扣金额
+  total: { type: Number }, // 应收金额
+  status: { type: String, default: '0' }, // 0-待审核;1-通过;-1-拒绝
+  remark: { type: String },
+  // 需要上传的资料
+  contract: { type: Array }, // 上传合同
+  accept: { type: Array }, // 官方受理通知书
+  cost: { type: Array }, // 官方缴费证明
+  result: { type: Array }, // 服务结果证明
+  result_else: { type: Array }, // 其他能够证明服务真是发生的材料
+  record: { type: Array }, // 记录
+};
+const schema = new Schema(cashing, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ cashing_no: 1 });
+schema.index({ coupons_id: 1 });
+schema.index({ coupons_type: 1 });
+schema.index({ coupons_name: 1 });
+schema.index({ company_id: 1 });
+schema.index({ company_name: 1 });
+schema.index({ create_time: 1 });
+schema.index({ end_time: 1 });
+schema.index({ mechanism_id: 1 });
+schema.index({ mechanism_name: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Cashing', schema, 'cashing');
+};

+ 4 - 5
app/model/policy.js

@@ -3,10 +3,9 @@ const Schema = require('mongoose').Schema;
 const moment = require('moment');
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const { ObjectId } = require('mongoose').Types;
-// 高企政策服务
-const policy = {
+// 创新券
+const coupons = {
   user_id: { type: ObjectId }, // 创建者id
-  type: { type: String }, // 0-研发补贴,1-奖励兑现,2-创新券
   name: { type: String }, // 名称
   discount_type: { type: String }, // 折扣类型: 全额折扣券;折扣券;定额折扣券
   use_type: { type: String }, // 使用服务类型
@@ -20,7 +19,7 @@ const policy = {
   status: { type: String, default: '0' }, // 0:待上架;1:上架;-1:下架
   remark: { type: String },
 };
-const schema = new Schema(policy, { toJSON: { virtuals: true } });
+const schema = new Schema(coupons, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ user_id: 1 });
 schema.index({ type: 1 });
@@ -33,5 +32,5 @@ schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model('Policy', schema, 'policy');
+  return mongoose.model('Coupons', schema, 'coupons');
 };

+ 8 - 6
app/model/policy_apply.js

@@ -3,10 +3,10 @@ const Schema = require('mongoose').Schema;
 const moment = require('moment');
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const { ObjectId } = require('mongoose').Types;
-// 高企服务政策申请
-const policy_apply = {
+// 创新券申领
+const coupons_apply = {
   user_id: { type: ObjectId }, // 申请人id
-  policy_id: { type: ObjectId }, // 创新券id
+  coupons_id: { type: ObjectId }, // 创新券id
   company: { type: String }, // 申请企业
   apply_personal: { type: String }, // 申请人
   phone: { type: String }, // 联系电话
@@ -16,17 +16,19 @@ const policy_apply = {
   record: { type: Array }, // 审核记录
   remark: { type: String },
   status: { type: String, default: '0' }, // 0-待处理;1-已通过;2已拒绝
+  is_use: { type: Boolean, default: true },
 };
-const schema = new Schema(policy_apply, { toJSON: { virtuals: true } });
+const schema = new Schema(coupons_apply, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ user_id: 1 });
-schema.index({ policy_id: 1 });
+schema.index({ coupons_id: 1 });
 schema.index({ company: 1 });
 schema.index({ apply_personal: 1 });
 schema.index({ phone: 1 });
+schema.index({ is_use: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model('Policy_apply', schema, 'policy_apply');
+  return mongoose.model('Coupons_apply', schema, 'coupons_apply');
 };

+ 4 - 4
app/model/ticket.js

@@ -4,7 +4,7 @@ const moment = require('moment');
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 const { ObjectId } = require('mongoose').Types;
 // 高企申报表
-const ticket = {
+const declare = {
   user_id: { type: ObjectId }, // 用户id
   mechanism_id: { type: ObjectId }, // 中介机构id
   material: { type: Array }, // 审核资料
@@ -14,10 +14,10 @@ const ticket = {
   // 0-初审;
   // 1-初审通过(企业,中介上传合同);-1-初审失败;
   // 2-高企申报成功;-2:高企申报失败
+  record: { type: Array },
   remark: { type: String },
-  create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
 };
-const schema = new Schema(ticket, { toJSON: { virtuals: true } });
+const schema = new Schema(declare, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ status: 1 });
 schema.index({ user_id: 1 });
@@ -25,5 +25,5 @@ schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model('Ticket', schema, 'ticket');
+  return mongoose.model('Declare', schema, 'declare');
 };

+ 29 - 0
app/model/declare_order.js

@@ -0,0 +1,29 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 高企申报订单表
+const declare_order = {
+  user_id: { type: ObjectId }, // 企业id
+  name: { type: String }, // 企业名称
+  mechanism_id: { type: ObjectId }, // 中介机构id, 需要换信息
+  no: { type: String, unique: true }, // 订单号,时间戳
+  is_pay: { type: String, default: '0' }, // 兑付状态 0;1;2
+  time: { type: String }, // 创建时间
+  remark: { type: String },
+};
+const schema = new Schema(declare_order, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ user_id: 1 });
+schema.index({ name: 1 });
+schema.index({ mechanism_id: 1 });
+schema.index({ no: 1 });
+schema.index({ is_pay: 1 });
+schema.index({ time: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Declare_order', schema, 'declare_order');
+};

+ 0 - 43
app/model/policy_order.js

@@ -1,43 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { ObjectId } = require('mongoose').Types;
-// 高企政策服务订单表
-const policy_order = {
-  user_id: { type: ObjectId }, // 申请用户,需求机构名称
-  policy_id: { type: ObjectId }, // 创新券id
-  apply_id: { type: ObjectId }, // 申请id
-  policy_user_type: { type: String }, // 创新券使用服务类型
-  req_desc: { type: String }, // 需求描述
-  name: { type: String }, // 订单名称
-  no: { type: String, unique: true }, // 订单号,时间戳
-  user_name: { type: String }, // 需方机构名称
-  person: { type: String }, // 申请人
-  phone: { type: String }, // 联系电话
-  email: { type: String }, // 电子邮箱
-  mechanism_id: { type: ObjectId }, // 服务机构,申请中的票子的user._id
-  mechanism_name: { type: String }, // 服务机构
-  mechanism_person: { type: String }, // 服务机构联系人,user的name
-  mechanism_mobile: { type: String }, // 服务机构联系人,user的mobile
-  money: { type: Number }, // 订单总金额
-  allowance: { type: Number }, // 券抵扣金额
-  total: { type: Number }, // 应收金额
-  remark: { type: String }, // 备注
-  status: { type: String, default: '0' }, // 0-待确认;1-确认订单;2-取消订单
-};
-const schema = new Schema(policy_order, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ user_id: 1 });
-schema.index({ policy_id: 1 });
-schema.index({ apply_id: 1 });
-schema.index({ name: 1 });
-schema.index({ mechanism_id: 1 });
-schema.index({ user_name: 1 });
-schema.index({ mechanism_name: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Policy_order', schema, 'policy_order');
-};

+ 31 - 0
app/model/reward.js

@@ -0,0 +1,31 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 研发补贴,奖励兑现申领表
+const reward = {
+  type: { type: String }, // 研发补贴/奖励兑换
+  company: { type: String }, // 申领企业
+  apply_personal: { type: String }, // 申领人
+  phone: { type: String }, // 联系电话
+  qyfr: { type: Array }, // 企业法人
+  yyzz: { type: Array }, // 营业执照
+  qylr: { type: Array }, // 企业利润
+  user_id: { type: Object }, // 申领人id
+  status: { type: String, default: '0' }, // 状态:0:待审核;1-审核通过(生成订单);1-审核拒绝
+  remark: { type: String },
+  record: { type: Array }, // 记录
+};
+const schema = new Schema(reward, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ type: 1 });
+schema.index({ company: 1 });
+schema.index({ user_id: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Reward', schema, 'reward');
+};

+ 41 - 0
app/model/reward_order.js

@@ -0,0 +1,41 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 研发补贴,奖励兑现订单表
+const reward_order = {
+  no: { type: String }, // 兑付申请号(自动生成)
+  type: { type: String }, // 类型
+  company_id: { type: ObjectId }, // 使用单位id
+  company_name: { type: String }, // 使用单位
+  create_time: { type: String }, // 提交时间,服务端生成
+  end_time: { type: String }, // 最后审核时间
+  money: { type: Number }, // 订单金额
+  allowance: { type: Number }, // 抵扣金额
+  total: { type: Number }, // 应收金额
+  status: { type: String, default: '0' }, // 0-待审核;1-通过;-1-拒绝
+  remark: { type: String },
+  // 需要上传的资料
+  contract: { type: Array }, // 上传合同
+  accept: { type: Array }, // 官方受理通知书
+  cost: { type: Array }, // 官方缴费证明
+  result: { type: Array }, // 服务结果证明
+  result_else: { type: Array }, // 其他能够证明服务真是发生的材料
+  record: { type: Array }, // 记录
+};
+const schema = new Schema(reward_order, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ no: 1 });
+schema.index({ type: 1 });
+schema.index({ company_id: 1 });
+schema.index({ company_name: 1 });
+schema.index({ create_time: 1 });
+schema.index({ end_time: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Reward_order', schema, 'reward_order');
+};

+ 0 - 24
app/model/ticket_record.js

@@ -1,24 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const { ObjectId } = require('mongoose').Types;
-// 创新劵审核记录表
-const ticket_record = {
-  ticket_id: { type: ObjectId },
-  opera_id: { type: ObjectId }, // 审核人
-  status: { type: String }, // 改变为的状态
-  desc: { type: String }, // 建议
-  remark: { type: String },
-  create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
-};
-const schema = new Schema(ticket_record, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.index({ ticket_id: 1 });
-schema.index({ status: 1 });
-schema.index({ 'meta.createdAt': 1 });
-schema.plugin(metaPlugin);
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Ticket_record', schema, 'ticket_record');
-};

+ 7 - 5
app/router.js

@@ -42,9 +42,11 @@ module.exports = app => {
   require('./router/dock/patent')(app); // e专利
   require('./router/tecinfo/science')(app); // 科技新闻
   require('./router/statistics/index')(app); // 首页统计
-  require('./router/cysci/policy')(app); // 高企政策
-  require('./router/cysci/policy_apply')(app); // 高企政策申请
-  require('./router/cysci/policy_order')(app); // 高企订单
-  require('./router/cysci/ticket')(app); // 高企申报
-  require('./router/cysci/ticket_record')(app); // 高企申报记录
+  require('./router/cysci/coupons')(app); // 创新券
+  require('./router/cysci/coupons_apply')(app); // 创新券申请
+  require('./router/cysci/declare')(app); // 高企申报
+  require('./router/cysci/declare_order')(app); // 高企申报订单
+  require('./router/cysci/cashing')(app); // 高企申报兑付
+  require('./router/cysci/reward')(app); // 研发补贴/奖励兑换申领
+  require('./router/cysci/reward_order')(app); // 研发补贴/奖励兑换订单
 };

+ 12 - 12
app/router/cysci/policy.js

@@ -1,12 +1,12 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'cysci';
-  const target = 'policy';
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'cashing';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 12 - 0
app/router/cysci/coupons.js

@@ -0,0 +1,12 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'coupons';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 13 - 13
app/router/cysci/policy_apply.js

@@ -1,13 +1,13 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'cysci';
-  const target = 'policyApply';
-  const pa = app.middleware.policyApply();
-  router.resources(target, `${profix}${vision}/${index}/${target}`, pa, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'couponsApply';
+  const ca = app.middleware.couponsApply();
+  router.resources(target, `${profix}${vision}/${index}/${target}`, ca, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 1 - 1
app/router/cysci/policy_order.js

@@ -6,7 +6,7 @@ module.exports = app => {
   const profix = '/api/live/';
   const vision = 'v0';
   const index = 'cysci';
-  const target = 'policyOrder';
+  const target = 'declare';
   router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
   router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
 };

+ 13 - 0
app/router/cysci/declare_order.js

@@ -0,0 +1,13 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'declareOrder';
+  const doware = app.middleware.declareOrder();
+  router.resources(target, `${profix}${vision}/${index}/${target}`, doware, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 12 - 13
app/router/cysci/ticket.js

@@ -1,13 +1,12 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'cysci';
-  const target = 'ticket';
-  router.post(target, `${profix}${vision}/${index}/${target}/status/:id`, controller[index][target].status);
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'reward';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 12 - 12
app/router/cysci/ticket_record.js

@@ -1,12 +1,12 @@
-'use strict';
-
-
-module.exports = app => {
-  const { router, controller } = app;
-  const profix = '/api/live/';
-  const vision = 'v0';
-  const index = 'cysci';
-  const target = 'ticketRecord';
-  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
-  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
-};
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const profix = '/api/live/';
+  const vision = 'v0';
+  const index = 'cysci';
+  const target = 'rewardOrder';
+  router.resources(target, `${profix}${vision}/${index}/${target}`, controller[index][target]); // index、create、show、destroy
+  router.post(target, `${profix}${vision}/${index}/${target}/update/:id`, controller[index][target].update);
+};

+ 1 - 1
app/router/statistics/index.js

@@ -15,5 +15,5 @@ module.exports = app => {
   router.get(target, `${profix}${vision}/${index}/${target}/circle`, controller[index][target].circle);
   router.get(target, `${profix}${vision}/${index}/${target}/orgCount`, controller[index][target].orgCount);
   router.get(target, `${profix}${vision}/${index}/${target}/pac`, controller[index][target].policyApplyCount);
-  router.get(target, `${profix}${vision}/${index}/${target}/ticket`, controller[index][target].ticketCount);
+  router.get(target, `${profix}${vision}/${index}/${target}/declare`, controller[index][target].declare);
 };

+ 22 - 0
app/service/cysci/cashing.js

@@ -0,0 +1,22 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const moment = require('moment');
+
+// 高企申报兑付
+class CashingService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'cashing');
+    this.model = this.ctx.model.Cashing;
+  }
+  async create(body) {
+    const cashing_no = `${moment().format('YYYYMMDD')}${moment().format('x')}DF`;
+    const create_time = moment().format('YYYY-MM-DD HH:mm:ss');
+    body = { ...body, cashing_no, create_time };
+    return await this.model.create(body);
+  }
+}
+
+module.exports = CashingService;

+ 5 - 5
app/service/cysci/policy.js

@@ -4,12 +4,12 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 高企政策
-class PolicyService extends CrudService {
+// 创新券
+class CouponsService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'policy');
-    this.model = this.ctx.model.Policy;
+    super(ctx, 'coupons');
+    this.model = this.ctx.model.Coupons;
   }
 }
 
-module.exports = PolicyService;
+module.exports = CouponsService;

+ 5 - 5
app/service/cysci/ticket_record.js

@@ -4,12 +4,12 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-//
-class Ticket_recordService extends CrudService {
+// 创新券申领表
+class Coupons_applyService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'ticket_record');
-    this.model = this.ctx.model.TicketRecord;
+    super(ctx, 'coupons_apply');
+    this.model = this.ctx.model.CouponsApply;
   }
 }
 
-module.exports = Ticket_recordService;
+module.exports = Coupons_applyService;

+ 19 - 10
app/service/cysci/ticket.js

@@ -3,14 +3,14 @@ const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
+const moment = require('moment');
 const { ObjectId } = require('mongoose').Types;
 
 // 高企申报
-class TicketService extends CrudService {
+class DeclareService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'ticket');
-    this.model = this.ctx.model.Ticket;
-    this.record = this.ctx.model.TicketRecord;
+    super(ctx, 'declare');
+    this.model = this.ctx.model.Declare;
   }
 
   async query({ skip = 0, limit = 0, ...query } = {}) {
@@ -54,13 +54,22 @@ class TicketService extends CrudService {
     return res;
   }
 
-  async status({ id }, body) {
+  async update({ id }, body) {
+    const data = await this.model.findById(id);
+    if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到数据');
+    const keys = [ 'user_id', 'name', 'mechanism_id' ];
+    const toUpdate = _.omit(body, keys);
+    await this.model.updateOne({ _id: id }, toUpdate);
     const { status } = body;
-    await this.model.updateOne({ _id: id }, { status });
-    // TODO,添加记录
-    body.ticket_id = id;
-    await this.record.create(body);
+    if (status === '2') {
+      const order = _.pick(body, keys);
+      const stemp = `${moment().format('YYYYMMDD')}${moment().format('x')}`;
+      order.no = stemp;
+      const time = moment().format('YYYY-MM-DD HH:mm:ss');
+      order.time = time;
+      await this.ctx.model.DeclareOrder.create(order);
+    }
   }
 }
 
-module.exports = TicketService;
+module.exports = DeclareService;

+ 5 - 5
app/service/cysci/policy_apply.js

@@ -4,12 +4,12 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 高企服务政策申请表
-class Policy_applyService extends CrudService {
+// 高企申报订单
+class Declare_orderService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'policy_apply');
-    this.model = this.ctx.model.PolicyApply;
+    super(ctx, 'declare_order');
+    this.model = this.ctx.model.DeclareOrder;
   }
 }
 
-module.exports = Policy_applyService;
+module.exports = Declare_orderService;

+ 0 - 22
app/service/cysci/policy_order.js

@@ -1,22 +0,0 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const _ = require('lodash');
-const assert = require('assert');
-const moment = require('moment');
-
-// 高企政策服务订单
-class Policy_orderService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'policy_order');
-    this.model = this.ctx.model.PolicyOrder;
-  }
-  async create(body) {
-    const stemp = `${moment().format('YYYYMMDD')}${moment().format('x')}`;
-    body.no = stemp;
-    const res = await this.model.create(body);
-    return res;
-  }
-}
-
-module.exports = Policy_orderService;

+ 25 - 0
app/service/cysci/reward.js

@@ -0,0 +1,25 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const moment = require('moment');
+
+// 研发补贴,奖励兑现申领
+class RewardService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'reward');
+    this.model = this.ctx.model.Reward;
+    this.order = this.ctx.model.RewardOrder;
+  }
+  // async update({ id }, body) {
+  //   const data = await this.model.findById(id);
+  //   if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到数据');
+  //   await this.model.updateOne({ _id: id }, body);
+  //   const { status } = body;
+  //   if (status === '1') {
+  //   }
+  // }
+}
+
+module.exports = RewardService;

+ 23 - 0
app/service/cysci/reward_order.js

@@ -0,0 +1,23 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+const moment = require('moment');
+
+// 研发补贴,奖励兑换订单
+class Reward_orderService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'reward_order');
+    this.model = this.ctx.model.RewardOrder;
+  }
+
+  async create(body) {
+    const no = `${moment().format('YYYYMMDD')}${moment().format('x')}DF`;
+    const create_time = moment().format('YYYY-MM-DD HH:mm:ss');
+    body = { ...body, no, create_time };
+    return await this.model.create(body);
+  }
+}
+
+module.exports = Reward_orderService;

+ 55 - 27
app/service/statistics/index.js

@@ -134,7 +134,10 @@ class IndexService extends CrudService {
       value: organization,
     });
     // TODO:如果需要专家和个人用户区分开,则is_expert:false, 混查则不需要is_expert条件
-    const user = await this.personalModel.count({ status: '1', is_expert: false });
+    const user = await this.personalModel.count({
+      status: '1',
+      is_expert: false,
+    });
     arr.push({
       name: '个人注册数量',
       value: user,
@@ -165,20 +168,31 @@ class IndexService extends CrudService {
     ]);
     arr.push({
       name: '正在洽谈',
-      value: _.get(trans.find(f => f._id === '0'), 'value', 0),
+      value: _.get(
+        trans.find(f => f._id === '0'),
+        'value',
+        0
+      ),
     });
     arr.push({
       name: '达成意向',
-      value: _.get(trans.find(f => f._id === '1'), 'value', 0),
+      value: _.get(
+        trans.find(f => f._id === '1'),
+        'value',
+        0
+      ),
     });
     arr.push({
       name: '对接完成',
-      value: _.get(trans.find(f => f._id === '3'), 'value', 0),
+      value: _.get(
+        trans.find(f => f._id === '3'),
+        'value',
+        0
+      ),
     });
     return arr;
   }
 
-
   /**
    * 专家列表
    */
@@ -230,12 +244,29 @@ class IndexService extends CrudService {
         },
       },
     ]);
-    const qthz = _.get(trans.find(f => f._id === '0'), 'value', 0);
-    const dcyx = _.get(trans.find(f => f._id === '1'), 'value', 0);
-    const jywc = _.get(trans.find(f => f._id === '3'), 'value', 0);
+    const qthz = _.get(
+      trans.find(f => f._id === '0'),
+      'value',
+      0
+    );
+    const dcyx = _.get(
+      trans.find(f => f._id === '1'),
+      'value',
+      0
+    );
+    const jywc = _.get(
+      trans.find(f => f._id === '3'),
+      'value',
+      0
+    );
     // 参展项目
-    const res = await this.dockUser.aggregate()
-      .match({ dock_id: ObjectId(dock_id), 'goodsList.type': '1', 'goodsList.dockStatus': '1' })
+    const res = await this.dockUser
+      .aggregate()
+      .match({
+        dock_id: ObjectId(dock_id),
+        'goodsList.type': '1',
+        'goodsList.dockStatus': '1',
+      })
       .unwind('$goodsList')
       .group({
         _id: '$dock_id',
@@ -251,42 +282,38 @@ class IndexService extends CrudService {
       { name: '参展项目', num: czxm, unit: '项' },
     ];
     return arr;
-
   }
 
   /**
-   * 高企服务政策申请统计
+   * 创新券订单/研发补贴,奖励兑现订单, 兑付成功(status=='1')
    */
   async pac() {
-    const res = await this.ctx.model.PolicyApply.aggregate([
+    // 创新券兑付成功的数量
+    const cres = await this.ctx.model.Cashing.count({ status: '1' });
+    // 研发/奖励
+    const rres = await this.ctx.model.RewardOrder.aggregate([
+      { $match: { status: '1' } },
       {
-        $lookup: {
-          from: 'policy',
-          localField: 'policy_id',
-          foreignField: '_id',
-          as: 'policy',
+        $group: {
+          _id: '$type',
+          count: { $sum: 1 },
         },
       },
-      { $unwind: '$policy' },
-      { $group: {
-        _id: '$policy.type',
-        count: { $sum: 1 },
-      } },
     ]);
     const arr = [
       { key: '奖励兑现', name: '奖励兑现' },
-      { key: '创新券', name: '创新券' },
       { key: '研发补贴', name: '研发补贴' },
     ];
-    const obj = this.setData(res, arr);
+    const obj = this.setData(rres, arr);
+    obj.push({ name: '创新券', value: cres });
     return obj;
   }
 
   /**
    * 高企申报个步骤统计
    */
-  async ticket() {
-    const res = await this.ctx.model.Ticket.aggregate([
+  async declare() {
+    const res = await this.ctx.model.Declare.aggregate([
       { $group: {
         _id: '$status',
         count: { $sum: 1 },
@@ -297,6 +324,7 @@ class IndexService extends CrudService {
       { key: '1', name: '企业信息审核成功' },
       { key: '-1', name: '企业信息审核失败' },
       { key: '2', name: '高企申报成功' },
+      { key: '-2', name: '高企申报失败' },
     ];
     const obj = this.setData(res, arr);
     return obj;

+ 1 - 0
config/config.default.js

@@ -77,6 +77,7 @@ module.exports = appInfo => {
   };
   config.project = {
     mission: 'http://127.0.0.1:4001',
+    hnhmain: 'http://127.0.0.1:9201',
   };
   return {
     ...config,