|
@@ -3,9 +3,167 @@ import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
|
import { BaseService } from 'free-midway-component';
|
|
|
import { Transtion } from '../entity/transtion.entity';
|
|
|
+import { ExamNotice } from '../entity/examNotice.entity';
|
|
|
+const moment = require('moment');
|
|
|
type modelType = ReturnModelType<typeof Transtion>;
|
|
|
@Provide()
|
|
|
export class TranstionService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(Transtion)
|
|
|
model: modelType;
|
|
|
+
|
|
|
+ @InjectEntityModel(ExamNotice)
|
|
|
+ examModel: ReturnModelType<typeof ExamNotice>;
|
|
|
+
|
|
|
+ //添加处理数据
|
|
|
+ async create(body) {
|
|
|
+ const { status, user_id, mech_id, user_name, patent_name } = body;
|
|
|
+ if (status === '0') {
|
|
|
+ const info = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: user_id,
|
|
|
+ save_name: user_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息,请及时查看并处理`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: user_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: mech_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ }
|
|
|
+ const res = await this.model.create(body);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改处理数据
|
|
|
+ async update(id, body) {
|
|
|
+ const {
|
|
|
+ status,
|
|
|
+ user_id,
|
|
|
+ user_name,
|
|
|
+ patent_name,
|
|
|
+ mech_id,
|
|
|
+ mech_name,
|
|
|
+ desc,
|
|
|
+ } = body;
|
|
|
+ if (status === '0') {
|
|
|
+ const info = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: user_id,
|
|
|
+ save_name: user_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息,请及时查看并处理`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: user_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: mech_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ } else if (status === '1' || status === '2') {
|
|
|
+ const info = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: mech_id,
|
|
|
+ save_name: mech_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息已经审核完成,审核意见:${
|
|
|
+ desc || '无'
|
|
|
+ },请及时查看审核通知消息`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: mech_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: user_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ } else if (status === '3') {
|
|
|
+ const info = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: user_id,
|
|
|
+ save_name: user_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息的合同,请及时查看并处理`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: user_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: mech_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ } else if (status === '4' || status === '5') {
|
|
|
+ const info: any = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: mech_id,
|
|
|
+ save_name: mech_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息已经审核完成,审核意见:${
|
|
|
+ desc || '无'
|
|
|
+ },请及时查看审核通知消息`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: mech_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: user_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ } else if (status === '6') {
|
|
|
+ const info: any = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: user_id,
|
|
|
+ save_name: user_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息的合同,用户已确认。请及时查看并处理`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: user_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: mech_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ } else if (status === '7') {
|
|
|
+ const info: any = {
|
|
|
+ status: status,
|
|
|
+ create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ save_id: mech_id,
|
|
|
+ save_name: mech_name,
|
|
|
+ content: `${user_name}提交了${patent_name}专利的交易信息已经完成信息归档,交易完成,请及时查看审核通知消息`,
|
|
|
+ };
|
|
|
+ if (body.record) body.record.push(info);
|
|
|
+ else body.record = [info];
|
|
|
+ const exam = {
|
|
|
+ send_id: mech_id,
|
|
|
+ send_date: info.create_time,
|
|
|
+ receive_id: user_id,
|
|
|
+ content: info.content,
|
|
|
+ is_read: '0',
|
|
|
+ };
|
|
|
+ await this.examModel.create(exam);
|
|
|
+ }
|
|
|
+ await this.model.updateOne({ _id: id }, body);
|
|
|
+ }
|
|
|
}
|