change.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/8/14
  7. * @version
  8. */
  9. const audit = require('../const/audit');
  10. module.exports = app => {
  11. class Change extends app.BaseService {
  12. /**
  13. * 构造函数
  14. *
  15. * @param {Object} ctx - egg全局变量
  16. * @return {void}
  17. */
  18. constructor(ctx) {
  19. super(ctx);
  20. this.tableName = 'change';
  21. }
  22. /**
  23. * 查找数据
  24. *
  25. * @param {Object} data - 筛选表单中的get数据
  26. * @return {void}
  27. */
  28. searchFilter(data) {
  29. this.initSqlBuilder();
  30. // this.sqlBuilder.columns = ['id', 'username', 'real_name', 'create_time', 'last_login', 'login_ip',
  31. // 'group_id', 'token', 'can_login'];
  32. data.type = parseInt(data.status);
  33. if (data.keyword !== undefined) {
  34. switch (data.type) {
  35. // 用户名
  36. case 1:
  37. this.sqlBuilder.setAndWhere('username', {
  38. value: this.db.escape(data.keyword + '%'),
  39. operate: 'like',
  40. });
  41. break;
  42. // 姓名
  43. case 2:
  44. this.sqlBuilder.setAndWhere('real_name', {
  45. value: this.db.escape(data.keyword + '%'),
  46. operate: 'like',
  47. });
  48. break;
  49. // 联系电话
  50. case 3:
  51. this.sqlBuilder.setAndWhere('telephone', {
  52. value: this.db.escape(data.keyword + '%'),
  53. operate: 'like',
  54. });
  55. break;
  56. default:
  57. break;
  58. }
  59. }
  60. // 办事处筛选
  61. if (data.office !== undefined && data.office !== '') {
  62. this.sqlBuilder.setAndWhere('office', {
  63. value: this.db.escape(data.office),
  64. operate: '=',
  65. });
  66. }
  67. }
  68. async add(tenderId, userId, code, name) {
  69. const count = await this.count({ tid: tenderId, code });
  70. if (count > 0) {
  71. throw '变更令号重复';
  72. }
  73. // 初始化事务
  74. this.transaction = await this.db.beginTransaction();
  75. let result = false;
  76. try {
  77. const cid = this.uuid.v4();
  78. const change = {
  79. cid,
  80. tid: tenderId,
  81. uid: userId,
  82. status: audit.flow.status.uncheck,
  83. times: 1,
  84. valid: true,
  85. in_time: new Date(),
  86. code,
  87. name,
  88. };
  89. const operate = await this.transaction.insert(this.tableName, change);
  90. if (operate.affectedRows <= 0) {
  91. throw '新建变更令数据失败';
  92. }
  93. // 把提交人信息添加到zh_change_audit
  94. const userInfo = await this.ctx.service.projectAccount.getDataById(userId);
  95. const changeaudit = {
  96. tid: tenderId,
  97. cid,
  98. uid: userId,
  99. name: userInfo.name,
  100. jobs: userInfo.role,
  101. company: userInfo.company,
  102. times: 1,
  103. usite: 0,
  104. usort: 0,
  105. status: 2,
  106. };
  107. await this.transaction.insert(this.ctx.service.changeAudit.tableName, changeaudit);
  108. result = change;
  109. this.transaction.commit();
  110. } catch (error) {
  111. console.log(error);
  112. // 回滚
  113. await this.transaction.rollback();
  114. }
  115. return result;
  116. }
  117. async pendingDatas(tenderId, userId) {
  118. return await this.getAllDataByCondition({
  119. tid: tenderId,
  120. uid: userId,
  121. status: audit.flow.status.checking,
  122. });
  123. }
  124. async uncheckDatas(tenderId, userId) {
  125. return await this.getAllDataByCondition({
  126. tid: tenderId,
  127. uid: userId,
  128. status: audit.flow.status.uncheck,
  129. });
  130. }
  131. async checkingDatas(tenderId, userId) {
  132. return await this.getAllDataByCondition({
  133. tid: tenderId,
  134. uid: userId,
  135. status: audit.flow.status.checking,
  136. });
  137. }
  138. async checkedDatas(tenderId, userId) {
  139. return await this.getAllDataByCondition({
  140. tid: tenderId,
  141. uid: userId,
  142. status: audit.flow.status.checked,
  143. });
  144. }
  145. async checkNoDatas(tenderId, userId) {
  146. return await this.getAllDataByCondition({
  147. tid: tenderId,
  148. uid: userId,
  149. status: audit.flow.status.checkNo,
  150. });
  151. }
  152. async checkNoCount(tenderId, userId) {
  153. return await this.count({
  154. tid: tenderId,
  155. uid: userId,
  156. status: audit.flow.status.checkNo,
  157. });
  158. }
  159. /**
  160. * 获取变更令列表
  161. * @param {int} tenderId - 标段id
  162. * @param {int} status - 状态
  163. * @return {object} list - 列表
  164. */
  165. async getListByStatus(tenderId, status = 0) {
  166. let sql = '';
  167. let sqlParam = '';
  168. switch (status) {
  169. case 0:// 包含你的所有变更令
  170. sql = 'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND ' +
  171. '(a.uid = ? OR (a.status != 1 AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))) ORDER BY a.in_time DESC';
  172. sqlParam = [this.tableName, tenderId, this.ctx.session.sessionUser.accountId,
  173. this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
  174. break;
  175. case 1:// 待处理(你的)
  176. sql = 'SELECT a.* FROM ?? as a WHERE cid in(SELECT b.cid FROM ?? as b WHERE tid = ? AND uid = ? AND status = ?) ORDER BY in_time DESC';
  177. sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName, tenderId, this.ctx.session.sessionUser.accountId, 2];
  178. break;
  179. case 5:// 待上报(所有的)PS:取未上报和退回的变更令
  180. sql = 'SELECT a.* FROM ?? AS a WHERE ' +
  181. 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND ' +
  182. '(a.status = 1 OR a.status = 5) AND a.tid = ? ORDER BY a.in_time DESC';
  183. sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName,
  184. this.ctx.session.sessionUser.accountId, tenderId];
  185. break;
  186. case 2:// 进行中(所有的)
  187. case 3:// 已完成(所有的)
  188. case 4:// 终止(所有的)
  189. sql = 'SELECT a.* FROM ?? AS a WHERE ' +
  190. 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND ' +
  191. 'a.status = ? AND a.tid = ? ORDER BY a.in_time DESC';
  192. sqlParam = [this.tableName, this.ctx.service.changeAudit.tableName,
  193. this.ctx.session.sessionUser.accountId, status, tenderId];
  194. break;
  195. default:
  196. break;
  197. }
  198. const limit = this.app.config.pageSize;
  199. const offset = limit * (this.ctx.page - 1);
  200. const limitString = offset >= 0 ? offset + ',' + limit : limit;
  201. sql += ' LIMIT ' + limitString;
  202. const list = await this.db.query(sql, sqlParam);
  203. return list;
  204. }
  205. /**
  206. * 获取变更令个数
  207. * @param {int} tenderId - 标段id
  208. * @param {int} status - 状态
  209. * @return {void}
  210. */
  211. async getCountByStatus(tenderId, status) {
  212. switch (status) {
  213. case 0:// 包含你的所有变更令
  214. const sql = 'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ? AND ' +
  215. '(a.uid = ? OR a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))';
  216. const sqlParam = [this.tableName, tenderId, this.ctx.session.sessionUser.accountId,
  217. this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
  218. const result = await this.db.query(sql, sqlParam);
  219. return result[0].count;
  220. case 1:// 待处理(你的)
  221. return await this.ctx.service.changeAudit.count({
  222. tid: tenderId,
  223. uid: this.ctx.session.sessionUser.accountId,
  224. status: 2,
  225. });
  226. case 5:// 待上报(所有的)PS:取未上报和退回的变更令
  227. const sql2 = 'SELECT count(*) AS count FROM ?? AS a WHERE ' +
  228. 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) ' +
  229. 'AND (a.status = 1 OR a.status = 5) AND a.tid = ?';
  230. const sqlParam2 = [this.tableName, this.ctx.service.changeAudit.tableName,
  231. this.ctx.session.sessionUser.accountId, tenderId];
  232. const result2 = await this.db.query(sql2, sqlParam2);
  233. return result2[0].count;
  234. case 2:// 进行中(所有的)
  235. case 3:// 已完成(所有的)
  236. case 4:// 终止(所有的)
  237. const sql3 = 'SELECT count(*) AS count FROM ?? AS a WHERE ' +
  238. 'a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid) AND a.status = ? AND a.tid = ?';
  239. const sqlParam3 = [this.tableName, this.ctx.service.changeAudit.tableName,
  240. this.ctx.session.sessionUser.accountId, status, tenderId];
  241. const result3 = await this.db.query(sql3, sqlParam3);
  242. return result3[0].count;
  243. default:
  244. break;
  245. }
  246. }
  247. /**
  248. * 上报或重新上报或保存修改功能
  249. * @param {int} postData - 表单提交的数据
  250. * @param {int} tenderId - 标段id
  251. * @return {void}
  252. */
  253. async save(postData, tenderId) {
  254. // 初始化事务
  255. this.transaction = await this.db.beginTransaction();
  256. let result = false;
  257. try {
  258. // 变更令信息
  259. const changeInfo = await this.getDataByCondition({ cid: postData.cid });
  260. // 该变更令原报人信息
  261. const lastUser = await this.ctx.service.changeAudit.getLastUser(changeInfo.cid, changeInfo.times, 0);
  262. // 先删除本次原有的变更审批人和清单
  263. await this.ctx.service.changeAudit.deleteAuditData(this.transaction, changeInfo.cid, changeInfo.times);
  264. await this.transaction.delete(this.ctx.service.changeAuditList.tableName, { cid: changeInfo.cid });
  265. let change_status = false;
  266. // 获取变更令提交状态
  267. if (postData.changestatus !== undefined && parseInt(postData.changestatus) === 1) {
  268. change_status = true;
  269. // 更新原报人审批状态
  270. await this.transaction.update(this.ctx.service.changeAudit.tableName, { id: lastUser.id, status: 3, sin_time: new Date() });
  271. }
  272. // 再插入postData里的变更审批人和清单
  273. if (postData.changeaudit !== undefined && postData.changeaudit !== '') {
  274. const changeAudit = postData.changeaudit.split(',');
  275. const insertCA = [];
  276. let uSite = 1;
  277. let uSort = parseInt(lastUser.usort) + 1;
  278. for (const [index, ca] of changeAudit.entries()) {
  279. const auditInfo = ca.split('/%/');
  280. const uStatus = change_status && index === 0 ? 2 : 1;
  281. const sin_time = change_status && index === 0 ? new Date() : null;
  282. const caArray = {
  283. tid: tenderId,
  284. cid: changeInfo.cid,
  285. uid: auditInfo[0],
  286. name: auditInfo[1],
  287. jobs: auditInfo[2],
  288. company: auditInfo[3],
  289. times: changeInfo.times,
  290. usite: uSite,
  291. usort: uSort,
  292. status: uStatus,
  293. sin_time,
  294. };
  295. uSite++;
  296. uSort++;
  297. insertCA.push(caArray);
  298. }
  299. await this.transaction.insert(this.ctx.service.changeAudit.tableName, insertCA);
  300. }
  301. let changeList = [];
  302. if (postData.changelist !== undefined && postData.changelist !== '') {
  303. changeList = postData.changelist.split('^_^');
  304. }
  305. let changeWhiteList = [];
  306. if (postData.changewhitelist !== undefined && postData.changewhitelist !== '') {
  307. changeWhiteList = postData.changewhitelist.split('^_^');
  308. }
  309. changeList.push.apply(changeList, changeWhiteList);
  310. const insertCL = [];
  311. let total_price = 0;
  312. for (const cl of changeList) {
  313. const clInfo = cl.split(';');
  314. const clArray = {
  315. tid: tenderId,
  316. cid: changeInfo.cid,
  317. lid: clInfo[7],
  318. code: clInfo[0],
  319. name: clInfo[1],
  320. unit: clInfo[2],
  321. unit_price: clInfo[3],
  322. oamount: clInfo[4],
  323. camount: clInfo[5],
  324. samount: '',
  325. detail: clInfo[6],
  326. };
  327. insertCL.push(clArray);
  328. total_price += this.ctx.helper.accMul(clArray.unit_price, clArray.camount);
  329. }
  330. await this.transaction.insert(this.ctx.service.changeAuditList.tableName, insertCL);
  331. // 修改变更令基本数据
  332. const cArray = {
  333. code: postData.code,
  334. name: postData.name,
  335. peg: postData.peg,
  336. org_name: postData.org_name,
  337. org_code: postData.org_code,
  338. new_name: postData.new_name,
  339. new_code: postData.new_code,
  340. content: postData.content,
  341. basis: postData.basis,
  342. memo: postData.memo,
  343. type: postData.type.join(','),
  344. class: postData.class,
  345. quality: postData.quality,
  346. company: postData.company,
  347. charge: postData.charge,
  348. total_price,
  349. };
  350. const options = {
  351. where: {
  352. cid: changeInfo.cid,
  353. },
  354. };
  355. if (change_status) {
  356. cArray.status = 2;
  357. cArray.cin_time = Date.parse(new Date()) / 1000;
  358. }
  359. await this.transaction.update(this.tableName, cArray, options);
  360. await this.transaction.commit();
  361. result = true;
  362. } catch (error) {
  363. await this.transaction.rollback();
  364. result = false;
  365. }
  366. return result;
  367. }
  368. /**
  369. * 审批通过
  370. * @param {int} postData - 表单提交的数据
  371. * @return {void}
  372. */
  373. async approvalSuccess(postData) {
  374. // 初始化事务
  375. this.transaction = await this.db.beginTransaction();
  376. let result = false;
  377. try {
  378. // 设置审批人通过
  379. const audit_update = {
  380. id: postData.audit_id,
  381. sdesc: postData.sdesc,
  382. status: 3,
  383. sin_time: new Date(),
  384. };
  385. const change_update = {
  386. w_code: postData.w_code,
  387. status: 2,
  388. cin_time: Date.parse(new Date()) / 1000,
  389. };
  390. await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
  391. // 清单数据更新
  392. const bills_list = postData.bills_list.split(',');
  393. let total_price = 0;
  394. for (const bl of bills_list) {
  395. const listInfo = bl.split('_');
  396. const lid = listInfo[0];
  397. const amount = listInfo[1];
  398. const changeListInfo = await this.ctx.service.changeAuditList.getDataById(lid);
  399. if (changeListInfo !== undefined) {
  400. total_price += this.ctx.helper.accMul(changeListInfo.unit_price, parseFloat(amount));
  401. const audit_amount = changeListInfo.audit_amount !== null && changeListInfo.audit_amount !== '' ? changeListInfo.audit_amount.split(',') : [];
  402. audit_amount.push(amount);
  403. const list_update = {
  404. id: lid,
  405. audit_amount: audit_amount.join(','),
  406. };
  407. if (postData.audit_next_id === undefined) {
  408. list_update.samount = amount;
  409. }
  410. await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
  411. }
  412. }
  413. if (postData.audit_next_id === undefined) {
  414. // 变更令审批完成
  415. change_update.status = 3;
  416. change_update.p_code = postData.p_code;
  417. change_update.sin_time = Date.parse(new Date()) / 1000;
  418. change_update.total_price = total_price;
  419. } else {
  420. // 设置下一个审批人为审批状态
  421. const nextAudit_update = {
  422. id: postData.audit_next_id,
  423. status: 2,
  424. };
  425. await this.transaction.update(this.ctx.service.changeAudit.tableName, nextAudit_update);
  426. }
  427. const options = {
  428. where: {
  429. cid: postData.change_id,
  430. },
  431. };
  432. await this.transaction.update(this.tableName, change_update, options);
  433. await this.transaction.commit();
  434. result = true;
  435. } catch (error) {
  436. await this.transaction.rollback();
  437. result = false;
  438. }
  439. return result;
  440. }
  441. /**
  442. * 审批终止
  443. * @param {int} postData - 表单提交的数据
  444. * @return {void}
  445. */
  446. async approvalStop(postData) {
  447. // 初始化事务
  448. this.transaction = await this.db.beginTransaction();
  449. let result = false;
  450. try {
  451. // 设置审批人终止
  452. const audit_update = {
  453. id: postData.audit_id,
  454. sdesc: postData.sdesc,
  455. status: 4,
  456. sin_time: new Date(),
  457. };
  458. await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
  459. // 设置变更令终止
  460. const change_update = {
  461. w_code: postData.w_code,
  462. status: 4,
  463. cin_time: Date.parse(new Date()) / 1000,
  464. };
  465. const options = {
  466. where: {
  467. cid: postData.change_id,
  468. },
  469. };
  470. await this.transaction.update(this.tableName, change_update, options);
  471. await this.transaction.commit();
  472. result = true;
  473. } catch (error) {
  474. await this.transaction.rollback();
  475. result = false;
  476. }
  477. return result;
  478. }
  479. /**
  480. * 审批退回到原报人
  481. * @param {int} postData - 表单提交的数据
  482. * @return {void}
  483. */
  484. async approvalBack(postData) {
  485. // 初始化事务
  486. this.transaction = await this.db.beginTransaction();
  487. let result = false;
  488. try {
  489. const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
  490. // 设置审批人退回
  491. const audit_update = {
  492. id: postData.audit_id,
  493. sdesc: postData.sdesc,
  494. status: 5,
  495. sin_time: new Date(),
  496. };
  497. await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
  498. // 新增新一次的审批人列表
  499. // 获取当前次数审批人列表
  500. const auditList = await this.ctx.service.changeAudit.getListGroupByTimes(changeInfo.cid, changeInfo.times);
  501. const lastauditInfo = await this.ctx.service.changeAudit.getLastUser(changeInfo.cid, changeInfo.times, 1, 0);
  502. let usort = lastauditInfo.usort + 1;
  503. const newTimes = changeInfo.times + 1;
  504. const insert_audit_array = [];
  505. for (const al of auditList) {
  506. const insert_audit = {
  507. tid: al.tid,
  508. cid: al.cid,
  509. uid: al.uid,
  510. name: al.name,
  511. jobs: al.jobs,
  512. company: al.company,
  513. times: newTimes,
  514. usite: al.usite,
  515. usort,
  516. status: al.usite !== 0 ? 1 : 2,
  517. };
  518. insert_audit_array.push(insert_audit);
  519. usort++;
  520. }
  521. await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit_array);
  522. // 设置变更令退回
  523. const change_update = {
  524. w_code: postData.w_code,
  525. status: 5,
  526. times: newTimes,
  527. cin_time: Date.parse(new Date()) / 1000,
  528. };
  529. const options = {
  530. where: {
  531. cid: postData.change_id,
  532. },
  533. };
  534. await this.transaction.update(this.tableName, change_update, options);
  535. await this.transaction.commit();
  536. result = true;
  537. } catch (error) {
  538. await this.transaction.rollback();
  539. result = false;
  540. }
  541. return result;
  542. }
  543. /**
  544. * 审批退回到上一个审批人
  545. * @param {int} postData - 表单提交的数据
  546. * @return {void}
  547. */
  548. async approvalBackNew(postData) {
  549. // 初始化事务
  550. this.transaction = await this.db.beginTransaction();
  551. let result = false;
  552. try {
  553. const changeInfo = await this.getDataByCondition({ cid: postData.change_id });
  554. // 设置审批人退回
  555. const audit_update = {
  556. id: postData.audit_id,
  557. sdesc: postData.sdesc,
  558. status: 6,
  559. sin_time: new Date(),
  560. };
  561. await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
  562. // 获取当前审批人信息
  563. const auditInfo = await this.ctx.service.changeAudit.getDataById(postData.audit_id);
  564. // 获取当前次数审批人列表
  565. const auditList = await this.ctx.service.changeAudit.getNextAuditList(changeInfo.cid, auditInfo.usort);
  566. let usort = auditInfo.usort + 1;
  567. // 获取上一个审批人信息
  568. const lastauditInfo = await this.ctx.service.changeAudit.getDataById(postData.audit_last_id);
  569. // 新增2个审批人到审批列表中
  570. const insert_audit1 = {
  571. tid: lastauditInfo.tid,
  572. cid: lastauditInfo.cid,
  573. uid: lastauditInfo.uid,
  574. name: lastauditInfo.name,
  575. jobs: lastauditInfo.jobs,
  576. company: lastauditInfo.company,
  577. times: lastauditInfo.times,
  578. usite: lastauditInfo.usite,
  579. usort,
  580. status: 2,
  581. };
  582. await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit1);
  583. usort++;
  584. // 新增2个审批人到审批列表中
  585. const insert_audit2 = {
  586. tid: auditInfo.tid,
  587. cid: auditInfo.cid,
  588. uid: auditInfo.uid,
  589. name: auditInfo.name,
  590. jobs: auditInfo.jobs,
  591. company: auditInfo.company,
  592. times: auditInfo.times,
  593. usite: auditInfo.usite,
  594. usort,
  595. status: 1,
  596. };
  597. await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit2);
  598. // 把接下未审批的审批人排序都加2
  599. for (const al of auditList) {
  600. const audit_update = {
  601. id: al.id,
  602. usort: al.usort + 2,
  603. };
  604. await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
  605. }
  606. // 审批列表数据也要回退
  607. const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
  608. for (const cl of changeList) {
  609. const audit_amount = cl.audit_amount.split(',');
  610. audit_amount.splice(-1, 1);
  611. const list_update = {
  612. id: cl.id,
  613. audit_amount: audit_amount.join(','),
  614. };
  615. await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
  616. }
  617. // 设置变更令退回
  618. const change_update = {
  619. w_code: postData.w_code,
  620. status: 6,
  621. cin_time: Date.parse(new Date()) / 1000,
  622. };
  623. const options = {
  624. where: {
  625. cid: postData.change_id,
  626. },
  627. };
  628. await this.transaction.update(this.tableName, change_update, options);
  629. await this.transaction.commit();
  630. result = true;
  631. } catch (error) {
  632. await this.transaction.rollback();
  633. result = false;
  634. }
  635. return result;
  636. }
  637. }
  638. return Change;
  639. };