Commit 9cf7636e by 王勇飞

Merge branch 'ic-deliver' of gitlab.gongsibao.com:jiangyong/zhichan into ic-deliver

parents 0755a53d e8f81609
......@@ -82,6 +82,7 @@ class CtlBase {
}
if (req.xctx.userid) {//在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid;
pobj.username= req.xctx.username
}
pobj.bizpath = req.xctx.bizpath;
}
......
......@@ -31,6 +31,10 @@ class BizOptCtl extends CtlBase {
robj.business_info_phone = element.business_info.contactsPhone;//联系电话
robj.business_status = element.business_status;//商机当前状态
robj.updated_at = this.timeFormat(element.updated_at);//商机当前状态日期
robj.servicerName = element.facilitator_name;
robj.sourceName = element.source_name;//渠道来源
rarr.push(robj);
});
rs.results.rows = rarr;
......
......@@ -27,9 +27,11 @@ class DeliverybillCtl extends CtlBase {
robj.businessType = element.product_code;//产品编码
robj.sourceName = element.source_name;//渠道来源
robj.channelNumber = element.source_number;//渠道编码
robj.servicerName = element.facilitator_name;
robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态
robj.costPrice = element.cost_price;//成本
robj.settleStatus=element.settle_status;
if (robj.businessName == '公司注册'){
if (robj.baseInfo.isWhether == "是" || robj.baseInfo.isVirtual == "是"){//如果有刻章需求或者是虚拟地址
robj.relatedProducts = '有';
......@@ -224,9 +226,11 @@ class DeliverybillCtl extends CtlBase {
}
async settleApply(p,q,req){
let ids=p.ids
let rtn=await this.service.settleApply(ids,req.userid,req.username)
return system.getResult({})
}
/*根据商机编号插入交付单信息*/
async insertInfo(pobj,qobj,req){//队列的时候用
if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.schemeNumber && pobj.schemeNumber != 'undefined'
......
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");
}
}
module.exports = SettleBillCtl;
......@@ -67,6 +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, });
//交付单关联结算单
this.db.models.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false, });
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
......
......@@ -6,6 +6,22 @@ class DeliverybillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService));
}
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 settlecode=await self. getBusUid("JSD")
let settleObj={
code:settlecode,
settle_amount:settleAmount,
}
//生成结算单,结算单状态为待审核
await self.db.models.settlebill.create(settleObj,{transaction:t})
//然后按照ids更新交付单的状态为结算中,更新结算单的id到交付单表
});
}
async findAndCountAll(obj) {
var self = this;
const apps = await this.dao.findAndCountAll(obj);
......
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