|
@@ -17,6 +17,7 @@ class CardService extends CrudService {
|
|
super(ctx, 'card');
|
|
super(ctx, 'card');
|
|
this.model = this.ctx.model.Card;
|
|
this.model = this.ctx.model.Card;
|
|
this.record = this.ctx.model.Record;
|
|
this.record = this.ctx.model.Record;
|
|
|
|
+ this.set = this.ctx.model.Set;
|
|
/**
|
|
/**
|
|
* @constant Number 车奖的积分 default:131400
|
|
* @constant Number 车奖的积分 default:131400
|
|
*/
|
|
*/
|
|
@@ -46,16 +47,6 @@ class CardService extends CrudService {
|
|
*/
|
|
*/
|
|
this.car_show_b_limit_person = 5;
|
|
this.car_show_b_limit_person = 5;
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * 修改密码
|
|
|
|
- * @param {Object} param 参数
|
|
|
|
- */
|
|
|
|
- async passwd({ id, password }) {
|
|
|
|
- password = { secret: password };
|
|
|
|
- const res = await this.model.update({ _id: ObjectId(id) }, { password });
|
|
|
|
- return res;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 1创建卡用户;2检查推荐人
|
|
* 1创建卡用户;2检查推荐人
|
|
* @param {Object} data 参数
|
|
* @param {Object} data 参数
|
|
@@ -89,8 +80,11 @@ class CardService extends CrudService {
|
|
'推荐人信息错误,用户创建失败!'
|
|
'推荐人信息错误,用户创建失败!'
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- // 4,判断是129套餐,还是169套餐,如果是129套餐,那就不需要继续了
|
|
|
|
- if (set === '129') return user;
|
|
|
|
|
|
+ // 4,判断是套餐有没有推荐制度(此处因为套餐可维护,修改了)
|
|
|
|
+ const setInfo = await this.set.findById(set);
|
|
|
|
+ if (!setInfo) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到选择的套餐信息!');
|
|
|
|
+ const { has_group } = setInfo;
|
|
|
|
+ if (!has_group) return user;
|
|
// 5,根据等级,找下推荐人应该加多少分
|
|
// 5,根据等级,找下推荐人应该加多少分
|
|
const { stockholder, level } = recommender;
|
|
const { stockholder, level } = recommender;
|
|
// 6,重新计算推荐人用户等级
|
|
// 6,重新计算推荐人用户等级
|
|
@@ -128,7 +122,7 @@ class CardService extends CrudService {
|
|
try {
|
|
try {
|
|
await this.record.create(record);
|
|
await this.record.create(record);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-131-积分记录添加失败${JSON.stringify(record)}`);
|
|
|
|
|
|
+ this.logger.error(`line-121-积分记录添加失败${JSON.stringify(record)}`);
|
|
}
|
|
}
|
|
// 9,以上为用户创建,计算推荐人等级=>计算推荐人积分=>生成记录
|
|
// 9,以上为用户创建,计算推荐人等级=>计算推荐人积分=>生成记录
|
|
// 先算等级,避免分数基础部队
|
|
// 先算等级,避免分数基础部队
|
|
@@ -185,7 +179,7 @@ class CardService extends CrudService {
|
|
const group_number = b.length + c;
|
|
const group_number = b.length + c;
|
|
return group_number > this.stockholder_limit;
|
|
return group_number > this.stockholder_limit;
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.ctx.logger.error(`line-188-${moment().format('YYYY-MM-DD HH:mm:ss')}-${user.name}-${user.mobile}:股东检查出错`);
|
|
|
|
|
|
+ this.ctx.logger.error(`line-178-${moment().format('YYYY-MM-DD HH:mm:ss')}-${user.name}-${user.mobile}:股东检查出错`);
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -209,12 +203,12 @@ class CardService extends CrudService {
|
|
try {
|
|
try {
|
|
await this.record.create(record);
|
|
await this.record.create(record);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-212-积分记录添加失败${JSON.stringify(record)}`);
|
|
|
|
|
|
+ this.logger.error(`line-202-积分记录添加失败${JSON.stringify(record)}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.ctx.logger.error(`line-217-${moment().format('YYYY-MM-DD HH:mm:ss')}-车奖检查出错`);
|
|
|
|
|
|
+ this.ctx.logger.error(`line-207-${moment().format('YYYY-MM-DD HH:mm:ss')}-车奖检查出错`);
|
|
return undefined;
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -257,10 +251,10 @@ class CardService extends CrudService {
|
|
record.opera = '同级奖励';
|
|
record.opera = '同级奖励';
|
|
await this.record.create(record);
|
|
await this.record.create(record);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-260-积分记录添加失败${JSON.stringify(record)}`);
|
|
|
|
|
|
+ this.logger.error(`line-250-积分记录添加失败${JSON.stringify(record)}`);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-263-捕获检查用户推荐人的推荐人失败:${JSON.stringify(error)}`);
|
|
|
|
|
|
+ this.logger.error(`line-253-捕获检查用户推荐人的推荐人失败:${JSON.stringify(error)}`);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -289,10 +283,10 @@ class CardService extends CrudService {
|
|
record.opera = '直推下级完成业绩反佣金';
|
|
record.opera = '直推下级完成业绩反佣金';
|
|
await this.record.create(record);
|
|
await this.record.create(record);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-292-积分记录添加失败${JSON.stringify(record)}`);
|
|
|
|
|
|
+ this.logger.error(`line-282-积分记录添加失败${JSON.stringify(record)}`);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- this.logger.error(`line-295-捕获检查用户推荐人的推荐人失败:${JSON.stringify(error)}`);
|
|
|
|
|
|
+ this.logger.error(`line-285-捕获检查用户推荐人的推荐人失败:${JSON.stringify(error)}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -376,6 +370,28 @@ class CardService extends CrudService {
|
|
if (!obj) throw new BusinessError(ErrorCode.SERVICE_FAULT, '为找到推荐人适合的规则');
|
|
if (!obj) throw new BusinessError(ErrorCode.SERVICE_FAULT, '为找到推荐人适合的规则');
|
|
return _.get(obj, r_level);
|
|
return _.get(obj, r_level);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改密码
|
|
|
|
+ * @param {Object} param 参数
|
|
|
|
+ */
|
|
|
|
+ async passwd({ id, password }) {
|
|
|
|
+ password = { secret: password };
|
|
|
|
+ const res = await this.model.update({ _id: ObjectId(id) }, { password });
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据条件查询该用户的团队人员
|
|
|
|
+ * @param {Object} query 查询条件
|
|
|
|
+ */
|
|
|
|
+ async group(query) {
|
|
|
|
+ const condition = this.ctx.service.util.queryReset(query);
|
|
|
|
+ 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 };
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = CardService;
|
|
module.exports = CardService;
|