Commit 830cc61f by 孙亚楠

Merge branch 'xgg-saas-merchant' of gitlab.gongsibao.com:jiangyong/zhichan into xgg-saas-merchant

parents a3c44d52 3d1a0c0d
...@@ -57,7 +57,7 @@ class TradeService extends ServiceBase { ...@@ -57,7 +57,7 @@ class TradeService extends ServiceBase {
return system.getResultFail(-1, `锁定批次无数据`, itemList); return system.getResultFail(-1, `锁定批次无数据`, itemList);
} }
// 验证字段 // 验证字段
let error = await this.checkItemList(itemList, params.saas_merchant_id); let error = await this.checkItemList(itemList, params);
if (error) { if (error) {
return system.getResultFail(-1, `批次内有错误数据,请检查后修改`, itemList); return system.getResultFail(-1, `批次内有错误数据,请检查后修改`, itemList);
} }
...@@ -66,7 +66,7 @@ class TradeService extends ServiceBase { ...@@ -66,7 +66,7 @@ class TradeService extends ServiceBase {
info = info.data || {}; info = info.data || {};
let main = info.main_trade || {}; let main = info.main_trade || {};
// 计算预计付款金额 // 计算预计付款金额
let result = await this.countAmt(itemList, info); let result = await this.countAmt(itemList, info, params);
for (let item of itemList) { for (let item of itemList) {
item.amt = system.y2f(item.actual_amt); item.amt = system.y2f(item.actual_amt);
...@@ -126,13 +126,13 @@ class TradeService extends ServiceBase { ...@@ -126,13 +126,13 @@ class TradeService extends ServiceBase {
} }
// 读取excel // 读取excel
let itemList = await this.readItems(params.fileUrl, params.fileName); let itemList = await this.readItems(params);
// 验证字段 // 验证字段
let error = await this.checkItemList(itemList, params.saas_merchant_id); let error = await this.checkItemList(itemList, params);
// 计算预计付款基恩 // 计算预计付款基恩
let result = await this.countAmt(itemList, info); let result = await this.countAmt(itemList, info, params);
// 封装返回对象 // 封装返回对象
result.error = error; result.error = error;
...@@ -150,7 +150,7 @@ class TradeService extends ServiceBase { ...@@ -150,7 +150,7 @@ class TradeService extends ServiceBase {
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
async countAmt(itemList, info) { async countAmt(itemList, info, params) {
let result = {amt: 0, actual_amt: 0, deduct_amt: 0, service_tax: 0}; let result = {amt: 0, actual_amt: 0, deduct_amt: 0, service_tax: 0};
if (!itemList) { if (!itemList) {
return result; return result;
...@@ -178,7 +178,9 @@ class TradeService extends ServiceBase { ...@@ -178,7 +178,9 @@ class TradeService extends ServiceBase {
return result; return result;
} }
async readItems(fileUrl, fileName) { async readItems(params) {
let fileUrl = params.fileUrl;
let fileName = params.fileName;
let itemList = []; let itemList = [];
let filePath = settings.localpath() + "saas_xgg_trade_order_" + this.trim(fileName) + ".xlsx"; let filePath = settings.localpath() + "saas_xgg_trade_order_" + this.trim(fileName) + ".xlsx";
try { try {
...@@ -228,7 +230,8 @@ class TradeService extends ServiceBase { ...@@ -228,7 +230,8 @@ class TradeService extends ServiceBase {
} }
} }
async checkItemList(itemList, saas_merchant_id) { async checkItemList(itemList, params) {
let saas_merchant_id = params.saas_merchant_id;
let error = false; let error = false;
if (!itemList || itemList.length == 0) { if (!itemList || itemList.length == 0) {
return system.getResult(null, "打款文件无数据") return system.getResult(null, "打款文件无数据")
......
...@@ -166,6 +166,12 @@ class System { ...@@ -166,6 +166,12 @@ class System {
return uuid.join(''); return uuid.join('');
} }
static endWith(source, str){
if(!str || !source || source.length == 0 || str.length > source.length) {
return false;
}
return source.substring(source.length - str.length) == str;
}
static microsetting() { static microsetting() {
console.log(settings.env, "-------------- microsetting env ------------------"); console.log(settings.env, "-------------- microsetting env ------------------");
var path = "/api/op/action/springboard"; var path = "/api/op/action/springboard";
......
...@@ -3,6 +3,20 @@ var System = require("../../base/system"); ...@@ -3,6 +3,20 @@ var System = require("../../base/system");
const settings = require("../settings"); const settings = require("../settings");
module.exports = function (app) { module.exports = function (app) {
app.all("/applet/*", function (req, res, next) { app.all("/applet/*", function (req, res, next) {
let openid = req.body.openid || req.query.openid;
if (System.endWith(req.url, "applet/merchantApplet/login") ||
System.endWith(req.url, "applet/merchantApplet/uploadConfig")) {
if (openid) {
req.openid = openid;
} else {
req.openid = null;
}
return next();
}
if (!openid) {
res.end(JSON.stringify({ code: 403, msg: "no login" }));
return;
}
return next(); return next();
}); });
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
``` javascript ``` javascript
{ {
"order_type": "10", // 10批量上传 20交易上传
// 上传文件地址 // 上传文件地址
"fileUrl": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_273315857206750512020113575551testbank2.xlsx" "fileUrl": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_273315857206750512020113575551testbank2.xlsx"
} }
...@@ -136,6 +137,7 @@ ...@@ -136,6 +137,7 @@
{ {
"acc_type": "00", "acc_type": "00",
"order_type": "10", // 10批量上传 20交易上传
"fileUrl": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_273315857206750512020113575551testbank2.xlsx", "fileUrl": "https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_273315857206750512020113575551testbank2.xlsx",
"itemList": [ "itemList": [
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment