Commit 72f366e7 by 王勇飞

gyq

parent 62177dbc
......@@ -10,6 +10,7 @@ class BizOptCtl extends CtlBase {
super("bizchance", CtlBase.getServiceName(BizOptCtl));
this.schemeService = system.getObject("service.bizchance.schemeSve");
this.logService = system.getObject("service.bizchance.statuslogSve");
this.shisService = system.getObject("service.bizchance.salesmanhisSve");
this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl();
//this.wdyUrl = settings.wdyUrl();
......@@ -127,6 +128,42 @@ class BizOptCtl extends CtlBase {
}
}
/*更新业务员信息*/
async updateSalesmanInfoByDemandCode(mobj, qobj, req){
var pobj = mobj.d;
if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.salesmanId && pobj.salesmanId != 'undefined' && pobj.salesmanName && pobj.salesmanName != 'undefined' && pobj.salesmanOpcode && pobj.salesmanOpcode != 'undefined'){
try{
var res = await this.service.findInfoByDemandCode(pobj);
if (res){
var sInfo = {
"flowType": "BIZ",
"flowId": res.id,
"flowCode":pobj.businessMode,
"salesmanInfo":{
"oldOpcode": res.salesman_opcode,
"oldClerkName": res.salesman_name,
"oldClerkId": res.salesman_id,
"newOpcode": pobj.salesmanOpcode,
"newClerkName": pobj.salesmanName,
"newClerkId": pobj.salesmanId
}
}
await this.shisService.insertInfo(sInfo);//之前业务员转历史
await this.service.updateSalesmanInfoByDemandCode(pobj);//更新业务员信息
}
else{
return system.getResultError("未找到相关数据");
}
}
catch(error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
/*根据商机编号更新商机状态*/
async updateStatusByDemandCode(mobj, qobj, req) {
var pobj = mobj.d;
......@@ -229,7 +266,7 @@ class BizOptCtl extends CtlBase {
module.exports = BizOptCtl;
// var task = new BizOptCtl();
// var obj={"businessMode":"202006100001","currentStatus":"isClosed","statusReason":"未付款"};
// task.updateStatusByDemandCode(obj,{},{}).then(d=>{
// var obj={"d":{"businessMode":"201111093003","salesmanId":"12","salesmanName":"zhangsan","salesmanOpcode":"root/ic/zhangsan"}};
// task.updateSalesmanInfoByDemandCode(obj,{},{}).then(d=>{
// console.log(d);
// })
......@@ -13,6 +13,7 @@ class DeliverybillCtl extends CtlBase {
this.bizoptService = system.getObject("service.bizchance.bizoptSve");
this.logService = system.getObject("service.bizchance.statuslogSve");
this.cacheService = system.getObject("service.bizchance.cacheinfoSve");
this.shisService = system.getObject("service.bizchance.salesmanhisSve");
this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl();
this.wdyUrl = settings.wdyUrl();
......@@ -33,7 +34,7 @@ class DeliverybillCtl extends CtlBase {
const rs = await this.service.findAndCountAll(pobj);
let rarr = [];
let results = rs.results.rows;
console.log("-----------------------------------------" +JSON.stringify(results));
console.log("-----------------------------------------" + JSON.stringify(results));
results.forEach(element => {
let robj = {};
robj.id = element.id;//数据的id
......@@ -48,18 +49,18 @@ class DeliverybillCtl extends CtlBase {
robj.channelNumber = element.source_number;//渠道编码
robj.facilitator_name = element.facilitator_name;//服务商--前端服务
robj.facilitator_id = element.facilitator_id;//服务商--id
if (element.delivery_info.serviceName && element.delivery_info.serviceName != 'undefined'){
if (element.delivery_info.serviceName && element.delivery_info.serviceName != 'undefined') {
robj.serviceName = element.delivery_info.serviceName;
}
robj.baseInfo = element.delivery_info;//交付单详情
robj.payStatus = element.delivery_info.payStatus;//交付状态
if (element.pay_status && element.pay_status != 'undefined'){
if (element.pay_status && element.pay_status != 'undefined') {
robj.pay_status = element.pay_status;//交付状态---前端服务
}
else{
else {
robj.pay_status = "";//交付状态---前端服务
}
robj.costPrice = this.FenToYuan(element.cost_price);//成本
robj.settle_status = element.settle_status;
robj.settlebill = element.settlebill;
......@@ -100,7 +101,7 @@ class DeliverybillCtl extends CtlBase {
rs.results.rows = rarr;
return system.getResult(rs);
} catch (error) {
console.log("error-------------------" +error);
console.log("error-------------------" + error);
return system.getResultError(error);
}
}
......@@ -512,6 +513,43 @@ class DeliverybillCtl extends CtlBase {
}
}
/*更新业务员信息*/
async updateSalesmanInfoByDeliverCode(mobj, qobj, req) {
var pobj = mobj.d;
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined' && pobj.salesmanId && pobj.salesmanId != 'undefined' && pobj.salesmanName && pobj.salesmanName != 'undefined' && pobj.salesmanOpcode && pobj.salesmanOpcode != 'undefined') {
try {
var res = await this.service.findInfoByDeliverCode(pobj);
if (res) {
var sInfo = {
"flowType": "DELIVERY",
"flowId": res.id,
"flowCode": pobj.deliverNumber,
"salesmanInfo": {
"oldOpcode": res.salesman_opcode,
"oldClerkName": res.salesman_name,
"oldClerkId": res.salesman_id,
"newOpcode": pobj.salesmanOpcode,
"newClerkName": pobj.salesmanName,
"newClerkId": pobj.salesmanId
}
}
await this.shisService.insertInfo(sInfo);//之前业务员转历史
await this.service.updateSalesmanInfoByDeliverCode(pobj);//更新业务员信息
}
else {
return system.getResultError("未找到相关数据");
}
}
catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
}
}
/*根据交付单编号更新交付单详情*/
async updateInfoByDeliverCode(mobj, qobj, req) {//
var pobj = mobj.d;
......@@ -783,25 +821,25 @@ class DeliverybillCtl extends CtlBase {
if (ms.download_url && ms.download_url != undefined) {
var comInfo = ms.company_info;
var rtndata = {
"zipUrl":ms.download_url,
"companyName":comInfo.companyName
"zipUrl": ms.download_url,
"companyName": comInfo.companyName
}
if (comInfo.companyProperties == "limitedLiabilityCompany"){
if (comInfo.companyProperties == "limitedLiabilityCompany") {
rtndata.companyProperties = "有限责任公司"
}
else if (comInfo.companyProperties == "incorporatedCompany"){
else if (comInfo.companyProperties == "incorporatedCompany") {
rtndata.companyProperties = "股份有限公司"
}
else if (comInfo.companyProperties == "groupLimitedCompany"){
else if (comInfo.companyProperties == "groupLimitedCompany") {
rtndata.companyProperties = "集团有限公司"
}
else if (comInfo.companyProperties == "selfEmployed"){
else if (comInfo.companyProperties == "selfEmployed") {
rtndata.companyProperties = "个体工商户"
}
else if (comInfo.companyProperties == "soleProprietorship"){
else if (comInfo.companyProperties == "soleProprietorship") {
rtndata.companyProperties = "个人独资企业"
}
else if (comInfo.companyProperties == "company"){
else if (comInfo.companyProperties == "company") {
rtndata.companyProperties = "有限公司"
}
return system.getResult(rtndata);
......@@ -898,7 +936,7 @@ class DeliverybillCtl extends CtlBase {
}
module.exports = DeliverybillCtl;
// var task = new DeliverybillCtl();
// var task = new DeliverybillCtl();
// // var d = new Date("2020-06-05");
// // console.log("dddddddddddd:" + d);
// // var oneYear = task.oneYearPast(d,1);
......@@ -906,8 +944,8 @@ module.exports = DeliverybillCtl;
// // var diff = task.diffDays(ss,oneYear);
// // console.log(oneYear);
// // console.log(diff);
// var obj={"d":{"deliverNumber":"1111111"}};
// task.findAndCountAll(obj,{},{}).then(d=>{
// var obj={"d":{"deliverNumber":"1111111","salesmanId":"12","salesmanName":"zhangsan","salesmanOpcode":"root/ic/zhangsan"}};
// task.updateSalesmanInfoByDeliverCode(obj,{},{}).then(d=>{
// console.log(d);
// //console.log(d[0].analyse);
......
......@@ -52,6 +52,17 @@ class BizoptDao extends Dao {
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj,t){
var setobj = {
"salesman_id": qobj.salesmanId,
"salesman_name":qobj.salesmanName,
"salesman_opcode":qobj.salesmanOpcode
};
var whereobj = { "demand_code": qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入商机信息*/
async insertInfo(qobj, t) {
var obj = {
......
......@@ -6,15 +6,15 @@ class DeliverybillDao extends Dao {
}
extraModelFilter(pobj) {
return {"key":"include","value":{model:this.db.models.settlebill,raw:true,attributes:['memo']}};
return { "key": "include", "value": { model: this.db.models.settlebill, raw: true, attributes: ['memo'] } };
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if(qw["delivery_status"]=="handling"){//解决首页多状态查询
qw["delivery_status"]= { [this.db.Op.notIn]:['received', 'success', 'closed']}
if (qw["delivery_status"] == "handling") {//解决首页多状态查询
qw["delivery_status"] = { [this.db.Op.notIn]: ['received', 'success', 'closed'] }
}
if (qobj.company_id == 1) {
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是从商机列表过来的
......@@ -22,15 +22,15 @@ class DeliverybillDao extends Dao {
qw["settle_status"] = "waittosettle";
}
}
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = { [this.db.Op.like]:`%${qobj.opath}%`}
}else{//说明是租户管理员,给租户自己核销结算的功能,
qw["salesman_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` }
} else {//说明是租户管理员,给租户自己核销结算的功能,
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是结算核销路由过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
......@@ -40,7 +40,7 @@ class DeliverybillDao extends Dao {
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.product_code = qc.where.product_code || {
[this.db.Op.notIn]: ["ICP", "EDI","ICPANNUALREPORT","EDIANNUALREPORT"]
[this.db.Op.notIn]: ["ICP", "EDI", "ICPANNUALREPORT", "EDIANNUALREPORT"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myDeliver") > 0) {//说明是从商机列表过来的
......@@ -64,19 +64,19 @@ class DeliverybillDao extends Dao {
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
}
else{
else {
setobj.close_reason = "";
}
var whereobj = { "delivery_code": qobj.deliverNumber };
var rs = await this.findOne(whereobj);
if (rs && rs != 'undefined'){
if (qobj.deliverStatus == "collecting" || qobj.deliverStatus == "received" || qobj.deliverStatus == "paid"){
if (rs && rs != 'undefined') {
if (qobj.deliverStatus == "collecting" || qobj.deliverStatus == "received" || qobj.deliverStatus == "paid") {
rs.delivery_info.payStatus = "待交付";
}
else if (qobj.deliverStatus == "closed"){
else if (qobj.deliverStatus == "closed") {
rs.delivery_info.payStatus = "已关闭";
}
else{
else {
rs.delivery_info.payStatus = "已交付";
}
setobj.delivery_info = rs.delivery_info;
......@@ -84,17 +84,28 @@ class DeliverybillDao extends Dao {
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新业务员信息*/
async updateSalesmanInfoByDeliverCode(qobj, t) {
var setobj = {
"salesman_id": qobj.salesmanId,
"salesman_name": qobj.salesmanName,
"salesman_opcode": qobj.salesmanOpcode
};
var whereobj = { "delivery_code": qobj.deliverNumber };
return await this.updateByWhere(setobj, whereobj, t);
}
/*根据交付单更新交付材料信息*/
async updateInfoByDeliverCode(qobj, t) {//公司注册、云上园区注册时填写交付材料
var whereobj = { "delivery_code": qobj.deliverNumber };
var setobj = { "delivery_info": qobj.baseInfo };
if (qobj.deliverStatus && qobj.deliverStatus != 'undefined'){
if (qobj.deliverStatus && qobj.deliverStatus != 'undefined') {
setobj.delivery_status = qobj.deliverStatus;
}
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
}
else{
else {
setobj.close_reason = "";
}
return await this.updateByWhere(setobj, whereobj, t);
......@@ -105,12 +116,12 @@ class DeliverybillDao extends Dao {
var obj = {
"delivery_code": qobj.deliverNumber,
"delivery_status": qobj.deliverStatus,
"delivery_info":qobj.baseInfo
"delivery_info": qobj.baseInfo
};
if (qobj.businessMode && qobj.businessMode != 'undefined'){
if (qobj.businessMode && qobj.businessMode != 'undefined') {
obj.demand_code = qobj.businessMode;
}
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
obj.scheme_number = qobj.schemeNumber;
}
if (qobj.businessName && qobj.businessName != 'undefined') {
......@@ -120,8 +131,8 @@ class DeliverybillDao extends Dao {
obj.product_code = qobj.businessType;
}
if (qobj.txOrderNum && qobj.txOrderNum != 'undefined'){
obj.master_source_number= qobj.txOrderNum;
if (qobj.txOrderNum && qobj.txOrderNum != 'undefined') {
obj.master_source_number = qobj.txOrderNum;
}
if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SalesmanhisDao extends Dao {
constructor() {
super(Dao.getModelName(SalesmanhisDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"flow_code":qobj.flowCode,
"salesman_info":qobj.salesmanInfo
};
return await this.create(obj,t);
}
}
module.exports = SalesmanhisDao;
const system = require("../../../system");
const moment = require('moment');
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 方案表
*/
module.exports = (db, DataTypes) => {
return db.define("salesmanhis", {
flow_type: { // 流程类型(商机、方案、交付单)
allowNull: false,
type: DataTypes.STRING
},
flow_id: { //流程对应id(各种表里对应的id)
allowNull: false,
type: DataTypes.STRING
},
flow_code: {//类型的编号
allowNull: false,
type: DataTypes.STRING
},
salesman_info: {//业务员信息
allowNull: false,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'salesman_his',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -25,53 +25,53 @@ module.exports = (db, DataTypes) => {
salesman_id: {// 业务员id
allowNull: true,
type: DataTypes.STRING
},
salesman_name: { // 业务员姓名
},
salesman_name: { // 业务员姓名
allowNull: true,
type: DataTypes.STRING
}
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'status_log',
validate: {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'status_log',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -90,6 +90,14 @@ class BizOptService extends ServiceBase {
});
}
/*更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj){
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateSalesmanInfoByDemandCode(qobj, t);
});
}
/*插入商机信息*/
async insertInfo(qobj) {
var self = this;
......
......@@ -206,7 +206,13 @@ class DeliverybillService extends ServiceBase {
return await self.dao.updateStatusByDeliverCode(qobj, t);
});
}
/*更新业务员信息*/
async updateSalesmanInfoByDeliverCode(qobj){
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateSalesmanInfoByDeliverCode(qobj, t);
});
}
async updateInfoByDeliverCode(qobj) {//*更新交付单信息 */
console.log("--------------------------------------------------------------------------------------------------------------------------------------");
var self = this;
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SalesmanhisService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SalesmanhisService));
}
/*插入状态信息*/
async insertInfo(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = SalesmanhisService;
\ 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