浏览代码

变更令,小数位数总是为空

MaiXinRong 2 年之前
父节点
当前提交
4dd2ca1db8
共有 3 个文件被更改,包括 8 次插入7 次删除
  1. 3 2
      app/lib/revise_price.js
  2. 3 3
      db_script/change.js
  3. 2 2
      sql/update.sql

+ 3 - 2
app/lib/revise_price.js

@@ -175,6 +175,7 @@ class revisePriceCalc {
      * @param {Object} transaction - 事务 (无则非事务提交)
      */
     async calcChange(change, transaction) {
+        const decimal = this.ctx.tender.info.decimal;
         const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: change.cid } });
         const updateBills = [];
         let total_price = 0, positive_tp = 0, negative_tp = 0;
@@ -183,9 +184,9 @@ class revisePriceCalc {
             let bills_tp;
             if (p) {
                 updateBills.push({ id: b.id, unit_price: p.new_price });
-                bills_tp = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal);
+                bills_tp = this.ctx.helper.mul(p.new_price, b.spamount, change.tp_decimal || decimal.tp);
             } else {
-                bills_tp = this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal);
+                bills_tp = this.ctx.helper.mul(b.unit_price, b.spamount, change.tp_decimal || decimal.tp);
             }
             total_price = this.ctx.helper.add(total_price, bills_tp);
             if (b.spamount >= 0) {

+ 3 - 3
db_script/change.js

@@ -187,11 +187,11 @@ const checkStageBills = async function (stage, decimal, preStage) {
 
 const doComplete = async function() {
     try {
-        const tender = await querySql('Select * From zh_tender');
+        const tender = await querySql('Select * From zh_tender Where id >= 11405');
         for (const t of tender) {
             console.log(`Update Tender ${t.id}:`);
             const info = await querySql('Select * From zh_tender_info where tid = ?', [t.id]);
-            const decimal = info[0].decimal ? JSON.parse(info[0].decimal) : defaultInfo.parseInfo.decimal;
+            const decimal = info.length > 0 && info[0].decimal ? JSON.parse(info[0].decimal) : defaultInfo.defaultInfo.decimal;
 
             const changes = await querySql('Select * From zh_change where tid = ?', [t.id]);
             for (const c of changes) {
@@ -215,7 +215,7 @@ const doCompleteTest = async function(tid) {
         for (const t of tender) {
             console.log(`Update Tender ${t.id}:`);
             const info = await querySql('Select * From zh_tender_info where tid = ?', [t.id]);
-            const decimal = info[0].decimal ? JSON.parse(info[0].decimal) : defaultInfo.parseInfo.decimal;
+            const decimal = info.length > 0 && info[0].decimal ? JSON.parse(info[0].decimal) : defaultInfo.defaultInfo.decimal;
 
             const changes = await querySql('Select * From zh_change where tid = ?', [t.id]);
             for (const c of changes) {

+ 2 - 2
sql/update.sql

@@ -85,8 +85,8 @@ CREATE TABLE `zh_stage_bills_pc` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   `tid` int(11) unsigned NOT NULL COMMENT '标段id',
   `sid` int(11) UNSIGNED NOT NULL COMMENT '期id',
-  `sorder` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第几期'
-  `lid` varchar(36) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目节id',
+  `sorder` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '第几期',
+  `lid` varchar(36) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '项目节id',
   `org_price` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '原单价',
   `unit_price` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期单价',
   `contract_pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(合同)',