Commit 646eb790 by 王勇飞

gyq

parents 88592ad9 aa70fce0
...@@ -33,6 +33,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -33,6 +33,7 @@ class DeliverybillCtl extends CtlBase {
robj.source_name = element.source_name;//渠道来源--前端服务 robj.source_name = element.source_name;//渠道来源--前端服务
robj.channelNumber = element.source_number;//渠道编码 robj.channelNumber = element.source_number;//渠道编码
robj.facilitator_name = element.facilitator_name;//服务商--前端服务 robj.facilitator_name = element.facilitator_name;//服务商--前端服务
robj.facilitator_id = element.facilitator_id;//服务商--id
robj.serviceName = element.facilitator_name; robj.serviceName = element.facilitator_name;
robj.baseInfo = element.delivery_info;//交付单详情 robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态 robj.payStatus = element.delivery_info.payStatus;//交付状态
...@@ -454,11 +455,27 @@ class DeliverybillCtl extends CtlBase { ...@@ -454,11 +455,27 @@ class DeliverybillCtl extends CtlBase {
} }
} }
<<<<<<< HEAD
async settleApply(p, q, req) { async settleApply(p, q, req) {
let ids = p.ids let ids = p.ids
let rtn = await this.service.settleApply(ids, p.userid, p.username) let rtn = await this.service.settleApply(ids, p.userid, p.username)
return system.getResult({}) return system.getResult({})
=======
async settleApplyForTacent(p,q,req){
let ids=p.ids
let spname=p.spname
let spid=p.spid
let rtn=await this.service.settleApplyForTacent(ids,p.userid,p.username,spname,spid)
return system.getResult({})
}
async settleApply(p,q,req){
let ids=p.ids
let spname=p.spname
let spid=p.spid
let rtn=await this.service.settleApply(ids,p.userid,p.username,spname,spid)
return system.getResult({})
>>>>>>> aa70fce057be916a4fa83f794ed2e2334e50370d
} }
/*根据商机编号插入交付单信息*/ /*根据商机编号插入交付单信息*/
async insertInfo(nobj, qobj, req) {//队列的时候用 async insertInfo(nobj, qobj, req) {//队列的时候用
......
...@@ -25,6 +25,12 @@ class DeliverybillDao extends Dao { ...@@ -25,6 +25,12 @@ class DeliverybillDao extends Dao {
// 为空说明是管理员,不需设置组织结构过滤 // 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") { if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = { [this.db.Op.like]:'%qobj.opath%'} qw["salesman_opcode"] = { [this.db.Op.like]:'%qobj.opath%'}
}else{//说明是租户管理员,给租户自己核销结算的功能,
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是结算核销路由过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
}
} }
//不是来自平台前端查询 //不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) { if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SettlebillDao extends Dao {
constructor() {
super(Dao.getModelName(SettlebillDao));
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
}
return qw;
}
}
module.exports = SettlebillDao;
...@@ -49,7 +49,15 @@ module.exports = (db, DataTypes) => { ...@@ -49,7 +49,15 @@ module.exports = (db, DataTypes) => {
payer:{ payer:{
allowNull: true, allowNull: true,
type: DataTypes.STRING, type: DataTypes.STRING,
} },
facilitator_id:{
allowNull: true,
type: DataTypes.INTEGER,
},
facilitator_name:{
allowNull: true,
type: DataTypes.STRING,
},
}, { }, {
paranoid: true,//真的删除 paranoid: true,//真的删除
underscored: true, underscored: true,
......
...@@ -78,6 +78,7 @@ class DeliverybillService extends ServiceBase { ...@@ -78,6 +78,7 @@ class DeliverybillService extends ServiceBase {
} }
} }
<<<<<<< HEAD
async settleApply(ids, uid, uname) { async settleApply(ids, uid, uname) {
var self = this var self = this
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
...@@ -102,6 +103,70 @@ class DeliverybillService extends ServiceBase { ...@@ -102,6 +103,70 @@ class DeliverybillService extends ServiceBase {
} }
return newentity return newentity
}); });
=======
//为租户自己给交付打标记,表示中台已经给予结算,自己记账用
//租户自己临时记录结算情况
async settleApplyForTacent(ids,uid,uname,spname,spid){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let d= await self.dao.customQuery("select sum(cost_price) as settleAmount from delivery_bill where id in (:idstr)",{idstr:ids});
// let settleAmount=await self.dao.model.sum("cost_price",{where:{id:{[self.db.Op.In]:['40','41','42']}},transaction:t})
let settleAmount=d[0].settleAmount
settleAmount=isNaN(settleAmount)?0:settleAmount
let settlecode=await self. getBusUid("JSD")
let settleObj={
code:settlecode,
settle_amount:settleAmount,
creator_id:uid,
creator:uname,
facilitator_name:spname,
facilitator_id:spid,
isPayedStatus:false,
auditedStatus:true,
payer_id:uid,
payer:uname,
auditor_id:uid,
auditor:uname
}
//生成结算单,结算单状态直接更改为已经付款
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 settleApply(ids,uid,uname,spname,spid){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let d= await self.dao.customQuery("select sum(cost_price) as settleAmount from delivery_bill where id in (:idstr)",{idstr:ids});
// let settleAmount=await self.dao.model.sum("cost_price",{where:{id:{[self.db.Op.In]:['40','41','42']}},transaction:t})
let settleAmount=d[0].settleAmount
settleAmount=isNaN(settleAmount)?0:settleAmount
let settlecode=await self. getBusUid("JSD")
let settleObj={
code:settlecode,
settle_amount:settleAmount,
creator_id:uid,
creator:uname,
facilitator_name:spname,
facilitator_id:spid
}
//生成结算单,结算单状态为待审核
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
});
>>>>>>> aa70fce057be916a4fa83f794ed2e2334e50370d
} }
async findAndCountAll(obj) { async findAndCountAll(obj) {
var self = this; var self = this;
......
...@@ -60,6 +60,7 @@ var settings = { ...@@ -60,6 +60,7 @@ var settings = {
idle: 1000000 idle: 1000000
}, },
debug:false, debug:false,
timezone:'+08:00',
dialectOptions:{ dialectOptions:{
requestTimeout: 999999, requestTimeout: 999999,
// instanceName:'DEV' // instanceName:'DEV'
......
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