lrf402788946 4 years ago
parent
commit
5e3073e982

+ 4 - 1
app/controller/.achieve_apply.js

@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["basic", "brief", "research", "datalist"],
+    requestBody: ["basic", "brief", "research", "datalist", "experts", "status"],
   },
   show: {
     parameters: {
@@ -19,6 +19,9 @@ module.exports = {
   index: {
     parameters: {
       query: {
+        user_id: "user_id",
+        status: "status",
+        "basic.achieve_num": "basic.achieve_num",
         "create_time@start": "create_time@start",
         "create_time@end": "create_time@end",
       },

+ 2 - 0
app/controller/.achieve_verify_record.js

@@ -7,6 +7,7 @@ module.exports = {
       "!verify_id",
       "verify_phone",
       "verify",
+      "step"
     ],
   },
   destroy: {
@@ -22,6 +23,7 @@ module.exports = {
       "verify_id",
       "verify_phone",
       "verify",
+      "step"
     ],
   },
   show: {

+ 7 - 0
app/model/achieve_apply.js

@@ -75,10 +75,17 @@ datalist.index({ id: 1 });
 const achieve_apply = {
   user_id: { type: ObjectId }, // 关联用户
   status: { type: String, default: '0' }, // 状态
+  // 1=>初审通过;-1=>初审失败
+  // 2=>评分通过;-2=>评分失败
+  // 3=>已缴费
+  // 4=>补充资料
+  // 5=>会审通过;-5=>会审失败(不能改了,没机会了)
+  // 6=>证书发放
   basic: { type: basic },
   brief: { type: brief },
   research: { type: [ research ] },
   datalist: { type: datalist },
+  experts: { type: [ Object ] }, // 专家列表
   remark: { type: String, maxLength: 200 },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
 };

+ 1 - 1
app/model/achieve_verify_record.js

@@ -11,7 +11,7 @@ const achieve_verify_record = {
   verify_id: { type: ObjectId }, // 本次审核人
   verify_phone: { type: String }, // 本次审核人的联系电话
   verify: { type: String }, // 本次审核人
-  step: { type: String }, // 初审=>评分
+  step: { type: String }, // 初审=>评分=>会审=>资料/发证
   remark: { type: String, maxLength: 200 },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
 };

+ 17 - 7
app/service/achieve_apply.js

@@ -15,17 +15,27 @@ class Achieve_applyService extends CrudService {
   }
 
   async create(body) {
-    // TODO 没有账号需要创建账号
+    // 没有账号需要创建账号
     const { user_id, basic } = body;
     let res;
     if (!user_id) {
       const { phone, email, contacts, addr } = basic;
-      const personalData = { name: contacts, phone, email, addr };
-      personalData.password = '123456';
-      personalData.code = 'CGPJXTYW';
-      personalData.status = '1';
-      const user = await this.httpUtil.cpost('/users/personal', 'live', personalData);
-      if (!user) throw new BusinessError(ErrorCode.SERVICE_FAULT, '用户创建失败!');
+      // 拿手机号去个人里找
+      const users = await this.httpUtil.cget('/users/personal', 'live', { phone });
+      let user;
+      if (users.length <= 0) {
+        // 该手机号没有用户使用,创建
+        const personalData = { name: contacts, phone, email, addr };
+        personalData.password = '123456';
+        personalData.code = 'CGPJXTYW';
+        personalData.status = '1';
+        user = await this.httpUtil.cpost('/users/personal', 'live', personalData);
+        if (!user) throw new BusinessError(ErrorCode.SERVICE_FAULT, '用户创建失败!');
+      } else {
+        // 该手机号有用户使用,取出来
+        user = _.head(users);
+      }
+
       body.user_id = user._id;
       res = await this.model.create(body);
     } else {