Commit f3ea4a47 by wangyong

feat: (agriculture) 磐农项目

parent 6531e823
.DS_Store
app/front/entry/public/.DS_Store
# modules
node_modules/ node_modules/
# localsetting
app/config/localsettings.js app/config/localsettings.js
app/front/entry/public/.DS_Store
\ No newline at end of file # change history
.history/
\ No newline at end of file
...@@ -17,6 +17,8 @@ class CtlBase { ...@@ -17,6 +17,8 @@ class CtlBase {
return system.getResult(up); return system.getResult(up);
} }
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
console.log('---------------------aaa------------------');
console.log(res);
const up = await this.service.create(pobj); const up = await this.service.create(pobj);
return system.getResult(up); return system.getResult(up);
} }
...@@ -41,10 +43,10 @@ class CtlBase { ...@@ -41,10 +43,10 @@ class CtlBase {
let lastindex = custtags ? custtags.length - 1 : 0; let lastindex = custtags ? custtags.length - 1 : 0;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值 //当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = { req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色 appkey: req.headers["xappkey"], //用于系统管理区分应用,比如角色
fromappkey: req.headers["xfromappkey"],//来源APP,如果没有来源与appkey相同 fromappkey: req.headers["xfromappkey"], //来源APP,如果没有来源与appkey相同
companyid: custtags ? custtags[0].split("_")[1] : null, companyid: custtags ? custtags[0].split("_")[1] : null,
fromcompanykey: req.headers["xfromcompanykey"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司 fromcompanykey: req.headers["xfromcompanykey"], //专用于自由用户注册,自由用户用于一定属于某个存在的公司
password: custtags ? custtags[lastindex].split("_")[1] : null, password: custtags ? custtags[lastindex].split("_")[1] : null,
username: req.headers["x-consumer-username"], username: req.headers["x-consumer-username"],
userid: req.headers["x-consumer-custom-id"], userid: req.headers["x-consumer-custom-id"],
...@@ -81,13 +83,13 @@ class CtlBase { ...@@ -81,13 +83,13 @@ class CtlBase {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey); let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey);
req.xctx.companyid = comptmp.id; req.xctx.companyid = comptmp.id;
} }
if (req.xctx.companyid) {//在请求传递数据对象注入公司id if (req.xctx.companyid) { //在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid; pobj.company_id = req.xctx.companyid;
} }
if (req.xctx.userid) {//在请求传递数据对象注入公司id if (req.xctx.userid) { //在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid; pobj.userid = req.xctx.userid;
} }
if (req.xctx.username) {//在请求传递数据对象注入公司名称 if (req.xctx.username) { //在请求传递数据对象注入公司名称
pobj.username = req.xctx.username; pobj.username = req.xctx.username;
} }
pobj.bizpath = req.xctx.bizpath; pobj.bizpath = req.xctx.bizpath;
......
const CtlBase = require("../../ctl.base");
/**
* @module agriculture/
* @class accountingCtl
* 会计 ctl
*/
class accountingCtl extends CtlBase {
constructor() {
super("agriculture", CtlBase.getServiceName(accountingCtl));
}
}
module.exports = accountingCtl;
\ No newline at end of file
const CtlBase = require("../../ctl.base");
/**
* @module agriculture
* @class accountsetCtl
* 帐套 ctl
*/
class accountsetCtl extends CtlBase {
constructor() {
super("agriculture", CtlBase.getServiceName(accountsetCtl));
}
}
module.exports = accountsetCtl;
\ No newline at end of file
var system = require("../../../system");
const CtlBase = require("../../ctl.base");
/**
* @module agriculture
* @class servicelistCtl
* 服务单ctl
*/
class servicebillCtl extends CtlBase {
constructor() {
super("agriculture", CtlBase.getServiceName(servicebillCtl));
}
async create(obj) {
//TODO: 复写create 校验服务单是否已存在
const res = await this.service.findOne({ bizId: obj.bizId });
if (res != null) {
return system.getResult({ massage: "该服务单已创建" });
}
const cre_res = await this.service.create(obj);
return system.getResult(cre_res);
}
async updateStatus(obj) {
const rs = await this.service.updateStatus(obj);
return system.getResult(rs);
}
async updateAndPush(obj) {
const rs = await this.service.updateAndPush(obj);
return system.getResult(rs);
}
async updateAndFeedback(obj) {
const rs = await this.service.updateAndFeedback(obj);
return system.getResult(rs);
}
}
module.exports = servicebillCtl;
\ No newline at end of file
/**
* 会计表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("accounting", {
name: { // 姓名
allowNull: false,
type: DataTypes.STRING
},
agentAccountId: { //易代账ID
allowNull: true,
type: DataTypes.STRING
},
sex: { //性别
allowNull: false,
type: DataTypes.STRING
},
age: { //年龄
allowNull: false,
type: DataTypes.STRING
},
mobile: { //电话
allowNull: true,
type: DataTypes.INTEGER
}
}, {
paranoid: false, //假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'accounting',
validate: {},
indexes: []
});
}
\ No newline at end of file
/**
* 账套表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("accountset", {
manageId: { // 工作台管理ID
allowNull: false,
type: DataTypes.STRING
},
custName: { //客户名称
allowNull: false,
type: DataTypes.STRING
},
code: { //助记码
allowNull: true,
type: DataTypes.STRING
},
corpAddress: { //公司地址
allowNull: true,
type: DataTypes.STRING
},
opsCertificate: { //营业执照
allowNull: true,
type: DataTypes.STRING
},
legalRepresentative: { //法人
allowNull: true,
type: DataTypes.STRING
},
legalRepresentativeSsn: { //法人身份证号
allowNull: true,
type: DataTypes.STRING
},
contactName: { //联系人
allowNull: true,
type: DataTypes.STRING
},
contactTel: { //联系方式
allowNull: true,
type: DataTypes.STRING
},
corpName: { //企业名称
allowNull: false,
type: DataTypes.STRING
},
taxiationArea: { //报税地区
allowNull: false,
type: DataTypes.STRING
},
taxIndustryId: { //行业
allowNull: false,
type: DataTypes.STRING
},
serviceTypeEnum: { //服务类型:枚举型,包括ACCOUTING-记账服务、INDUSTRY_COMMERCE-工商服务、BOTH-记账与工商服务。
allowNull: false,
type: DataTypes.STRING
},
taxNo: { //税号
allowNull: false,
type: DataTypes.STRING
},
certDueDate: { //证书到期日
allowNull: true,
type: DataTypes.STRING
},
taxCpNo: { //计算机代码
allowNull: true,
type: DataTypes.STRING
},
hasTaxCtrl: { //是否有税控机
allowNull: true,
type: DataTypes.BOOLEAN,
defaultValue: false
},
taxClaimTypeEnum: { //所得税申报类型:枚举型,包括NATIONAL-国税、LOCAL-地税
allowNull: true,
type: DataTypes.STRING
},
taxDep: { //税管所
allowNull: true,
type: DataTypes.STRING
},
taxManager: { //专管员
allowNull: true,
type: DataTypes.STRING
},
taxPhone: { //税务联系电话
allowNull: true,
type: DataTypes.STRING
},
comments: { //备注
allowNull: true,
type: DataTypes.STRING
},
accountantEmployeeId: { //所属会计
allowNull: false,
type: DataTypes.STRING
},
taxClaimMethodEnum: { //申报方式:TAX_DECLARATION-税款申报;ZERO_DECLARATION-零申报;
allowNull: false,
type: DataTypes.STRING
},
isBuild: { //是否建账
allowNull: false,
type: DataTypes.BOOLEAN,
defaultValue: true
},
accountBook: { //账套信息
allowNull: true,
type: DataTypes.JSON
}
}, {
paranoid: false, //假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'accountset',
validate: {},
indexes: []
});
}
\ No newline at end of file
/**
* 服务单
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("servicebill", {
bizId: { // 服务单id
allowNull: false,
type: DataTypes.INTEGER
},
orderNo: {
allowNull: false,
type: DataTypes.INTEGER
},
contactName: { //联系人名称
allowNull: true,
type: DataTypes.STRING
},
contactMobile: { //联系人电话
allowNull: false,
type: DataTypes.STRING
},
timeUnit: { //时间单位年:year
allowNull: false,
type: DataTypes.STRING
},
quantity: { //数量
allowNull: true,
type: DataTypes.INTEGER
},
note: { //备注
allowNull: true,
type: DataTypes.STRING
},
companyInfo: { //公司信息
allowNull: false,
type: DataTypes.JSON
},
orderNo: { //订单号
allowNull: true,
type: DataTypes.STRING
},
status: { //服务单状态
allowNull: false,
type: DataTypes.STRING,
defaultValue: 0,
},
feedback_notes: { //服务单状态审核描述
allowNull: true,
type: DataTypes.STRING
},
accountantEmployeeId: { //所属会计ID
allowNull: true,
type: DataTypes.INTEGER
},
accountantEmployeeName: { //所属会计姓名
allowNull: true,
type: DataTypes.INTEGER
},
accountantAgentAccountId: { //所属会计易代账ID
allowNull: true,
type: DataTypes.INTEGER
}
// companyInfo: { // 对象
// companyName // 公司名称
// taxpayerType // 纳税性质 NORMAL_TAXPAYER 一般纳税人; SMALL_TAXPAYER 小规模纳税人
// acctgSystemId // 会计制度 10001=2013 小企业会计准 则;10002=2007 企业会计准 则;10003=民间非营利组织会 计制度; 10004=工会会计制度
// companyForm // 企业形式 1 公司; 2 合伙企业; 3 个独; 4 个体工商户
// industry //所属行业
// taxpayerNumber // 税号
// companyArea // 公司区域
// }
}, {
paranoid: false, //假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'service_bill',
validate: {},
indexes: []
});
}
\ No newline at end of file
const ServiceBase = require("../../sve.base");
class AccountingService extends ServiceBase {
constructor() {
super("agriculture", ServiceBase.getDaoName(AccountingService));
}
async findAndCountAll(obj) {
const apps = await super.findAndCountAll(obj);
return apps;
}
}
module.exports = AccountingService;
\ No newline at end of file
const ServiceBase = require("../../sve.base");
class AccountsetService extends ServiceBase {
constructor() {
super("agriculture", ServiceBase.getDaoName(AccountsetService));
}
async findAndCountAll(obj) {
const apps = await super.findAndCountAll(obj);
return apps;
}
async create(obj) {
const res = await this.dao.update(obj);
return res;
}
}
module.exports = AccountsetService;
\ No newline at end of file
const ServiceBase = require("../../sve.base");
const ydzPush = require("./../../../utils/ydzClient");
const settings = require("./../../../../config/settings");
const System = require("../../../system");
const moment = require("moment");
const toQft = require("./../../../utils/toQft/index")
class ServicebillService extends ServiceBase {
constructor() {
super("agriculture", ServiceBase.getDaoName(ServicebillService));
this.accountsetSve = system.getObject("service.agriculture.accountsetSve");
}
async findAndCountAll(obj) {
var self = this;
console.log('---------------findAndCountAll ------------------');
const apps = await super.findAndCountAll(obj);
return apps;
}
async updateStatus(obj) {
obj.id = obj.bizId;
const res = await this.dao.update(obj);
return res;
}
async updateAndPush(obj) { //服务单分配会计推企服通回传会计信息、并推易代账新建帐套
const res = await this.dao.update(obj);
const findService = await this.dao.findOne({ bizId: obj.bizId });
if (findService) {
let data = {
custName: findService.contactName, //客户名称
corpName: findService.companyInfo.companyName, //企业名称
taxiationArea: findService.companyInfo.companyArea, //报税地区
taxIndustryId: findService.companyInfo.industry, //行业
serviceTypeEnum: "ACCOUTING", // 服务类型:枚举型,包括ACCOUTING-记账服务、INDUSTRY_COMMERCE-工商服务、BOTH-记账与工商服务。
taxNo: findService.companyInfo.taxpayerNumber, // 税号
accountantEmployeeId: obj.accountantAgentAccountId, //所属会计
taxClaimMethodEnum: "TAX_DECLARATION", //申报方式:TAX_DECLARATION-税款申报;ZERO_DECLARATION-零申报;
isBuild: true //是否建账
}
console.log(data);
//TODO: 推企服通回传会计信息
// dev gsbweb.qifu-dev.gongsibao.com/api/opreceive/service/notice
// pro gsbweb.qifu.gongsibao.com/api/opreceive/service/notice
// pushQiFuTong({"actionType":"accountingInfo","actionBody": backData});
// TODO: 分配会计并推送易代账新建帐套 回传后新建本地帐套
const accountset = await ydzPush.pushYiDaZhang(user, data);
const res = await this.accountsetSve.create(accountset);
// TODO: 推送企服通帐套信息
// pushQiFuTong({"actionType":"booksInfo","actionBody": res});
} else {
console.log('查无此单:' + obj.bizId);
}
return res;
}
async updateAndFeedback(obj) { //服务单审核并推送企服通
const res = await this.dao.update(obj);
const findOne = await this.dao.findOne({ bizId: obj.bizId });
const deadline = moment(findOne.updated_at).add(findOne.quantity, 'years');
let backData = {};
if (findOne) {
backData.bizId = findOne.bizId;
backData.auditResult = findOne.status;
if (backData.auditResult == 1) { //审核通过
backData.serviceStartTime = findOne.updated_at;
backData.serviceEndTime = deadline;
}
if (backData.auditResult == 2) { // 审核未通过
backData.note = findOne.feedback_notes;
}
//TODO: 推送企服通
// pushQiFuTong({"actionType":"feedback","actionBody": backData});
} else {
console.log('查无此单:' + obj.bizId);
}
}
}
module.exports = ServicebillService;
\ No newline at end of file
const axios = require("axios");
const settings = require("../../config/settings");
const system = require("../system");
const centerChannelUrl = settings.centerChannelUrl();
/**
* 请求易代账
* 封装 获取 userpin token
*/
const pushYiDaZhang = async(data = {}) => {
const ydzUrl = settings.ydzUrl();
const { appKey, appSecret } = settings.ydzKey();
// const openToken = getOpenTokenByAppKey(appKey, appSecret);
const header = {
"Content-Type": "application/json",
"appKey": appKey,
"appSecret": appSecret,
"openToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdG9rZW4iOiI4MjE3MjExMS0xOGIzLTQ4YzgtYTUzMi01ZjVkZjE3ZmM0MTMiLCJzdWIiOiJpc3YiLCJhdWQiOiJpc3YiLCJuYmYiOjE2MDQ2NTcxNDEsImFwcElkIjoiMTA2NSIsInNjb3BlIjoiYXV0aF9hbGwiLCJpc3MiOiJjaGFuamV0IiwiZXhwIjoxNjA1MTc1NTQxLCJ1c2VySWQiOiI2MTAwMDQzMjU3NSIsImlhdCI6MTYwNDY1NzE0MSwib3JnSWQiOiI5MDAwMTIwNTYyNSIsIm9yZ0FjY291bnQiOiJ1MzEzbWN2czR5d2EifQ.j-97chbDAVZQ060EYaLqC6UldYdgdsA4FFrKmCT2tbo"
}
const manageId = await this.getManageIdByOpenToken(header);
await this.postRequest(`${ydzUrl}/ydz/easyacctg/customer/create/{${manageId}}`, data, header);
}
const getOpenTokenByAppKey = async(appKey, appSecret) => {
const data = await this.postRequest(`${ydzUrl}/api/opreceive/accessAuth/getAppTokenByAppKey`, {
"Content-Type": "application/json",
"appKey": appKey,
"appSecret": appSecret
});
return data.token
}
const getManageIdByOpenToken = async(header) => {
const data = await this.postRequest(`${centerChannelUrl}/ydz/setup/openAccess/MainTenant/findMainTenant`, {}, header);
return { manageId: data.id }
}
const postRequest = async(url, data, headers = {}) => {
try {
console.log(` ${url} : 请求信息 ------- `);
console.log(JSON.stringify(data))
console.log(JSON.stringify(headers))
let result = await axios.post(`${url}`, data, {
headers: {
'Content-Type': 'application/json',
...headers
}
});
result = result.data;
console.log(` ${url} : 返回信息 ------- `);
console.log(result);
system.execLogs(
`请求易代账`, {
url,
data,
headers
},
'交付请求',
result,
null
).catch(err => {
console.log(`日志写入错误 ${url}`)
});
if (result.status === 0) {
return result.data
} else {
throw new Error(result.msg)
}
} catch (err) {
console.log(` ${url} : 返回错误信息 ------- `);
console.log(err)
throw (err)
}
}
module.exports = {
pushYiDaZhang,
getManageIdByOpenToken,
getAppTokenByAppKey,
postRequest
}
\ No newline at end of file
...@@ -21,50 +21,63 @@ var settings = { ...@@ -21,50 +21,63 @@ var settings = {
appname: "icp_deliver", appname: "icp_deliver",
appKey: "202003231118", appKey: "202003231118",
secret: "7cbb846246874167b5c7e01cd0016c99", secret: "7cbb846246874167b5c7e01cd0016c99",
kongurl: function () { if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.kongurl; } else { return ENVINPUT.KONG_ADMIAN; } }, kongurl: function() { if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.kongurl; } else { return ENVINPUT.KONG_ADMIAN; } },
txurl: function () { txurl: function() {
if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.txurl; } if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.txurl; } else { return "http://brg-user-center-service"; }
else { return "http://brg-user-center-service"; }
}, },
logUrl: function () { logUrl: function() {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.18.101:4019/api/queueAction/producer/springBoard"; return "http://192.168.18.101:4019/api/queueAction/producer/springBoard";
} else { } else {
return "http://logs-sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard"; return "http://logs-sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard";
} }
}, },
requrl: function () { requrl: function() {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.1.128:4018"; return "http://192.168.1.128:4018";
} else { } else {
return "http://sytxpublic-msgq-service"; return "http://sytxpublic-msgq-service";
} }
}, },
centerChannelUrl: function () {//---------center-channel centerChannelUrl: function() { //---------center-channel
if (this.env == "dev") { if (this.env == "dev") {
return "http://alitm.qifu-dev.gongsibao.com"; return "http://alitm.qifu-dev.gongsibao.com";
} else { } else {
return "http://center-channel-service.chaolai"; return "http://center-channel-service.chaolai";
} }
}, },
qifutongUrl: function () {//---------center-channel qifutongUrl: function() { //---------center-channel
if (this.env == "dev") { if (this.env == "dev") {
return "http://gsbweb.qifu-dev.gongsibao.com"; return "http://gsbweb.qifu-dev.gongsibao.com";
} else { } else {
return "https://fqgsbweb.gongsibao.com"; return "https://fqgsbweb.gongsibao.com";
} }
}, },
queueUrl: function () { queueUrl: function() {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.18.101:4018/api/queueAction/producer/springBoard"; return "http://192.168.18.101:4018/api/queueAction/producer/springBoard";
} else { } else {
return "http://sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard"; return "http://sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard";
} }
}, },
ydzUrl: function() { //TODO: 易代账URL
if (this.env == "dev") {
return "https://sandbox-openapi.chanjet.com";
} else {
return "";
}
},
ydzKey: function() { //TODO: 易代账Key
if (this.env == "dev") {
return { "appKey": "qP2tgcfw", "appSecret": "D25E0435ACFB4844DB75E7E0F87B9F71" };
} else {
return { "appKey": "", "appSecret": "" };
}
},
pmappid: 1, pmappid: 1,
pmcompanyid: 1, pmcompanyid: 1,
pmroleid: { "ta": 1, "pr": 2 }, pmroleid: { "ta": 1, "pr": 2 },
redis: function () { redis: function() {
if (this.env == "dev") { if (this.env == "dev") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
return localsettings.redis; return localsettings.redis;
...@@ -77,7 +90,7 @@ var settings = { ...@@ -77,7 +90,7 @@ var settings = {
}; };
} }
}, },
database: function () { database: function() {
if (this.env == "dev") { if (this.env == "dev") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
return localsettings.database; return localsettings.database;
......
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