Browse Source

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 5 years ago
parent
commit
da2c2705ad

+ 1 - 0
app/const/deal_pay.js

@@ -33,6 +33,7 @@ const calcBase = [
     {name: '本期合同计量', code: 'bqht', limit: true, sort: 10},
     {name: '本期变更计量', code: 'bqbg', limit: true, sort: 10},
     {name: '100章本期完成计量', code: 'ybbqwc', limit: true, sort: 1},
+    {name: '本期应付', code: 'bqyf', limit: true, ptNormalLimit: true, sort: 20},
 ];
 
 const chapterDetailType = {

+ 21 - 0
app/controller/profile_controller.js

@@ -395,11 +395,32 @@ module.exports = app => {
         async removeWechat(ctx) {
             try {
                 const sessionUser = ctx.session.sessionUser;
+                // 获取账号数据
+                const accountData = await ctx.service.projectAccount.getDataByCondition({ id: sessionUser.accountId });
                 const result = await ctx.service.projectAccount.bindWx(sessionUser.accountId, null, null);
 
                 if (!result) {
                     throw '解绑微信失败!';
                 }
+                // 解绑成功通知
+                const templateId = 'gsYUIt5CFY1uJQhiqnkhu38yi0adkZtEH9fGI49g_Lk';
+                const url = '';
+                const msgData = {
+                    first: {
+                        value: '你已成功与纵横云计量帐号解除绑定',
+                    },
+                    keyword1: {
+                        value: sessionUser.account,
+                    },
+                    keyword2: {
+                        value: '项目编号' + ctx.session.sessionProject.code + ' 账号' + sessionUser.account + ' 解绑成功',
+                    },
+                    remark: {
+                        value: '欢迎使用纵横云计量,我们竭诚为您服务。',
+                    },
+                };
+                await app.wechat.api.sendTemplate(accountData.wx_openid, templateId, url, '', msgData);
+
                 this.setMessage('微信解绑成功', this.messageType.SUCCESS);
             } catch (error) {
                 console.log(error);

+ 1 - 0
app/controller/stage_controller.js

@@ -720,6 +720,7 @@ module.exports = app => {
                     const payCalculator = new PayCalculator(ctx, ctx.stage, ctx.tender.info);
                     await payCalculator.calculateAll(renderData.dealPay);
                     await this._updateStageCache(ctx, payCalculator);
+                    //renderData.calcBase = payCalculator.bases;
                 }
                 await this.layout('stage/pay.ejs', renderData, 'stage/pay_modal.ejs');
             } catch (err) {

+ 9 - 7
app/controller/wechat_controller.js

@@ -140,25 +140,27 @@ module.exports = app => {
 
         async testwx(ctx) {
             try {
-                // 绑定成功通知
-                const templateId = 'ElT988uf7EV8ROPKSAX7z7tN9ZxZCDMaXK5ouc9N49E';
+                const sessionUser = ctx.session.sessionUser;
+                // 获取账号数据
+                const accountData = await ctx.service.projectAccount.getDataByCondition({ id: sessionUser.accountId });
+                // 解绑成功通知
+                const templateId = 'gsYUIt5CFY1uJQhiqnkhu38yi0adkZtEH9fGI49g_Lk';
                 const url = '';
-                const topColor = '#FFFFFF';
                 const msgData = {
                     first: {
-                        value: '微信绑定成功',
+                        value: '你已成功与纵横云计量帐号解除绑定',
                     },
                     keyword1: {
-                        value: 'hello world',
+                        value: sessionUser.account,
                     },
                     keyword2: {
-                        value: 'hello world 绑定成功',
+                        value: '项目编号' + ctx.session.sessionProject.code + ' 账号' + sessionUser.account + ' 解绑成功',
                     },
                     remark: {
                         value: '欢迎使用纵横云计量,我们竭诚为您服务。',
                     },
                 };
-                await app.wechat.api.sendTemplate(ctx.session.wechatToken.openid, templateId, url, topColor, msgData);
+                await app.wechat.api.sendTemplate(accountData.wx_openid, templateId, url, '', msgData);
                 ctx.body = 'success';
             } catch (error) {
                 console.log(error);

+ 6 - 2
app/lib/pay_calc.js

@@ -82,7 +82,7 @@ class PayCalculate {
     _calculateExpr(expr) {
         let formula = expr;
         for (const b of this.bases) {
-            formula = formula.replace(b.reg, b.value);
+            formula = formula.replace(b.reg, b.value ? b.value : 0);
         }
         const percent = formula.match(this.percentReg);
         if (percent) {
@@ -223,10 +223,14 @@ class PayCalculate {
             p.end_tp = this.ctx.helper.round(this.ctx.helper.add(p.tp, p.pre_tp), this.decimal);
         }
         this.yf.end_tp = this.ctx.helper.add(this.yf.tp, this.yf.pre_tp);
+        const bqyf = this.bases.find(function (x) {return x.code === 'bqyf'});
+        if (bqyf) {
+            bqyf.value = this.yf.tp;
+        }
         if (this.sf.expr === null || this.sf.expr === '') {
             this.sf.tp = this.yf.tp;
         } else {
-            this.sf.tp = this.ctx.helper._.toNumber(this.sf.expr);
+            this.sf.tp = this.ctx.helper.round(this._calculateTpExpr(this.sf), this.decimal);
         }
         this.sf.end_tp = this.ctx.helper.add(this.sf.tp, this.sf.pre_tp);
     }

BIN
app/public/images/wechat.png


+ 30 - 7
app/public/js/stage_pay.js

@@ -405,7 +405,7 @@ $(document).ready(() => {
             const num = text ? _.toNumber(text) : null;
             let expr = text ? (num ? null : text) : null;
             expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase(): null;
-            const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg']);
+            const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
             if (!valid) return [valid, msg];
 
             if (payBase.isStarted(payNode)) {
@@ -431,7 +431,7 @@ $(document).ready(() => {
             const num = text ? _.toNumber(text) : null;
             let expr = text ? (num ? null : text) : null;
             expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase(): null;
-            const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg']);
+            const [valid, msg] = this._checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
             if (!valid) return [valid, msg];
 
             if (payBase.isStarted(payNode)) {
@@ -455,6 +455,25 @@ $(document).ready(() => {
                     data.expr = null;
                 } else {
                     const expr = $.trim(text).replace('\t', '').replace('=', '').toLowerCase();
+                    const [valid, msg] = this._checkExprValid(expr, ['bqyf']);
+                    if (!valid) return [valid, msg];
+                    data.expr = expr;
+                    data.tp = null;
+                }
+            } else {
+                data.tp = null;
+                data.expr = null;
+            }
+            return [true, ''];
+        },
+        _checkSfExpr: function (text, data) {
+            if (text) {
+                const num = _.toNumber(text);
+                if (num) {
+                    data.tp = num;
+                    data.expr = null;
+                } else {
+                    const expr = $.trim(text).replace('\t', '').replace('=', '').toLowerCase();
                     const [valid, msg] = this._checkExprValid(expr);
                     if (!valid) return [valid, msg];
                     data.expr = expr;
@@ -624,15 +643,17 @@ $(document).ready(() => {
                 // 获取更新数据
                 if (col.field === 'tp') {
                     data.updateData.pid = select.pid;
-                    const [valid, msg] = paySpreadObj._checkExpr(validText, data.updateData);
+                    const [valid, msg] = payBase.isSF(select)
+                        ? paySpreadObj._checkSfExpr(validText, data.updateData)
+                        : paySpreadObj._checkExpr(validText, data.updateData);
                     if (!valid) {
                         toastr.warning(msg);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
-                    if (payBase.isSF(select)) {
-                        data.updateData.expr = data.updateData.tp;
-                    }
+                    // if (payBase.isSF(select)) {
+                    //     data.updateData.expr = data.updateData.tp;
+                    // }
                 } else if (col.field === 'name') {
                     data.updateData.pid = select.pid;
                     data.updateData.name = validText;
@@ -793,7 +814,9 @@ $(document).ready(() => {
                         const updateData = {};
                         if (col.field === 'tp') {
                             updateData.pid = node.pid;
-                            const [valid, msg] = paySpreadObj._checkExpr(validText, updateData);
+                            const [valid, msg] = payBase.isSF(node)
+                                ? paySpreadObj._checkSfExpr(validText, data.updateData)
+                                : paySpreadObj._checkExpr(validText, data.updateData);
                             if (!valid) {
                                 toastr.warning(msg);
                                 SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());

+ 2 - 0
app/service/project_account.js

@@ -128,6 +128,7 @@ module.exports = app => {
                     projectInfo = {
                         id: projectData.id,
                         name: projectData.name,
+                        code: projectData.code,
                         userAccount: projectData.user_account,
                         custom: projectData.custom,
                         page_show: projectData.page_show ? JSON.parse(projectData.page_show) : null,
@@ -177,6 +178,7 @@ module.exports = app => {
 
                     projectInfo = {
                         id: projectData.id,
+                        code: projectData.code,
                         name: projectData.name,
                         userAccount: projectData.user_account,
                         custom: projectData.custom,

+ 4 - 0
app/view/stage/pay.ejs

@@ -38,7 +38,11 @@
                             <td><%- iBase + 1 %></td>
                             <td><%- calcBase[iBase].name %></td>
                             <td><%- calcBase[iBase].code %></td>
+                            <% if (calcBase[iBase].code === 'bqyf') { %>
+                            <td class="text-right">--</td>
+                            <% } else {%>
                             <td class="text-right"><%- (ctx.tender.info.display.thousandth ? ctx.helper.formatNum(calcBase[iBase].value, '#,##0.######') : calcBase[iBase].value) %></td>
+                            <% } %>
                         </tr>
                         <% } %>
                     </table>

+ 16 - 0
sql/update.sql

@@ -25,3 +25,19 @@ ADD COLUMN `dagl_status`  int(4) NULL DEFAULT 0 COMMENT '档案管理-状态' AF
 
 ALTER TABLE `calculation`.`zh_notice`
 DROP COLUMN `is_read`;
+
+ALTER TABLE `zh_tender`
+ADD COLUMN `uuid`  varchar(50) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL COMMENT 'uuid' AFTER `deal_tp`;
+
+CREATE TABLE `zh_s2b_log` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `pid` int(11) NOT NULL COMMENT '项目id',
+  `tid` int(11) NOT NULL COMMENT '标段id',
+  `url` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '请求url',
+  `post_data` text CHARACTER SET utf8 COMMENT '请求数据',
+  `post_data_file` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '请求数据文件(部分请求可能数据量比较大,以文件形式存储)',
+  `result_data` text COLLATE utf8_unicode_ci,
+  `result_data_file` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '结果数据文件(部分请求结果可能数据量比较大,以文件形式存储)',
+  `post_time` datetime DEFAULT NULL COMMENT '请求时间',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;