Commit 5ae0d911 by 蒋勇

d

parent 24663175
......@@ -32,6 +32,7 @@ class DeliverybillCtl extends CtlBase {
robj.source_name = element.source_name;//渠道来源--前端服务
robj.channelNumber = element.source_number;//渠道编码
robj.facilitator_name = element.facilitator_name;//服务商--前端服务
robj.facilitator_id = element.facilitator_id;//服务商--id
robj.serviceName = element.facilitator_name;
robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态
......@@ -418,10 +419,18 @@ class DeliverybillCtl extends CtlBase {
}
}
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 rtn=await this.service.settleApply(ids,p.userid,p.username)
let spname=p.spname
let spid=p.spid
let rtn=await this.service.settleApply(ids,p.userid,p.username,spname,spid)
return system.getResult({})
}
/*根据商机编号插入交付单信息*/
......
......@@ -25,6 +25,12 @@ class DeliverybillDao extends Dao {
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && 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) {
......
......@@ -49,7 +49,15 @@ module.exports = (db, DataTypes) => {
payer:{
allowNull: true,
type: DataTypes.STRING,
}
},
facilitator_id:{
allowNull: true,
type: DataTypes.INTEGER,
},
facilitator_name:{
allowNull: true,
type: DataTypes.STRING,
},
}, {
paranoid: true,//真的删除
underscored: true,
......
......@@ -75,7 +75,9 @@ class DeliverybillService extends ServiceBase {
}
}
async settleApply(ids,uid,uname){
//为租户自己给交付打标记,表示中台已经给予结算,自己记账用
//租户自己临时记录结算情况
async settleApplyForTacent(ids,uid,uname,spname,spid){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
......@@ -88,7 +90,43 @@ class DeliverybillService extends ServiceBase {
code:settlecode,
settle_amount:settleAmount,
creator_id:uid,
creator:uname
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})
......
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