Commit 0ca979a1 by 王勇飞

gyq

parents ecd0e8cc 4eff5374
#!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com"
ADD icp-deliver /apps/icp-deliver/
WORKDIR /apps/icp-deliver/
ADD ic-deliver /apps/ic-deliver/
WORKDIR /apps/ic-deliver/
RUN cnpm install -S
CMD ["node","/apps/icp-deliver/main.js"]
CMD ["node","/apps/ic-deliver/main.js"]
......
......@@ -4,7 +4,8 @@ var settings = require("../../../../config/settings");
class BizChanceAPI extends APIBase {
constructor() {
super();
this.bizChanceS=system.getObject("service.bizchance.bizoptSve")
this.bizChanceS = system.getObject("service.bizchance.bizoptSve");
this.dateUtil = system.getObject("util.dateClient");
}
/**
* 按照服务商进行分组统计
......@@ -13,11 +14,12 @@ class BizChanceAPI extends APIBase {
* @param {*} req
*/
async statBizChanceCountBySp(p,q,req){
let bizStatus=p.bizStatus
let rtn=await this.bizChanceS.statBizChanceCountBySp(bizStatus)
return system.getResult(rtn)
}
async statBizChanceCountBySp(p, q, req) {
let bizStatus = p.bizStatus
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
/**
* 待处理商机beforeSubmission
......@@ -27,12 +29,13 @@ class BizChanceAPI extends APIBase {
* @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)
async statBizChance(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn)
}
classDesc() {
......
......@@ -4,16 +4,18 @@ var settings = require("../../../../config/settings");
class BizDeliverAPI extends APIBase {
constructor() {
super();
this.bizDeliveryS=system.getObject("service.bizchance.deliverybillSve")
this.bizDeliveryS = system.getObject("service.bizchance.deliverybillSve")
this.dateUtil = system.getObject("util.dateClient");
}
async statBizDeliveryCountBySp(p,q,req){
let bizStatus=p.bizStatus
let rtn=await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus)
async statBizDeliveryCountBySp(p, q, req) {
let bizStatus = p.bizStatus;
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
async statBizDeliverySettleAmountBySp(p,q,req){
let bizStatus=p.bizStatus
let rtn=await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus)
async statBizDeliverySettleAmountBySp(p, q, req) {
let bizStatus = p.bizStatus
let rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus)
return system.getResult(rtn)
}
/**
......@@ -24,12 +26,13 @@ class BizDeliverAPI extends APIBase {
* @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)
async statBizDelivery(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime)
return system.getResult(rtn)
}
classDesc() {
......
......@@ -13,6 +13,7 @@ class BizOptCtl extends CtlBase {
this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl();
//this.wdyUrl = settings.wdyUrl();
this.dateUtil = system.getObject("util.dateClient");
}
/*根据用户id获取商机信息,分页获取*/
......@@ -21,6 +22,12 @@ class BizOptCtl extends CtlBase {
//TODO 根据业务员id获取该业务员所有列表
//设置查询条件
console.log("pobj--", pobj)
if (pobj.search && pobj.search.dateType) {
if (pobj.search.dateType !== '全部') {
pobj.search.created_at = this.dateUtil.betweenTime(pobj.search.dateType);
}
delete pobj.search.dateType
}
const rs = await this.service.findAndCountAll(pobj);
let rarr = [];
let results = rs.results.rows;
......
......@@ -16,12 +16,20 @@ class DeliverybillCtl extends CtlBase {
this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl();
this.wdyUrl = settings.wdyUrl();
this.dateUtil = system.getObject("util.dateClient");
}
/*根据用户id获取商机信息,分页获取*/
async findAndCountAll(pobj, qobj, req) {
try {
//TODO 根据业务员id获取该业务员所有交付单列表
if (pobj.search && pobj.search.dateType) {
if (pobj.search.dateType !== '全部') {
pobj.search.created_at = this.dateUtil.betweenTime(pobj.search.dateType);
}
delete pobj.search.dateType
}
const rs = await this.service.findAndCountAll(pobj);
let rarr = [];
let results = rs.results.rows;
......@@ -52,7 +60,7 @@ class DeliverybillCtl extends CtlBase {
}
else if (robj.businessName == '云上园区注册') {
robj.registeredType = element.delivery_info.registeredType;//园区注册时,根据该值跳界面
if (robj.baseInfo.isWhether == "yes"|| robj.baseInfo.financial == "yes") {//如果有刻章需求或者是财税服务
if (robj.baseInfo.isWhether == "yes" || robj.baseInfo.financial == "yes") {//如果有刻章需求或者是财税服务
robj.relatedProducts = '有';
}
else {
......@@ -75,6 +83,7 @@ class DeliverybillCtl extends CtlBase {
rs.results.rows = rarr;
return system.getResult(rs);
} catch (error) {
console.log(error)
return system.getResultError(error);
}
}
......@@ -185,9 +194,9 @@ class DeliverybillCtl extends CtlBase {
rarr.baseInfo.startTime = rs.delivery_info.startTime;//开始计费时间
}
if (rs.delivery_info.buyDuration && rs.delivery_info.buyDuration != 'undefined' && rarr.baseInfo.startTime && rarr.baseInfo.startTime != 'undefined') {
console.log("ddddddddddd____________________________"+ rarr.baseInfo.startTime );
console.log("ddddddddddd____________________________" + rarr.baseInfo.startTime);
var d = new Date(rarr.baseInfo.startTime);
console.log("ddddddddddd____________________________"+ d );
console.log("ddddddddddd____________________________" + d);
rarr.baseInfo.endTime = this.oneYearPast(d, 1);//到期时间
var ss = moment();
rarr.baseInfo.surplusDuration = this.diffDays(ss, rarr.baseInfo.endTime);//剩余时长
......@@ -228,8 +237,8 @@ class DeliverybillCtl extends CtlBase {
async updatestartTimeByDeliverCode(mobj, qobj, red) {//根据交付单编号更新开始计费时间
var pobj = mobj.d;
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined' && pobj.baseInfo.startTime && pobj.baseInfo.startTime != 'undefined'){
try{
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined' && pobj.baseInfo.startTime && pobj.baseInfo.startTime != 'undefined') {
try {
var rs = await this.service.findInfoByDeliverCode(pobj)//先得到交付单详情
if (rs && rs != 'undefined') {
rs.delivery_info.startTime = pobj.baseInfo.startTime;
......@@ -290,11 +299,11 @@ class DeliverybillCtl extends CtlBase {
return system.getResultError("数据不存在!");
}
}
catch(error){
catch (error) {
return system.getResultError(error);
}
}
else{
else {
return system.getResultError("参数错误!");
}
}
......@@ -325,7 +334,7 @@ class DeliverybillCtl extends CtlBase {
var j = JSON.parse(rtn.stdout);
var j1status = 1;
if (pobj.deliverStatus == "closed"){//退款
if (pobj.deliverStatus == "closed") {//退款
params = {
"actionType": "produceData",
"actionBody": {
......@@ -787,7 +796,7 @@ class DeliverybillCtl extends CtlBase {
//time时间n年后的的前一天
oneYearPast(time, n) {
//var time=new Date();
try{
try {
var year = time.getFullYear() + n;
var d = time.setFullYear(year);
var date = time.getDate(d) - 1;
......@@ -802,7 +811,7 @@ class DeliverybillCtl extends CtlBase {
//计算俩日期相差多少天
diffDays(time1, time2) {
try{
try {
var m1 = moment(time1);
var m2 = moment(time2);
return m2.diff(m1, 'day');
......@@ -810,7 +819,7 @@ class DeliverybillCtl extends CtlBase {
catch{
return "";
}
}
}
module.exports = DeliverybillCtl;
......
......@@ -15,7 +15,7 @@ class BizoptDao extends Dao {
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = { [this.db.Op.like]:'%qobj.opath%'}
qw["salesman_opcode"] = { [this.db.Op.like]: `'%${qobj.opath}%'` }
}
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
......@@ -45,7 +45,7 @@ class BizoptDao extends Dao {
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj["close_reason"] = qobj.statusReason;
}
else{
else {
setobj["close_reason"] = "";
}
var whereobj = { "demand_code": qobj.businessMode };
......@@ -58,7 +58,7 @@ class BizoptDao extends Dao {
"demand_code": qobj.businessMode,
"business_type": qobj.businessType,
"business_status": qobj.currentStatus,
"business_info":{}
"business_info": {}
};
if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource;
......@@ -81,16 +81,16 @@ class BizoptDao extends Dao {
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone;
}
if (qobj.serviceName && qobj.serviceName != 'undefined'){
obj.business_info.serviceName = qobj.serviceName;
if (qobj.serviceName && qobj.serviceName != 'undefined') {
obj.business_info.serviceName = qobj.serviceName;
}
if (qobj.businessName && qobj.businessName != 'undefined'){
if (qobj.businessName && qobj.businessName != 'undefined') {
obj.business_info.businessName = qobj.businessName;
}
if (qobj.UserName && qobj.UserName != 'undefined'){
if (qobj.UserName && qobj.UserName != 'undefined') {
obj.business_info.userName = qobj.UserNames;
}
if (qobj.companyName && qobj.companyName != 'undefined'){
if (qobj.companyName && qobj.companyName != 'undefined') {
obj.business_info.companyName = qobj.companyName;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
......
......@@ -6,19 +6,22 @@ class BizOptService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(BizOptService));
}
async statBizChanceCountBySp(bizStatus){
let params={}
params.group={
byFields:['facilitator_name'],
actionType:'count',
aggField:'id',
aliasField:' as chanceCount',
tblName:'bussiness_opportunity',
where:bizStatus!=""?`where business_status='${bizStatus}'`:'',
having:'',
async statBizChanceCountBySp(bizStatus, betweenTime) {
let params = {}
params.group = {
byFields: ['facilitator_name'],
actionType: 'count',
aggField: 'id',
aliasField: ' as chanceCount',
tblName: 'bussiness_opportunity',
where: bizStatus != "" ? `where business_status='${bizStatus}'` : '',
having: '',
}
let s=await this.dao.statGroupBy(params,null)
return s
if (betweenTime.length > 0) {
params.group.where = `${params.group.where} ${params.group.where ? 'AND' : "WHERE"} (created_at BETWEEN '${betweenTime[0]}' AND '${betweenTime[1]}')`
}
let s = await this.dao.statGroupBy(params, null)
return s
}
/**
* 公司id,平台公司ID为1
......@@ -27,38 +30,46 @@ class BizOptService extends ServiceBase {
* @param {*} username
* @param {*} userid
*/
async statBizChance(companyId,opath,username,userid){
async statBizChance(companyId, opath, username, userid, betweenTime) {
// 时间 筛选
let andWhere = [];
if (betweenTime.length > 0) {
andWhere.push({
"created_at": { [this.db.Op.between]: betweenTime }
})
}
//如果当前登录人是平台,返回所有商机
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 waittoHandledCount = 0
let handlingCount = 0
let finishedCount = 0
let closedCount = 0
if (companyId == 1) {
waittoHandledCount = await this.dao.findCount({ where: { business_status: 'beforeSubmission', [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', [this.db.Op.and]: andWhere } })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', [this.db.Op.and]: andWhere } })
} 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, [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
} else {
waittoHandledCount = await this.dao.findCount({ where: { business_status: 'beforeSubmission', 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', 'facilitator_id': companyId }, [this.db.Op.and]: andWhere })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', 'facilitator_id': companyId }, [this.db.Op.and]: andWhere })
}
}
//成单率
let allChance=waittoHandledCount+handlingCount+finishedCount+closedCount
let successRadio=Math.ceil((finishedCount/allChance) * 100)
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}
return { waittoHandledCount: waittoHandledCount, handlingCount: handlingCount, finishedCount: finishedCount, closedCount: closedCount, successRadio: successRadio }
}
async findAndCountAll(obj) {
var self = this;
......@@ -67,23 +78,23 @@ class BizOptService extends ServiceBase {
}
/*根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj){
async findInfoByDemandCode(qobj) {
return await this.dao.findInfoByDemandCode(qobj);
}
/* 根据商机编号更新商机状态 */
async updateStatusByDemandCode(qobj){
var self=this;
async updateStatusByDemandCode(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateStatusByDemandCode(qobj,t);
return await self.dao.updateStatusByDemandCode(qobj, t);
});
}
/*插入商机信息*/
async insertInfo(qobj){
var self=this;
async insertInfo(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
return await self.dao.insertInfo(qobj, t);
});
}
......
......@@ -14,6 +14,7 @@ class SchemeService extends ServiceBase {
async findInfoByDemandCode(qobj){//根据方案编号获取方案详情
return await this.dao.findInfoByDemandCode(qobj);
}
async updateStatusByDemandCode(qobj){//根据商机编号号更新方案状态及原因
......
const moment = require('moment');
class DateClient {
constructor() {
}
betweenDay() {
return [moment().startOf('day').format('YYYY-MM-DD HH:mm:ss'), moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')]
}
betweenMonth() {
return [moment().startOf('month').format('YYYY-MM-DD HH:mm:ss'), moment().endOf('month').format('YYYY-MM-DD HH:mm:ss')]
}
betweenYear() {
return [moment().startOf('year').format('YYYY-MM-DD HH:mm:ss'), moment().endOf('year').format('YYYY-MM-DD HH:mm:ss')]
}
betweenTime(type) {
let times = [];
switch (type) {
case "日":
times = this.betweenDay();
break
case "月":
times = this.betweenMonth();
break
case "年":
times = this.betweenYear();
break
case "全部":
break
}
return times
}
}
module.exports = DateClient;
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