Commit f3fe7ce0 by 王昆

gsb

parent d9c7f676
#!/bin/bash #!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2 FROM registry.cn-beijing.aliyuncs.com/hantang/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com" MAINTAINER jy "jiangyong@gongsibao.com"
ADD xgg-pc /apps/xgg-pc/ ADD xgg-admin /apps/xgg-admin/
WORKDIR /apps/xgg-pc/ WORKDIR /apps/xgg-admin/
RUN cnpm install -S RUN cnpm install -S
CMD ["node","/apps/xgg-pc/main.js"] CMD ["node","/apps/xgg-admin/main.js"]
......
{
"editor.tabSize": 2
}
\ No newline at end of file
...@@ -37,7 +37,7 @@ class APIBase extends DocBase { ...@@ -37,7 +37,7 @@ class APIBase extends DocBase {
} }
for (let k = 0; k < keys.length; k++) { for (let k = 0; k < keys.length; k++) {
const tKey = keys[k]; const tKey = keys[k];
if (tKey != "sign" && params[tKey]) { if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]); signArr.push(tKey + "=" + params[tKey]);
} }
} }
...@@ -79,11 +79,12 @@ class APIBase extends DocBase { ...@@ -79,11 +79,12 @@ class APIBase extends DocBase {
result.status = system.appidFail; result.status = system.appidFail;
result.msg = "请求头app_id值失效,请重新获取"; result.msg = "请求头app_id值失效,请重新获取";
} }
// var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// if (signResult.status != 0) { var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// result.status = system.signFail; if (signResult.status != 0) {
// result.msg = signResult.msg; result.status = system.signFail;
// } result.msg = signResult.msg;
}
}//验签 }//验签
else if (appkey) { else if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000); appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
...@@ -102,11 +103,11 @@ class APIBase extends DocBase { ...@@ -102,11 +103,11 @@ class APIBase extends DocBase {
var requestid = this.getUUID(); var requestid = this.getUUID();
try { try {
//验证accesskey或验签 //验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req); var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) { if (isPassResult.status != 0) {
// isPassResult.requestid = ""; isPassResult.requestid = "";
// return isPassResult; return isPassResult;
// } }
if (pobj && pobj.action_body) { if (pobj && pobj.action_body) {
pobj.action_body.merchant_id = pobj.action_body.merchant_id || req.headers["app_id"]; pobj.action_body.merchant_id = pobj.action_body.merchant_id || req.headers["app_id"];
} }
......
...@@ -4,8 +4,8 @@ const querystring = require('querystring'); ...@@ -4,8 +4,8 @@ const querystring = require('querystring');
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl"); const logCtl = system.getObject("web.common.oplogCtl");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
var cacheBaseComp = null; var cacheBaseComp = null;
class UserCtl extends CtlBase { class UserCtl extends CtlBase {
...@@ -30,11 +30,11 @@ class UserCtl extends CtlBase { ...@@ -30,11 +30,11 @@ class UserCtl extends CtlBase {
} }
} }
async login(qobj, pobj, req, res) { async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName); var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password); var password = this.trim(pobj.password);
var captchaKey = this.trim(qobj.captchaKey); var captchaKey = this.trim(pobj.captchaKey);
var captchaCode = this.trim(qobj.captchaCode); var captchaCode = this.trim(pobj.captchaCode);
try { try {
...@@ -49,11 +49,22 @@ class UserCtl extends CtlBase { ...@@ -49,11 +49,22 @@ class UserCtl extends CtlBase {
// return system.getResult(null, "图片验证码不一致,请点击重试"); // return system.getResult(null, "图片验证码不一致,请点击重试");
// } // }
var adminUser = await this.service.findById(1); var adminUser = await this.service.findOne({ucname: loginName});
// var adminUser = await this.service.findById(1);
if(!adminUser) {
return system.getResult(null, "用户名或密码错误");
}
var passwdMD5 = md5(password);
if(passwdMD5 != adminUser.passwd) {
return system.getResult(null, "用户名或密码错误");
}
adminUser.lastLoginTime = new Date();
await adminUser.save();
var xggadminsid = uuidv4(); var xggadminsid = uuidv4();
xggadminsid = "3cb49932-fa02-44f0-90db-9f06fe02e5c7"; xggadminsid = "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
await this.redisClient.setWithEx(xggadminsid, JSON.stringify(adminUser), 60 * 60 * 2); await this.redisClient.setWithEx(xggadminsid, JSON.stringify(adminUser), 60 * 60 * 2);
// 处理登录逻辑 // 处理登录逻辑
var result = { var result = {
xggadminsid: xggadminsid, xggadminsid: xggadminsid,
......
...@@ -9,47 +9,137 @@ class BusinessmenCtl extends CtlBase { ...@@ -9,47 +9,137 @@ class BusinessmenCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.businessmenSve = system.getObject("service.business.businessmenSve"); this.businessmenSve = system.getObject("service.business.businessmenSve");
} }
async myPage(pobj, pobj2, req) {
async allPage(pobj, pobj2, req) {
try { try {
var condition = { var condition = {
currentPage: pobj.currentPage, currentPage: pobj.currentPage,
pageSize: pobj.pageSize, pageSize: pobj.pageSize,
userId: req.loginUser.ucid, merchantId: pobj.merchantId,
orderId: pobj.orderId, orderId: this.trim(pobj.orderId),
bstatus: pobj.status,
} }
return await this.businessmenSve.myPage(condition);
return await this.businessmenSve.allPage(condition);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResultFail(500, "接口异常:" + error.message); return system.getResultFail(500, "接口异常:" + error.message);
} }
} }
async invoicePage(pobj, pobj2, req) { async info(pobj, pobj2, req) {
try {
var condition = {
id: pobj.id,
}
return await this.businessmenSve.info(condition);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async sign(pobj, pobj2, req) {
var params = {
id: pobj.id,
taxUpType: pobj.taxUpType,
addValueUpType: pobj.addValueUpType,
costRate: system.y2f(pobj.costRate),
taxRate: system.y2f(pobj.taxRate),
serviceRate: system.y2f(pobj.serviceRate),
signNotes: this.trim(pobj.signNotes),
commonTaxLadder: JSON.stringify(pobj.commonTaxLadder),
commonOtherLadder: JSON.stringify(pobj.commonOtherLadder),
specialTaxLadder: JSON.stringify(pobj.specialTaxLadder),
specialOtherLadder: JSON.stringify(pobj.specialOtherLadder),
invoicecontents: pobj.invoicecontents,
}
try {
return await this.businessmenSve.sign(params);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async signNames(pobj, pobj2, req) {
try {
var condition = {
bstatuses: ["2020"],
}
return await this.businessmenSve.nameList(condition);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async signPage(pobj, pobj2, req) {
try { try {
var condition = { var condition = {
currentPage: pobj.currentPage, currentPage: pobj.currentPage,
pageSize: pobj.pageSize, pageSize: pobj.pageSize,
userId: req.loginUser.ucid, businessmenId: pobj.businessmenId,
orderId: pobj.orderId,
} }
return await this.businessmenSve.invoicePage(condition);
return await this.businessmenSve.signPage(condition);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResultFail(500, "接口异常:" + error.message); return system.getResultFail(500, "接口异常:" + error.message);
} }
} }
async info(pobj, pobj2, req) {
async deliverPage(pobj, pobj2, req) {
try { try {
var condition = { var condition = {
id: pobj.id, currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
orderId: pobj.orderId,
dstatus: pobj.status,
deliverId: "",
} }
return await this.businessmenSve.info(condition);
return await this.businessmenSve.deliverPage(condition);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResultFail(500, "接口异常:" + error.message); return system.getResultFail(500, "接口异常:" + error.message);
} }
} }
// async auditContract(pobj, pobj2, req) {
// try {
// var id = Number(pobj.id);
// var status = Number(pobj.status);
// var notes = this.trim(pobj.notes);
// return await this.service.auditContract(id, status, notes);
// } catch (error) {
// console.log(error);
// return system.getResultFail(500, "接口异常:" + error.message);
// }
// }
// async businessmenSign(pobj, pobj2, req) {
// var params = {
// id: pobj.id,
// commonTaxLadder: this.trim(pobj.commonTaxLadder),
// commonOtherLadder: this.trim(pobj.commonOtherLadder),
// specialTaxLadder: this.trim(pobj.specialTaxLadder),
// specialOtherLadder: this.trim(pobj.specialOtherLadder),
// }
// try {
// return await this.service.businessmenSign(params);
// } catch (error) {
// console.log(error);
// return system.getResultFail(500, "接口异常:" + error.message);
// }
// }
} }
module.exports = BusinessmenCtl; module.exports = BusinessmenCtl;
\ No newline at end of file
...@@ -8,12 +8,12 @@ var svgCaptcha = require('svg-captcha'); ...@@ -8,12 +8,12 @@ var svgCaptcha = require('svg-captcha');
class InvoicecontentCtl extends CtlBase { class InvoicecontentCtl extends CtlBase {
constructor() { constructor() {
super(); super();
this.invoicecontentSev = system.getObject("service.common.invoicecontentSev"); this.invoicecontentSve = system.getObject("service.common.invoicecontentSve");
} }
async list(pobj, pobj2, req) { async list(pobj, pobj2, req) {
try { try {
return await this.invoicecontentSev.list(pobj); return await this.invoicecontentSve.list(pobj);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResultFail(500, "接口错误"); return system.getResultFail(500, "接口错误");
...@@ -22,7 +22,7 @@ class InvoicecontentCtl extends CtlBase { ...@@ -22,7 +22,7 @@ class InvoicecontentCtl extends CtlBase {
async info(pobj, pobj2, req) { async info(pobj, pobj2, req) {
try { try {
return await this.invoicecontentSev.info(pobj); return await this.invoicecontentSve.info(pobj);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResultFail(500, "接口错误"); return system.getResultFail(500, "接口错误");
...@@ -31,7 +31,7 @@ class InvoicecontentCtl extends CtlBase { ...@@ -31,7 +31,7 @@ class InvoicecontentCtl extends CtlBase {
async save(pobj, pobj2, req) { async save(pobj, pobj2, req) {
try { try {
return await this.invoicecontentSev.save(pobj); return await this.invoicecontentSve.save(pobj);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResultFail(500, "接口错误"); return system.getResultFail(500, "接口错误");
...@@ -40,7 +40,7 @@ class InvoicecontentCtl extends CtlBase { ...@@ -40,7 +40,7 @@ class InvoicecontentCtl extends CtlBase {
async del(pobj, pobj2, req) { async del(pobj, pobj2, req) {
try { try {
return await this.invoicecontentSev.del(pobj); return await this.invoicecontentSve.del(pobj);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResultFail(500, "接口错误"); return system.getResultFail(500, "接口错误");
......
...@@ -23,7 +23,7 @@ class MetaCtl extends CtlBase { ...@@ -23,7 +23,7 @@ class MetaCtl extends CtlBase {
["starts-with", "$key", "zc"] ["starts-with", "$key", "zc"]
] ]
}; };
var b = new Buffer.from(JSON.stringify(policyText)); var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64'); var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64 var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64
......
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ManagerCtl extends CtlBase {
constructor() {
super();
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
}
/**
* 交易数据(平台)
* @param {*} pobj
*/
async transData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 交易数据
return await this.invoiceSve.statManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据(平台)
* @param {*} pobj
*/
async businessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 业务数据
return await this.invoiceSve.statBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页交易数据(交付商)
* @param {*} pobj
*/
async delTransData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
delivererId:this.trim(pobj.delivererId)
};
// 交易数据
return await this.invoiceSve.delStatManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据(交付商)
* @param {*} pobj
*/
async delBusinessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
delivererId:this.trim(pobj.delivererId)
};
// 业务数据
return await this.invoiceSve.delStatBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
//业务概览 (平台)
async deliverData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 10,
}
// 业务办理概览
return await this.invoiceSve.statDeliverData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = ManagerCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const logCtl = system.getObject("web.common.oplogCtl");
var cacheBaseComp = null;
class ManagerCtl extends CtlBase {
constructor() {
super();
this.orderSve = system.getObject("service.order.orderSve");
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
}
/**
* 首页交易数据
* @param {*} pobj
*/
async transData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 交易数据
return await this.orderSve.statManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据
* @param {*} pobj
*/
async businessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 业务数据
return await this.orderSve.statBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 10,
}
// 业务办理概览
return await this.orderSve.statDeliverData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = ManagerCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class InvoiceCtl extends CtlBase {
constructor() {
super();
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
}
/**
* 申请发票校验
* @param {*} pobj
*/
async verification(pobj) {
try {
return await this.invoiceSve.apiVerification(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 查询明细(平台)
* @param {*} pobj
*/
async queryInvoice(pobj) {
try {
return await this.invoiceSve.apiQueryInvoiceAdmin(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票明细(交付商)
* @param {*} pobj
*/
async queryInvoiceDeliverer(pobj) {
try {
return await this.invoiceSve.apiQueryInvoiceDeliverer(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票试算接口
* @param {*} pobj
*/
async calcInvoice(pobj) {
try {
return await this.invoiceSve.apiCalcInvoice(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票申请保存
* @param {*} pobj
*/
async saveInvoice(pobj) {
try {
return await this.invoiceSve.apiSaveInvoiceAdm(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 平台审批
* @param {*} pobj
*/
async platformAssignment(pobj){
try {
let nextStatus = this.trim(pobj.nextStatus);
if(nextStatus=="1030"){ //平台交付商分配
pobj.id=this.trim(pobj.id);
pobj.delivererAmount=system.y2f(pobj.delivererAmount);
pobj.merchantId=this.trim(pobj.merchantId);
pobj.delivererId=this.trim(pobj.delivererId);
pobj.delivererName=this.trim(pobj.delivererName);
}else if(nextStatus=="1070"){//平台提交审批
pobj.id=this.trim(pobj.id);
pobj.auditContent=this.trim(pobj.auditContent);
pobj.delivererContent=this.trim(pobj.delivererContent);
pobj.mailAddr=this.trim(pobj.mailAddr);
pobj.mailMobile=this.trim(pobj.mailMobile);
pobj.mailTo=this.trim(pobj.mailTo);
}else if(nextStatus=="1090"){//平台完成
pobj.id=this.trim(pobj.id);
pobj.auditContent=this.trim(pobj.auditContent);
pobj.delivererContent=this.trim(pobj.delivererContent);
pobj.mailAddr=this.trim(pobj.mailAddr);
pobj.mailMobile=this.trim(pobj.mailMobile);
pobj.mailTo=this.trim(pobj.mailTo);
}else if(nextStatus=="1300"){//平台第二次审核不通过
pobj.id=this.trim(pobj.id);
}
return await this.invoiceSve.apiPlatformAssignment(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 交付商审批
* @param {*} pobj
*/
async delivererAssignment(pobj){
try {
let nextStatus = this.trim(pobj.nextStatus);
if(nextStatus=="1050"){ //交付商审批
pobj.id=this.trim(pobj.id);
pobj.invoiceNo=this.trim(pobj.invoiceNo);
pobj.invoiceImg=this.trim(pobj.invoiceImg);
}else if(nextStatus=="1060"){ //交付商提交审批
pobj.id=this.trim(pobj.id);
}else if(nextStatus=="1080"){ //交付商邮寄
pobj.id=this.trim(pobj.id);
pobj.mailNo=this.trim(pobj.mailNo);
}else if(nextStatus=="1040"){ //交付商拒绝处理
pobj.breakReason=this.trim(pobj.breakReason);
}
return await this.invoiceSve.apiDelivererAssignment(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 完税证明
* @param {*} pobj
*/
async txPayment(pobj){
try {
return await this.invoiceSve.apiTxPayment(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 查看完税证明
* @param {*} pobj
*/
async queryTxPayment(pobj){
try {
return await this.invoiceSve.apiQueryTxPayment(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票列表(交付商)
* @param {*} pobj
*/
async delivererInvoices(pobj){
try {
return await this.invoiceSve.apiDelivererInvoices(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票审核列表(交付商)
* @param {*} pobj
*/
async delivererApplyInvoices(pobj){
try {
return await this.invoiceSve.apiDelivererApplyInvoices(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票列表(平台)
* @param {*} pobj
*/
async queryInvoices(pobj){
try {
return await this.invoiceSve.apiQueryInvoices(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 发票申请列表(平台)
* @param {*} pobj
*/
async queryApplyInvoices(pobj){
try {
return await this.invoiceSve.apiQueryApplyInvoices(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 平台更新邮寄号(平台)
* @param {*} pobj
*/
async upEmNo(pobj){
try {
return await this.invoiceSve.apiUpEmNo(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
async redrush(pobj, pobj2, req, res) {
try {
return await this.invoiceSve.apiRedrush(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
}
module.exports = InvoiceCtl;
\ No newline at end of file
...@@ -32,9 +32,10 @@ class MerchantrechargeCtl extends CtlBase { ...@@ -32,9 +32,10 @@ class MerchantrechargeCtl extends CtlBase {
async audit(pobj, pobj2, req) { async audit(pobj, pobj2, req) {
try { try {
var loginUser = req.loginUser;
pobj.opUser = { pobj.opUser = {
"ucid": "111111", "ucid": loginUser.ucid,
"ucname": "ceshi" "ucname": loginUser.ucname
} }
return await this.merchantrechargeSve.audit(pobj); return await this.merchantrechargeSve.audit(pobj);
} catch (e) { } catch (e) {
......
...@@ -9,7 +9,7 @@ class CacheBase { ...@@ -9,7 +9,7 @@ class CacheBase {
this.isdebug = this.isdebug(); this.isdebug = this.isdebug();
} }
isdebug() { isdebug() {
return false; return true;
} }
desc() { desc() {
throw new Error("子类需要定义desc方法,返回缓存描述"); throw new Error("子类需要定义desc方法,返回缓存描述");
......
...@@ -4,7 +4,8 @@ const settings = require("../../../config/settings"); ...@@ -4,7 +4,8 @@ const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase { class ApiAppIdCheckCache extends CacheBase {
constructor() { constructor() {
super(); super();
this.merchantDao = system.getObject("db.merchant.merchantDao");
this.merchantSve = system.getObject("service.merchant.merchantSve");
} }
desc() { desc() {
return "应用中来访访问appid缓存"; return "应用中来访访问appid缓存";
...@@ -13,11 +14,11 @@ class ApiAppIdCheckCache extends CacheBase { ...@@ -13,11 +14,11 @@ class ApiAppIdCheckCache extends CacheBase {
return settings.cacheprefix + "_verify_appid:"; return settings.cacheprefix + "_verify_appid:";
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var item = await this.merchantDao.getItemByAppId(inputkey); var item = await this.merchantSve.getById(inputkey);
if (!item) { if (!item && item.data) {
return null; return null;
} }
return JSON.stringify(item); return JSON.stringify(item.data);
} }
} }
module.exports = ApiAppIdCheckCache; module.exports = ApiAppIdCheckCache;
\ No newline at end of file
...@@ -24,17 +24,6 @@ class Dao { ...@@ -24,17 +24,6 @@ class Dao {
}); });
} }
} }
async bulkCreate(objs){
if(!objs || objs.length == 0) {
return;
}
for(var obj of objs) {
if(!obj.id) {
obj.id = await this.redisClient.genrateId(this.modelName);
}
}
return await this.model.bulkCreate(objs);
}
static getModelName(ClassObj) { static getModelName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase(); return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase();
} }
...@@ -222,8 +211,8 @@ class Dao { ...@@ -222,8 +211,8 @@ class Dao {
return await this.model.findAndCountAll(tmpWhere); return await this.model.findAndCountAll(tmpWhere);
} }
async findOne(obj, t) { async findOne(obj, t) {
var params = {"where": obj}; var params = { "where": obj };
if(t) { if (t) {
params.transaction = t; params.transaction = t;
} }
return this.model.findOne(params); return this.model.findOne(params);
...@@ -231,5 +220,72 @@ class Dao { ...@@ -231,5 +220,72 @@ class Dao {
async findById(oid) { async findById(oid) {
return this.model.findById(oid); return this.model.findById(oid);
} }
async setListCodeName(list, field) {
if (!list) {
return;
}
for (item of list) {
await this.setRowCodeName(item, field);
}
}
async setRowCodeName(item, field) {
if (!item || !field) {
return;
}
var map = this[field + "Map"] || {};
if (!item) {
return;
}
item[field + "Name"] = map[item[field] || ""] || "";
}
async getRowCodeName(item, field) {
if (!item || !field) {
return "";
}
var map = this[field + "Map"] || {};
if (!item) {
return "";
}
return map[item[field] || ""] || "";
}
async getById(id, attrs) {
if (!id) {
return null;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where id = :id ";
var list = await this.customQuery(sql, {
id: id
});
return list && list.length > 0 ? list[0] : null;
}
async getListByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where id IN (:ids) ";
return await this.customQuery(sql, {
ids: ids
}) || [];
}
async getMapByIds(ids, attrs) {
var result = {};
var list = await this.getListByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
} }
module.exports = Dao; module.exports = Dao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class PushapiDao extends Dao {
constructor() {
super(Dao.getModelName(PushapiDao));
}
}
module.exports = PushapiDao;
\ No newline at end of file
const system=require("../../../system"); const system = require("../../../system");
const Dao=require("../../dao.base"); const Dao = require("../../dao.base");
class MerchantpushlogDao extends Dao{ class PushlogDao extends Dao {
constructor(){ constructor() {
super(Dao.getModelName(MerchantpushlogDao)); super(Dao.getModelName(PushlogDao));
} }
} }
module.exports=MerchantpushlogDao; module.exports = PushlogDao;
// var u=new UserDao(); // var u=new UserDao();
// var roledao=system.getObject("db.roleDao"); // var roledao=system.getObject("db.roleDao");
// (async ()=>{ // (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}}); // var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}}); // var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role); // console.log(role);
// for(var i=0;i<users.length;i++){ // for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]); // await users[i].setRoles([role]);
// console.log(i); // console.log(i);
// } // }
// //
// })(); // })();
\ No newline at end of file
...@@ -11,6 +11,11 @@ module.exports = (db, DataTypes) => { ...@@ -11,6 +11,11 @@ module.exports = (db, DataTypes) => {
type:DataTypes.STRING, type:DataTypes.STRING,
allowNull: false, allowNull: false,
}, },
lastLoginTime: {
type:DataTypes.DATE,
allowNull: true,
},
passwd: DataTypes.STRING,
},{ },{
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
...@@ -18,7 +23,7 @@ module.exports = (db, DataTypes) => { ...@@ -18,7 +23,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true, freezeTableName: true,
// freezeTableName: true, // freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_user', tableName: 'xgg_admin_user',
validate: { validate: {
}, },
indexes:[ indexes:[
......
...@@ -2,58 +2,89 @@ const system = require("../../../system"); ...@@ -2,58 +2,89 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("merchanttradeprocess", { return db.define("businessmen", {
order_id: DataTypes.BIGINT,
merchant_id: DataTypes.BIGINT, merchant_id: DataTypes.BIGINT,
invoice_id: DataTypes.BIGINT, orderNo: DataTypes.STRING(64),
invoiceNo: DataTypes.STRING(64), channelOrderNo: DataTypes.STRING(64),
amtType: DataTypes.STRING, status: DataTypes.STRING(20),//状态 00待处理 10出执照 20已刻章 30银行开户 40税务报道 50已邮寄 60已签约
amt: DataTypes.BIGINT, legalName: DataTypes.STRING(20),
frozen_amt: DataTypes.BIGINT, legalMobile: DataTypes.STRING(20),
available_amt: DataTypes.BIGINT, name: DataTypes.STRING(100),
busiType: DataTypes.STRING, creditCode: DataTypes.STRING(100),
complete: { businessPlace: DataTypes.STRING(100),
businessScope: DataTypes.STRING(500),
regDate: DataTypes.DATE,
businessImg: DataTypes.STRING(300),
gongzhang: DataTypes.STRING(300),
caiwuzhang: DataTypes.STRING(300),
fapiaozhang: DataTypes.STRING(300),
hetongzhang: DataTypes.STRING(300),
farenzhang: DataTypes.STRING(300),
isBank: {
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
defaultValue: false defaultValue: false
}, },
bankName: DataTypes.STRING(50),
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(100),
bankImg: DataTypes.STRING(300),
caImg: DataTypes.STRING(300),
taxRegDay: DataTypes.DATE,
taxOrg: DataTypes.STRING(100),
courierNo: DataTypes.STRING(100),
courierImg: DataTypes.STRING(100),
addedValueRate: DataTypes.DOUBLE(11, 2),
supertaxRate: DataTypes.DOUBLE(11, 2),
commonTaxLadder: DataTypes.STRING(1000),
commonOtherLadder: DataTypes.STRING(1000),
specialTaxLadder: DataTypes.STRING(1000),
specialOtherLadder: DataTypes.STRING(1000),
contractStartData: DataTypes.DATE,
contractEndData: DataTypes.DATE,
contract: DataTypes.STRING(300),//个体户合同
notes: DataTypes.STRING,//备注
opNotes: DataTypes.STRING,//操作备注
}, { }, {
paranoid: true, //假的删除 paranoid: true, //假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_merchant_trade_process', tableName: 'xgg_businessmen',
validate: {}, validate: {},
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ]
}); });
} }
\ No newline at end of file
...@@ -2,60 +2,63 @@ const system = require("../../../system"); ...@@ -2,60 +2,63 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("merchantpush", { return db.define("order", {
merchant_id: DataTypes.BIGINT, merchant_id: DataTypes.BIGINT,
merchangeUpdate: DataTypes.STRING(200), orderNo: DataTypes.STRING(64),
orderUpdate: DataTypes.STRING(200), channelOrderNo: DataTypes.STRING(64),
yichuzhizhao: DataTypes.STRING(200), legalName: DataTypes.STRING(20),
yikezhang: DataTypes.STRING(200), legalMobile: DataTypes.STRING(20),
yikaihu: DataTypes.STRING(200), legalImg: DataTypes.STRING(300),
yishuiwubaodao: DataTypes.STRING(200), idcard: DataTypes.STRING(20),
yiyouji: DataTypes.STRING(200), idcardFront: DataTypes.STRING(300),
fapiaoshenhe: DataTypes.STRING(200), idcardBack: DataTypes.STRING(300),
fapiaokaiju: DataTypes.STRING(200), bankNo: DataTypes.STRING(30),
fapiaoyouji: DataTypes.STRING(200), bank: DataTypes.STRING(200),
fapiaowanshui: DataTypes.STRING(200), names: DataTypes.STRING(300),
chongzhishenhe: DataTypes.STRING(200), businessScope: DataTypes.STRING(500),
capital: DataTypes.STRING(100),
status: DataTypes.STRING(20),//订单状态 00待处理 10出执照 20已刻章 30银行开户 40税务报道 50已邮寄
notes: DataTypes.STRING,//备注
opNotes: DataTypes.STRING,//操作备注
}, { }, {
paranoid: true, //假的删除 paranoid: true, //假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_merchant_push', tableName: 'xgg_order',
validate: {}, validate: {},
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ]
}); });
} }
\ No newline at end of file
...@@ -2,18 +2,13 @@ const system = require("../../../system"); ...@@ -2,18 +2,13 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("merchanttrade", { return db.define("pushapi", {
merchant_id: DataTypes.BIGINT, merchant_id: DataTypes.BIGINT,
invoice_id: DataTypes.BIGINT, rechargeAudit: DataTypes.STRING(200),
invoiceNo: DataTypes.STRING(64), orderStatus: DataTypes.STRING(200),
invoiceApplyNo: DataTypes.STRING(64), businessmenSign: DataTypes.STRING(200),
recharge_id: DataTypes.BIGINT, invoiceStatus: DataTypes.STRING(200),
outTradeNo: DataTypes.STRING(64), invoiceTax: DataTypes.STRING(200),
amt: DataTypes.BIGINT,
balance: DataTypes.BIGINT,
type: DataTypes.INTEGER,
businessType: DataTypes.INTEGER,
outTradeNo: DataTypes.STRING(64),
}, { }, {
paranoid: true, //假的删除 paranoid: true, //假的删除
underscored: true, underscored: true,
...@@ -21,7 +16,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,7 +16,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_merchant_trade', tableName: 'xgg_push_api',
validate: {}, validate: {},
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
......
...@@ -2,9 +2,10 @@ const system = require("../../../system"); ...@@ -2,9 +2,10 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("merchantpushlog", { return db.define("pushlog", {
merchant_id: DataTypes.BIGINT, merchant_id: DataTypes.STRING,
dataType: DataTypes.INTEGER,
dataId: DataTypes.STRING,
api: DataTypes.STRING(200), api: DataTypes.STRING(200),
params: DataTypes.STRING(5000), params: DataTypes.STRING(5000),
rs: DataTypes.STRING(200), rs: DataTypes.STRING(200),
...@@ -20,7 +21,7 @@ module.exports = (db, DataTypes) => { ...@@ -20,7 +21,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_merchant_push_log', tableName: 'xgg_push_log',
validate: {}, validate: {},
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
......
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class BusinessmenService extends ServiceBase {
constructor() {
super();
}
async allPage(params) {
var rs = await this.callms("order", "businessmenPage", params);
if (rs.status != 0 || !rs.data || !rs.data.rows) {
return rs;
}
await this.setMerchant(rs.data.rows);
this.transField(rs.data.rows);
return rs;
}
async signPage(params) {
var rs = await this.callms("order", "businessmenSignPage", params);
if (rs.status != 0 || !rs.data || !rs.data.rows) {
return rs;
}
this.transField(rs.data.rows);
return rs;
}
async deliverPage(params) {
var rs = await this.callms("order", "businessmenDeliverPage", params);
if (rs.status != 0 || !rs.data || !rs.data.rows) {
return rs;
}
this.transField(rs.data.rows);
return rs;
}
async info(params) {
var rs = await this.callms("order", "businessmenInfo", params);
await this.setMerchant([rs.data]);
this.transField([rs.data]);
return rs;
}
async sign(params) {
return await this.callms("order", "businessmenSign", params);
}
async nameList(params) {
return await this.callms("order", "businessmenNameList", params);
}
async queryBusinessmen(params) {
var condition = {
merchantId: this.trim(params.merchant_id || params.merchantId),
channelOrderNo: this.trim(params.channelOrderNo),
}
var rs = await this.callms("order", "businessmenByChannelOrderNo", condition);
if (rs.status != 0 && !rs.data) {
return rs;
}
var businessmen = rs.data;
if(!businessmen) {
return system.getResult(null, "个体户不存在");
}
var dto = {};
dto.orderNo = this.trim(businessmen.orderNo);
dto.channelOrderNo = this.trim(businessmen.channelOrderNo);
dto.status = this.trim(businessmen.gstatus);
dto.legalName = this.trim(businessmen.legalName);
dto.legalMobile = this.trim(businessmen.legalMobile);
dto.legalIdCard = this.trim(businessmen.legalIdCard);
dto.name = this.trim(businessmen.name);
dto.creditCode = this.trim(businessmen.creditCode);
dto.businessPlace = this.trim(businessmen.businessPlace);
dto.businessScope = this.trim(businessmen.businessScope);
dto.regDate = this.trim(businessmen.regDate);
dto.businessImg = this.trim(businessmen.businessImg);
dto.gongzhang = this.trim(businessmen.gongzhang);
dto.caiwuzhang = this.trim(businessmen.caiwuzhang);
dto.fapiaozhang = this.trim(businessmen.fapiaozhang);
dto.hetongzhang = this.trim(businessmen.hetongzhang);
dto.farenzhang = this.trim(businessmen.farenzhang);
dto.isBank = this.trim(businessmen.isBank);
dto.bankName = this.trim(businessmen.bankName);
dto.bankNo = this.trim(businessmen.bankNo);
dto.bank = this.trim(businessmen.bank);
dto.bankImg = this.trim(businessmen.bankImg);
dto.caImg = this.trim(businessmen.caImg);
dto.taxRegDay = this.trim(businessmen.taxRegDay);
dto.taxOrg = this.trim(businessmen.taxOrg);
dto.courierNo = this.trim(businessmen.courierNo);
dto.courierImg = this.trim(businessmen.courierImg);
dto.addedValueRate = this.trim(businessmen.addedValueRate);
dto.supertaxRate = this.trim(businessmen.supertaxRate);
dto.commonTaxLadder = this.trim(businessmen.commonTaxLadder);
dto.commonOtherLadder = this.trim(businessmen.commonOtherLadder);
dto.specialTaxLadder = this.trim(businessmen.specialTaxLadder);
dto.specialOtherLadder = this.trim(businessmen.specialOtherLadder);
dto.contractStartData = this.trim(businessmen.contractStartData);
dto.contractEndData = this.trim(businessmen.contractEndData);
dto.contract = this.trim(businessmen.contract);
dto.opNotes = this.trim(businessmen.opNotes);
dto.taxUpType = this.trim(businessmen.taxUpType);
dto.costRate = this.trim(businessmen.costRate);
dto.signNotes = this.trim(businessmen.signNotes);
dto.invoiceContents = this.trim(businessmen.invoiceContents);
return system.getResultSuccess(dto);
}
async putContract(params) {
var merchantId = params.merchant_id || params.merchantId;
var condition = {
merchantId: merchantId,
channelOrderNo: params.channelOrderNo,
contractStartData: params.contractStartData,
contractEndData: params.contractEndData,
contract: params.contract,
};
var rs = await this.callms("order", "addBusinessmenContract", condition);
return rs;
}
async setMerchant(rows) {
if (!rows || rows.length == 0) {
return;
}
var merchantIds = [];
for (var row of rows) {
merchantIds.push(row.merchant_id);
}
var mmap = await this.callms("merchant", "getMapByIds", {
ids: merchantIds,
attrs: "id, name"
});
mmap = mmap.data || {};
for (var row of rows) {
row.merchant = mmap[row.merchant_id] || {};
}
}
transField(rows) {
if (!rows) {
return;
}
for (var row of rows) {
row.costRate = system.f2y(row.costRate);
row.taxRate = system.f2y(row.taxRate);
row.serviceRate = system.f2y(row.serviceRate);
this.parseJsonField(row, ["commonTaxLadder", "commonOtherLadder", "specialTaxLadder", "specialOtherLadder"]);
}
}
parseJsonField(row, fields) {
if (!row || !fields || fields.length == 0) {
return;
}
for (var f of fields) {
if (!f || !row[f]) {
continue;
}
try {
row[f] = JSON.parse(row[f]);
} catch (error) {
console.log(error);
}
}
}
}
module.exports = BusinessmenService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DeliverService extends ServiceBase {
constructor() {
super();
}
async queryCourierTrace(params) {
var result = {
merchantId: "11111202101312",
courierNo: "222222222",
courierStatus: "配送中",
courierTime: "2019-10-01 10:10:10",
desc: "到达xxxxx",
applyNo: "100001",
}
return system.getResultSuccess(result);
}
}
module.exports = DeliverService;
\ No newline at end of file
...@@ -6,6 +6,71 @@ class MerchantService extends ServiceBase { ...@@ -6,6 +6,71 @@ class MerchantService extends ServiceBase {
super(); super();
} }
//查询商户
async apiQueryMerchant(params) {
try {
return await this.queryMerchant(params);
} catch (error) {
return system.getResultFail(-1);
}
}
// ----------------------------------- 以上为api --------------------------------------
async queryMerchant(params) {
try {
var p = {
id : params.merchant_id || params.merchantId,
options: {
title: true,
address:true,
}
}
var rs = await this.callms("merchant", "getById", p);
if(rs.status != 0 || !rs.data) {
return system.getResult(null, "商户不存在");
}
let merchant ={};
merchant.name=rs.data.name;
merchant.taxType=rs.data.taxType;
merchant.contactName=rs.data.contactName;
merchant.contactMobile=rs.data.contactMobile;
merchant.contactEmail=rs.data.contactEmail;
merchant.invoiceValid=rs.data.invoiceValid;
merchant.mustPay=rs.data.mustPay;
merchant.status=rs.data.status;
merchant.ownerName=rs.data.ownerName;
merchant.ownerMobile=rs.data.ownerMobile;
merchant.created_at=rs.data.created_at;
merchant.titleList=[];
for (let item of rs.data.titleList) {
let temp={};
temp.titleNo=item.titleNo;
temp.taxNo=item.taxNo;
temp.invoiceAddr=item.invoiceAddr;
temp.invoiceMobile=item.invoiceMobile;
temp.accountName=item.accountName;
temp.accountPublic=item.accountName;
merchant.titleList.push(temp);
}
merchant.addressList=[];
for (let item of rs.data.addressList) {
let temp={};
temp.addressNo=item.addressNo;
temp.mailAddr=item.mailAddr;
temp.mailTo=item.mailTo;
temp.mailMobile=item.mailMobile;
merchant.addressList.push(temp);
}
return system.getResultSuccess(merchant);
} catch (error) {
return system.getResultFail(-1);
}
}
async nameList() { async nameList() {
var rs = await this.callms("merchant", "nameList", {}); var rs = await this.callms("merchant", "nameList", {});
return rs; return rs;
...@@ -16,6 +81,11 @@ class MerchantService extends ServiceBase { ...@@ -16,6 +81,11 @@ class MerchantService extends ServiceBase {
return rs; return rs;
} }
async getById(id) {
var rs = await this.callms("merchant", "getById", {id: id});
return rs;
}
async add(params) { async add(params) {
var merchant = {}; var merchant = {};
var title = {}; var title = {};
...@@ -92,11 +162,11 @@ class MerchantService extends ServiceBase { ...@@ -92,11 +162,11 @@ class MerchantService extends ServiceBase {
async audit(params) { async audit(params) {
var mobile = this.trim(params.mobile); var mobile = this.trim(params.mobile);
var ucname = this.trim(params.ucname); var ucname = this.trim(params.mobile);
params.status = "10"; params.status = "10";
params.ucname = ucname; params.ucname = ucname;
params.ucid = ucname + "_id TODO"; params.ucid = ucid;
// TODO 调用平台,创建商户用户 // TODO 调用平台,创建商户用户
var auditRs = await this.callms("merchant", "auditMerchant", params); var auditRs = await this.callms("merchant", "auditMerchant", params);
return auditRs; return auditRs;
......
...@@ -12,6 +12,22 @@ class MerchantaccountService extends ServiceBase{ ...@@ -12,6 +12,22 @@ class MerchantaccountService extends ServiceBase{
return res; return res;
} }
async infoByMerchantId(params) {
var merchantId = params.merchantId || params.merchant_id;
var res = await this.callms("merchant", "merchantAccountInfoByMerchantId", {merchantId : merchantId});
if(res.status != 0 || !res.data) {
return res;
}
var info = res.data;
var dto = {
"merchant_id": info.merchant_id,
"banlance": info.banlance
};
return system.getResultSuccess(dto);
}
async trans(rows) { async trans(rows) {
if (!rows) { if (!rows) {
return; return;
......
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")
class MerchantrechargeService extends ServiceBase{ class MerchantrechargeService extends ServiceBase {
constructor(){ constructor() {
super(); super();
this.pushapiSve = system.getObject("service.push.pushapiSve");
} }
async add(params) { async add(params) {
// var res = await this.callms("merchant", "merchantRechargePage", params); //
var recharge = {};
recharge.merchantId = params.merchant_id || params.merchantId;
recharge.amt = Number(params.amt);
recharge.outTradeNo = this.trim(params.outTradeNo);
recharge.voucher = this.trim(params.voucher);
if (recharge.amt <= 0) {
return system.getResult(null, "充值金额不能小于0");
}
return await this.callms("merchant", "merchantRechargeAdd", params);
// await this.transfield(res.data.rows); // await this.transfield(res.data.rows);
// return res; // return res;
} }
...@@ -20,6 +33,9 @@ class MerchantrechargeService extends ServiceBase{ ...@@ -20,6 +33,9 @@ class MerchantrechargeService extends ServiceBase{
async audit(params) { async audit(params) {
var res = await this.callms("merchant", "merchantRechargeAudit", params); var res = await this.callms("merchant", "merchantRechargeAudit", params);
if (res.status == 0) {
this.pushAudit(params);
}
return res; return res;
} }
...@@ -29,6 +45,34 @@ class MerchantrechargeService extends ServiceBase{ ...@@ -29,6 +45,34 @@ class MerchantrechargeService extends ServiceBase{
return res; return res;
} }
async pushAudit(params) {
try {
var recharge = await this.callms("merchant", "merchantRechargeInfo", params);
recharge = recharge.data;
// 查商户加密信息
var merchant = await this.callms("merchant", "secretById", {
id: recharge.merchant_id
});
merchant = merchant.data;
// 推送审核信息
await this.pushapiSve.push({
merchantId: merchant.id,
appKey: merchant.appSecret,
dataType: 0,
dataId: merchant.id,
field: "rechargeAudit",
params: {
merchantId: merchant.id,
outTradeNo: recharge.outTradeNo,
status: recharge.status,
remark: this.trim(recharge.remark)
},
});
} catch (error) {
console.log(error);
}
}
async transfield(rows) { async transfield(rows) {
if (!rows) { if (!rows) {
return; return;
...@@ -41,10 +85,10 @@ class MerchantrechargeService extends ServiceBase{ ...@@ -41,10 +85,10 @@ class MerchantrechargeService extends ServiceBase{
} }
} }
} }
module.exports=MerchantrechargeService; module.exports = MerchantrechargeService;
// var task=new UserService(); // var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){ // task.getUserStatisticGroupByApp().then(function(result){
// console.log((result)); // console.log((result));
// }).catch(function(e){ // }).catch(function(e){
// console.log(e); // console.log(e);
// }); // });
\ No newline at end of file
...@@ -7,7 +7,6 @@ class MerchanttitleService extends ServiceBase{ ...@@ -7,7 +7,6 @@ class MerchanttitleService extends ServiceBase{
} }
async merchantTitleList(params){ async merchantTitleList(params){
console.log("天助我也");
return await this.callms("merchant","merchantTitleList",params); return await this.callms("merchant","merchantTitleList",params);
} }
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class PushapiService extends ServiceBase {
constructor() {
super("push", ServiceBase.getDaoName(PushapiService));
this.pushlogDao = system.getObject("db.push.pushlogDao");
}
/**
*
* @param {} options 参数如下
* @param merchantId 商户id
* @param appKey 商户加密key
* @param dataType 数据类型
* @param dataId 数据id
* @param field 推送字段,通过字段去查找推送地址
* @param params 推送参数
*/
async push(options) {
var api = await this.findById(options.merchantId);
if (!api) {
console.log("api不存在[" + JSON.stringify(options) + "]");
return;
}
var apiurl = api[options.field];
if (!apiurl) {
console.log("api地址不存在[" + JSON.stringify(options) + "]");
return;
}
var log;
try {
var params = options.params;
params.times_tamp = new Date().getTime();
var signData = await this.createSign(params, options.appKey);
params.sign = signData.data;
params.requestid = this.getUUID();
log = await this.pushlogDao.create({
dataType: Number(options.dataType),
dataId: options.dataId,
api: apiurl,
params: JSON.stringify(options.params),
rs: "",
success: 0,
});
try {
console.log(JSON.stringify(params));
var rtn = await this.restS.execPost(params, apiurl);
var returnValue = 0;
if (rtn.stdout) {
var result = JSON.parse(rtn.stdout);
if (result.code == "success") {
log.success = 1;
log.rs = trn.stdout;
await log.save();
}
}
} catch (error) {
log.success = 0;
log.rs = error.message;
await log.save();
}
} catch (error) {
if (log) {
log.success = 0;
log.rs = error.message;
await log.save();
}
console.log(error.stack, JSON.stringify(options), "--------------------------------- push exception ---------------------------------");
}
}
}
module.exports = PushapiService;
\ No newline at end of file
const system=require("../../../system"); const system = require("../../../system");
const ServiceBase=require("../../sve.base") const ServiceBase = require("../../sve.base")
const settings=require("../../../../config/settings") const settings = require("../../../../config/settings")
class MerchantService extends ServiceBase{ class PushlogService extends ServiceBase {
constructor(){ constructor() {
super("merchant", ServiceBase.getDaoName(MerchantService)); super("push", ServiceBase.getDaoName(PushlogService));
} }
} }
module.exports=MerchantService; module.exports = PushlogService;
// var task=new UserService(); // var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){ // task.getUserStatisticGroupByApp().then(function(result){
// console.log((result)); // console.log((result));
// }).catch(function(e){ // }).catch(function(e){
// console.log(e); // console.log(e);
// }); // });
\ No newline at end of file
const system = require("../system"); const system = require("../system");
const moment = require('moment') const moment = require('moment')
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5"); const md5 = require("MD5");
class ServiceBase { class ServiceBase {
constructor(gname, daoName) { constructor(gname, daoName) {
...@@ -268,5 +269,12 @@ class ServiceBase { ...@@ -268,5 +269,12 @@ class ServiceBase {
} }
return o.toString().trim(); return o.toString().trim();
} }
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
} }
module.exports = ServiceBase; module.exports = ServiceBase;
\ No newline at end of file
const system = require("../system");
const moment = require('moment')
const settings = require("../../config/settings");
const md5 = require("MD5");
class ServiceBase {
constructor() {
this.restClient = system.getObject("util.restClient");
this.micro = system.microsetting();
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "返回值签名验证失败");
}
return system.getResultSuccess();
}
/**
* 创建签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async createSign(params, app_key) {
if (!params) {
return system.getResultFail(-310, "请求参数为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResultFail(-330, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResultFail(-350, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
return system.getResultSuccess(resultTmpSign);
}
/**
* 验证参数信息不能为空
* @param {*} params 验证的参数
* @param {*} verifyParamsCount 需要验证参数的数量,如至少验证3个,则传入3
* @param {*} columnList 需要过滤掉的验证参数列表,格式:[]
*/
async verifyParams(params, verifyParamsCount, columnList) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!columnList) {
columnList = [];
}
var keys = Object.keys(params);
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
if (keys.length < verifyParamsCount) {
return system.getResult(null, "请求参数不完整");
}
var tResult = system.getResultSuccess();
for (let k = 0; k < keys.length; k++) {
const tKeyValue = keys[k];
if (columnList.length == 0 || columnList.indexOf(tKeyValue) < 0) {
if (!tKeyValue) {
tResult = system.getResult(null, k + "参数不能为空");
break;
}
} //白名单为空或不在白名单中,则需要验证不能为空
}
return tResult;
}
async apiCallWithAk(url, params) {
var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
var acck = acckapp.accessKey;
//按照访问token
var restResult = await this.restClient.execPostWithAK(params, url, acck);
if (restResult) {
if (restResult.status == 0) {
var resultRtn = restResult.data;
return resultRtn;
} else {
await this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
return null;
}
}
return null;
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); //长度62,到yz长度为长36
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('');
}
handleDate(row, fields, pattern, addHours) {
pattern = pattern || "YYYY-MM-DD HH:mm";
if (!row) {
return;
}
for (var field of fields) {
if (row[field]) {
if (addHours) {
row[field] = moment(row[field]).add(addHours, "hours").format(pattern);
} else {
row[field] = moment(row[field]).format(pattern);
}
}
}
}
addWhereTime(where, field, begin, end) {
if (!begin && !end) {
return;
}
if (begin && end) {
where[field] = {
[this.db.Op.between]: [begin, end]
};
} else if (begin && !end) {
where[field] = {
[this.db.Op.gte]: begin
};
} else if (!begin && end) {
where[field] = {
[this.db.Op.lte]: end
};
}
}
async callms(sveName, apiName, params) {
var reqUrl = this.micro[sveName];
if (!reqUrl) {
return system.getResult(null, "未找到【" + sveName + "】服务,请检查settings文件是否存在");
}
if (!apiName) {
return system.getResult(null, "apiName不能为空");
}
try {
var params = {
"action_process": "xgg-admin",
"action_type": apiName,
"action_body": params || {},
}
var rs = await this.restClient.execPost(params, reqUrl);
if (rs && rs.stdout) {
return JSON.parse(rs.stdout);
}
return system.getResult(null, rs);
} catch (error) {
console.log(error);
this.logCtl.error({
optitle: "微服务请求失败",
op: "sveName = " + sveName + "; apiName = " + apiName,
content: "params = " + JSON.stringify(params),
clientIp: ""
});
return system.getResult(null, error.message);
}
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = ServiceBase;
\ No newline at end of file
...@@ -168,23 +168,35 @@ class System { ...@@ -168,23 +168,35 @@ class System {
static microsetting() { static microsetting() {
var path = "/api/op/action/springboard"; var path = "/api/op/action/springboard";
if (settings.env == "dev") { if (settings.env == "dev") {
var domain = "http://192.168.18.125"; var domain = "http://192.168.18.237";
// var domain = "http://127.0.0.1";
return { return {
// 公共服务
common: domain + ":3102" + path, common: domain + ":3102" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务
merchant: domain + ":3101" + path, merchant: domain + ":3101" + path,
order:domain + ":3103" + path, // merchant: "http://127.0.0.1:3101" + path,
// order: "http://39.97.116.129:8336" + path,
// 订单服务
order: domain +":3103" + path,
// order: "http://127.0.0.1:3103" + path,
// 发票服务
// invoice: domain + ":3105" + path,
invoice: "http://127.0.0.1:3105" + path,
invoice: "" + path,
payment: "" + path, payment: "" + path,
} }
} else { } else {
var odomain = "http://39.107.51.68"
return { return {
common: "http://39.106.189.242:8333" + path, common: odomain + ":8333" + path,
merchant: "http://39.106.189.242:8335" + path, merchant: odomain + ":8335" + path,
order: "http://39.97.116.129:8336" + path, order: odomain + ":8336" + path,
invoice: "http://xggsveinvoice.gongsibao.com" + path, invoice: odomain + ":8338" + path,
payment: "http://39.97.116.129:8337" + path, payment: odomain + ":8337" + path,
} }
} }
} }
......
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