瀏覽代碼

变更金额位数bug修复

laiguoran 4 年之前
父節點
當前提交
4b29cc0878
共有 6 個文件被更改,包括 96 次插入73 次删除
  1. 2 2
      app/controller/change_controller.js
  2. 10 4
      app/service/change.js
  3. 13 8
      app/service/change_audit.js
  4. 2 1
      app/service/change_audit_list.js
  5. 1 58
      sql/update.sql
  6. 68 0
      sql/update20201126.sql

+ 2 - 2
app/controller/change_controller.js

@@ -293,7 +293,7 @@ module.exports = app => {
                     whiteList,
                     auditList,
                     changeList,
-                    tpUnit: ctx.tender.info.decimal.tp,
+                    tpUnit: change.tp_decimal ? change.tp_decimal : ctx.tender.info.decimal.tp,
                     upUnit: ctx.tender.info.decimal.up,
                     authMobile: auth_mobile,
                     shenpiConst,
@@ -559,7 +559,7 @@ module.exports = app => {
                     attList,
                     whiteList,
                     auditList,
-                    tpUnit: ctx.tender.info.decimal.tp,
+                    tpUnit: change.tp_decimal ? change.tp_decimal : ctx.tender.info.decimal.tp,
                     upUnit: ctx.tender.info.decimal.up,
                     authMobile: auth_mobile,
                     shenpiConst,

+ 10 - 4
app/service/change.js

@@ -487,6 +487,7 @@ module.exports = app => {
                     charge: postData.charge,
                     w_code: postData.w_code,
                     total_price,
+                    tp_decimal: this.ctx.tender.info.decimal.tp,
                 };
                 const options = {
                     where: {
@@ -579,13 +580,14 @@ module.exports = app => {
                 // 清单数据更新
                 const bills_list = postData.bills_list.split(',');
                 let total_price = 0;
+                const tp_decimal = changeData.tp_decimal ? changeData.tp_decimal : this.ctx.tender.info.decimal.tp;
                 for (const bl of bills_list) {
                     const listInfo = bl.split('_');
                     const lid = listInfo[0];
                     const amount = listInfo[1];
                     const changeListInfo = await this.ctx.service.changeAuditList.getDataById(lid);
                     if (changeListInfo !== undefined) {
-                        total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(changeListInfo.unit_price, amount, this.ctx.tender.info.decimal.tp));
+                        total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(changeListInfo.unit_price, amount, tp_decimal));
                         const audit_amount = changeListInfo.audit_amount !== null && changeListInfo.audit_amount !== '' ? changeListInfo.audit_amount.split(',') : [];
                         audit_amount.push(amount);
                         const list_update = {
@@ -780,8 +782,9 @@ module.exports = app => {
                     where: { cid: changeInfo.cid },
                 });
                 let total_price = 0;
+                const tp_decimal = changeData.tp_decimal ? changeData.tp_decimal : this.ctx.tender.info.decimal.tp;
                 for (const cl of changeList) {
-                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, cl.camount, this.ctx.tender.info.decimal.tp));
+                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, cl.camount, tp_decimal));
                 }
                 // 设置变更令退回
                 const change_update = {
@@ -790,6 +793,7 @@ module.exports = app => {
                     times: newTimes,
                     cin_time: Date.parse(new Date()) / 1000,
                     total_price,
+                    tp_decimal: null,
                 };
                 const options = {
                     where: {
@@ -919,6 +923,7 @@ module.exports = app => {
                     where: { cid: changeInfo.cid },
                 });
                 let total_price = 0;
+                const tp_decimal = changeData.tp_decimal ? changeData.tp_decimal : this.ctx.tender.info.decimal.tp;
                 for (const cl of changeList) {
                     const audit_amount = cl.audit_amount.split(',');
                     const last_amount = audit_amount[audit_amount.length - 1];
@@ -928,7 +933,7 @@ module.exports = app => {
                         audit_amount: audit_amount.join(','),
                         spamount: parseFloat(last_amount),
                     };
-                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), this.ctx.tender.info.decimal.tp));
+                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), tp_decimal));
                     await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
                 }
 
@@ -1231,6 +1236,7 @@ module.exports = app => {
 
                 // 审批列表数据也要回退
                 let total_price = 0;
+                const tp_decimal = changeInfo.tp_decimal ? changeInfo.tp_decimal : this.ctx.tender.info.decimal.tp;
                 const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({
                     where: { cid: changeInfo.cid },
                 });
@@ -1243,7 +1249,7 @@ module.exports = app => {
                         audit_amount: audit_amount.join(','),
                         samount: '',
                     };
-                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), this.ctx.tender.info.decimal.tp));
+                    total_price = this.ctx.helper.add(total_price, this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), tp_decimal));
                     await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
                 }
 

+ 13 - 8
app/service/change_audit.js

@@ -566,14 +566,6 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: auditConst.auditStatus.checking, sin_time: new Date() });
-                const options = {
-                    where: {
-                        cid: cid,
-                    },
-                };
-                await transaction.update(this.ctx.service.change.tableName, {
-                    status: auditConst.status.checking,
-                }, options);
                 // 更新原报人审批状态
                 await transaction.update(this.tableName, {
                     id: yBAudit.id,
@@ -581,9 +573,11 @@ module.exports = app => {
                     sin_time: new Date(),
                 });
                 const changeList = await this.ctx.service.changeAuditList.getList(cid);
+                let total_price = 0;
                 // 更新清单spamount的值
                 const updateListData = [];
                 for (const cl of changeList) {
+                    total_price = this.ctx.helper.accAdd(total_price, this.ctx.helper.mul(cl.unit_price, cl.camount, this.ctx.tender.info.decimal.tp));
                     if(cl.camount !== cl.spamount) {
                         const uld = {
                             id: cl.id,
@@ -593,6 +587,17 @@ module.exports = app => {
                     }
                 }
                 if(updateListData.length > 0) await transaction.updateRows(this.ctx.service.changeAuditList.tableName, updateListData);
+                const options = {
+                    where: {
+                        cid: cid,
+                    },
+                };
+                const updateData = {
+                    total_price,
+                    tp_decimal: this.ctx.tender.info.decimal.tp,
+                    status: auditConst.status.checking,
+                };
+                await transaction.update(this.ctx.service.change.tableName, updateData, options);
 
                 // 添加短信通知-需要审批提醒功能
                 const sms = new SMS(this.ctx);

+ 2 - 1
app/service/change_audit_list.js

@@ -189,8 +189,9 @@ module.exports = app => {
             const sqlParam = [this.tableName, this.ctx.change.cid];
             const changeList = await transaction.query(sql, sqlParam);
             let total_price = 0;
+            const tp_decimal = this.ctx.change.tp_decimal ? this.ctx.change.tp_decimal : this.ctx.tender.info.decimal.tp;
             for (const cl of changeList) {
-                total_price = this.ctx.helper.accAdd(total_price, this.ctx.helper.mul(cl.unit_price, cl.spamount, this.ctx.tender.info.decimal.tp));
+                total_price = this.ctx.helper.accAdd(total_price, this.ctx.helper.mul(cl.unit_price, cl.spamount, tp_decimal));
             }
             const updateData = {
                 total_price,

+ 1 - 58
sql/update.sql

@@ -1,68 +1 @@
-ALTER TABLE `zh_tender`
-ADD COLUMN `copy_id` INT(10) NULL COMMENT '被拷贝标段id' AFTER `uuid`;
-
-
-ALTER TABLE `zh_change_audit_list` ADD `gcl_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '台账对应id(非准确)' AFTER `xmj_jldy`;
-UPDATE `zh_change_audit_list` SET `gcl_id`=`lid` WHERE `lid` != '0';
-
-ALTER TABLE `zh_s2b_proj`
-ADD COLUMN `merge_code`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `common_option`;
-
-CREATE TABLE `zh_tender_tag` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `tid` int(11) NOT NULL COMMENT '标段id',
-  `pid` int(11) NOT NULL COMMENT '项目id',
-  `ledger_time` datetime DEFAULT NULL COMMENT '台账分解审批完成时间',
-  `revise_time` datetime DEFAULT NULL COMMENT '最后一次台账修订审批完成时间',
-  `stage_time` datetime DEFAULT NULL COMMENT '最后一次期审批完成时间',
-  `bgl_time` datetime DEFAULT NULL COMMENT '最后一次变更令审批完成时间',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2049 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-CREATE TABLE `zh_s2b_proj_push` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `pid` int(11) NOT NULL COMMENT '项目id-zh_s2b_proj中的id',
-  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
-  `url` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '推送的url',
-  `ledger` tinyint(1) NOT NULL DEFAULT '1' COMMENT '台账审批通过-是否推送',
-  `revise` tinyint(1) NOT NULL DEFAULT '1' COMMENT '台账修订审批通过-是否推送',
-  `stage` tinyint(1) NOT NULL DEFAULT '1' COMMENT '期审批通过-是否推送',
-  `bgl` tinyint(1) NOT NULL DEFAULT '1' COMMENT '变更令审批通过-是否需要推送',
-  `add_time` datetime(4) DEFAULT NULL COMMENT '创建时间',
-  `lastest_time` datetime(4) DEFAULT NULL COMMENT '最后修改时间',
-  `push_time` datetime(4) DEFAULT NULL COMMENT '最近一次推送时间',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-Insert Into zh_tender_tag (tid, pid) Select id, project_id From zh_tender Where 1=1;
-
-CREATE TABLE `zh_s2b_push_log` (
-  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `pid` int(11) NOT NULL COMMENT '项目id',
-  `push_id` int(11) NOT NULL COMMENT '推送id',
-  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '推送url',
-  `push_data` text COLLATE utf8_unicode_ci COMMENT '推送内容',
-  `push_time` datetime NOT NULL COMMENT '推送时间',
-  `push_result` text COLLATE utf8_unicode_ci COMMENT '推送结果',
-  `push_err` varchar(1000) CHARACTER SET utf8 DEFAULT NULL COMMENT '推送错误',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-ALTER TABLE `zh_s2b_c_proj`
-ADD COLUMN `push_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '推送的标段' AFTER `base_data`;
-
-ALTER TABLE `zh_s2b_proj`
-ADD COLUMN `filter_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '过滤标段' AFTER `merge_code`;
-
-ALTER TABLE `zh_category_value` ADD `sort` int(11) DEFAULT NULL COMMENT '排序' AFTER `value`;
-UPDATE `zh_category_value` SET `sort`=`id`;
+ALTER TABLE `zh_change` ADD `tp_decimal` TINYINT(3) NULL DEFAULT NULL COMMENT '金额位数' AFTER `sin_time`;

+ 68 - 0
sql/update20201126.sql

@@ -0,0 +1,68 @@
+ALTER TABLE `zh_tender`
+ADD COLUMN `copy_id` INT(10) NULL COMMENT '被拷贝标段id' AFTER `uuid`;
+
+
+ALTER TABLE `zh_change_audit_list` ADD `gcl_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '台账对应id(非准确)' AFTER `xmj_jldy`;
+UPDATE `zh_change_audit_list` SET `gcl_id`=`lid` WHERE `lid` != '0';
+
+-- sync2bim相关
+ALTER TABLE `zh_s2b_proj`
+ADD COLUMN `merge_code`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `common_option`;
+
+-- ----------------------------
+-- Table structure for zh_tender_tag
+-- ----------------------------
+CREATE TABLE `zh_tender_tag` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `tid` int(11) NOT NULL COMMENT '标段id',
+  `pid` int(11) NOT NULL COMMENT '项目id',
+  `ledger_time` datetime DEFAULT NULL COMMENT '台账分解审批完成时间',
+  `revise_time` datetime DEFAULT NULL COMMENT '最后一次台账修订审批完成时间',
+  `stage_time` datetime DEFAULT NULL COMMENT '最后一次期审批完成时间',
+  `bgl_time` datetime DEFAULT NULL COMMENT '最后一次变更令审批完成时间',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2049 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+-- ----------------------------
+-- Table structure for zh_s2b_proj_push
+-- ----------------------------
+CREATE TABLE `zh_s2b_proj_push` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `pid` int(11) NOT NULL COMMENT '项目id-zh_s2b_proj中的id',
+  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
+  `url` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '推送的url',
+  `ledger` tinyint(1) NOT NULL DEFAULT '1' COMMENT '台账审批通过-是否推送',
+  `revise` tinyint(1) NOT NULL DEFAULT '1' COMMENT '台账修订审批通过-是否推送',
+  `stage` tinyint(1) NOT NULL DEFAULT '1' COMMENT '期审批通过-是否推送',
+  `bgl` tinyint(1) NOT NULL DEFAULT '1' COMMENT '变更令审批通过-是否需要推送',
+  `add_time` datetime(4) DEFAULT NULL COMMENT '创建时间',
+  `lastest_time` datetime(4) DEFAULT NULL COMMENT '最后修改时间',
+  `push_time` datetime(4) DEFAULT NULL COMMENT '最近一次推送时间',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+Insert Into zh_tender_tag (tid, pid) Select id, project_id From zh_tender Where 1=1;
+
+-- ----------------------------
+-- Table structure for zh_s2b_push_log
+-- ----------------------------
+CREATE TABLE `zh_s2b_push_log` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `pid` int(11) NOT NULL COMMENT '项目id',
+  `push_id` int(11) NOT NULL COMMENT '推送id',
+  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '推送url',
+  `push_data` text COLLATE utf8_unicode_ci COMMENT '推送内容',
+  `push_time` datetime NOT NULL COMMENT '推送时间',
+  `push_result` text COLLATE utf8_unicode_ci COMMENT '推送结果',
+  `push_err` varchar(1000) CHARACTER SET utf8 DEFAULT NULL COMMENT '推送错误',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+ALTER TABLE `zh_s2b_c_proj`
+ADD COLUMN `push_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '推送的标段' AFTER `base_data`;
+
+ALTER TABLE `zh_s2b_proj`
+ADD COLUMN `filter_tender`  varchar(1000) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '过滤标段' AFTER `merge_code`;
+
+ALTER TABLE `zh_category_value` ADD `sort` int(11) DEFAULT NULL COMMENT '排序' AFTER `value`;
+UPDATE `zh_category_value` SET `sort`=`id`;