Browse Source

修改积分记录表,opera=4的分数加对了,人记错了。

lrf402788946 4 years ago
parent
commit
5e7971826e
2 changed files with 8 additions and 8 deletions
  1. 1 1
      app/model/record.js
  2. 7 7
      app/service/card.js

+ 1 - 1
app/model/record.js

@@ -7,7 +7,7 @@ const record = {
   mobile: { type: String, required: true }, // 电话
   name: { type: String, required: true }, // 姓名
   points: { type: Number, default: 600 }, // 积分
-  opera: { type: String, required: true }, // 操作行为:推荐办卡/提现/车奖
+  opera: { type: String, required: true }, // 操作行为:-1:提现/1:推荐办卡/2:车奖/3,同级奖励/4,直推下级完成业绩反佣金
   params: { type: Object },
   remark: { type: String, maxLength: 200 },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },

+ 7 - 7
app/service/card.js

@@ -117,8 +117,8 @@ class CardService extends CrudService {
     await recommender.save();
     const record = _.pick(recommender, [ 'mobile', 'name' ]);
     record.points = score;
-    record.opera = '推荐办卡';
-    record.params = { name: user.name, mobile: user.mobile };
+    record.opera = '1';
+    record.params = { name: user.name, mobile: user.mobile, level: user.level };
     try {
       await this.record.create(record);
     } catch (error) {
@@ -199,7 +199,7 @@ class CardService extends CrudService {
           // 添加积分记录
           const record = _.pick(user, [ 'mobile', 'name' ]);
           record.points = this.car_point;
-          record.opera = '车奖';
+          record.opera = '2';
           try {
             await this.record.create(record);
           } catch (error) {
@@ -248,7 +248,7 @@ class CardService extends CrudService {
       const record = _.pick(rec, [ 'mobile', 'name' ]);
       try {
         record.points = 20;
-        record.opera = '同级奖励';
+        record.opera = '3';
         await this.record.create(record);
       } catch (error) {
         this.logger.error(`line-250-积分记录添加失败${JSON.stringify(record)}`);
@@ -277,10 +277,10 @@ class CardService extends CrudService {
       const points = this.getReturns(level, r_level);
       r_rec.points = r_rec.points + points;
       await r_rec.save();
-      const record = _.pick(rec, [ 'mobile', 'name' ]);
+      const record = _.pick(r_rec, [ 'mobile', 'name' ]);
       try {
         record.points = points;
-        record.opera = '直推下级完成业绩反佣金';
+        record.opera = '4';
         await this.record.create(record);
       } catch (error) {
         this.logger.error(`line-282-积分记录添加失败${JSON.stringify(record)}`);
@@ -390,7 +390,7 @@ class CardService extends CrudService {
     const { filter } = condition;
     const bTerm = await this.model.find(filter);
     const cTerm = await this.model.find({ r_mobile: bTerm.map(i => i.mobile) });
-    return { list: [ ...bTerm, ...cTerm ], total: bTerm.length + cTerm.length };
+    return { list: _.uniqBy([ ...bTerm, ...cTerm ], '_id'), total: bTerm.length + cTerm.length };
   }
 }