123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2018/6/1
- * @version
- */
- 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;
- };
|