Commit 94ebaaa5 by 王勇飞

gyq

parents c64e897e 901900a1
const system = require("../system");
const uuidv4 = require('uuid/v4');
const settings = require("../../config/settings");
class APIBase{
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
class APIBase {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
companyid: custtags ? custtags[0].split("_")[1] : null,
password: custtags ? custtags[1].split("_")[1] : null,
username: req.headers["x-consumer-username"],
userid: req.headers["x-consumer-custom-id"],
credid: req.headers["x-credential-identifier"],
companykey: req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath: req.headers['xopath'],
ptags: req.headers['xptags'],
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"]?req.headers["x-consumetag"].split("|"):null;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
companyid: custtags?custtags[0].split("_")[1]:null,
password: custtags?custtags[1].split("_")[1]:null,
username: req.headers["x-consumer-username"],
credid: req.headers["x-credential-identifier"],
companykey:req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
}
if(!req.xctx.appkey){
return [-200,"请求头缺少应用x-app-key"]
}else{
let app=await this.cacheManager["AppCache"].cache(req.xctx.appkey);
req.xctx.appid=app.id;
pobj.app_id=app.id;//传递参数对象里注入app_id
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if(!req.xctx.companyid && req.xctx.companykey){
let comptmp=await this.cacheManager["CompanyCache"].cache(req.xctx.companykey);
req.xctx.companyid=comptmp.id;
}
if(req.xctx.companyid){//在请求传递数据对象注入公司id
pobj.company_id=req.xctx.companyid;
}
//添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags
} else {
pobj.opath = req.xctx.opath
}
if (req.xctx.userid) {//在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid;
pobj.username= req.xctx.username
}
if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"]
} else {
// let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
// req.xctx.appid = app.id;
// pobj.app_id = app.id;//传递参数对象里注入app_id
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if (!req.xctx.companyid && req.xctx.companykey) {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.companykey);
req.xctx.companyid = comptmp.id;
}
if (req.xctx.companyid) {//在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid;
}
}
async doexec(gname, methodname, pobj, query, req) {
try {
let xarg = await this.setContextParams(pobj, query, req);
if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg);
}
async doexec(gname, methodname, pobj, query, req) {
try {
let xarg=await this.setContextParams(pobj, query, req);
if(xarg && xarg[0]<0){
return system.getResultFail(...xarg);
}
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack, "api调用异常--error...................");
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
return rtnerror;
}
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack, "api调用异常--error...................");
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
return rtnerror;
}
}
}
module.exports = APIBase;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class BizChanceAPI extends APIBase {
constructor() {
super();
this.bizChanceS=system.getObject("service.bizchance.bizoptSve")
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizChance(p,q,req){
let companyId=p.company_id
let userid=p.userid
let username=p.username
let opath=p.opath
let rtn=await this.bizChanceS.statBizChance(companyId,opath,username,userid)
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
}
module.exports = BizChanceAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class BizDeliverAPI extends APIBase {
constructor() {
super();
this.bizDeliveryS=system.getObject("service.bizchance.deliverybillSve")
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizDelivery(p,q,req){
let companyId=p.company_id
let userid=p.userid
let username=p.username
let opath=p.opath
let rtn=await this.bizDeliveryS.statBizDelivery(companyId,opath,username,userid)
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
}
module.exports = BizDeliverAPI;
......@@ -29,14 +29,24 @@ class DeliverybillCtl extends CtlBase {
robj.businessName = element.product_name;//产品名称
robj.businessType = element.product_code;//产品编码
robj.sourceName = element.source_name;//渠道来源
robj.source_name = element.source_name;//渠道来源--前端服务
robj.channelNumber = element.source_number;//渠道编码
robj.servicerName = element.facilitator_name;
robj.facilitator_name = element.facilitator_name;//服务商--前端服务
robj.serviceName = element.facilitator_name;
robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态
<<<<<<< HEAD
robj.costPrice = this.FenToYuan(element.cost_price);//成本
robj.settleStatus = element.settle_status;
if (robj.businessName == '公司注册') {
if (robj.baseInfo.isWhether == "是" || robj.baseInfo.isVirtual == "是") {//如果有刻章需求或者是虚拟地址
=======
robj.costPrice = element.cost_price;//成本
robj.settle_status=element.settle_status;
robj.settlebill=element.settlebill;
if (robj.businessName == '公司注册'){
if (robj.baseInfo.isWhether == "是" || robj.baseInfo.isVirtual == "是"){//如果有刻章需求或者是虚拟地址
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
robj.relatedProducts = '有';
}
else {
......@@ -405,10 +415,17 @@ class DeliverybillCtl extends CtlBase {
}
<<<<<<< HEAD
async settleApply(p, q, req) {
let ids = p.ids
let rtn = await this.service.settleApply(ids, req.userid, req.username)
return system.getResult({})
=======
async settleApply(p,q,req){
let ids=p.ids
let rtn=await this.service.settleApply(ids,p.userid,p.username)
return system.getResult({})
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
}
/*根据商机编号插入交付单信息*/
async insertInfo(pobj, qobj, req) {//队列的时候用
......
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require('moment');
const appconfig = system.getSysConfig();
class SettleBillCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(BizOptCtl));
this.deliverService = system.getObject("service.bizchance.deliverybillSve");
super("bizchance", CtlBase.getServiceName(SettleBillCtl));
}
async advice(p,q,req){
let sid= p.advice.settleId
let msg=p.advice.memo
let userid=p.userid
let userName=p.username
let rtn=await this.service.advice(sid,msg,userid,userName)
return system.getResult(rtn)
}
async auditPass(p,q,req){
let sid= p.pass.settleId
let rtn=await this.service.auditPass(sid,p.userid,p.username)
return system.getResult(rtn)
}
async pay(p,q,req){
let sid= p.pay.settleId
let rtn=await this.service.pay(sid,p.userid,p.username)
return system.getResult(rtn)
}
}
module.exports = SettleBillCtl;
......@@ -74,8 +74,8 @@ class Dao {
if (en != null) {
return en.destroy();
}
return en
}
return null;
}
extraModelFilter(pobj) {
//return {"key":"include","value":{model:this.db.models.app}};
......
......@@ -5,8 +5,11 @@ class DeliverybillDao extends Dao {
super(Dao.getModelName(DeliverybillDao));
}
extraModelFilter(pobj) {
return {"key":"include","value":{model:this.db.models.settlebill,raw:true,attributes:['memo']}};
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
qc.raw = true;
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
if (qobj.bizpath && qobj.bizpath != "") {
......
......@@ -67,9 +67,9 @@ class DbFactory {
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, });
this.db.models.bizopt.hasOne(this.db.models.scheme, { constraints: false, });
//交付单关联结算单
//交付单关联结算单deliverybill
this.db.models.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false, });
this.db.models.settlebill.hasMany(this.db.models.deliverybill,{as:"dbs",constraints: false,});
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
......
......@@ -38,7 +38,11 @@ module.exports = {
},
"deliverStatus": {//交付单状态
"received": "已接单",//接单日期,公司注册云上园区
<<<<<<< HEAD
"collecting": "材料收集环节",//请配合顾问尽快提供,公司注册
=======
"collecting": "收集工商注册材料",//请配合顾问尽快提供,公司注册
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
"uploading": "上传注册材料",//请配合顾问尽快提供,云上园区注册
"checking": "园区入驻审核",//1个工作日完成,云上园区注册
"auditing": "工商审核环节",//10个工作日内,公司注册、云上园区
......@@ -53,7 +57,11 @@ module.exports = {
},
"diliverStatus1": {//公司注册交付单状态
"received": "已接单",//接单日期
<<<<<<< HEAD
"collecting": "材料收集环节",//请配合顾问尽快提供
=======
"collecting": "收集工商注册材料",//请配合顾问尽快提供
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
"auditing": "工商审核环节",//10个工作日内
"engraving": "刻章环节",//5个工作日内,只有选择了刻章服务时才有该状态
"posting": "证件邮寄环节",//3个工作日内
......@@ -62,7 +70,11 @@ module.exports = {
},
"diliverSataus2": {//云上园区注册交付状态
"received": "已接单",//接单日期
<<<<<<< HEAD
"collecting": "材料收集环节",//请配合顾问尽快提供
=======
"uploading": "上传注册材料",//请配合顾问尽快提供
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
"checking": "园区入驻审核",//1个工作日完成
"auditing": "工商审核环节",//10个工作日内
"engraving": "刻章环节",//5个工作日内,只有选择了刻章服务时才有该状态
......@@ -74,7 +86,11 @@ module.exports = {
"paid": "已付款",
"received": "已接单",
"inservice": "已交付",
<<<<<<< HEAD
"success": "已完成"
=======
"completed": "已完成"
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
},
"payStatus": {//交付状态
"已交付": "已交付",
......@@ -159,10 +175,13 @@ module.exports = {
"agentTypeDict": {//代理记账主体类型
"company": "公司",
"individual": "个体户"
<<<<<<< HEAD
},
"financialDict": {//财税服务
"yes": "需要",
"no": "不需要"
=======
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
},
"buyDurationDict": {//购买时长
"buyDuration": "1年",
......@@ -215,6 +234,15 @@ module.exports = {
"BIZ": "BIZ",//商机表
"SCHEME": "SCHEME",//方案表
"DELIVERY": "DELIVERY"//服务单表
},
settle_status: {
"waittosettle": "待结算",
"settling": "结算中",
"settled": "已结算"
},
audit_status: {
"waittoaudit": "待审核",
"audited": "已审核",
}
}
}
......
......@@ -10,18 +10,45 @@ module.exports = (db, DataTypes) => {
allowNull: true,
type: DataTypes.STRING
},
audit_status: {// 审核状态
allowNull: false,
type: DataTypes.STRING,
defaultValue:'waittoaudit'
auditedStatus: {// 审核状态
type:DataTypes.BOOLEAN,
defaultValue: false
},
settle_amount: {//结算金额
allowNull: true,
type: DataTypes.INTEGER
},
isPayed:{
isPayedStatus:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
memo:{//结算建议
allowNull: true,
type:DataTypes.STRING,
},
creator_id:{//申请人
allowNull: true,
type: DataTypes.INTEGER
},
creator:{
allowNull: true,
type: DataTypes.STRING,
},
auditor_id:{//审核人
allowNull: true,
type: DataTypes.INTEGER
},
auditor:{//审核人
allowNull: true,
type: DataTypes.STRING,
},
payer_id:{//付款人
allowNull: true,
type: DataTypes.INTEGER
},
payer:{
allowNull: true,
type: DataTypes.STRING,
}
}, {
paranoid: true,//真的删除
......
......@@ -6,6 +6,46 @@ class BizOptService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(BizOptService));
}
/**
* 公司id,平台公司ID为1
* @param {*} companyId
* @param {*} opath
* @param {*} username
* @param {*} userid
*/
async statBizChance(companyId,opath,username,userid){
//如果当前登录人是平台,返回所有商机
let waittoHandledCount=0
let handlingCount=0
let finishedCount=0
let closedCount=0
if(companyId==1){
waittoHandledCount=await this.dao.findCount({where:{business_status:'beforeSubmission'}})
handlingCount=await this.dao.findCount({where:{business_status:'beforeConfirmation'}})
finishedCount=await this.dao.findCount({where:{business_status:'isFinished'}})
closedCount=await this.dao.findCount({where:{business_status:'isClosed'}})
}else{
let opathstr=''
if(opath){
opathstr=opath
waittoHandledCount=await this.dao.findCount({where:{business_status:'beforeSubmission',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
handlingCount=await this.dao.findCount({where:{business_status:'beforeConfirmation',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
finishedCount=await this.dao.findCount({where:{business_status:'isFinished',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
closedCount=await this.dao.findCount({where:{business_status:'isClosed',salesman_opcode:{[this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
}else{
waittoHandledCount=await this.dao.findCount({where:{business_status:'beforeSubmission','facilitator_id':companyId}})
handlingCount=await this.dao.findCount({where:{business_status:'beforeConfirmation','facilitator_id':companyId}})
finishedCount=await this.dao.findCount({where:{business_status:'isFinished','facilitator_id':companyId}})
closedCount=await this.dao.findCount({where:{business_status:'isClosed','facilitator_id':companyId}})
}
}
//成单率
let allChance=waittoHandledCount+handlingCount+finishedCount+closedCount
let successRadio=Math.ceil((finishedCount/allChance) * 100)
//如果当前登录人不是平台,那么需要按照opath查询
return {waittoHandledCount:waittoHandledCount,handlingCount:handlingCount,finishedCount:finishedCount,closedCount:closedCount,successRadio:successRadio}
}
async findAndCountAll(obj) {
var self = this;
const apps = await this.dao.findAndCountAll(obj);
......
......@@ -6,20 +6,96 @@ class DeliverybillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService));
}
async statBizDelivery(companyId,opath,username,userid){
//如果当前登录人是平台,返回所有商机
let waittoHandledCount=0//received
let handlingCount=0
let finishedCount=0//success
let closedCount=0//closed
let toSettle=0
let toSettleAmount=0
let settling=0
let settlingAmount=0
let settled=0
let settledAmount=0
if(companyId==1){
waittoHandledCount=await this.dao.findCount({where:{delivery_status:'received'}})
handlingCount=await this.dao.findCount({where:{delivery_status:{[this.db.Op.notIn]:['received','success','closed']}}})
finishedCount=await this.dao.findCount({where:{delivery_status:'success'}})
closedCount=await this.dao.findCount({where:{delivery_status:'closed'}})
toSettle=await this.dao.findCount({where:{settle_status:'waittosettle'}})
toSettleAmount=await this.dao.findSum('cost_price',{where:{settle_status:'waittosettle'}})
settling=await this.dao.findCount({where:{settle_status:'settling'}})
settlingAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settling'}})
settled=await this.dao.findCount({where:{settle_status:'settled'}})
settledAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settled'}})
}else{
let opathstr=''
if(opath){
opathstr=opath
waittoHandledCount=await this.dao.findCount({where:{delivery_status:'received',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
handlingCount=await this.dao.findCount({where:{delivery_status:{[this.db.Op.notIn]:['received','success','closed']},salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
finishedCount=await this.dao.findCount({where:{delivery_status:'success',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
closedCount=await this.dao.findCount({where:{delivery_status:'closed',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
toSettle=await this.dao.findCount({where:{settle_status:'waittosettle',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
toSettleAmount=await this.dao.findSum('cost_price',{where:{settle_status:'waittosettle',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
settling=await this.dao.findCount({where:{settle_status:'settling',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
settlingAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settling',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
settled=await this.dao.findCount({where:{settle_status:'settled',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
settledAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settled',salesman_opcode:{ [this.db.Op.like]:`%${opathstr}%`},'facilitator_id':companyId}})
}else{
waittoHandledCount=await this.dao.findCount({where:{delivery_status:'received','facilitator_id':companyId}})
handlingCount=await this.dao.findCount({where:{delivery_status:{[this.db.Op.notIn]:['received','success','closed']},'facilitator_id':companyId}})
finishedCount=await this.dao.findCount({where:{delivery_status:'success','facilitator_id':companyId}})
closedCount=await this.dao.findCount({where:{delivery_status:'closed','facilitator_id':companyId}})
toSettle=await this.dao.findCount({where:{settle_status:'waittosettle','facilitator_id':companyId}})
toSettleAmount=await this.dao.findSum('cost_price',{where:{settle_status:'waittosettle','facilitator_id':companyId}})
settling=await this.dao.findCount({where:{settle_status:'settling','facilitator_id':companyId}})
settlingAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settling','facilitator_id':companyId}})
settled=await this.dao.findCount({where:{settle_status:'settled','facilitator_id':companyId}})
settledAmount=await this.dao.findSum('cost_price',{where:{settle_status:'settled','facilitator_id':companyId}})
}
}
//成单率
let allHandled=finishedCount+closedCount
//如果当前登录人不是平台,那么需要按照opath查询
return {
waittoHandledCount:waittoHandledCount,
handlingCount:handlingCount,
finishedCount:finishedCount,
closedCount:closedCount,
allHandled:allHandled,
toSettle:toSettle,
toSettleAmount:toSettleAmount?toSettleAmount:0,
settling:settling,
settlingAmount:settlingAmount?settlingAmount:0,
settled:settled,
settledAmount:settledAmount?settledAmount:0
}
}
async settleApply(ids,uid,uname){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let settleAmount=await self.dao.model.findSum("cost_price",{where:{[self.db.Op.In]:ids},transaction:t})
let settleAmount=await self.dao.findSum("cost_price",{where:{id:{[self.db.Op.In]:ids}},transaction:t})
settleAmount=isNaN(settleAmount)?0:settleAmount
let settlecode=await self. getBusUid("JSD")
let settleObj={
code:settlecode,
settle_amount:settleAmount,
creator_id:uid,
creator:uname
}
//生成结算单,结算单状态为待审核
await self.db.models.settlebill.create(settleObj,{transaction:t})
let newentity=await self.db.models.settlebill.create(settleObj,{transaction:t})
//然后按照ids更新交付单的状态为结算中,更新结算单的id到交付单表
for(let idstr of ids){
let up = await self.dao.updateByWhere({settle_status:'settling',
settlebill_id:newentity.id }, { id: idstr }, t);
}
return newentity
});
}
async findAndCountAll(obj) {
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SettleBillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SettleBillService));
this.deliverbillDao=system.getObject("db.bizchance.deliverybillDao")
}
async advice(id,msg,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(id,{transaction:t})
st.auditor_id=userId
st.auditor=userName
st.memo=msg
await st.save({transaction:t})
return st
});
}
async auditPass(settleId,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.auditedStatus=true
st.auditor_id=userId
st.auditor=userName
await st.save({transaction:t})
return st
});
}
async pay(settleId,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.isPayedStatus=true
st.payer_id=userId
st.payer=userName
await st.save({transaction:t})
//改变所有交付单的结算settle_status settled ,
await self.deliverbillDao.updateByWhere({settle_status:'settled'}, { settlebill_id: st.id }, t);
return st
});
}
async delete(p){
var self=this
return this.db.transaction(async function(t){
let dobj=await self.dao.delete(p,t)
//更新交付单上结算状态为waittosettle--待结算,清空settlebill_id
//waittosettle
await self.deliverbillDao.updateByWhere({settle_status:'waittosettle',settlebill_id:null}, { settlebill_id: dobj.id }, t);
return dobj
})
}
}
module.exports = SettleBillService;
\ No newline at end of file
......@@ -217,8 +217,12 @@ class System {
try {
ClassObj = require(objabspath);
} catch (e) {
<<<<<<< HEAD
console.log("ooooooooooooooooooooooooooo");
console.log(e)
=======
console.log(e)
>>>>>>> 901900a178eab18cd3e4171b03f80dbaa5ca62e5
let fname = objsettings[packageName + "base"];
ClassObj = require(fname);
}
......
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