Commit 78d5d964 by 蒋勇

d

parent eb9c296b
...@@ -33,7 +33,8 @@ class DeliverybillCtl extends CtlBase { ...@@ -33,7 +33,8 @@ class DeliverybillCtl extends CtlBase {
robj.baseInfo = element.delivery_info;//交付单详情 robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态 robj.payStatus = element.delivery_info.payStatus;//交付状态
robj.costPrice = element.cost_price;//成本 robj.costPrice = element.cost_price;//成本
robj.settleStatus=element.settle_status; robj.settle_status=element.settle_status;
robj.settlebill=element.settlebill;
if (robj.businessName == '公司注册'){ if (robj.businessName == '公司注册'){
if (robj.baseInfo.isWhether == "是" || robj.baseInfo.isVirtual == "是"){//如果有刻章需求或者是虚拟地址 if (robj.baseInfo.isWhether == "是" || robj.baseInfo.isVirtual == "是"){//如果有刻章需求或者是虚拟地址
robj.relatedProducts = '有'; robj.relatedProducts = '有';
...@@ -230,7 +231,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -230,7 +231,7 @@ class DeliverybillCtl extends CtlBase {
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,req.userid,req.username) let rtn=await this.service.settleApply(ids,p.userid,p.username)
return system.getResult({}) return system.getResult({})
} }
/*根据商机编号插入交付单信息*/ /*根据商机编号插入交付单信息*/
......
...@@ -7,10 +7,24 @@ const moment = require('moment'); ...@@ -7,10 +7,24 @@ const moment = require('moment');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class SettleBillCtl extends CtlBase { class SettleBillCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(BizOptCtl)); super("bizchance", CtlBase.getServiceName(SettleBillCtl));
this.deliverService = system.getObject("service.bizchance.deliverybillSve"); }
async advice(p,q,req){
let sid= p.advice.settleId
let msg=p.advice.memo
let rtn=await this.service.advice(sid,msg)
return system.getResult(rtn)
}
async auditPass(p,q,req){
let sid= p.pass.settleId
let rtn=await this.service.auditPass(sid)
return system.getResult(rtn)
}
async pay(p,q,req){
let sid= p.pay.settleId
let rtn=await this.service.pay(sid)
return system.getResult(rtn)
} }
} }
module.exports = SettleBillCtl; module.exports = SettleBillCtl;
...@@ -5,8 +5,11 @@ class DeliverybillDao extends Dao { ...@@ -5,8 +5,11 @@ class DeliverybillDao extends Dao {
super(Dao.getModelName(DeliverybillDao)); super(Dao.getModelName(DeliverybillDao));
} }
extraModelFilter(pobj) {
return {"key":"include","value":{model:this.db.models.settlebill,raw:true,attributes:['memo']}};
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件 extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
qc.raw = true; //qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据 //检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) { if (qobj.company_id == 1) {
if (qobj.bizpath && qobj.bizpath != "") { if (qobj.bizpath && qobj.bizpath != "") {
......
...@@ -67,9 +67,9 @@ class DbFactory { ...@@ -67,9 +67,9 @@ class DbFactory {
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, }); this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, });
this.db.models.bizopt.hasOne(this.db.models.scheme, { 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.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false, });
this.db.models.settlebill.hasMany(this.db.models.deliverybill,{as:"dbs",constraints: false,});
} }
//async getCon(){,用于使用替换table模型内字段数据使用 //async getCon(){,用于使用替换table模型内字段数据使用
getCon() { getCon() {
......
...@@ -10,10 +10,9 @@ module.exports = (db, DataTypes) => { ...@@ -10,10 +10,9 @@ module.exports = (db, DataTypes) => {
allowNull: true, allowNull: true,
type: DataTypes.STRING type: DataTypes.STRING
}, },
audit_status: {// 审核状态 audited: {// 审核状态
allowNull: false, type:DataTypes.BOOLEAN,
type: DataTypes.STRING, defaultValue: false
defaultValue:'waittoaudit'
}, },
settle_amount: {//结算金额 settle_amount: {//结算金额
allowNull: true, allowNull: true,
...@@ -22,6 +21,18 @@ module.exports = (db, DataTypes) => { ...@@ -22,6 +21,18 @@ module.exports = (db, DataTypes) => {
isPayed:{ isPayed:{
type:DataTypes.BOOLEAN, type:DataTypes.BOOLEAN,
defaultValue: false defaultValue: false
},
memo:{//结算建议
allowNull: true,
type:DataTypes.STRING,
},
creator_id:{
allowNull: true,
type: DataTypes.INTEGER
},
creator:{
allowNull: true,
type: DataTypes.STRING,
} }
}, { }, {
paranoid: true,//真的删除 paranoid: true,//真的删除
......
...@@ -10,19 +10,22 @@ class DeliverybillService extends ServiceBase { ...@@ -10,19 +10,22 @@ class DeliverybillService extends ServiceBase {
var self=this var self=this
return this.db.transaction(async function (t){ return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本 //先按照ids查询出交付单的合计服务成本
let settleAmount=await self.dao.model.findSum("cost_price",{where:{id:{[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 settlecode=await self. getBusUid("JSD")
let settleObj={ let settleObj={
code:settlecode, code:settlecode,
settle_amount:settleAmount, settle_amount:settleAmount,
creator_id:uid,
creator:uname
} }
//生成结算单,结算单状态为待审核 //生成结算单,结算单状态为待审核
let newentity=await self.db.models.settlebill.create(settleObj,{transaction:t}) let newentity=await self.db.models.settlebill.create(settleObj,{transaction:t})
//然后按照ids更新交付单的状态为结算中,更新结算单的id到交付单表 //然后按照ids更新交付单的状态为结算中,更新结算单的id到交付单表
await self.updateByWhere({ for(let idstr of ids){
'settle_status':'settling', let up = await self.dao.updateByWhere({settle_status:'settling',
'settlebill_id':newentity.id settlebill_id:newentity.id }, { id: idstr }, t);
},{id:{[self.db.Op.In]:ids}},t) }
return newentity return newentity
}); });
} }
......
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){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(id,{transaction:t})
st.memo=msg
await st.save({transaction:t})
return st
});
}
async auditPass(settleId){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.audited=true
await st.save({transaction:t})
return st
});
}
async pay(settleId){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.isPayed=true
await st.save({transaction:t})
//改变所有交付单的结算settle_status settled ,
await self.deliverbillDao.updateByWhere({settle_status:'settled'}, { settlebill_id: st.id }, t);
return st
});
}
}
module.exports = SettleBillService;
\ 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