|
@@ -30,23 +30,31 @@ module.exports = app => {
|
|
|
*/
|
|
|
async addDefaultPayData(tid, transaction) {
|
|
|
const existPays = this.getAllDataByCondition({tid: tid});
|
|
|
- const pays = JSON.parse(JSON.stringify(payConst.payTemplate));
|
|
|
- if (existPays.length >= pays.length) { return false; }
|
|
|
+ if (existPays.length >= 0) { return false; }
|
|
|
|
|
|
- for (const p of pays) {
|
|
|
- p.tid = tid;
|
|
|
- p.csid = 0;
|
|
|
- p.cstimes = 0;
|
|
|
- p.csorder = 0;
|
|
|
- p.csaorder = 0;
|
|
|
- }
|
|
|
- let result;
|
|
|
- if (transaction) {
|
|
|
- result = await transaction.insert(this.tableName, pays);
|
|
|
- } else {
|
|
|
- result = await this.db.insert(this.tableName, pays);
|
|
|
+ try {
|
|
|
+ const projectData = await this.ctx.service.project.getDataById(this.ctx.session.sessionProject.id);
|
|
|
+ const pays = projectData.dealpay_json
|
|
|
+ ? JSON.parse(projectData.dealpay_json)
|
|
|
+ : JSON.parse(JSON.stringify(payConst.payTemplate));
|
|
|
+
|
|
|
+ for (const p of pays) {
|
|
|
+ p.tid = tid;
|
|
|
+ p.csid = 0;
|
|
|
+ p.cstimes = 0;
|
|
|
+ p.csorder = 0;
|
|
|
+ p.csaorder = 0;
|
|
|
+ }
|
|
|
+ let result;
|
|
|
+ if (transaction) {
|
|
|
+ result = await transaction.insert(this.tableName, pays);
|
|
|
+ } else {
|
|
|
+ result = await this.db.insert(this.tableName, pays);
|
|
|
+ }
|
|
|
+ return result.affectedRows === pays.length;
|
|
|
+ } catch(error) {
|
|
|
+ throw '项目的默认合同支付数据有误';
|
|
|
}
|
|
|
- return result.affectedRows === pays.length;
|
|
|
}
|
|
|
|
|
|
async _getMaxOrder(tenderId) {
|