12345678910111213141516171819202122232425262728293031323334 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/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.Cysci.Cashing;
- }
- async create({ declare_id, reward_id, ...body }) {
- // 将高企/ 研发/奖励 的 is_cashing改成1
- if (declare_id) await this.ctx.model.Cysci.Declare.updateOne({ _id: declare_id }, { is_cashing: '1' });
- if (reward_id) await this.ctx.model.Cysci.Reward.updateOne({ _id: reward_id }, { is_cashing: '1' });
- // 之后将使用的券改为使用 is_use = 1
- const { user_id, coupons_id } = body;
- await this.ctx.model.Cysci.CouponsApply.updateOne({ user_id, coupons_id }, { is_use: '1' });
- // const no = `${moment().format('YYYYMMDD')}${moment().format('x')}DF`;
- // body = { ...body, no };
- if (declare_id)body.from_id = declare_id;
- else if (reward_id)body.from_id = reward_id;
- return await this.model.create(body);
- }
- async getFromId({ from_id }) {
- const data = await this.model.findOne({ from_id });
- return data;
- }
- }
- module.exports = CashingService;
|