cooperation_confirm.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/6/1
  7. * @version
  8. */
  9. const auditConst = require('../const/audit');
  10. module.exports = app => {
  11. class CooperationConfirm extends app.BaseService {
  12. /**
  13. * 构造函数
  14. *
  15. * @param {Object} ctx - egg全局变量
  16. * @return {void}
  17. */
  18. constructor(ctx) {
  19. super(ctx);
  20. this.tableName = 'cooperation_confirm';
  21. }
  22. async save(data) {
  23. 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 });
  24. if (info) {
  25. const updateData = {
  26. id: info.id,
  27. create_time: new Date(),
  28. };
  29. return await this.db.update(this.tableName, updateData);
  30. }
  31. const insertData = {
  32. tid: this.ctx.tender.id,
  33. sid: this.ctx.stage.id,
  34. times: this.ctx.stage.times,
  35. uid: this.ctx.session.sessionUser.accountId,
  36. ledger_id: data.ledger_id,
  37. create_time: new Date(),
  38. };
  39. return await this.db.insert(this.tableName, insertData);
  40. }
  41. async del(data) {
  42. 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 });
  43. }
  44. async getValidData(tid, sid, times, uid) {
  45. const condition = { where: { tid, sid, times, uid } };
  46. // if (uid) {
  47. // condition.where.uid = uid;
  48. // condition.colums = ['ledger_id', 'pwd'];
  49. // }
  50. return await this.getAllDataByCondition(condition);
  51. }
  52. async delBycheckNoPre(uid, stage, transaction) {
  53. return await transaction.delete(this.tableName, { tid: stage.tid, sid: stage.id, times: stage.times, uid });
  54. }
  55. }
  56. return CooperationConfirm;
  57. };