1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2018/6/1
- * @version
- */
- const auditConst = require('../const/audit');
- module.exports = app => {
- class CooperationConfirm extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'cooperation_confirm';
- }
- async save(data) {
- const info = await this.getDataByCondition({ tid: this.ctx.tender.id, sid: this.ctx.stage.id, times: this.ctx.stage.times, ledger_id: data.ledger_id, uid: this.ctx.session.sessionUser.accountId });
- if (info) {
- const updateData = {
- id: info.id,
- create_time: new Date(),
- };
- return await this.db.update(this.tableName, updateData);
- }
- const insertData = {
- tid: this.ctx.tender.id,
- sid: this.ctx.stage.id,
- times: this.ctx.stage.times,
- uid: this.ctx.session.sessionUser.accountId,
- ledger_id: data.ledger_id,
- create_time: new Date(),
- };
- return await this.db.insert(this.tableName, insertData);
- }
- async del(data) {
- return await this.db.delete(this.tableName, { tid: this.ctx.tender.id, sid: this.ctx.stage.id, times: this.ctx.stage.times, ledger_id: data.ledger_id, uid: this.ctx.session.sessionUser.accountId });
- }
- async getValidData(tid, sid, times, uid) {
- const condition = { where: { tid, sid, times, uid } };
- // if (uid) {
- // condition.where.uid = uid;
- // condition.colums = ['ledger_id', 'pwd'];
- // }
- return await this.getAllDataByCondition(condition);
- }
- async delBycheckNoPre(uid, stage, transaction) {
- return await transaction.delete(this.tableName, { tid: stage.tid, sid: stage.id, times: stage.times, uid });
- }
- }
- return CooperationConfirm;
- };
|