Commit dcafa940 by 王昆

gsb

parent 3b26f526
/xgg-deliver/node_modules/ /bpo-stat/node_modules/
.idea/* .idea/*
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
}
/**
* 接口跳转
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springboard(pobj, qobj, req) {
console.log(pobj, pobj.action_type, !pobj.action_type, "--------------------------------------this is xgg admin ----------------------");
if (!pobj.action_process) {
return system.getResult(null, "action_process参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "action_type参数不能为空");
}
var result = null;
switch (pobj.action_process) {
case "sijibao"://司机宝
result = await this.sijibaoOpActionProcess(pobj.action_process, pobj.action_type, pobj.action_body);
break;
default:
result = system.getResult(null, "action_process参数错误");
break;
}
return result;
}
async sijibaoOpActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
exam() {
return `<pre><pre/>`;
}
classDesc() {
return {
groupName: "op",
groupDesc: "元数据服务包",
name: "ActionAPI",
desc: "此类是对外提供接口服务",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: `<pre><pre/>`,
methodName: "springboard",
paramdescs: [
{
paramDesc: "请求的行为,传递如:sijibao",
paramName: "action_process",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型,详情见方法中的描述",
paramName: "action_type",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "请求体",
paramName: "action_body",
paramType: "json",
defaultValue: null,
}
],
rtnTypeDesc: `<pre><pre/>`,
rtnType: `<pre><pre/>`
}
];
}
}
module.exports = ActionAPI;
\ No newline at end of file
...@@ -4,48 +4,28 @@ const querystring = require('querystring'); ...@@ -4,48 +4,28 @@ 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 MerchanttradeprocessCtl extends CtlBase { class UserCtl extends CtlBase {
constructor() { constructor() {
super("merchant", CtlBase.getServiceName(MerchanttradeprocessCtl)); super("auth", CtlBase.getServiceName(UserCtl));
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.merchant.merchantSve");
} }
async processList(pobj, pobj2, req) { async login(pobj, pobj2, req, res) {
try { var loginName = this.trim(pobj.loginName);
var condition = { var password = this.trim(pobj.password);
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantId: pobj.merchantId,
busiType: pobj.busiType,
invoiceApplyNo: this.trim(pobj.invoiceApplyNo),
createdBegin: this.trim(pobj.createdBegin),
createdEnd: this.trim(pobj.createdEnd),
}
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
var page = await this.service.pageByCondition(condition); try {
return system.getResultSuccess(page); return system.getResultSuccess(1);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return system.getResultFail(500, "接口异常:" + error.message); return system.getResultFail(500, "接口异常:" + error.message);
} }
} }
// try {
// } catch (error) {
// return system.getResultFail(500, "接口异常:" + error.message);
// }
} }
module.exports = MerchanttradeprocessCtl; module.exports = UserCtl;
\ No newline at end of file \ No newline at end of file
...@@ -4,8 +4,6 @@ const settings = require("../../../config/settings"); ...@@ -4,8 +4,6 @@ const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase { class ApiAppIdCheckCache extends CacheBase {
constructor() { constructor() {
super(); super();
this.merchantSve = system.getObject("service.merchant.merchantSve");
} }
desc() { desc() {
return "应用中来访访问appid缓存"; return "应用中来访访问appid缓存";
...@@ -14,11 +12,12 @@ class ApiAppIdCheckCache extends CacheBase { ...@@ -14,11 +12,12 @@ 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.merchantSve.getById(inputkey); // var item = await this.merchantSve.getById(inputkey);
if (!item && item.data) { // if (!item && item.data) {
return null; // return null;
} // }
return JSON.stringify(item.data); // return JSON.stringify(item.data);
return {};
} }
} }
module.exports = ApiAppIdCheckCache; module.exports = ApiAppIdCheckCache;
\ No newline at end of file
...@@ -7,8 +7,8 @@ var ENVINPUT = { ...@@ -7,8 +7,8 @@ var ENVINPUT = {
REDIS_HOST: process.env.REDIS_HOST, REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT, REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD, REDIS_PWD: process.env.REDIS_PWD,
DB_NAME: process.env.XGGDELIVER_DB_NAME, DB_NAME: process.env.BPOSTAT_DB_NAME,
REDIS_DB: process.env.XGGDELIVER_REDIS_DB, REDIS_DB: process.env.BPOSTAT_REDIS_DB,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev" APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
}; };
var settings = { var settings = {
......
{ {
"name": "xgg-deliver", "name": "bpo-stat",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
......
{ {
"name": "xgg-deliver", "name": "bpo-stat",
"version": "1.0.0", "version": "1.0.0",
"description": "h5framework", "description": "h5framework",
"main": "main.js", "main": "main.js",
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
17. xggweb release-v17.x.x 17. xggweb release-v17.x.x
18. xggpjb release-v18.x.x 18. xggpjb release-v18.x.x
19. xggdeliver release-v19.x.x 19. xggdeliver release-v19.x.x
19. bpostat release-v20.x.x
后续号端请继续补充 后续号端请继续补充
查看自己项目号段到达的数字,执行git tag | grep v【号段前缀】 查看自己项目号段到达的数字,执行git tag | grep v【号段前缀】
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.merchantSve = system.getObject("service.merchant.merchantSve");
this.orderSve = system.getObject("service.order.orderSve");
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
this.courierSve = system.getObject("service.common.courierSve");
}
/**
* 接口跳转
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springboard(pobj, qobj, req) {
console.log(pobj, pobj.action_type, !pobj.action_type, "--------------------------------------this is xgg admin ----------------------");
if (!pobj.action_process) {
return system.getResult(null, "action_process参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "action_type参数不能为空");
}
var result = null;
switch (pobj.action_process) {
case "sijibao"://司机宝
result = await this.sijibaoOpActionProcess(pobj.action_process, pobj.action_type, pobj.action_body);
break;
default:
result = system.getResult(null, "action_process参数错误");
break;
}
return result;
}
async sijibaoOpActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "queryMerchant"://查询商户
opResult = await this.merchantSve.apiQueryMerchant(action_body);
break;
case "addOrder"://添加订单
opResult = await this.orderSve.addOrder(action_body);
break;
case "putOrder"://修改订单
opResult = await this.orderSve.putOrder(action_body);
break;
case "queryOrder"://订单查询
opResult = await this.orderSve.queryOrder(action_body);
break;
case "orderClose"://订单查询
opResult = await this.orderSve.orderClose(action_body);
break;
case "putContract"://个体工商户合同接收接口
opResult = await this.businessmenSve.putContract(action_body);
break;
case "queryBusinessmen"://个体工商户信息查询接口
opResult = await this.businessmenSve.queryBusinessmen(action_body);
break;
case "rechargeApplication":// 商户充值申请
opResult = await this.merchantrechargeSve.add(action_body);
break;
case "queryMerchantAccount":// 商户充值申请
opResult = await this.merchantaccountSve.infoByMerchantId(action_body);
break;
case "calcInvoice": // 发票试算接口
opResult = await this.invoiceSve.apiCalcInvoice(action_body);
break;
case "saveInvoice": // 发票提交接口
opResult = await this.invoiceSve.apiSaveInvoice(action_body);
break;
case "cancelInvoice": // 发票提交接口
opResult = await this.invoiceSve.apiCancelInvoice(action_body);
break;
case "queryInvoice": // 发票提交接口
opResult = await this.invoiceSve.apiQueryInvoice(action_body);
break;
case "queryTaxInvoice":
opResult = await this.invoiceSve.apiQueryTaxInvoice(action_body);
break;
case "queryCourierTrace":
opResult = await this.courierSve.queryCourierTrace(action_body);
break;
// // 以下接口为推送测试
// case "testRechargeAudit":// 发票信息查询接口
// opResult = await this.merchantrechargeSve.apiAudit(action_body);
// break;
// case "testInvoiceAudit": // 发票审核
// opResult = await this.invoiceSve.testInvoiceAudit(action_body);
// break;
// case "testKaipiao": // 发票状态已开具
// opResult = await this.invoiceSve.testKaipiao(action_body);
// break;
// case "testToemail": // 发票已邮寄
// opResult = await this.invoiceSve.testToemail(action_body);
// break;
// case "testTaxCertificate": // 发票已邮寄
// opResult = await this.invoiceSve.testToemail(action_body);
// break;
// wk
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
exam() {
return `<pre>
### queryMerchant:查询商户
功能描述:
查询公司宝开通的商户基本信息,包含商户基本信息、开票信息、邮寄地址、客户经理等信息,如果业务不需要,可不调用
请求参数:
{
"action_process": "sijibao",
"action_type": "queryMerchant",
"action_body": {
"sign":"CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp: long : 必填 : 时间戳
返回值:
{
"status": 0,
"msg": "success",
"data": {
"name": "司机宝",
"taxType": "00",
"contactName": "杨庆菊",
"contactMobile": "18810277728",
"contactEmail": "qjyang@gongsibao.com",
"invoiceValid": 1,
"mustPay": 1,
"status": "1000",
"ownerName": "客户经理姓名",
"ownerMobile": "客户经理电话",
"created_at": "2019-10-01 09:04", // 添加时间
"titleList": [
{
"titleNo": "13661908986000576",
"taxNo": "11111111",
"invoiceAddr": "222222",
"invoiceMobile": "333333",
"accountName": "4444444",
"accountPublic": "555555555",
}
],
"addressList": [
{
"addressNo": "12085607321000472",
"mailAddr": "111111111",
"mailTo": "2222222222",
"mailMobile": "333333333333333",
}
]
},
"requestid": "8cbd498f9d1441b1812ecaa2653933f4"
}
返回值说明:
name : String :商户名称
taxType : STRING :纳税人类型 00一般纳税人 10小规模纳税人
contactName : String :联系人姓名
contactMobile: String :联系人手机
contactEmail : String :开票申请校验 0否 1是
invoiceValid : int :联系人邮箱
mustPay : int :校验订单支付 0否 1是
ownerName : String :客户经理姓名
ownerMobile : String :客户经理电话
status : String :商户状态 00待审核 10待签约 90签约完成
titleList : Array :开票抬头列表
titleNo : String :抬头编码
taxNo : String :纳税人识别号
invoiceAddr : String :开票地址
invoiceMobile: String :开票电话
accountName : String :开户名称
accountPublic: String :对公账户
addressList : Array :开票地址列表
addressNo : String :邮寄地址编码
mailAddr : String :邮寄地址
mailTo : String :收件人
mailMobile : String :收件电话
### addOrder:添加订单
功能描述:
提交/修改 需要注册的个体工商户信息(待处理状态可进行修改,其他状态会修改失败)
请求参数:
{
"action_process": "sijibao",
"action_type": "addOrder",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248,
"channelOrderNo": "test0002",
"legalName": "测试法人修改",
"legalMobile": "15010929368",
"legalImg": "http://sss1.jpg",
"idcard": "222403",
"idcardFront": "http://sss2.jpg",
"idcardBack": "http://sss3.jpg",
"bankNo": "33333990209874819",
"bank": "北京市地球村",
"names": "名称1,名称2,名称3",
"capital": "1000万",
"domicileId": "11064622752480055",
"businessScopeId": "12219252215000155",
"businessScope": "国内物流信息服务;装卸搬运服务;...",
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
channelOrderNo : String : 必填 :渠道单号
legalName : String : 必填 :法人姓名
legalMobile : String : 必填 :法人电话
legalImg : String : 非必填 :法人电话
idcard : String : 必填 :法人身份证
idcardFront : String : 必填 :身份证正面照片
idcardBack : String : 必填 :身份证反面照片
bankNo : String : 必填 :银行卡号
bank : String : 必填 :开户行
bankImg : String : 非必填 :银行卡照片
names : String : 必填 :个体户名称,多个格式为:name1,name2,name3
capital : String : 必填 :注册资本
domicileId : String : 必填 :注册地编码
businessscopeId : String : 必填 :经营范围编码
businesssScope : String : 必填 :经营范围详情
返回值:
添加返回值:
{
"status": 0,
"msg": "success",
"data": {
"orderNo": "sijibao201909191148sJXGu"
},
"requestid": "9952e339512740ebb6e5df72a4c09895"
}
修改返回值:
{
"status": 0,
"msg": "success",
"data": null,
"requestid": "e8f31dacc07c4764b8fd4f9955622385"
}
返回值说明:
data : String :订单号
### queryOrder:订单查询
功能描述:
查询以前添加的订单或者查询某个订单的状态
请求参数:
{
"action_process": "sijibao",
"action_type": "queryOrder",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248,
"channelOrderNo": "test0001"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
channelOrderNo : String : 必填 :渠道订单号
返回值:
{
"status": 0,
"msg": "success",
"data": {
"orderNo": "sijibao2019091816016FXaj",
"channelOrderNo": "test0001",
"legalName": "测试法人修改",
"legalMobile": "15010929368",
"legalImg": "http://sss1.jpg",
"idcard": "341221198808328500",
"idcardFront": "http://sss2.jpg",
"idcardBack": "http://sss3.jpg",
"bankNo": "33333990209874819",
"bank": "北京市地球村",
"bankImg": "银行卡照片"
"names": "名称1,名称2,名称3",
"businessScope": "科技服务行业",
"capital": "1000万",
"status": "10",
"opNotes": null,
"domicileId": "11064622752480055",
"businessScopeId": "12219252215000155",
"businesssScope": "国内物流信息服务;装卸搬运服务;..."
},
"requestid": "d108d7fa93984886a3a659114e188a75"
}
返回值说明:
orderNo : String :订单号
channelOrderNo : String :渠道单号
legalName : String :法人姓名
legalMobile : String :法人电话
legalImg : String :法人证件照
idcard : String :法人身份证
idcardFront : String :身份证正面照片
idcardBack : String :身份证反面照片
bankNo : String :银行卡号
bank : String :开户行
bankImg : String :银行卡照片
names : String :个体户名称
businessScope : String :经营范围
capital : String :注册资本
status : String :订单状态 1000未付款, 1010订单关闭, 1030待处理, 1050执照办理中, 1060已出执照, 1070刻章办理中,
1080已刻章, 1090银行开户中, 1100银行卡已开户, 1110税务报道中, 1120已税务报道, 1170已完成
opNotes : String :操作备注
domicileId : String :注册地编码
businessscopeId : String :经营范围编码
businesssScope : String :经营范围详情
### orderClose:订单关闭接口
功能描述:
如果客户订单提交错误,可使用该接口,关闭订单的操作,只允许再 1000未付款 状态下关闭,如果其他状态下关闭,请联系业务办理人员进行沟通
请求参数:
{
"action_process": "sijibao",
"action_type": "orderClose",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248,
"channelOrderNo": "test0001",
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
channelOrderNo : String : 必填 :渠道订单号
返回值:
{
"status": 0,
"msg": "success",
"data": 1,
"requestid": "b14a73f9d6d84fc7be1e62feaf8316a0"
}
### putContract:个体工商户合同接收接口
功能描述:
个体工商户注册成功后,传入该个体工商户和商户之间的合同信息,才可以做到发票合规
请求参数:
{
"action_process": "sijibao",
"action_type": "putContract",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248,
"channelOrderNo": "test0001",
"contract": "http://ttt.jpg",
"contractStartData": "2019-01-10",
"contractEndData": "2020-01-10"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
channelOrderNo : String : 必填 :渠道订单号
contract : String : 必填 :合同地址
contractStartData : String : 必填 :合同开始时间(YYYY-MM-DD)
contractEndData : String : 必填 :合同结束时间(YYYY-MM-DD)
返回值:
{
"status": 0,
"msg": "success",
"data": null,
"requestid": "b14a73f9d6d84fc7be1e62feaf8316a0"
}
### queryMerchantAccount: 商户账户查询
功能描述:
查询商户再公司宝系统中的余额
请求参数:
{
"action_process": "sijibao",
"action_type": "queryMerchantAccount",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
返回值:
{
"status": 0,
"msg": "success",
"data": {
"merchant_id": "sijibao2019091816016FXaj", // 商户ID
"banlance": 2222222 // 可用余额
},
"requestid": "305bcbe9b7f444e38c6155033e6cb66c"
}
返回值说明:
merchant_id : String :商户ID
banlance : bigint :可用余额(分)
### queryBusinessmen:个体工商户信息查询接口
功能描述
查询订单办理的个体工商户信息,包括执照、刻章、银行卡户、税务报道、邮寄、个税/增值税/附加税梯度等信息。
请求参数:
{
"action_process": "sijibao",
"action_type": "queryBusinessmen",
"action_body": {
"sign": "CBCE83769118A4D8906F097ECA558ACF",
"times_tamp": 1568713248,
"channelOrderNo": "test0001"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
channelOrderNo : String : 必填 :渠道订单号
返回值:
{
"status": 0,
"msg": "success",
"data": {
"orderNo": "sijibao2019091816016FXaj",
"channelOrderNo": "test0001",
"status": "1050",
"legalName": "测试法人修改",
"legalMobile": "15010929368",
"legalIdCard": "1111110"
"name": "",
"creditCode": "",
"businessPlace": "",
"businessScope": "",
"regDate": null,
"businessImg": "",
"gongzhang": "",
"caiwuzhang": "",
"fapiaozhang": "",
"hetongzhang": "",
"farenzhang": "",
"isBank": 0,
"bankName": "",
"bankNo": "",
"bank": "",
"bankImg": "",
"caImg": "",
"taxRegDay": null,
"taxOrg": "",
"courierNo": "",
"courierImg": "",
"addedValueRate": 0,
"supertaxRate": 0,
"commonTaxLadder": "",
"commonOtherLadder": "",
"specialTaxLadder": "",
"specialOtherLadder": "",
"contractStartData": "2019-01-10",
"contractEndData": "2020-01-10",
"contract": "http://ttt.jpg",
"opNotes": null,
"taxUpType": "10",
"costRate": "5.55",
"signNotes": "xxx",
"invoiceContents": "",
},
"requestid": "305bcbe9b7f444e38c6155033e6cb66c"
}
返回值说明:
orderNo : String :订单号
channelOrderNo : String :渠道订单号
status : String :状态 1030已出执照, 1050已刻章, 1070银行已开户, 1090已税务报道, 1100待签约 1120已签约
legalName : String :法人姓名
legalMobile : String :法人电话
legalIdCard : String :法人身份证号
name : String :个体工商户名称
creditCode : String :统一社会信用代码
businessPlace : String :经营场所
businessScope : String :经营范围
regDate : String :注册日期(YYYY-MM-DD)
businessImg : String :执照照片
gongzhang : String :公章
caiwuzhang : String :财务章
fapiaozhang : String :发票章
hetongzhang : String :合同章
farenzhang : String :法人章
isBank : int :是否开户 0否 1是
bankName : String :账户名称
bankNo : String :账户号
bank : String :开户行
bankImg : String :账户信息
caImg : String :CA照片
taxRegDay : String :税务登记日
taxOrg : String :税务机构名称
courierNo : String :快递单号
courierImg : String :快递交接单图片
addedValueRate : Double :增值税率
supertaxRate : Double :附加税率
commonTaxLadder : String :普票个税阶梯
commonOtherLadder : String :普票增值税、附加税阶梯
specialTaxLadder : String :专票个税阶梯
specialOtherLadder: String :专票增值税、附加税阶梯
contract : String :个体户合同
contractStartData : String :合同开始时间(YYYY-MM-DD)
contractEndData : String :合同结束时间(YYYY-MM-DD)
opNotes : String :操作备注
taxUpType : String :个税累计类型 10无 20按月累计 30按年累计
costRate : Double :核定成本费用率
signNotes : Double :签约备注
invoiceContents : String :开票内容(多个以英文逗号分割)
### rechargeApplication:商户充值申请接口
功能描述:
商户线下充值到公司宝后,提交充值申请接口,由公司宝财务审核通过后,金额加入到账户可用余额中
请求参数:
{
"action_process": "sijibao",
"action_type": "rechargeApplication",
"action_body": {
"amt": 100000,
"outTradeNo":"1",
"times_tamp": 1568713248,
"sign": "D4393F17C96CDA582C1EE5FF0053671E",
"voucher":"https://www.xxx.com/1.png"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
amt : bigint : 必填 :充值金额(分为单位)
outTradeNo : String : 必填 :充值流水号(商户下不能重复)
voucher : String : 必填 :充值凭证图片地址
返回值:
{
"status": 0,
"msg": "success",
"requestid": "305bcbe9b7f444e38c6155033e6cb66c"
}
### calcInvoice:发票试算接口
功能描述:
商户使用试算接口,计算出当前开票所需要缴纳的个税、增值税、附加税、服务费等信息,用于开票前的展示,如果商户业务不需要展示,忽略此接口
请求参数:
{
"action_process": "sijibao",
"action_type": "calcInvoice",
"action_body": {
"invoiceList": [
{
"businessmenCreditCode":"1111",
"invoiceTime": "2019-09-19",
"invoiceAmt":440000000,
"type": 1
}
],
"times_tamp": 1568713248,
"sign": "D4393F17C96CDA582C1EE5FF0053671E"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
invoiceList : Array : 必填 :发票试算列表,最多不超过10个,不参与签名
businessmenCreditCode : String : 必填 :个体工商户统一社会信用代码
invoiceTime : String : 必填 :开票时间(YYYY-MM-DD)
invoiceAmt : bigint : 必填 :开票金额(分)
type : int : 必填 :开票类型 0普票 1专票
返回值:
{
"status": 0,
"msg": "success",
"data": [{
"creditCode" : "1",
"code": 1,
"msg": "success",
"incomeTax": "20042494",
"addedValueTax": "28042996",
"specialTax": "2720171",
"serviceTax": "9372000",
"warning": "年度总开票金额已达到4400000",
"monthAmt": 440000
},
{
"creditCode" : "2",
"code": 1,
"msg": "success",
"incomeTax": "20042494",
"addedValueTax": "28042996",
"specialTax": "2720171",
"serviceTax": "9372000",
"warning": "年度总开票金额已达到4400000",
"monthAmt": 440000
},
],
"requestid": "363e0391a43c4dedb5656623d1bcd540"
}
返回值说明:
"data" : Array : 发票处理结果
"creditCode" : int : 个体户同意社会信用代码
"code" : int : 该个体工商户试算状态 1成功 -1失败
"msg" : String : 试算结果提示,错误时返回错误信息
"incomeTax" : bigint : 试算个税结果(分)
"addedValueTax" : bigint : 试算增值税结果(分)
"specialTax" : bigint : 试算附加费结果(分)
"serviceTax" : bigint : 试算服务费结果(分)
"warning" : String : 警告信息,该字段不为空时,在前端显示,
"monthAmt" : bigint : 该个体工商户在开票时间的月分中,已经申请开票的总金额
### saveInvoice:申请开票接口
功能描述:
商户为个体工商户申请开发票,批量开,一次不超过10条发票记录
请求参数:
{
"action_process": "sijibao",
"action_type": "saveInvoice",
"action_body": {
"invoiceList": [
{
"businessmenCreditCode":"1111",
"invoiceTime": "2019-09-19",
"applyNo": "100001",
"invoiceAmt":330000,
"settleImg": "https://bpohhr.gongsibao.com",
"type": 1
},
{
"businessmenCreditCode":"2222",
"applyNo": "100002",
"invoiceTime": "2019-09-19",
"invoiceAmt":200000,
"settleImg": "https://bpohhr.gongsibao.com",
"type": 1
}
],
"times_tamp": 1568713248,
"sign": "D4393F17C96CDA582C1EE5FF0053671E"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
invoiceList : Array : 必填 :开票申请列表,最多不超过10个,不参与签名
businessmenCreditCode : String : 必填 :个体工商户统一社会信用代码
applyNo : String : 必填 :开票申请编码(商户内唯一)
invoiceTime : String : 必填 :开票时间(YYYY-MM-DD)
invoiceAmt : bigint : 必填 :开票金额(分)
settleImg: String : 必填 :结算单图片地址
type : int : 必填 :开票类型 0普票 1专票
返回值:
{
"status": 0,
"msg": "success",
"data": [{
"creditCode": "1",
"code": 1,
"msg": "success"
},
{
"creditCode": "2",
"code": -1,
"msg": "该个体户有发票处于审核中,审核通过后才能继续提交"
}
],
"requestid": "a39a364d83c14664b8e3399387fa847d"
}
返回值说明:
data : Array : 发票处理结果
"creditCode" : Object : 个体工商户统一社会信用代码为key的对象
"code" : int : 该个体工商户试算状态 1成功 -1失败
"msg" : String : 试算结果提示,错误时返回错误信息
### cancelInvoice:发票申请撤回接口
功能描述:
商户可再开票申请之后,公司宝财务审核之前进行发票撤回,其他情况联系客户经理
请求参数:
{
"action_process": "sijibao",
"action_type": "cancelInvoice",
"action_body": {
"times_tamp": 1568713248,
"applyNo": "100001"
}
}
请求参数说明:
sign : String : 必填 :签名
times_tamp : long : 必填 :时间戳
applyNo : String : 必填 :开票申请编号
返回值:
{
"status": 0,
"msg": "success",
"data": "",
"requestid": "090bde8c5bb74b9d8c6b97beabf39161"
}
### queryInvoice:发票查询接口
功能描述:
查询某次开票申请的信息,包括发票状态、开票信息、邮寄信息、完税证明等信息
请求参数:
{
"action_process": "sijibao",
"action_type": "queryInvoice",
"action_body": {
"times_tamp": 1568713248,
"applyNo": "100001"
}
}
请求参数说明:
sign : String :签名
times_tamp : long :时间戳
applyNo : String :开票申请编号
返回值:
{
"status": 0,
"msg": "success",
"data": {
merchant_id // 商户id
applyNo // 发票申请编号
status // 发票状态 00开票申请 10已撤回 20审核驳回 30审核通过 40已开票 50已邮寄
auditRemark // 审核备注
invoiceNo // 发票编号
invoiceTime // 开票时间
invoiceImg // 发票照片
payVoucher // 支付凭证
courierNo // 快递单号
courierImg // 快递交接单图片
taxNo // 完税批号
taxTime // 完税时间
taxVoucher // 完税证明(图片地址)
},
"requestid": "090bde8c5bb74b9d8c6b97beabf39161"
}
返回值说明:
merchantId : bigint : 商户id
applyNo : String : 发票申请编号
status : String : 发票状态 00开票申请 10已撤回 20审核驳回 30审核通过 40已开票 50已邮寄
auditRemark : String : 审核备注
invoiceNo : String : 发票编号
invoiceTime : String : 开票时间(YYYY-MM-DD)
invoiceImg : String : 发票照片
payVoucher : String : 支付凭证
courierNo : String : 快递单号
courierImg : String : 快递交接单图片
complateTax : int : 是否完税 0否 1是
taxNo : String : 完税批号
taxTime : String : 完税时间
taxVoucher : String : 完税证明(图片地址)
### queryTaxInvoice:完税证明查询
功能描述:
查询发票完税证明信息
请求参数:
{
"action_process": "sijibao",
"action_type": "queryTaxInvoice",
"action_body": {
"times_tamp": 1568713248,
"applyNo": "100001"
}
}
请求参数说明:
sign : String :签名
times_tamp : long :时间戳
applyNo : String :开票申请编号
返回值:
{
merchant_id // 商户id
applyNo // 发票申请编号
complateTax // 是否完税 0否 1是
taxNo // 完税批号
taxTime // 完税时间
taxVoucher // 完税证明(图片地址)
}
返回值说明:
merchant_id : bigint : 商户id
applyNo : String : 发票申请编号
complateTax : int : 是否完税 0否 1是
taxNo : String : 完税批号
taxTime : String : 完税时间
taxVoucher : String : 完税证明(图片地址)
### queryCourierTrace:查询邮寄进度
功能描述:
查询邮寄进度
请求参数:
{
"action_process": "sijibao",
"action_type": "queryTaxInvoice",
"action_body": {
"times_tamp": 1568713248,
"applyNo": "100001"
}
}
请求参数说明:
sign : String :签名
times_tamp : long :时间戳
applyNo : String :开票申请编号
返回值:
{
"status": 0,
"msg": "success",
"data": {
merchantId: "", // 商户id
applyNo: "", // 开票申请编号,
courierNo: "xx" // 快递单号
courierStatus // 邮寄状态
courierTime // 时间
desc // 当前状态描述信息
},
"requestid": "090bde8c5bb74b9d8c6b97beabf39161"
}
返回值说明:
merchant_id : bigint : 商户id
applyNo : String : 发票申请编号
courierNo : String : 快递单号
courierStatus : String : 邮寄状态
courierTime : String : 时间(YYYY-MM-DD HH:mm:ss)
desc : String : 当前状态描述信息
------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------
通知回调商户接口:需要商户提供以下接收的回调地址,回调方式:POST
1. 充值审核
2. 订单状态变更推送
3. 个体户合同审核结果推送
4. 个体户签约结果推送
5. 发票状态变更推送
6. 发票完税证明推送
### 充值审核
功能描述:商户提交发票申请后,公司宝财务在审核该申请之后,通知商户审核状态
推送参数:
{
merchantId : String :商户id
outTradeNo : String :充值流水号,
status : int :审核状态 00待审核 10已入账 20审核失败
remark : String :审核备注
}
### 订单状态变更推送
功能描述:订单状态发生变更后,公司宝将状态变更内容推送给商户
推送参数:
{
merchantId : String : 商户id
status : String : 订单状态 1050执照办理中, 1060已出执照, 1070刻章办理中, 1080已刻章, 1090银行开户中, 1100银行卡已开户, 1110税务报道中, 1120已税务报道, 1170已完成
channelOrderNo : String : 渠道订单号
// ----- 出执照推送数据 -----
name : String : 个体工商户名称
creditCode : String : 统一社会信用代码
businessPlace : String : 经营场所
businessScope : String : 经营范围
regDate : String : 注册日期 (YYYY-MM-DD)
businessImg : String : 执照照片
orderNo : String : 订单号
legalName : String : 法人姓名
legalMobile : String : 法人电话
// ----- 刻章推送数据 -----
gongzhang : String : 公章
caiwuzhang : String : 财务章
businessImg : String : 执照照片
fapiaozhang : String : 发票章
hetongzhang : String : 合同章
farenzhang : String : 法人章
// ----- 开户推送数据 -----
isBank : int : 是否开户
bankName : String : 账户名称
bankNo : String : 账户号
bank : String : 开户行
bankImg : String : 账户信息
// ----- 税务报到推送数据 -----
caImg : String : CA照片
taxRegDay : String : 税务登记日
taxOrg : String : 税务机构名称
// ----- 邮寄推送数据 -----
courierNo : String : 快递单号
courierImg : String : 快递交接单图片
}
### 个体户合同审核结果推送
推送参数:
{
merchantId : String : 商户id
channelOrderNo : String : 渠道订单号
status : String : 审核状态 10成功 20失败
}
6. 个体户签约结果推送
推送参数
{
merchantId : String :商户id
channelOrderNo : String :渠道订单号
creditCode : String :统一社会信用代码
commonTaxLadder : String :普票个税阶梯
commonOtherLadder : String :普票增值税、附加税阶梯
specialTaxLadder : String :专票个税阶梯
specialOtherLadder: String :专票增值税、附加税阶梯
taxUpType : String :个税累计类型 10无 20按月累计 30按年累计
costRate : Double :核定成本费用率
signNotes : Double :签约备注
invoiceContents : String :开票内容(多个以英文逗号分割)
}
platformAssignment
7.发票状态变更推送
功能描述:发票状态变更后,公司宝将发票状态变更内容推送给商户
推送参数:
{
merchantId : bigint :商户id
applyNo : String :发票申请编号
status : String :发票状态 0090开票申请 1010审核驳回 1030审核通过 1050已开票 1090已完成
// ----- 发票审核数据字段 -----
auditRemark : String :审核备注
// ----- 发票开具数据字段 -----
invoiceNo : String :发票编号
invoiceTime : String :开票时间
invoiceImg : String :发票照片
payVoucher : String :支付凭证
// ----- 发票邮件数据字段 -----
courierNo : String :快递单号
courierImg : String :快递交接单图片
}
8.发票完税证明推送
功能描述:公司宝客户经理再处理完税证明后,公司宝将完税证明信息推送给商户
推送参数:
{
merchant_id : bigint :商户id
applyNo : String :发票申请编号
complateTax : String :是否完税 0否 1是
taxNo : String :完税批号
taxTime : String :完税时间
taxVoucher : String :完税证明(图片地址)
}
<pre/>`;
}
classDesc() {
return {
groupName: "op",
groupDesc: "元数据服务包",
name: "ActionAPI",
desc: "此类是对外提供接口服务",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: `<pre>请求地址:http://sj.app.com:3002/api/op/action/springboard
请求时需要在请求头中增加app_id参数信息,app_id由平台提供给调用方
方法中的签名只有action_body中的参数参与,按照参数的首字母进行ASCII码进行正序排列后进行签名,action_body中的参数为空或参数为list或为json的不参与签名
签名字符串示例:times_tamp=1568713248&key=XXXX,key为平台提供的密钥,对字符串进行
后进行大写转换
方法中需要传递的action_type列表有:
queryMerchant:查询商户
addOrder/putOrder:添加订单/修改订单
queryOrder:订单查询
orderClose:订单关闭接口
putContract:个体工商户合同接收接口
queryMerchantAccount: 商户账户查询
queryBusinessmen:个体工商户信息查询接口
rechargeApplication:商户充值申请接口
calcInvoice:发票试算接口
saveInvoice:申请开票接口
cancelInvoice:发票申请撤回接口
queryInvoice:发票查询接口
queryTaxInvoice:完税证明查询
queryCourierTrace:查询邮寄进度
<pre/>`,
methodName: "springboard",
paramdescs: [
{
paramDesc: "请求的行为,传递如:sijibao",
paramName: "action_process",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型,详情见方法中的描述",
paramName: "action_type",
paramType: "string",
defaultValue: null,
},
{
paramDesc: "业务操作类型的参数,action_body必须传递的参数有,times_tamp(时间戳,类型int)、sign(签名,类型string),其余的为业务需要的参数",
paramName: "action_body",
paramType: "json",
defaultValue: null,
}
],
rtnTypeDesc: `<pre>
status: 返回状态,
msg: 返回信息描述,验证有误则为错误提示,
data: 返回数据信息,
requestid: 返回的处理此次请求的凭证
status状态码如下:
0 业务请求处理成功
-1 请求参数验证失败
1200 访问appid失效
1300 签名验证失败
<pre/>`,
rtnType: `<pre>
{
"status": 0,
"msg": "success",
"data": {},
"requestid": "8cbd498f9d1441b1812ecaa2653933f4"
}
<pre/>`
}
];
}
}
module.exports = ActionAPI;
\ 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("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
var cacheBaseComp = null;
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
this.redisClient = system.getObject("util.redisClient");
this.captchaSve = system.getObject("service.common.captchaSve");
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async smsCode(qobj, pobj, req) {
var mobile = this.trim(qobj.mobile);
try {
if (!/^1[23456789]\d{9}$/.test(mobile)) {
return system.getResult(null, "手机号码格式不正确");
}
// TODO 发送短信验证码
return system.getResultSuccess("发送成功");
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password);
var captchaKey = this.trim(pobj.captchaKey);
var captchaCode = this.trim(pobj.captchaCode);
try {
var vrs = await this.captchaSve.valid({
key: captchaKey,
code: captchaCode,
});
if (vrs.status !== 0) {
// return vrs;
}
// 查用户
var loginrs = await this.platformUtils.login(loginName, password);
if(loginrs.status !== 0) {
return loginrs;
}
var user = await this.service.authByCode(loginrs.data.opencode);
req.session.user = user;
var xggadminsid = await this.setLogin(user);
return system.getResultSuccess(xggadminsid);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async setLogin(user) {
var xggadminsid = uuidv4();
xggadminsid = "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
await this.redisClient.setWithEx(xggadminsid, JSON.stringify(user), 60 * 60);
return xggadminsid;
}
async forgetPassword(qobj, pobj, req, res) {
var mobile = this.trim(pobj.mobile);
var vcode = this.trim(pobj.vcode);
var password = this.trim(qobj.password);
try {
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser);
}
async getMenu(qobj, pobj, req) {
var menu = [{
"name": "首页",
"path": "/",
"submenu": []
},
{
"name": "商户中心",
"path": "/merchants",
"submenu": [{
"name": "客户管理",
"team": [{
"name": "商户信息",
"path": "/merchants/businessInformation"
},
{
"name": "签约信息",
"path": "/merchants/contractInformation"
},
{
"name": "地址信息",
"path": "/merchants/addressInformation"
},
{
"name": "抬头信息",
"path": "/merchants/lookUpInformation"
}
]
}]
},
{
"name": "业务中心",
"path": "/trading",
"submenu": [{
"name": "订单管理",
"team": [{
"name": "订单信息",
"path": "/trading/orderInformation"
}]
},
{
"name": "个体户管理",
"team": [{
"name": "用户信息",
"path": "/trading/userInformation"
},
{
"name": "用户签约",
"path": "/trading/usersSignUp"
}
]
},
{
"name": "发票管理",
"team": [{
"name": "发票申请",
"path": "/trading/invoiceApplyFor"
},
{
"name": "发票管理",
"path": "/trading/invoiceManagement"
}
]
}
]
},
{
"name": "财务中心",
"path": "/financial",
"submenu": [{
"name": "资金管理",
"team": [{
"name": "资金账户",
"path": "/financial/capitalAccount"
},
{
"name": "充值申请",
"path": "/financial/topUpApplication"
},
{
"name": "资金交易",
"path": "/financial/cashTransactions"
},
{
"name": "资金流水",
"path": "/financial/capitalFlows"
}
]
}]
},
{
"name": "数据中心",
"path": "/information",
"submenu": [{
"name": "暂无",
"team": [{
"name": "暂无",
"path": ""
}]
}]
},
{
"name": "系统中心",
"path": "/system",
"submenu": [{
"name": "信息维护",
"team": [{
"name": "注册地信息",
"path": "/system/registered"
},
{
"name": "经营范围信息",
"path": "/system/businessScope"
},
{
"name": "交付商信息",
"path": "/system/delivery"
},
{
"name": "发票内容信息",
"path": "/system/invoiceContent"
}
]
}]
}
]
return system.getResultSuccess(menu);
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(req) {
var opencode = req.query.code;
var user = await this.service.authByCode(opencode);
if (user) {
req.session.user = user;
} else {
req.session.user = null;
}
//缓存opencode,方便本应用跳转到其它应用
// /auth?code=xxxxx,缓存没有意义,如果需要跳转到其它应用,需要调用
//平台开放的登录方法,返回 <待跳转的目标地址>/auth?code=xxxxx
//this.cacheManager["OpenCodeCache"].cacheOpenCode(user.id,opencode);
return user;
}
async navSysSetting(pobj, qobj, req) {
//开始远程登录,返回code
var jumpobj = await this.service.navSysSetting(req.session.user);
if (jumpobj) {
return system.getResultSuccess(jumpobj);
}
return system.getResultFail();
}
async loginUser(qobj, pobj, req) {
return super.findById(req.session.user.id);
}
async initNewInstance(queryobj, req) {
var rtn = {};
rtn.roles = [];
if (rtn) {
return system.getResultSuccess(rtn);
}
return system.getResultFail();
}
async checkLogin(gobj, qobj, req) {
//当前如果缓存中存在user,还是要检查当前user所在的域名,如果不和来访一致,则退出重新登录
if (req.session.user) {
return system.getResultSuccess(req.session.user);
} else {
req.session.user = null;
return system.getResult(null, "用户未登录", req);
}
}
async exit(pobj, qobj, req) {
req.session.user = null;
req.session.destroy();
return system.getResultSuccess({
"env": settings.env
});
}
}
module.exports = UserCtl;
\ 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");
var cacheBaseComp = null;
class BusinessmenCtl extends CtlBase {
constructor() {
super();
this.businessmenSve = system.getObject("service.business.businessmenSve");
}
async allPage(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantId: pobj.merchantId,
orderId: this.trim(pobj.orderId),
bstatus: pobj.status,
}
return await this.businessmenSve.allPage(condition);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
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 {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
businessmenId: pobj.businessmenId,
}
return await this.businessmenSve.signPage(condition);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async deliverPage(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
orderId: pobj.orderId,
dstatus: pobj.status,
deliverId: "",
}
return await this.businessmenSve.deliverPage(condition);
} catch (error) {
console.log(error);
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;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class BusinessscopeCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.businessscopeSve = system.getObject("service.common.businessscopeSve");
}
async page(pobj, pobj2, req) {
try {
return await this.businessscopeSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.businessscopeSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.businessscopeSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.businessscopeSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async byDomicile(pobj, pobj2, req) {
try {
return await this.businessscopeSve.byDomicile(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = BusinessscopeCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class CaptchaCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.captchaSve = system.getObject("service.common.captchaSve");
}
async captcha(pobj, pobj2, req) {
try {
return await this.captchaSve.captcha(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = CaptchaCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class DeliverCtl extends CtlBase {
constructor() {
super();
this.deliverSve = system.getObject("service.common.deliverSve");
}
async all(pobj, pobj2, req) {
try {
return await this.deliverSve.all(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async page(pobj, pobj2, req) {
try {
return await this.deliverSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.deliverSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.deliverSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.deliverSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = DeliverCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class DomicileCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.domicileSve = system.getObject("service.common.domicileSve");
}
async nameList(pobj, pobj2, req) {
try {
return await this.domicileSve.nameList(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async all(pobj, pobj2, req) {
try {
return await this.domicileSve.tree(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async page(pobj, pobj2, req) {
try {
return await this.domicileSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.domicileSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.domicileSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.domicileSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = DomicileCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class InvoicecontentCtl extends CtlBase {
constructor() {
super();
this.invoicecontentSve = system.getObject("service.common.invoicecontentSve");
}
async list(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.list(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = InvoicecontentCtl;
\ No newline at end of file
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 verificationAndCalculation(pobj) {
try {
return await this.invoiceSve.apiVerificationAndCalculation(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 calculationValueAddedTax(pobj) {
try {
return await this.invoiceSve.calculationValueAddedTax(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
/**
* 计算发票附加税
* @param {*} pobj
*/
async calculationAdditionalTax(pobj) {
try {
return await this.invoiceSve.calculationAdditionalTax(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}`);
}
}
/**
* 发票红冲列表
* @param {*} pobj
* @param {*} pobj2
* @param {*} req
* @param {*} res
*/
async redRushList(pobj,pobj2,req,res){
try {
return await this.invoiceSve.apiRedrushList(pobj);
} catch (error) {
return system.getResultFail(500, `接口错误 错误信息 ${error}`);
}
}
}
module.exports = InvoiceCtl;
\ 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");
var cacheBaseComp = null;
class MerchantCtl extends CtlBase {
constructor() {
super();
this.merchantSve = system.getObject("service.merchant.merchantSve");
}
async nameList(pobj, pobj2, req) {
try {
return await this.merchantSve.nameList();
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async infoPage(pobj, pobj2, req) {
try {
this.doTimeCondition(pobj, ["createdBegin", "createdEnd"]);
return await this.merchantSve.infoPage(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async add(pobj, pobj2, req) {
try {
return await this.merchantSve.add(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async upd(pobj, pobj2, req) {
try {
return await this.merchantSve.upd(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async audit(pobj, pobj2, req) {
try {
return await this.merchantSve.audit(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = MerchantCtl;
\ 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 MerchantaccountCtl extends CtlBase {
constructor() {
super();
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
}
async page(pobj, pobj2, req) {
try {
return await this.merchantaccountSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = MerchantaccountCtl;
\ 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 MerchantaddressCtl extends CtlBase {
constructor() {
super();
this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve");
}
async page(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantId: pobj.merchantId || pobj.merchant_id,
}
var page = await this.merchantaddressSve.page(condition);
return page;
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async info(pobj, pobj2, req) {
try {
return await this.merchantaddressSve.info(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async save(pobj, pobj2, req) {
try {
var sign = {};
sign.id = pobj.id;
sign.merchantId = this.trim(pobj.merchantId) || this.trim(pobj.merchant_id);
sign.nameA = this.trim(pobj.nameA);
sign.contractNo = this.trim(pobj.contractNo);
sign.beginDate = this.trim(pobj.beginDate);
sign.endDate = this.trim(pobj.endDate);
sign.serviceRate = this.trim(pobj.serviceRate);
return await this.merchantaddressSve.save(sign);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async setDefault(pobj, pobj2, req) {
try {
return await this.merchantaddressSve.setDefault(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
}
module.exports = MerchantaddressCtl;
\ 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 MerchantrechargeCtl extends CtlBase {
constructor() {
super();
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
}
async page(pobj, pobj2, req) {
try {
return await this.merchantrechargeSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.merchantrechargeSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async audit(pobj, pobj2, req) {
try {
var loginUser = req.loginUser;
pobj.opUser = {
"ucid": loginUser.ucid,
"ucname": loginUser.ucname
}
return await this.merchantrechargeSve.audit(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = MerchantrechargeCtl;
\ 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 MerchantsignedCtl extends CtlBase {
constructor() {
super();
this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
}
async page(pobj, pobj2, req) {
try {
var condition = {
currentPage: pobj.currentPage,
pageSize: pobj.pageSize,
merchantId: pobj.merchantId || pobj.merchant_id,
}
return await this.merchantsignedSve.page(condition);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async save(pobj, pobj2, req) {
try {
var sign = {};
sign.id = pobj.id;
sign.merchantId = this.trim(pobj.merchantId) || this.trim(pobj.merchant_id);
sign.nameA = this.trim(pobj.nameA);
sign.contractNo = this.trim(pobj.contractNo);
sign.beginDate = this.trim(pobj.beginDate);
sign.endDate = this.trim(pobj.endDate);
sign.serviceRate = this.trim(pobj.serviceRate);
return await this.merchantsignedSve.save(sign);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async info(pobj, pobj2, req) {
try {
return await this.merchantsignedSve.info(pobj);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
}
module.exports = MerchantsignedCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
var cacheBaseComp = null;
class MerchanttitleCtl extends CtlBase {
constructor() {
super();
this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve");
}
async merchantTitleList(params){
params.currentPage=params.currentPage || 1;
params.pageSize=params.pageSize || 10;
try {
let res = await this.merchanttitleSve.merchantTitleList(params);
return res;
} catch (error) {
return system.getResultFail(500, "接口错误");
}
}
async merchantTitleSave(params){
try {
console.log(params);
return await this.merchanttitleSve.merchantTitleSave(params);
} catch (error) {
return system.getResultFail(500, "接口错误");
}
}
async merchantTitleInfo(params){
try {
console.log(params);
return await this.merchanttitleSve.merchantTitleInfo(params);
} catch (error) {
return system.getResultFail(500, "接口错误");
}
}
async merchantTitleDefault(params){
if(!params.id){
return system.getResultFail();
}else{
try {
return await this.merchanttitleSve.merchantTitleDefault(params);
} catch (error) {
return system.getResultFail(500, "接口错误");
}
}
}
}
module.exports = MerchanttitleCtl;
\ 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 OrderCtl extends CtlBase {
constructor() {
super();
this.orderSve = system.getObject("service.order.orderSve");
}
async allPage(pobj, pobj2, req) {
var condition = {
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 10,
merchantId: pobj.merchantId,
orderId: this.trim(pobj.orderNo),
channelOrderNo: this.trim(pobj.channelOrderNo),
status: pobj.status,
assignBegin: this.trim(pobj.assignBegin),
assignEnd: this.trim(pobj.assignEnd),
}
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
this.doTimeCondition(condition, ["assignBegin", "assignEnd"]);
try {
return await this.orderSve.allOrderList(condition);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async close(pobj, pobj2, req) {
try {
return await this.orderSve.closeById({
id: pobj.id
});
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async assign(pobj, pobj2, req) {
try {
var params = {
assignUcname: req.loginUser.ucname,
id: pobj.id,
deliver_id: this.trim(pobj.deliverId),
deliverName: this.trim(pobj.deliverName),
deliverDivide: system.y2f(Number(pobj.deliverDivide)),
}
return await this.orderSve.assign(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async orderEdit(pobj, pobj2, req) {
try {
var params = {
id: pobj.id,
merchantId: this.trim(pobj.merchantId),
price: system.y2f(Number(pobj.price)),
}
return await this.orderSve.orderEdit(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async allInfo(pobj, pobj2, req) {
try {
var params = {
id: pobj.id
}
return await this.orderSve.orderInfoAll(params, true);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverInfo(pobj, pobj2, req) {
try {
var params = {
id: pobj.id
}
return await this.orderSve.orderInfoAll(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverEdit(pobj, pobj2, req) {
try {
return await this.orderSve.deliverEdit(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverClose(pobj, pobj2, req) {
try {
return await this.orderSve.deliverClose(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async handlePage(pobj, pobj2, req) {
try {
var condition = {
id: pobj.id,
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 1,
orderId: this.trim(pobj.orderId) || this.trim(pobj.orderNo),
status: this.trim(pobj.status),
deliverId: "", // TODO 传入具体办理人
}
this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
return await this.orderSve.handlePage(condition);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverHandle(pobj, pobj2, req) {
try {
var handleObj = {
id: pobj.id,
status: pobj.status,
name: this.trim(pobj.name),
creditCode: this.trim(pobj.creditCode),
businessPlace: this.trim(pobj.businessPlace),
businessScope: this.trim(pobj.businessScope),
regDate: this.trim(pobj.regDate),
businessImg: this.trim(pobj.businessImg),
gongzhang: this.trim(pobj.gongzhang),
caiwuzhang: this.trim(pobj.caiwuzhang),
fapiaozhang: this.trim(pobj.fapiaozhang),
hetongzhang: this.trim(pobj.hetongzhang),
farenzhang: this.trim(pobj.farenzhang),
isBank: this.trim(pobj.isBank),
bankName: this.trim(pobj.bankName),
bankNo: this.trim(pobj.bankNo),
bank: this.trim(pobj.bank),
bankImg: this.trim(pobj.bankImg),
caImg: this.trim(pobj.caImg),
taxRegDay: this.trim(pobj.taxRegDay),
taxOrg: this.trim(pobj.taxOrg),
courierNo: this.trim(pobj.courierNo),
courierImg: this.trim(pobj.courierImg),
}
return await this.orderSve.deliverHandle(handleObj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverAudit(pobj, pobj2, req) {
try {
var auditObj = {};
auditObj.id = pobj.id;
auditObj.auditUser = req.loginUser.ucname;
auditObj.status = pobj.status;
auditObj.auditRemark = this.trim(pobj.auditRemark);
auditObj.content = this.trim(pobj.content);
auditObj.addressee = this.trim(pobj.addressee);
auditObj.mobile = this.trim(pobj.mobile);
auditObj.addr = this.trim(pobj.addr);
auditObj.auditResult = this.trim(pobj.auditResult);
return await this.orderSve.deliverAudit(auditObj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async orderComplete(pobj, pobj2, req) {
try {
var handleObj = {
id: pobj.id,
deliverType: this.trim(pobj.deliverType),
deliverNo: this.trim(pobj.deliverNo),
deliverImg: this.trim(pobj.deliverImg),
}
return await this.orderSve.orderComplete(handleObj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
// async orderList(pobj, pobj2, req) {
// try {
// // 订单状态 00待处理 10出执照 20已刻章 30银行开户 40税务报道 50已邮寄
// var condition = {
// currentPage: pobj.currentPage,
// pageSize: pobj.pageSize,
// merchantId: pobj.merchantId,
// orderNo: this.trim(pobj.orderNo),
// channelOrderNo: this.trim(pobj.channelOrderNo),
// status: pobj.status,
// createdBegin: this.trim(pobj.createdBegin),
// createdEnd: this.trim(pobj.createdEnd),
// }
// this.doTimeCondition(condition, ["createdBegin", "createdEnd"]);
// var page = await this.service.pageByCondition(condition);
// console.log(page);
// return system.getResultSuccess(page);
// } catch (error) {
// console.log(error);
// return system.getResultFail(500, "接口异常:" + error.message);
// }
// }
// async createStep(pobj, pobj2, req) {
// var id = Number(pobj.orderId);
// var status = pobj.status;
// try {
// switch (status) {
// case "05": //"执照办理中"
// case "15": //"刻章办理中"
// case "25": //"银行开户中"
// case "35": //"税务报到中"
// return await this.service.changeStatus(id, status);
// case "10": { //"已出执照"
// var params = {
// orderId: pobj.orderId,
// name: this.trim(pobj.name), // 个体工商户名称
// creditCode: this.trim(pobj.creditCode), // 统一社会信用代码
// businessPlace: this.trim(pobj.businessPlace), // 经营场所
// businessScope: this.trim(pobj.businessScope), // 经营范围
// regDate: this.trim(pobj.regDate), // 注册日期
// businessImg: this.trim(pobj.businessImg), // 执照照片
// };
// return await this.service.createLicense(pobj);
// }
// case "20": { //"已刻章"
// var params = {
// orderId: pobj.orderId,
// gongzhang: this.trim(pobj.gongzhang),
// caiwuzhang: this.trim(pobj.caiwuzhang),
// businessImg: this.trim(pobj.businessImg),
// fapiaozhang: this.trim(pobj.fapiaozhang),
// hetongzhang: this.trim(pobj.hetongzhang),
// farenzhang: this.trim(pobj.farenzhang),
// };
// return await this.businessmenSve.putSealInfo(params);
// }
// case "30": { //"银行已开户"
// var params = {
// orderId: pobj.orderId,
// isBank: Number(pobj.isBank) == 1,
// bankName: this.trim(pobj.bankName),
// bankNo: this.trim(pobj.bankNo),
// bank: this.trim(pobj.bank),
// bankImg: this.trim(pobj.bankImg),
// }
// return await this.businessmenSve.putBankInfo(params);
// }
// case "40": { //"已税务报到"
// var params = {
// orderId: pobj.orderId,
// caImg: this.trim(pobj.caImg),
// taxRegDay: this.trim(pobj.taxRegDay),
// taxOrg: this.trim(pobj.taxOrg),
// }
// return await this.businessmenSve.putTaxInfo(params);
// }
// case "50": { //"已邮寄"
// var params = {
// orderId: pobj.orderId,
// courierNo: this.trim(pobj.courierNo),
// courierImg: this.trim(pobj.courierImg),
// }
// return await this.businessmenSve.putExpressInfo(params);
// }
// default : {
// return system.getResult(null, "状态错误");
// }
// }
// } catch (error) {
// console.log(error);
// return system.getResultFail(500, "接口异常:" + error.message);
// }
// }
}
module.exports = OrderCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class AuthCtl extends CtlBase {
constructor() {
super();
this.authSve = system.getObject("service.uc.authSve");
}
/**
* 菜单 添加
* @param {*} params
*/
async addAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
var auth = {
pid: Number(params.pid || 0),
saas_id: params.saas_id,
menuType: Number(params.menuType || 0),
name: this.trim(params.name),
icon: this.trim(params.icon),
path: this.trim(params.path),
sort: 99,
};
return await this.authSve.addAuth(auth);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 更新
* @param {*} params
*/
async updAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
var auth = {
id: Number(params.id),
pid: Number(params.pid || 0),
saas_id: params.saas_id,
menuType: Number(params.menuType || 0),
name: this.trim(params.name),
icon: this.trim(params.icon),
path: this.trim(params.path),
};
try {
return await this.authSve.updAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 删除
* @param {*} params
*/
async delAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.delAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async byPid(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.byPid(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.tree(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = AuthCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class OrgCtl extends CtlBase {
constructor() {
super();
this.orgSve = system.getObject("service.uc.orgSve");
}
/**
* 组织机构 添加
* @param {*} params
*/
async addOrg(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.orgSve.addOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 更新
* @param {*} params
*/
async updOrg(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.updOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 删除
* @param {*} params
*/
async delOrg(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.delOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询列表
* @param {*} params
*/
async listOrg(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.orgSve.listOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.orgSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async byPid(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.byPid(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.tree(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = OrgCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class RoleCtl extends CtlBase {
constructor() {
super();
this.roleSve = system.getObject("service.uc.roleSve");
}
/**
* saas 添加
* @param {*} params
*/
async addRole(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.roleSve.addRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 更新
* @param {*} params
*/
async updRole(params, pobj2, req) {
try {
return await this.roleSve.updRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 删除
* @param {*} params
*/
async delRole(params, pobj2, req) {
try {
return await this.roleSve.delRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询列表
* @param {*} params
*/
async listRole(params, pobj2, req) {
try {
return await this.roleSve.listRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.roleSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async setAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.roleSve.setAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = RoleCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class SaasCtl extends CtlBase {
constructor() {
super();
this.saasSve = system.getObject("service.uc.saasSve");
}
/**
* saas 添加
* @param {*} params
*/
async addSaas(params, pobj2, req) {
try {
return await this.saasSve.addSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 更新
* @param {*} params
*/
async updSaas(params, pobj2, req) {
try {
return await this.saasSve.updSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 删除
* @param {*} params
*/
async delSaas(params, pobj2, req) {
try {
return await this.saasSve.delSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询列表
* @param {*} params
*/
async listSaas(params, pobj2, req) {
try {
return await this.saasSve.listSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.saasSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = SaasCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class UserCtl extends CtlBase {
constructor() {
super();
this.userSve = system.getObject("service.uc.userSve");
this.redisClient = system.getObject("util.redisClient");
this.captchaSve = system.getObject("service.common.captchaSve");
}
async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password);
// var captchaKey = this.trim(pobj.captchaKey);
// var captchaCode = this.trim(pobj.captchaCode);
try {
// var vrs = await this.captchaSve.valid({
// key: captchaKey,
// code: captchaCode,
// });
// if (vrs.status !== 0) {
// return vrs;
// }
var loginUser = await this.userSve.login({
ucname: loginName,
password: password,
});
if(loginUser.status != 0) {
return loginUser;
}
loginUser = loginUser.data;
var xggadminsid = await this.setLogin(loginUser);
return system.getResultSuccess(xggadminsid);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async setLogin(user) {
var xggadminsid = uuidv4();
xggadminsid = "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
await this.redisClient.setWithEx(xggadminsid, JSON.stringify(user), 60 * 60);
return xggadminsid;
}
async getMenu(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser.menus);
}
/**
* 添加
* @param {*} params
*/
async addUser(params, pobj2, req) {
try {
var user = {
saas_id: params.saas_id,
org_id: Number(params.org_id || 0),
ucname: this.trim(params.ucname),
password: this.trim(params.password),
uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile),
realName: this.trim(params.realName),
roles: params.roles || [],
};
if (!user.ucname) {
return system.getResult(null, "请填写用户名");
}
if (!user.password) {
return system.getResult(null, "请填写密码");
}
if (!user.mobile) {
return system.getResult(null, "请填写手机号");
}
if (!user.realName) {
return system.getResult(null, "请填写姓名");
}
if (user.uctype != 1) {
user.org_id = null;
user.roles = [];
}
return await this.userSve.addUser(user);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新
* @param {*} params
*/
async updUser(params, pobj2, req) {
var user = {
id: Number(params.id || 0),
saas_id: params.saas_id,
org_id: Number(params.org_id || 0),
uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile),
realName: this.trim(params.realName),
roles: params.roles || [],
};
if (!user.id) {
return system.getResult(null, "用户不存在");
}
if (!user.mobile) {
return system.getResult(null, "请填写手机号");
}
if (!user.realName) {
return system.getResult(null, "请填写姓名");
}
if (user.uctype != 1) {
user.org_id = null;
user.roles = [];
}
try {
return await this.userSve.updUser(user);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser);
}
/**
* 启用禁用
* @param {*} params
* @param {*} pobj2
* @param {*} req
*/
async enabled(params, pobj2, req) {
try {
params.id = Number(params.id || 0);
params.enabled = Number(params.enabled || 0);
return await this.userSve.enabled(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async delUser(params, pobj2, req) {
try {
return await this.userSve.delUser(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.userSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async updPassword(params, pobj2, req) {
params.password = this.trim(params.password);
if(!params.password) {
return system.getResult(null, `请填写密码`);
}
try {
return await this.userSve.updPassword(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async page(params, pobj2, req) {
try {
return await this.userSve.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserCtl;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class OpuserrelationDao extends Dao{
constructor(){
super(Dao.getModelName(OpuserrelationDao));
}
}
module.exports=OpuserrelationDao;
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 Dao = require("../../dao.base");
class PushlogDao extends Dao {
constructor() {
super(Dao.getModelName(PushlogDao));
}
}
module.exports = PushlogDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("opuserrelation", {
ucname: DataTypes.STRING,
ucid: DataTypes.STRING
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'op_user_relation',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("businessmen", {
order_id: DataTypes.BIGINT,
merchant_id: DataTypes.BIGINT,
orderNo: DataTypes.STRING(64),
channelOrderNo: DataTypes.STRING(64),
status: DataTypes.STRING(20),//状态 00待处理 10出执照 20已刻章 30银行开户 40税务报道 50已邮寄 60已签约
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
name: DataTypes.STRING(100),
creditCode: DataTypes.STRING(100),
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,
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, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_businessmen',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("order", {
merchant_id: DataTypes.BIGINT,
orderNo: DataTypes.STRING(64),
channelOrderNo: DataTypes.STRING(64),
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
legalImg: DataTypes.STRING(300),
idcard: DataTypes.STRING(20),
idcardFront: DataTypes.STRING(300),
idcardBack: DataTypes.STRING(300),
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(200),
names: DataTypes.STRING(300),
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, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_order',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushapi", {
merchant_id: DataTypes.BIGINT,
rechargeAudit: DataTypes.STRING(200),
orderStatus: DataTypes.STRING(200),
businessmenSign: DataTypes.STRING(200),
invoiceStatus: DataTypes.STRING(200),
invoiceTax: DataTypes.STRING(200),
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_push_api',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushlog", {
merchant_id: DataTypes.STRING,
dataType: DataTypes.INTEGER,
dataId: DataTypes.STRING,
api: DataTypes.STRING(200),
params: DataTypes.STRING(5000),
rs: DataTypes.STRING(200),
success: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_push_log',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class BusinessscopeService extends ServiceBase {
constructor() {
super();
}
async page(params) {
return await this.callms("common", "businessscopePage", params);
}
async info(params) {
return await this.callms("common", "businessscopeInfo", params);
}
async save(params) {
return await this.callms("common", "businessscopeSave", params);
}
async del(params) {
return await this.callms("common", "businessscopeDelete", params);
}
async byDomicile(params) {
return await this.callms("common", "businessscopeByDomicileId", params);
}
}
module.exports = BusinessscopeService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class CaptchaService extends ServiceBase {
constructor() {
super();
}
async captcha(params) {
// "width": 120, // 验证码图片宽度 默认 120px
// "height": 36, // 验证码图片高度 默认 36px
// "background": "", // 验证码图片背景色,默认 #E8E8E8
// "expire": 0 // 验证码过期时间(秒)
var result = {};
var capthaData = await this.callms("common", "getCaptha", params);
if(capthaData.status === 0) {
result.key = capthaData.data.key;
result.captcha = capthaData.data.captcha;
console.log(result.key + " : " + result.text);
return system.getResultSuccess(result);
}
return system.getResult(null, "获取图片验证码失败");
}
async valid(params) {
var result = {};
return await this.callms("common", "validCaptha", params);
}
}
module.exports = CaptchaService;
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
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DeliverService extends ServiceBase {
constructor() {
super();
}
async all(params) {
var rs = await this.callms("common", "deliverAll", {});
await this.doPercent(rs.data);
return rs;
}
async page(params) {
var rs = await this.callms("common", "deliverPage", params);
await this.doPercent(rs.data.rows);
return rs;
}
async info(params) {
var rs = await this.callms("common", "deliverInfo", params);
await this.doPercent([rs.data]);
return rs;
}
async save(params) {
params.invoiceDivide = system.y2f(params.invoiceDivide);
params.businessmenDivide = system.y2f(params.businessmenDivide);
var rs = await this.callms("common", "deliverSave", params);
await this.doPercent([rs.data]);
return rs;
}
async del(params) {
return await this.callms("common", "deliverDelete", params);
}
async doPercent(rows) {
if(!rows) {
return;
}
for(var row of rows) {
if(!row) {
continue;
}
row.invoiceDivide = system.f2y(row.invoiceDivide);
row.businessmenDivide = system.f2y(row.businessmenDivide);
}
}
}
module.exports = DeliverService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DomicileService extends ServiceBase {
constructor() {
super();
}
async nameList() {
return await this.callms("common", "domicileNameList", {});
}
async tree(params) {
return await this.callms("common", "domicileTree", {});
}
async page(params) {
return await this.callms("common", "domicilePage", params);
}
async info(params) {
return await this.callms("common", "domicileInfo", params);
}
async save(params) {
return await this.callms("common", "domicileSave", params);
}
async del(params) {
return await this.callms("common", "domicileDelete", params);
}
}
module.exports = DomicileService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class InvoicecontentService extends ServiceBase {
constructor() {
super();
}
async list(params) {
return await this.callms("common", "invoiceList", params);
}
async info(params) {
return await this.callms("common", "invoicecontent", params);
}
async save(params) {
return await this.callms("common", "invoicecontentSave", params);
}
async del(params) {
return await this.callms("common", "invoicecontentDelete", params);
}
}
module.exports = InvoicecontentService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class InvoiceService extends ServiceBase {
constructor() {
super();
this.status = {
"0090": {
"status": "0090",
"name": "未付款",
"next": "1000",
"cstatus": "0090", //客户
"dstatus": "", //交付商
},
"1000": {
"status": "1000",
"name": "待审核",
"next": "1020",
"cstatus": "0090", //客户
"dstatus": "", //交付商
},
"1010": {
"status": "1010",
"name": "审核不通过",
"next": "",
"cstatus": "1010",
"dstatus": "",
},
"1020": {
"status": "1020",
"name": "待分配",
"next": "1030",
"cstatus": "1030",
"dstatus": "",
},
"1030": {
"status": "1030",
"name": "待处理",
"next": "1050",
"cstatus": "1030",
"dstatus": "1030",
},
"1040": {
"status": "1040",
"name": "交付商关闭",
"next": "1020",
"cstatus": "1030",
"dstatus": "1040",
},
"1050": {
"status": "1050",
"name": "已开具",
"next": "1060",
"cstatus": "1050",
"dstatus": "1050",
},
"1060": {
"status": "1060",
"name": "待审核",
"next": "1070",
"cstatus": "1050",
"dstatus": "1070",
},
"1070": {
"status": "1070",
"name": "审核通过",
"next": "1080",
"cstatus": "1050",
"dstatus": "1070",
},
"1080": {
"status": "1080",
"name": "已邮寄",
"next": "1090",
"cstatus": "1050",
"dstatus": "1080",
},
"1090": {
"status": "1090",
"name": "完成",
"next": "1100",
"cstatus": "1090",
"dstatus": "1080",
},
"1100": {
"status": "1090",
"name": "发票撤回",
"next": "1100",
"cstatus": "1090",
"dstatus": "1080",
},
"1200": {
"status": "1200",
"name": "红冲",
"next": "",
"cstatus": "1200",
"dstatus": "",
},
"1300": {
"status": "1300",
"name": "审核失败(平台第二次审核)",
"next": "1060",
"cstatus": "1050",
"dstatus": "1060",
}
};
}
async apiCalcInvoice(pobj) {
var merchantId = pobj.merchant_id || pobj.merchantId;
var invoiceList = pobj.invoiceList;
if (!invoiceList || invoiceList.length == 0) {
return system.getResult(null, "请传入试算开票信息");
}
var creditCodes = [];
for (var invoice of invoiceList) {
creditCodes.push(invoice.businessmenCreditCode);
}
// 查询个体户签约信息
var mapRs = await this.callms("order", "businessmenCompleteMapByCreditCodes", {
creditCodes: creditCodes
});
var map = mapRs.data;
var result = [];
for (var invoice of invoiceList) {
var calc = {
creditCode: invoice.businessmenCreditCode,
incomeTax: 0,
addedValueTax: 0,
serviceTax: 0,
specialTax: 0,
warning: "",
monthAmt: 0,
};
var signInfo = map[invoice.businessmenCreditCode];
if (!signInfo) {
calc.code = -1;
calc.msg = "个体工商户【" + invoice.businessmenCreditCode + "】不存在";
result.push(calc);
continue;
}
invoice.invoiceAmount = Number(invoice.invoiceAmt);
invoice.invoiceTime = this.trim(invoice.invoiceTime);
invoice.businessmenCreditCode = this.trim(invoice.businessmenCreditCode);
invoice.businessmenType = this.trim(invoice.businessmenType) || "10";
invoice.ruleCode = this.trim(invoice.ruleCode) || "10";
invoice.perCalWay = signInfo.taxUpType; // TODO 确定值
invoice.valCalWay = signInfo.addValueUpType; // TODO 确定值
invoice.businessmenId = signInfo.id;
invoice.serviceRate = system.f2y(signInfo.serviceRate);
invoice.taxCostPriRat = system.f2y(signInfo.costRate);
invoice.taxIncPriRat = system.f2y(signInfo.taxRate);
if (invoice.type == 1) {
invoice.perIncTaxRange = JSON.parse(signInfo.specialTaxLadder);
invoice.valAddTaxRange = JSON.parse(signInfo.specialOtherLadder);
} else {
invoice.perIncTaxRange = JSON.parse(signInfo.commonTaxLadder);
invoice.valAddTaxRange = JSON.parse(signInfo.commonOtherLadder);
}
try {
console.log(JSON.stringify(invoice));
var rs = await this.callms("invoice", "verificationAndCalculation", invoice);
if (rs.status == 0 && rs.data) {
var calcRs = rs.data;
calc.code = 1;
calc.incomeTax = Number(calcRs.personalIncomeTax || 0).toFixed(0);
calc.addedValueTax = Number(calcRs.valueAddedTax || 0).toFixed(0);
calc.serviceTax = Number(calcRs.serviceCharge || 0).toFixed(0);
calc.specialTax = Number(calcRs.additionalTax || 0).toFixed(0);
calc.warning = this.trim(calcRs.warning);
calc.monthAmt = 0;
calc.msg = "success";
} else {
calc.code = -1;
calc.msg = rs.msg || "发票服务异常";
}
console.log(rs);
} catch (error) {
calc.code = -1;
calc.msg = "发票服务异常,请联系公司宝";
console.log(error);
}
result.push(calc);
}
return system.getResultSuccess(result);
}
async apiVerificationAndCalculation(pobj) {
pobj.serviceRate = Number(pobj.serviceRate) * 100;
pobj.taxIncPriRat = Number(pobj.taxIncPriRat) * 100;
pobj.taxCostPriRat = Number(pobj.taxCostPriRat) * 100;
pobj.invoiceAmount = system.y2f(pobj.invoiceAmount);
var rs = await this.callms("invoice", "verificationAndCalculation", pobj);
if (rs.status == 0) {
return rs
} else {
return system.getResult(null, rs.msg);
}
}
async apiSaveInvoice(pobj) {
var merchantId = pobj.merchant_id || pobj.merchantId;
var invoiceList = pobj.invoiceList;
if (!invoiceList || invoiceList.length == 0) {
return system.getResult(null, "请传入试算开票信息");
}
var creditCodes = [];
for (var invoice of invoiceList) {
creditCodes.push(invoice.businessmenCreditCode);
}
// 查商户titile
var merchantRs = await this.callms("merchant", "getById", {
id: merchantId
});
var merchant = merchantRs.data || {};
var title = await this.callms("merchant", "getMerchantTitleDefault", {
merchantId: merchantId
});
title = title.data;
var address = await this.callms("merchant", "getMerchantAddressDefault", {
merchantId: merchantId
});
var address = address.data || {};
// 查询个体户签约信息
var mapRs = await this.callms("order", "businessmenCompleteMapByCreditCodes", {
creditCodes: creditCodes
});
var map = mapRs.data;
var result = [];
for (var invoice of invoiceList) {
var data = {
creditCode: invoice.businessmenCreditCode,
code: 1,
msg: "success",
applyNo: invoice.applyNo,
};
var signInfo = map[invoice.businessmenCreditCode];
if (!signInfo) {
data.code = -1;
data.msg = "个体工商户【" + invoice.businessmenCreditCode + "】不存在";
result.push(data);
continue;
}
// 发票类型:10 普通发票 20 增值税专用发票 30 电子发票
if (invoice.type === 0) {
invoice.type == "10";
} else if (invoice.type === 1) {
invoice.type == "20";
} else {
invoice.type == "30";
}
// 购买方
invoice.merchantId = merchantId;
invoice.merchantName = merchant.name;
invoice.merchantCreditCode = title.taxNo;
invoice.merchantAddr = title.invoiceAddr;
invoice.merchantMobile = title.invoiceMobile;
invoice.merchantBank = title.accountName;
invoice.merchantAccount = title.accountPublic;
// 申请方联系电话
invoice.applyPhone = merchant.contactMobile;
// 邮寄地址
invoice.mailAddr = address.mailAddr;
invoice.mailMobile = address.mailMobile;
invoice.mailTo = address.mailTo;
invoice.invoiceAmount = Number(invoice.invoiceAmt);
invoice.invoiceTime = this.trim(invoice.invoiceTime);
invoice.businessmenCreditCode = this.trim(invoice.businessmenCreditCode);
// 开票内容
if (signInfo.invoicecontents && signInfo.invoicecontents.length > 0) {
invoice.invoiceContent = signInfo.invoicecontents[0].invoicecontentName;
} else {
invoice.invoiceContent = "服务费";
}
invoice.settleImg = "";
invoice.statements = invoice.settleImg;
invoice.contract = "";
invoice.applyNo = invoice.applyNo;
invoice.perCalWay = signInfo.taxUpType;
invoice.valCalWay = signInfo.addValueUpType;
// 销售方信息
invoice.businessmenType = this.trim(invoice.businessmenType) || "10";
invoice.ruleCode = this.trim(invoice.ruleCode) || "10";
invoice.businessmenId = signInfo.id;
invoice.businessName = signInfo.name;
invoice.isBank = signInfo.isBank;
invoice.taxAuthorities = signInfo.taxOrg;
// invoice.taxCostPriRat = signInfo.costRate;
// invoice.taxIncPriRat = signInfo.taxRate;
invoice.serviceRate = system.f2y(signInfo.serviceRate);
invoice.taxCostPriRat = system.f2y(signInfo.costRate);
invoice.taxIncPriRat = system.f2y(signInfo.taxRate);
if (invoice.type == 1) {
invoice.perIncTaxRange = JSON.parse(signInfo.specialTaxLadder);
invoice.valAddTaxRange = JSON.parse(signInfo.specialOtherLadder);
} else {
invoice.perIncTaxRange = JSON.parse(signInfo.commonTaxLadder);
invoice.valAddTaxRange = JSON.parse(signInfo.commonOtherLadder);
}
try {
var rs = await this.callms("invoice", "saveInvoice", invoice);
if (rs.status != 0) {
data.code = -1;
data.msg = rs.msg || "发票服务异常";
}
console.log(rs);
} catch (error) {
data.code = -1;
data.msg = "发票服务异常,请联系公司宝";
console.log(error);
}
result.push(data);
}
return system.getResultSuccess(result);
}
async apiCancelInvoice(pobj) {
var params = {
applyNo: pobj.applyNo,
merchantId: pobj.merchantId || pobj.merchant_id
}
var rs = await this.callms("invoice", "apiCancelInvoice", params);
if (rs.data) {
rs.data = null;
}
return rs;
}
async apiQueryInvoice(pobj) {
var params = {
applyNo: pobj.applyNo,
merchantId: pobj.merchantId || pobj.merchant_id
}
// queryInvoices
var rs = await this.callms("invoice", "queryInvoice", params);
if (rs.status != 0 || !rs.data) {
return system.getResult(null, "发票不存在");
}
var invoiceApply = rs.data || {};
var invoice = invoiceApply.invoice || {};
var result = {
"merchantId": this.trim(invoiceApply.merchantId),
"applyNo": this.trim(invoiceApply.applyNo),
"status": this.trim(invoiceApply.customerStatus),
"auditRemark": this.trim(invoiceApply.remark),
"invoiceNo": this.trim(invoiceApply.id),
"payVoucher": this.trim(invoiceApply.statements),
"courierImg": "",
"courierNo": this.trim(invoice.mailNo),
"invoiceTime": this.trim(invoice.invoiceTime),
"invoiceImg": this.trim(invoice.invoiceImg),
"complateTax": this.trim(invoice.complateTax),
"taxNo": this.trim(invoice.taxNo),
"taxTime": this.trim(invoice.taxTime),
"taxVoucher": this.trim(invoice.taxVoucher),
}
return system.getResultSuccess(result);
}
async apiQueryTaxInvoice(pobj) {
var params = {
applyNo: pobj.applyNo,
merchantId: pobj.merchantId || pobj.merchant_id,
id: pobj.id
}
// queryInvoices
var rs = await this.callms("invoice", "getByApplyNo", params);
if (rs.status != 0 || !rs.data) {
return system.getResult(null, "发票不存在");
}
var invoice = rs.data || {};
var paytaxes = invoice.paytaxes || {};
this.handleDate(paytaxes, ["payTaxesTime"], "YYYY-MM-DD", -8);
var result = {
"merchantId": this.trim(invoice.merchantId),
"applyNo": this.trim(invoice.applyNo),
"taxNo": this.trim(paytaxes.payTaxesNo),
"taxTime": this.trim(paytaxes.payTaxesTime),
"taxVoucher": this.trim(paytaxes.payTaxesImg),
}
return system.getResultSuccess(result);
}
/**
* 发票明细(平台)
* @param {*} pobj
* @param {string} id
* @param {string} applyNo
* @param {string} merchant_id
*/
async apiQueryInvoiceAdmin(pobj) {
var params = {
applyNo: pobj.applyNo,
merchantId: pobj.merchantId || pobj.merchant_id,
id: pobj.id || null
}
var res = await this.callms("invoice", "queryInvoice", params);
if (res.status != 0 || !res.data) {
return system.getResult(null, "发票不存在");
}
res.data.invoiceAmount = system.f2y(res.data.invoiceAmount);
res.data.personalIncomeTax = system.f2y(res.data.personalIncomeTax);
res.data.additionalTax = system.f2y(res.data.additionalTax);
res.data.valueAddedTax = system.f2y(res.data.valueAddedTax);
res.data.serviceCharge = system.f2y(res.data.serviceCharge);
res.data.isBank = res.data.isBank == 1 ? "已开户" : "未开户";
if (res.data.type == 10) {
res.data.type = "普通发票";
} else if (res.data.type == 20) {
res.data.type = "增值税专用发票";
} else {
res.data.type = "电子发票"
}
res.data.payWay = res.data.payWay == "20" ? "线上支付" : "系统账户扣款";
res.data.isPay = res.data.isPay == 1 ? "已支付" : "未付款";
res.data.isInvalid = res.data.isInvalid === 2 ? '未红冲' : '已红冲';
res.data.deliverer.delivererAmount = system.f2y(res.data.deliverer.delivererAmount);
res.data.invoice.complateTax = res.data.invoice.complateTax == "1" ? "已完税" : "未完税";
this.handleDate(res.data, ["invoiceTime"], "YYYY-MM-DD", -8);
this.handleDate(res.data, ["createdAt"], "YYYY-MM-DD", -8);
this.handleDate(res.data['deliverer'], ["createdAt"], "YYYY-MM-DD", -8);
this.handleDate(res.data['deliverer'], ["updatedAt"], "YYYY-MM-DD", -8);
this.handleDate(res.data['invoice'], ["invoiceTime"], "YYYY-MM-DD", -8);
this.handleDate(res.data['invoice'], ["taxTime"], "YYYY-MM-DD", -8);
this.handleDate(res.data["invoice"], ["createdAt"], "YYYY-MM-DD", -8);
this.handleDate(res.data["invoice"], ["updatedAt"], "YYYY-MM-DD", -8);
return res;
}
/**
* 发票明细(交付商)
* @param {*} pobj
* @param {string} id
* @param {string} applyNo
* @param {string} merchant_id
*/
async apiQueryInvoiceDeliverer(pobj) {
var params = {
applyNo: pobj.applyNo,
merchantId: pobj.merchantId || pobj.merchant_id,
id: pobj.id || null
}
var rs = await this.callms("invoice", "queryInvoiceDeliverer", params);
if (rs.status != 0 || !rs.data) {
return system.getResult(null, "发票不存在");
}
rs.data.invoiceAmount = system.f2y(rs.data.invoiceAmount);
rs.data.personalIncomeTax = system.f2y(rs.data.personalIncomeTax);
rs.data.additionalTax = system.f2y(rs.data.additionalTax);
rs.data.valueAddedTax = system.f2y(rs.data.valueAddedTax);
rs.data.serviceCharge = system.f2y(rs.data.serviceCharge);
return rs;
}
/**
* 校验审核
* @param {*} pobj
*/
async apiVerification(pobj) {
var params = {
businessmenCreditCode: pobj.businessmenCreditCode
}
var rs = await this.callms("invoice", "verification", params);
if (rs.status != 0) {
return system.getResult(null, "发票不存在");
}
return rs;
}
/**
* 试算
* @param {*} pobj
*/
async apiCalcInvoice2(pobj) {
pobj.serviceRate = Number(pobj.serviceRate || 0) * 100;
pobj.taxIncPriRat = Number(pobj.taxIncPriRat || 0) * 100;
pobj.taxCostPriRat = Number(pobj.taxCostPriRat || 0) * 100;
pobj.invoiceAmount = system.y2f(pobj.invoiceAmount || 0);
var rs = await this.callms("invoice", "verificationAndCalculation", pobj);
if (rs.status == 0) {
return rs
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 保存发票申请(提供管理)
* @param {*} pobj
*/
async apiSaveInvoiceAdm(pobj) {
pobj.serviceRate = Number(pobj.serviceRate) * 100;
pobj.taxIncPriRat = Number(pobj.taxIncPriRat) * 100;
pobj.taxCostPriRat = Number(pobj.taxCostPriRat) * 100;
pobj.invoiceAmount = system.y2f(pobj.invoiceAmount);
var rs = await this.callms("invoice", "saveInvoice", pobj);
if (rs.status == 0) {
return rs
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 平台审批
* @param {*} pobj
*/
async apiPlatformAssignment(pobj) {
if (!pobj.nextStatus) {
return system.getResult(null, `参数错误`);
}
var rs = await this.callms("invoice", "platformAssignment", pobj);
if (rs.status == 0) {
this.pushDeliver(pobj);
return rs;
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 交付商审批
* @param {*} pobj
*/
async apiDelivererAssignment(pobj) {
if (!pobj.nextStatus) {
return system.getResult(null, `参数错误`);
}
var rs = await this.callms("invoice", "delivererAssignment", pobj);
if (rs.status == 0) {
this.pushDeliver(pobj);
return rs;
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 完税证明
* @param {*} pobj
*/
async apiTxPayment(pobj) {
let params = {};
params.id = this.trim(pobj.id);
params.taxNo = this.trim(pobj.taxNo);
params.complateTax = this.trim(pobj.complateTax);
params.taxTime = this.trim(pobj.taxTime);
params.taxVoucher = this.trim(pobj.taxVoucher);
var rs = await this.callms("invoice", "txPayment", params);
if (rs.status == 0) {
return rs
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 查看完税证明
* @param {*} pobj
*/
async apiQueryTxPayment(pobj) {
let params = {};
params.id = this.trim(pobj.id);
var rs = await this.callms("invoice", "queryTxPayment", params);
if (rs.status == 0) {
return rs
} else {
return system.getResult(null, rs.msg);
}
}
/**
* 发票列表(交付商)
* @param {*} pobj
*/
async apiDelivererInvoices(pobj) {
if (pobj.pageIndex) {
pobj.pageIndex = Number(pobj.pageIndex) || 1;
}
if (pobj.pageSize) {
pobj.pageSize = Number(pobj.pageSize) || 10;
}
let res = await this.callms("invoice", "delivererInvoices", pobj);
for (let item of res.data.rows) {
item.invoice_amount = system.f2y(item.invoice_amount);
}
if (res.status == 0) {
return res;
} else {
return system.getResult(null, res.msg);
}
}
/**
* 发票申请列表(交付商)
* @param {*} pobj
*/
async apiDelivererApplyInvoices(pobj) {
if (pobj.pageIndex) {
pobj.pageIndex = Number(pobj.pageIndex) || 1;
}
if (pobj.pageSize) {
pobj.pageSize = Number(pobj.pageSize) || 10;
}
let res = await this.callms("invoice", "delivererApplyInvoices", pobj);
for (let item of res.data.rows) {
item.invoice_amount = system.f2y(item.invoice_amount);
}
if (res.status == 0) {
return res;
} else {
return system.getResult(null, res.msg);
}
}
/**
* 发票列表(平台)
* @param {*} pobj
*/
async apiQueryInvoices(pobj) {
pobj.pageIndex = Number(pobj.pageIndex || 1);
pobj.pageSize = Number(pobj.pageSize || 10);
var complateTax = this.trim(pobj.complateTax);
if (complateTax === "") {
complateTax = "-1";
}
pobj.complateTax = complateTax;
pobj.statuses = ['1070', '1080', '1090'];
let res = await this.callms("invoice", "queryInvoices", pobj);
for (let item of res.data.rows) {
item.apply.invoice_amount = system.f2y(item.apply.invoice_amount);
}
if (res.status == 0) {
return res;
} else {
return system.getResult(null, res.msg);
}
}
/**
* 发票申请列表(平台)
* @param {*} pobj
*/
async apiQueryApplyInvoices(pobj) {
pobj.pageIndex = Number(pobj.pageIndex || 1);
pobj.pageSize = Number(pobj.pageSize || 10);
let res = await this.callms("invoice", "queryApplyInvoices", pobj);
for (let item of res.data.rows) {
item.invoiceAmount = system.f2y(item.invoiceAmount);
item.personalIncomeTax = system.f2y(item.personalIncomeTax);
item.valueAddedTax = system.f2y(item.valueAddedTax);
item.serviceCharge = system.f2y(item.serviceCharge);
item.additionalTax = system.f2y(item.additionalTax);
}
if (res.status == 0) {
return res;
} else {
return system.getResult(null, res.msg);
}
}
/**
* 更新邮寄单号(平台)
* @param {*} pobj
*/
async apiUpEmNo(pobj) {
if (pobj.id) {
pobj.id = this.trim(pobj.id);
}
if (pobj.platformMailNo) {
pobj.platformMailNo = this.trim(pobj.platformMailNo);
}
let res = await this.callms("invoice", "updateEmail", pobj);
if (res.status == 0) {
return res;
} else {
return system.getResult(null, res.msg);
}
}
async pushDeliver(obj) {
var status = obj.nextStatus;
if (!status) {
return;
}
var pushStatus = ["1010", "1030", "1050", "1090"];
// 0090开票申请 1010审核驳回 1030审核通过 1050已开票 1090已完成
if (pushStatus.indexOf(status) == -1) {
return;
}
// 查发票
var invoiceApply = await this.callms("invoice", "queryInvoice", {
id: obj.id
});
invoiceApply = invoiceApply.data;
if (!invoice) {
console.log("推送信息失败[" + JSON.stringify(obj) + "],发票不存在 ------------------------");
return;
}
var invoice = invoiceApply.invoice || {};
var merchant = await this.callms("merchant", "secretById", {
id: order.merchant_id
});
merchant = merchant.data;
if (!merchant) {
console.log("推送信息失败[" + JSON.stringify(obj) + "],商户不存在 ------------------------");
return;
}
var options = {
merchantId: merchant.id,
appKey: merchant.appSecret,
dataType: 3,
dataId: invoiceApply.id,
field: "invoiceStatus",
};
var params = {
merchantId: merchant.id,
status: status,
applyNo: invoiceApply.applyNo,
}
// 0090开票申请 1030审核通过 1050已开票 1090已完成
if (status == "1010") {
// 1010审核驳回
params.auditRemark = this.trim(invoiceApply.remark);
} else if (status == "1030") {
// 1030审核通过
params.auditRemark = this.trim(invoiceApply.remark);
} else if (status == "1050") {
// invoiceNo : String :发票编号
params.invoiceNo = this.trim(invoiceApply.id);
// invoiceTime : String :开票时间
params.invoiceTime = this.trim(invoice.invoiceTime);
// invoiceImg : String :发票照片
params.invoiceImg = this.trim(invoice.invoiceImg);
// payVoucher : String :支付凭证
params.payVoucher = this.trim(invoiceApply.statements);
} else if (status == "1090") {
// courierNo : String :快递单号
params.courierNo = this.trim(invoice.mailNo);
// courierImg : String :快递交接单图片
params.courierImg = "";
} else {
return;
}
options.params = params;
await this.pushapiSve.push(options);
}
async redrush(params) {
try {
return await this.callms("invoice", "redRushInvoice", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
//交易数据 平台
async statManageData(params) {
try {
return await this.callms("invoice", "statTransData", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
//发票办理 平台
async statBusinessData(params) {
try {
return await this.callms("invoice", "statBusinessData", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息${error}`);
}
}
/**
* 交易数据(交付商)
* @param {*} params
*/
async delStatManageData(params) {
try {
return await this.callms("invoice", "delStatTransData", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
//发票办理(交付商)
async delStatBusinessData(params) {
try {
return await this.callms("invoice", "delStatBusinessData", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
//交付商列表(平台)
async statDeliverData(params) {
try {
return await this.callms("invoice", "statDeliverData", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
//计算发票增值税
async calculationValueAddedTax(params) {
try {
return await this.callms("invoice", "calculationValueAddedTax", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
//计算发票附加税
async calculationAdditionalTax(params) {
try {
return await this.callms("invoice", "calculationAdditionalTax", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
async apiRedrushList(params){
try {
return await this.callms("invoice", "redrushList", params);
} catch (error) {
return system.getResult(-1, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = InvoiceService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class MerchantService extends ServiceBase {
constructor() {
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() {
var rs = await this.callms("merchant", "nameList", {});
return rs;
}
async infoPage(params) {
var rs = await this.callms("merchant", "infoList", params);
return rs;
}
async getById(id) {
var rs = await this.callms("merchant", "getById", {id: id});
return rs;
}
async add(params) {
var merchant = {};
var title = {};
var address = {};
if(["00", "10"].indexOf(params.taxType) == -1) {
return system.getResult(null, "纳税人类型类型错误");
}
// 商户信息
merchant.name = this.trim(params.name);
merchant.taxType = params.taxType;
merchant.contactName = this.trim(params.contactName);
merchant.contactMobile = this.trim(params.contactMobile);
merchant.contactEmail = this.trim(params.contactEmail);
merchant.invoiceValid = params.invoiceValid ? 1 : 0;
merchant.mustPay = params.mustPay ? 1 : 0;
merchant.status = "00";
merchant.ownerId = this.trim(params.ownerId);
if(merchant.ownerId) {
// TODO 去用户平台查询用户信息
merchant.ownerName = "测试用户名";
merchant.ownerMobile = "测试用户手机号";
merchant.ownerPath = "/aaa/bbbb/ccc/ddd/eee/fff/zzz/yyy";
}
title.taxNo = this.trim(params.taxNo);
title.invoiceAddr = this.trim(params.invoiceAddr);
title.invoiceMobile = this.trim(params.invoiceMobile);
title.accountName = this.trim(params.accountName);
title.accountPublic = this.trim(params.accountPublic);
address.mailAddr = this.trim(params.mailAddr);
address.mailTo = this.trim(params.mailTo);
address.mailMobile = this.trim(params.mailMobile);
merchant.title = title;
merchant.address = address;
return await this.callms("merchant", "addMerchant", merchant);
}
async upd(params) {
var merchant = {};
var title = {};
var address = {};
if(["00", "10"].indexOf(params.taxType) == -1) {
return system.getResult(null, "纳税人类型类型错误");
}
// 商户信息
merchant.id = params.id;
merchant.name = this.trim(params.name);
merchant.taxType = params.taxType;
merchant.contactName = this.trim(params.contactName);
merchant.contactMobile = this.trim(params.contactMobile);
merchant.contactEmail = this.trim(params.contactEmail);
merchant.invoiceValid = params.invoiceValid ? 1 : 0;
merchant.mustPay = params.mustPay ? 1 : 0;
merchant.status = "00";
merchant.ownerId = this.trim(params.ownerId);
if(merchant.ownerId) {
// TODO 去用户平台查询用户信息
merchant.ownerName = "测试用户名";
merchant.ownerMobile = "测试用户手机号";
merchant.ownerPath = "/aaa/bbbb/ccc/ddd/eee/fff/zzz/yyy";
}
return await this.callms("merchant", "updMerchant", merchant);
}
async audit(params) {
var mobile = this.trim(params.mobile);
var ucname = this.trim(params.mobile);
params.status = "10";
params.ucname = ucname;
params.ucid = ucid;
// TODO 调用平台,创建商户用户
var auditRs = await this.callms("merchant", "auditMerchant", params);
return auditRs;
}
}
module.exports = MerchantService;
const system=require("../../../system");
const ServiceBase=require("../../svems.base")
const settings=require("../../../../config/settings")
class MerchantaccountService extends ServiceBase{
constructor(){
super();
}
async page(params) {
var res = await this.callms("merchant", "merchantAccountPage", params);
await this.trans(res.data.rows);
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) {
if (!rows) {
return;
}
for (var item of rows) {
if (!item) {
continue;
}
item.banlance = system.f2y(item.banlance);
}
}
}
module.exports=MerchantaccountService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class MerchantaddressService extends ServiceBase {
constructor() {
super();
}
async page(params) {
var res = await this.callms("merchant", "merchantAddressList", params);
return res;
}
async info(params) {
return await this.callms("merchant", "merchantAddressInfo", params);
}
async save(params) {
return await this.callms("merchant", "merchantAddressSave", params);
}
async setDefault(params) {
var res = await this.callms("merchant", "merchantAddressDefault", params);
return res;
}
}
module.exports = MerchantaddressService;
// 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")
const settings = require("../../../../config/settings")
class MerchantrechargeService extends ServiceBase {
constructor() {
super();
this.pushapiSve = system.getObject("service.push.pushapiSve");
}
async add(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);
// return res;
}
async info(params) {
var res = await this.callms("merchant", "merchantRechargeInfo", params);
await this.transfield([res.data]);
return res;
}
async audit(params) {
var res = await this.callms("merchant", "merchantRechargeAudit", params);
if (res.status == 0) {
this.pushAudit(params);
}
return res;
}
async page(params) {
var res = await this.callms("merchant", "merchantRechargePage", params);
await this.transfield(res.data.rows);
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) {
if (!rows) {
return;
}
for (var item of rows) {
if (!item) {
continue;
}
item.amt = system.f2y(item.amt);
}
}
}
module.exports = MerchantrechargeService;
// 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")
const settings = require("../../../../config/settings")
class MerchantsignedService extends ServiceBase {
constructor() {
super();
}
async page(params) {
var res = await this.callms("merchant", "merchantSignList", params);
await this.doRate(res.data.rows);
return res;
}
async save(params) {
params.serviceRate = system.y2f(params.serviceRate);
return await this.callms("merchant", "saveMerchantSign", params);
}
async info(params) {
var res = await this.callms("merchant", "merchantSignInfo", params);
await this.doRate([res.data]);
return res;
}
async doRate(rows) {
if (!rows) {
return;
}
for (var item of rows) {
if (!item) {
continue;
}
item.serviceRate = system.f2y(item.serviceRate);
}
}
}
module.exports = MerchantsignedService;
// 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 MerchanttitleService extends ServiceBase{
constructor(){
super();
}
async merchantTitleList(params){
return await this.callms("merchant","merchantTitleList",params);
}
async merchantTitleInfo(params){
console.log(JSON.stringify(params));
return await this.callms("merchant","merchantTitleInfo", params);
}
async merchantTitleSave(params){
console.log(JSON.stringify(params));
return await this.callms("merchant","merchantTitleSave",params);
}
async merchantTitleDefault(params){
return await this.callms("merchant","merchantTitleDefault",params);
}
}
module.exports=MerchanttitleService;
const system=require("../../../system");
const ServiceBase=require("../../sve.base");
class MsgHistoryService extends ServiceBase{
constructor(){
super(ServiceBase.getDaoName(MsgHistoryService));
this.msgnoticeDao = system.getObject("db.msgnoticeDao");
this.userDao = system.getObject("db.userDao");
this.redisClient = system.getObject("util.redisClient");
this.businesslicenseDao = system.getObject("db.businesslicenseDao");
}
getApp(appkey){
return this.cacheManager["AppCache"].cacheApp(appkey);
}
async saveMsg(msg) {
var self = this;
console.log("save msg ", msg);
// 事务
await this.db.transaction(async function (t){
// 1.保存聊天信息
msg = await self.dao.create(msg, t);
// 2.保存好友信息
await self.msgnoticeDao.saveNotice(msg, t);
});
return msg;
}
async pushBusinessLicenseMsg(senderId, targetId, businessLicense_id) {
if(!businessLicense_id) {
return 0;
}
var notice = await this.msgnoticeDao.findOne({fromId : senderId, toId : targetId});
if(notice && notice.businessLicense_id == businessLicense_id) {
return 0;
}
var senderUser = await this.userDao.findById(senderId);
var targetUser = await this.userDao.findById(targetId);
var senderChannel = senderUser.app_id + "¥" + senderUser.id;
var targetChannel = targetUser.app_id + "¥" + targetUser.id;
var sender = senderUser.app_id + "¥" + senderUser.id + "¥" + senderUser.headUrl;
var target = targetUser.app_id + "¥" + targetUser.id + "¥" + targetUser.headUrl;
var msg = {
msgType: "mryzLicense",
sender:sender,
senderId:senderId,
target:target,
targetId:targetId,
content:businessLicense_id,
isRead:false,
businessLicense_id:businessLicense_id
}
var obj = await this.saveMsg(msg);
var bl = await this.businesslicenseDao.findById(businessLicense_id);
msg.businessLicense = bl;
msg.id = obj.id;
msg.created_at = obj.created_at;
this.redisClient.publish(senderChannel, JSON.stringify(msg));
this.redisClient.publish(targetChannel, JSON.stringify(msg));
return 1;
}
async getChatList(senderId, targetId, maxId, pageSize) {
let sql = "SELECT * FROM `msghistory` WHERE id < :maxId AND ((senderId = :senderId AND targetId = :targetId) OR (targetId = :senderId AND senderId = :targetId)) ORDER BY id DESC LIMIT :pageSize "
let params = {senderId:senderId, targetId: targetId, maxId: maxId, pageSize: pageSize};
var list = await this.dao.customQuery(sql, params);
if(!list || list.length == 0) {
return [];
}
var licenseIds = [];
var msgIds = [];
list.forEach(item => {
if(item.msgType == 'mryzLicense') {
licenseIds.push(Number(item.businessLicense_id));
}
msgIds.push(item.id);
});
if(licenseIds.length > 0) {
let licenseSql = "SELECT * FROM yz_business_license WHERE id IN (" + licenseIds.join(",") + ") ";
var licenseList = await this.businesslicenseDao.customQuery(licenseSql);
var licenseMap = [];
licenseList.forEach(item => {
licenseMap["id" + item.id] = item;
});
list.forEach(item => {
if(item.msgType == 'mryzLicense') {
item.businessLicense = licenseMap['id' + item.businessLicense_id];
}
});
}
var self = this;
setTimeout(function(){
self.setRead(senderId, targetId, list);
}, 1000);
return list;
}
async setRead(senderId, targetId, list) {
if(!list || list.length == 0) {
return;
}
var target = await this.userDao.findById(targetId);
if(!target) {
return;
}
var pushIds = [];
for(var item of list) {
if(item.isRead || senderId != item.targetId) {
continue;
}
pushIds.push(item.id);
}
if(pushIds.length == 0) {
return;
}
this.dao.updateByWhere({isRead: true}, {where:{id:{[this.db.Op.in]:pushIds}}});
var channel = target.app_id + "¥" + target.id;
var rs = await this.redisClient.publish(channel, JSON.stringify({type:"readmsg", data : pushIds}));
console.log(rs, "------------------------------------------ publish result ");
}
async readMsg(userId, id) {
var msg = await this.dao.findById(id);
if(!msg || userId != msg.targetId) {
return 0;
}
msg.isRead = true;
await msg.save();
var user = await this.userDao.findById(msg.senderId);
if(!user) {
return 0;
}
var channel = user.app_id + "¥" + user.id;
return await this.redisClient.publish(channel, JSON.stringify({type:"readmsg", data : [msg.id]}));
}
}
module.exports=MsgHistoryService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
class MsgNoticeService extends ServiceBase {
constructor() {
super(ServiceBase.getDaoName(MsgNoticeService));
//this.appDao=system.getObject("db.appDao");
this.userDao = system.getObject("db.userDao");
this.businesslicenseDao = system.getObject("db.businesslicenseDao");
this.msghistoryDao = system.getObject("db.msghistoryDao");
}
getApp(appkey) {
return this.cacheManager["AppCache"].cacheApp(appkey);
}
async getUserList(userId) {
var list = await this.dao.model.findAll({
where: {
fromId: userId
},
order: [
["updated_at", "DESC"]
],
raw: true
});
if (!list || list.length == 0) {
return [];
}
var msgIds = [];
var businessLicenseIds = [];
var userIds = [];
for (var item of list) {
msgIds.push(item.lastMsgId);
businessLicenseIds.push(item.businessLicense_id);
userIds.push(item.toId);
}
var msgMap = [];
var businessLicenseMap = [];
var userMap = [];
var unreadMap = [];
// 最后一条聊天记录
if (msgIds.length > 0) {
var msgList = await this.msghistoryDao.customQuery("SELECT * FROM msghistory WHERE id IN (" + msgIds.join(",") + ") ");
msgList.forEach(item => {
msgMap["id" + item.id] = item;
});
}
// 最后一次聊天关联执照
if (businessLicenseIds.length > 0) {
var licenseList = await this.businesslicenseDao.customQuery("SELECT * FROM yz_business_license WHERE id IN (" + businessLicenseIds.join(",") + ") ");
var serviceTypeIds = [];
for (var item of licenseList) {
serviceTypeIds.push(item.serviceTypeOneId);
serviceTypeIds.push(item.serviceTypeTwoId);
}
if (serviceTypeIds.length > 0) {
var sql = "SELECT id, name FROM `p_service_type` WHERE id IN (" + serviceTypeIds.join(",") + ") ";
var typeList = await this.dao.customQuery(sql);
var typeMap = [];
if (typeList && typeList.length > 0) {
for (var t of typeList) {
typeMap["type_id_" + t.id] = t.name;
if (t.id == item.serviceTypeOneId) {
item.serviceTypeOneName = t.name;
} else if (t.id == item.serviceTypeTwoId) {
item.serviceTypeTwoName = t.name;
} else {}
}
}
}
for (var item of licenseList) {
item.serviceTypeOneName = typeMap["type_id_" + item.serviceTypeOneId];
item.serviceTypeTwoName = typeMap["type_id_" + item.serviceTypeTwoId];
}
licenseList.forEach(item => {
businessLicenseMap["id" + item.id] = item;
});
}
// 聊天好友用户信息
if (userIds.length > 0) {
var userList = await this.userDao.customQuery("SELECT * FROM p_user WHERE id IN (" + userIds.join(",") + ") ");
userList.forEach(item => {
userMap["id" + item.id] = item;
});
}
// 未读消息数量
var unreadList = await this.userDao.customQuery("SELECT senderId, COUNT(1) AS num FROM `msghistory` WHERE isRead = 0 AND targetId = " + userId + " GROUP BY senderId ");
unreadList.forEach(item => {
unreadMap["id" + item.senderId] = item.num;
});
var rs = [];
for (var i in list) {
var item = list[i];
item.lastMsg = msgMap["id" + item.lastMsgId];
item.businessLicense = businessLicenseMap["id" + item.businessLicense_id];
item.friend = userMap["id" + item.toId];
item.unreadCount = unreadMap["id" + item.toId] || 0;
rs.push(item);
}
return rs;
}
async countUnread(userId) {
debugger;
var unreadList = await this.userDao.customQuery("SELECT COUNT(1) AS num FROM `msghistory` WHERE isRead = 0 AND targetId = " + userId);
var count = 0;
if (unreadList && unreadList.length > 0) {
count = unreadList[0].num || 0;
}
return count;
}
}
module.exports = MsgNoticeService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class OrderService extends ServiceBase {
constructor() {
super();
this.pushapiSve = system.getObject("service.push.pushapiSve");
}
async addOrder(params) {
var merchantId = params.merchant_id;
var rs = await this.callms("merchant", "getById", {
id: merchantId
});
if (!rs || rs.status != 0 || !rs.data) {
return system.getResult(null, rs.msg || "商户不存在");
}
var merchant = rs.data;
// 处理参数
var order = {};
order.merchantId = merchantId;
order.channelOrderNo = this.trim(params.channelOrderNo);
order.legalName = this.trim(params.legalName);
order.legalMobile = this.trim(params.legalMobile);
order.legalImg = this.trim(params.legalImg);
order.idcard = this.trim(params.idcard);
order.idcardFront = this.trim(params.idcardFront);
order.idcardBack = this.trim(params.idcardBack);
order.bankNo = this.trim(params.bankNo);
order.bank = this.trim(params.bank);
order.names = this.trim(params.names);
order.capital = this.trim(params.capital);
order.domicileId = this.trim(params.domicileId);
order.businessScopeId = this.trim(params.businessScopeId);
order.businesssScope = this.trim(params.businesssScope);
order.bdId = this.trim(merchant.ownerId);
order.bdPath = this.trim(merchant.ownerPath);
return await this.callms("order", "addOrder", params);
}
async putOrder(params) {
var merchantId = params.merchant_id;
var rs = await this.callms("merchant", "getById", {
id: merchantId
});
if (!rs || rs.status != 0 || !rs.data) {
return system.getResult(null, rs.msg || "商户不存在");
}
var merchant = rs.data;
// 处理参数
var order = {};
order.merchantId = merchantId;
order.channelOrderNo = this.trim(params.channelOrderNo);
order.legalName = this.trim(params.legalName);
order.legalMobile = this.trim(params.legalMobile);
order.legalImg = this.trim(params.legalImg);
order.idcard = this.trim(params.idcard);
order.idcardFront = this.trim(params.idcardFront);
order.idcardBack = this.trim(params.idcardBack);
order.bankNo = this.trim(params.bankNo);
order.bank = this.trim(params.bank);
order.names = this.trim(params.names);
order.capital = this.trim(params.capital);
order.domicileId = this.trim(params.domicileId);
order.businessScopeId = this.trim(params.businessScopeId);
order.businessScope = this.trim(params.businessScope);
return await this.callms("order", "updOrder", params);
}
async queryOrder(params) {
var condition = {
merchantId: this.trim(params.merchant_id),
channelOrderNo: this.trim(params.channelOrderNo),
}
var rs = await this.callms("order", "byChannelOrderId", condition);
if (rs.status != 0) {
return rs;
}
var order = rs.data;
var dto = {};
dto.orderNo = order.id;
dto.channelOrderNo = order.channelOrderNo;
dto.legalName = order.legalName;
dto.legalMobile = order.legalMobile;
dto.legalImg = order.legalImg;
dto.idcard = order.idcard;
dto.idcardFront = order.idcardFront;
dto.idcardBack = order.idcardBack;
dto.bankNo = order.bankNo;
dto.bank = order.bank;
dto.bankImg = order.bankImg;
dto.names = order.names;
dto.businessScope = order.businessScope;
dto.capital = order.capital;
dto.status = order.ostatus;
dto.opNotes = order.opNotes;
dto.domicileId = order.domicile_id;
dto.businessScopeId = order.businessScope_id;
dto.businessScope = order.businessScope;
return system.getResultSuccess(dto);
}
async allOrderList(params) {
var rs = await this.callms("order", "allOrderList", params);
await this.transfield(rs.data.rows);
await this.setMerchant(rs.data.rows);
return rs;
}
async orderClose(params) {
var p = {
merchantId: params.merchantId || params.merchant_id,
channelOrderNo: params.channelOrderNo
};
var rs = await this.callms("order", "orderClose", p);
return rs;
}
async closeById(params) {
var rs = await this.callms("order", "closeOrderById", {
id: params.id
});
return rs;
}
async assign(params) {
var rs = await this.callms("order", "orderAssign", params);
return rs;
}
async orderEdit(params) {
var rs = await this.callms("order", "orderEdit", params);
return rs;
}
async orderComplete(params) {
var rs = await this.callms("order", "orderComplete", params);
if (rs.status == 0) {
this.pushDeliver(params);
}
return rs;
}
async orderInfoAll(params, isMerchant) {
var rs = await this.callms("order", "orderInfoAll", params);
await this.transfield([rs.data]);
if (rs.data) {
if (rs.data.deliver) {
rs.data.deliverDivide = system.f2y(rs.data.deliver.deliverDivide);
}
if (rs.data.businessmen) {
rs.data.businessmen.costRate = system.f2y(rs.data.businessmen.costRate);
rs.data.businessmen.taxRate = system.f2y(rs.data.businessmen.taxRate);
rs.data.businessmen.serviceRate = system.f2y(rs.data.businessmen.serviceRate);
}
if (isMerchant) {
var merchant = await this.callms("merchant", "getById", {
id: rs.data.merchant_id
}) || {};
rs.data.merchant = merchant.data || {};
}
}
return rs;
}
// 订单办理
async handlePage(params) {
var rs = await this.callms("order", "orderDeliverList", params);
if (rs.status === 0 && rs.data && rs.data.rows) {
for (var row of rs.data.rows) {
row.deliverDivide = system.f2y(row.deliverDivide);
row.order.price = system.f2y(row.order.price);
}
}
return rs;
}
async deliverEdit(params) {
var obj = {
order: params.order,
businessmen: params.businessmen
};
return await this.callms("order", "orderDeliverEdit", obj);
}
async deliverClose(params) {
var obj = {
id: params.id,
breakReason: params.breakReason,
};
return await this.callms("order", "orderDeliverClose", obj);
}
async deliverHandle(obj) {
var rs = await this.callms("order", "orderDeliverHandle", obj);
// var rs = {status: 0};
if (rs.status === 0) {
// 推送数据
this.pushDeliver(obj);
}
return rs;
}
async deliverAudit(obj) {
return await this.callms("order", "orderDeliverAudit", obj);
}
async pushDeliver(obj) {
var status = obj.status;
if (!status) {
return;
}
var order = await this.callms("order", "orderByDeliverId", {
orderDeliverId: obj.id
});
order = order.data;
if (!order) {
console.log("推送信息失败[" + JSON.stringify(obj) + "],订单不存在 ------------------------");
return;
}
var merchant = await this.callms("merchant", "secretById", {
id: order.merchant_id
});
merchant = merchant.data;
if (!merchant) {
console.log("推送信息失败[" + JSON.stringify(obj) + "],商户不存在 ------------------------");
return;
}
var options = {
merchantId: merchant.id,
appKey: merchant.appSecret,
dataType: 1,
dataId: order.id,
field: "orderStatus",
};
var params = {
merchantId: merchant.id,
status: status,
channelOrderNo: order.channelOrderNo,
}
var handlingStatus = ["1050", "1070", "1090", "1110"];
if (status == "1060") {
// 已出执照
params.name = this.trim(obj.name);
params.creditCode = this.trim(obj.creditCode);
params.businessPlace = this.trim(obj.businessPlace);
params.businessScope = this.trim(obj.businessScope);
params.regDate = this.trim(obj.regDate);
params.businessImg = this.trim(obj.businessImg);
params.orderNo = this.trim(obj.orderNo);
params.legalName = this.trim(obj.legalName);
params.legalMobile = this.trim(obj.legalMobile);
} else if (status == "1080") {
// 已刻章
params.gongzhang = this.trim(obj.gongzhang);
params.caiwuzhang = this.trim(obj.caiwuzhang);
params.businessImg = this.trim(obj.businessImg);
params.fapiaozhang = this.trim(obj.fapiaozhang);
params.hetongzhang = this.trim(obj.hetongzhang);
params.farenzhang = this.trim(obj.farenzhang);
} else if (status == "1100") {
// 银行卡已开户
params.isBank = obj.isBank ? 1 : 0;
params.bankName = this.trim(obj.bankName);
params.bankNo = this.trim(obj.bankNo);
params.bank = this.trim(obj.bank);
params.bankImg = this.trim(obj.bankImg);
} else if (status == "1120") {
// 已税务报道
params.caImg = this.trim(obj.caImg);
params.taxRegDay = this.trim(obj.taxRegDay);
params.taxOrg = this.trim(obj.taxOrg);
} else if (status == "1170") {
// 已完成
params.courierNo = this.trim(obj.deliverNo);
params.courierImg = this.trim(obj.deliverImg);
} else if (handlingStatus.indexOf(status) != -1) {} else {
return;
}
options.params = params;
await this.pushapiSve.push(options);
}
async statManageData(params) {
var res = await this.callms("order", "statTransData", params);
return res;
}
async statBusinessData(params) {
var res = await this.callms("order", "statBusinessData", params);
return res;
}
async statDeliverData(params) {
var res = await this.callms("order", "statDeliverData", params);
return res;
}
async transfield(rows) {
if (!rows || rows.length == 0) {
return;
}
for (var row of rows) {
row.price = system.f2y(row.price);
}
return rows;
}
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] || {};
}
}
}
module.exports = OrderService;
// 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("../../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 ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class PushlogService extends ServiceBase {
constructor() {
super("push", ServiceBase.getDaoName(PushlogService));
}
}
module.exports = PushlogService;
// 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")
class authService extends ServiceBase {
constructor() {
super();
}
/**
* 菜单 添加
* @param {*} params
*/
async addAuth(params) {
try {
return await this.callms("uc", "addAuth", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 更新
* @param {*} params
*/
async updAuth(params) {
try {
return await this.callms("uc", "updAuth", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 删除
* @param {*} params
*/
async delAuth(params) {
try {
return await this.callms("uc", "delAuth", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 查询明细
* @param {*} params
*/
async queryById(params) {
try {
return await this.callms("uc", "authInfo", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子菜单
* @param {*} params
*/
async byPid(params) {
try {
return await this.callms("uc", "authByPid", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params) {
try {
return await this.callms("uc", "authTree", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = authService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class OrgService extends ServiceBase {
constructor() {
super();
}
/**
* 组织机构 添加
* @param {*} params
*/
async addOrg(params) {
try {
return await this.callms("uc", "addOrg", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 更新
* @param {*} params
*/
async updOrg(params) {
try {
return await this.callms("uc", "updOrg", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 删除
* @param {*} params
*/
async delOrg(params) {
try {
return await this.callms("uc", "delOrg", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询列表
* @param {*} params
*/
async listOrg(params) {
try {
return await this.callms("uc", "listOrg", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询明细
* @param {*} params
*/
async queryById(params) {
try {
return await this.callms("uc", "orgQueryById", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async byPid(params) {
try {
return await this.callms("uc", "orgByPid", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params) {
try {
return await this.callms("uc", "orgTree", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = OrgService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class RoleService extends ServiceBase {
constructor() {
super();
}
/**
* 角色 添加
* @param {*} params
*/
async addRole(params) {
try {
return await this.callms("uc", "addRole", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 角色 更新
* @param {*} params
*/
async updRole(params) {
try {
return await this.callms("uc", "updRole", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 角色 删除
* @param {*} params
*/
async delRole(params) {
try {
return await this.callms("uc", "delRole", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 角色 查询列表
* @param {*} params
*/
async listRole(params) {
try {
return await this.callms("uc", "listRole", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 角色 查询明细
* @param {*} params
*/
async queryById(params) {
try {
return await this.callms("uc", "roleQueryById", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async setAuth(params) {
try {
return await this.callms("uc", "setAuth", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = RoleService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class SaasService extends ServiceBase {
constructor() {
super();
}
/**
* saas 添加
* @param {*} params
*/
async addSaas(params) {
try {
return await this.callms("uc", "addSaas", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 更新
* @param {*} params
*/
async updSaas(params) {
try {
return await this.callms("uc", "updSaas", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 删除
* @param {*} params
*/
async delSaas(params) {
try {
return await this.callms("uc", "delSaas", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询列表
* @param {*} params
*/
async listSaas(params) {
try {
return await this.callms("uc", "listSaas", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询明细
* @param {*} params
*/
async queryById(params) {
try {
return await this.callms("uc", "orgQuery", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = SaasService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class UserService extends ServiceBase {
constructor() {
super();
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.opuserrelationDao = system.getObject("db.common.opuserrelationDao");
}
async login(params) {
try {
return await this.callms("uc", "login", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 添加
* @param {*} params
*/
async addUser(params) {
try {
var relation = await this.opuserrelationDao.findOne({
ucname: params.ucname
});
if (!relation) {
var rs = await this.platformUtils.createUserInfo(params.ucname, params.ucname, params.password);
if (!rs.data || !rs.data.account_id) {
return rs;
}
params.ucid = rs.data.account_id;
this.opuserrelationDao.model.create({
ucname: params.ucname,
ucid: rs.data.account_id,
});
} else {
params.ucid = relation.ucid;
}
system.getResultSuccess();
return await this.callms("uc", "addUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新
* @param {*} params
*/
async updUser(params) {
try {
return await this.callms("uc", "updUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async enabled(params) {
try {
return await this.callms("uc", "enabled", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* @param {*} params
*/
async page(params) {
try {
return await this.callms("uc", "userPage", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 删除
* @param {*} params
*/
async delUser(params) {
try {
return await this.callms("uc", "delUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询明细
* @param {*} params
*/
async queryById(params) {
try {
return await this.callms("uc", "userInfo", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 修改密码
* @param {*} params
*/
async updPassword(params) {
try {
var user = await this.callms("uc", "userInfo", params);
user = user.data;
var rs = await this.platformUtils.modifyPassword(user.ucid, params.password);
if (rs.status !== 0) {
return rs;
}
await this.callms("uc", "updPassword", params);
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserService;
\ No newline at end of file
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