Commit d5c07466 by 王昆

gsb

parents 46ecc98c 70dd4d6a
...@@ -2,53 +2,71 @@ var system = require("../../../system") ...@@ -2,53 +2,71 @@ var system = require("../../../system")
const CtlBase = require("../../ctlms.base"); const CtlBase = require("../../ctlms.base");
class TaxCtl extends CtlBase { class TaxCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.taxSve = system.getObject("service.trade.tradeSve"); this.taxSve = system.getObject("service.tax.taxSve");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
} }
/** /**
* 月账期 * 月账期
* @param {*} params * @param {*} params
*/ */
async getReportData(params) { async getReportData(params) {
try { try {
let res = await this.taxSve.getReportData(params); let res = await this.taxSve.getReportData(params);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
}
} }
}
/** /**
* 季度账期 * 季度账期
* @param {*} params * @param {*} params
*/ */
async getReportDataQuarter(params) { async getReportDataQuarter(params) {
try { try {
let res = await this.taxSve.getReportData(params); let res = await this.taxSve.getReportDataQuarter(params);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
}
} }
}
/** /**
* 获取账簿用户信息 * 获取账簿用户信息
* @param {*} pobj * @param {*} pobj
* @param {*} pobj2 * @param {*} pobj2
* @param {*} req * @param {*} req
* @id * @id
*/ */
async getCustomerById(pobj, pobj2, req){ async getCustomerById(pobj, pobj2, req) {
if(!pobj.id){ try {
return system.getResult(null,`参数错误 ID 不能为空`); if (!pobj.id) {
return system.getResult(null, `参数错误 ID 不能为空`);
}
let res = await this.taxSve.getCustomerById(pobj);
return res;
} catch (error) {
console.log(error);
return system.getResult(error);
}
} }
let res = await this.orderSve.getCustomerById(pobj.invoice_id);
return res; // async businessmenPage(pobj, pobj2, req) {
} // try {
// if (!pobj.id) {
// return system.getResult(null, `参数错误 ID 不能为空`);
// }
// let res = await this.taxSve.businessmenPage(pobj);
// return res;
// } catch (error) {
// console.log(error);
// return system.getResult(error);
// }
// }
} }
module.exports = TaxCtl; module.exports = TaxCtl;
\ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../svems.base") const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const axios = require("axios");
class TaxService extends ServiceBase { class TaxService extends ServiceBase {
constructor() { constructor() {
super(); super();
...@@ -12,14 +13,14 @@ class TaxService extends ServiceBase { ...@@ -12,14 +13,14 @@ class TaxService extends ServiceBase {
async getReportData(params) { async getReportData(params) {
try { try {
let data ={ let data ={
"accountPeriod": 202003, "accountPeriod": this.trim(params.accountPeriod),
"companyId": 102, "companyId": this.trim(params.companyId),
"customerId": 498779, "customerId": this.trim(params.customerId),
"desc": "string", "desc": this.trim(params.desc) || "string",
"reportType": 2, "reportType":this.trim(params.reportType) || 2,
"signWithoutKey": "string" "signWithoutKey": this.trim(params.signWithoutKey)|| "string"
} }
let url = settings.ntapi().getReportData let url = settings.ntapi().getReportData;
return await this.callApi(url, data, "月账期"); return await this.callApi(url, data, "月账期");
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
...@@ -33,17 +34,15 @@ class TaxService extends ServiceBase { ...@@ -33,17 +34,15 @@ class TaxService extends ServiceBase {
async getReportDataQuarter(params) { async getReportDataQuarter(params) {
try { try {
let data ={ let data ={
"companyId": 102, "accountPeriod": this.trim(params.accountPeriod),
"customerId": 498779, "companyId": this.trim(params.companyId),
"desc": "string", "customerId": this.trim(params.customerId),
"endPeriod": 202003, "desc": this.trim(params.desc) || "string",
"reportType": 2, "reportType":this.trim(params.reportType) || 2,
"signWithoutKey": "string", "signWithoutKey": this.trim(params.signWithoutKey)|| "string"
"startPeriod": 202001 }
}; let url = settings.ntapi().getReportDataQuarter;
return await this.callApi(url, params, "季度账期");
let url = settings.ntapi().getReportDataQuarter
return await this.callApi(url, data, "季度账期");
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
...@@ -56,25 +55,17 @@ class TaxService extends ServiceBase { ...@@ -56,25 +55,17 @@ class TaxService extends ServiceBase {
*/ */
async getCustomerById(params) { async getCustomerById(params) {
try { try {
// let businessmen = await axios({
// let res = await axios({ method: 'post',
// method: 'post', url: settings.deliverSysApi().info,
// url: url, data: {id: params.id}
// data: settings.deliverSysApi().orderPushApi
// });
// console.log(res.data);
if(res.status == 200 && res.data && res.data.status == 0 && res.data.data) {
await this.updateOrder({id: id, deliver_order_id: res.data.data.id});
}
let businessmen = await this.callms("order", "queryObusinessmen", {
id: params.id
}); });
if (!businessmen || !businessmen.data) { if (businessmen.status=!200 || businessmen.data.status!=0 || !businessmen.data.data.customer_id) {
return system.getResult(null, `个体工商户不存在`); return system.getResult(null, `个体工商户不存在`);
} }
let url = settings.ntapi().getCustomerById; let url = settings.ntapi().getCustomerById;
let res = await this.callApi(url, { let res = await this.callApi(url, {
id: businessmen.customer_id id: businessmen.data.data.customer_id
}, "获取用户账簿信息"); }, "获取用户账簿信息");
return res; return res;
} catch (error) { } catch (error) {
...@@ -82,5 +73,37 @@ class TaxService extends ServiceBase { ...@@ -82,5 +73,37 @@ class TaxService extends ServiceBase {
return system.getResult(null, `系统错误`); return system.getResult(null, `系统错误`);
} }
} }
/**
* 获取工商户列表
* @param {*} params
*/
// async businessmenPage(params) {
// try {
// let businessmen = await axios({
// method: 'post',
// url: settings.deliverSysApi().businessmenPage,
// data: {id: params.id}
// });
// if (businessmen.status=!200 || businessmen.data.status!=0 ) {
// return system.getResult(null, `系统错误`);
// }
// let url = settings.ntapi().getCustomerById;
// let res = await this.callApi(url, {
// id: businessmen.data.data.customer_id
// }, "获取用户账簿信息");
// return res;
// } catch (error) {
// console.log(error);
// return system.getResult(null, `系统错误`);
// }
// }
} }
module.exports = TaxService; module.exports = TaxService;
\ No newline at end of file
...@@ -3,6 +3,7 @@ var objsettings = require("../config/objsettings"); ...@@ -3,6 +3,7 @@ var objsettings = require("../config/objsettings");
var settings = require("../config/settings"); var settings = require("../config/settings");
class System { class System {
<<<<<<< HEAD
static declare(ns) { static declare(ns) {
var ar = ns.split('.'); var ar = ns.split('.');
var root = System; var root = System;
...@@ -219,6 +220,215 @@ class System { ...@@ -219,6 +220,215 @@ class System {
} }
} }
} }
=======
static declare(ns) {
var ar = ns.split('.');
var root = System;
for (var i = 0, len = ar.length; i < len; ++i) {
var n = ar[i];
if (!root[n]) {
root[n] = {};
root = root[n];
} else {
root = root[n];
}
}
}
static register(key, ClassObj) {
if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在");
} else {
let obj = new ClassObj();
System.objTable[key] = obj;
}
return System.objTable[key];
}
static getResult(data, opmsg = "操作成功", req) {
return {
status: !data ? -1 : 0,
msg: opmsg,
data: data || null,
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty"
};
}
/**
* 请求返回成功
* @param {*} data 操作成功返回的数据
* @param {*} okmsg 操作成功的描述
*/
static getResultSuccess(data, okmsg = "success") {
return {
status: 0,
msg: okmsg,
data: data || null,
};
}
/**
* 请求返回失败
* @param {*} status 操作失败状态,默认为-1
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static getResultFail(status = -1, errmsg = "fail", data = null) {
return {
status: status,
msg: errmsg,
data: data,
};
}
static getObject(objpath) {
var pathArray = objpath.split(".");
var packageName = pathArray[0];
var groupName = pathArray[1];
var filename = pathArray[2];
var classpath = "";
if (filename) {
classpath = objsettings[packageName] + "/" + groupName;
} else {
classpath = objsettings[packageName];
filename = groupName;
}
var objabspath = classpath + "/" + filename + ".js";
if (System.objTable[objabspath] != null) {
console.log("get cached obj");
return System.objTable[objabspath];
} else {
console.log("no cached...");
var ClassObj = require(objabspath);
return System.register(objabspath, ClassObj);
}
}
static getUiConfig(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js";
if (settings.env == "dev") {
delete require.cache[configPath];
}
var configValue = require(configPath);
return configValue;
}
static getUiConfig2(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config");
// delete require.cache[configPath];
// }
delete require.cache[configPath];
var configValue = require(configPath);
return configValue[appid];
}
static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] ||
req.ip ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
(req.connection.socket && req.connection.socket.remoteAddress) || '';
var x = ip.match(/(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/);
if (x) {
return x[0];
} else {
return "localhost";
}
};
static y2f(y) {
if (!y) {
return 0;
}
return (Number(y) * 100).toFixed(0);
}
static f2y(f) {
if (!f) {
return 0;
}
return parseFloat((Number(f) / 100).toFixed(2));
}
static f2y4list(list, fields, prev) {
if (!list || list.length == 0 || !fields || fields.length == 0) {
return;
}
prev = prev || "";
for (var item of list) {
for (var f of fields) {
var v = item[f] || 0;
try {
item[f + "_y"] = prev + parseFloat((Number(v) / 100).toFixed(2));
} catch (error) {
console.log(error);
}
}
}
}
static getUid(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [],
i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
static microsetting() {
console.log(settings.env, "-------------- microsetting env ------------------");
var path = "/api/op/action/springboard";
if (settings.env == "dev") {
// var domain = "http://192.168.18.237";
let local = "http://127.0.0.1";
let dev = "http://39.107.234.14";
return {
// 公共服务
common: dev + ":3102" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务
merchant: dev + ":3101" + path,
// merchant: "http://127.0.0.1:3101" + path,
// 订单服务
// order: dev + ":3103" + path,
order: "http://127.0.0.1:3103" + path,
// 发票服务
invoice: dev + ":3105" + path,
// invoice: "http://127.0.0.1:3105" + path,
// 用户服务
uc: dev + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path,
// 交易
trade: local + ":3107" + path,
// uc: "http://127.0.0.1:3106" + path,
}
} else {
var odomain = "http://123.57.217.203"
return {
common: "xggsvecommon-service" + path,
merchant: "xggsvemerchant-service" + path,
order: "xggsveorder-service" + path,
invoice: "xggsveinvoice-service" + path,
uc: "xggsveuc-service" + path,
trade: "xggsvetrade-service" + path,
}
}
}
>>>>>>> 70dd4d6a06ce8b5666709fec7981da46532606aa
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
......
...@@ -128,13 +128,18 @@ var settings = { ...@@ -128,13 +128,18 @@ var settings = {
deliverSysApi: function () { deliverSysApi: function () {
let domain = ""; let domain = "";
if (this.env == "dev") { if (this.env == "dev") {
domain = "http://39.107.234.14:3002"; // domain = "http://39.107.234.14:3002";
domain = "http://127.0.0.1:3002";
} else { } else {
domain = "https://xggadmin.gongsibao.com"; domain = "https://xggadmin.gongsibao.com";
} }
return { return {
// 推送订单s // 推送订单s
orderPushApi: domain + "/web/order/orderCtl/addSourceOrder", orderPushApi: domain + "/web/order/orderCtl/addSourceOrder",
// 获取个体工商户信息
info: domain + "/web/business/businessmenCtl/info",
//获取工商户列表
businessmenPage:"/web/business/businessmenCtl/businessmenPage",
} }
}, },
redis: function () { redis: function () {
......
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