Commit 92cf8d08 by 孙亚楠

d

parent adf228ae
const system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ChanceCtl extends CtlBase {
constructor() {
super();
this.chanceSve = system.getObject("service.chance.chanceSve");
}
/**
* 保存线索
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveClue(pobj, pobj2, req) {
return await this.chanceSve.saveClue(pobj);
}
/**
* 关闭商机
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async closeClue(pobj, pobj2, req) {
return await this.chanceSve.closeClue(pobj);
}
/**
* 列表商机
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async listClue(pobj, pobj2, req) {
return await this.chanceSve.listClue(pobj);
}
/**
* 列表商机字典
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async clueStatusDict(pobj, pobj2, req) {
return await this.chanceSve.clueStatusDict(pobj);
}
/**
* 关闭商机字典
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async closeReasonDict(pobj, pobj2, req) {
return await this.chanceSve.closeReasonDict(pobj);
}
/**
* 根据线索ID查询详细
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async getClueById(pobj, pobj2, req) {
return await this.chanceSve.getClueById(pobj);
}
/**
* 保存跟进进度
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveCfollowLog(pobj, pobj2, req) {
return await this.chanceSve.saveCfollowLog(pobj);
}
/**
* 保存方案
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveCscheme(pobj, pobj2, req) {
return await this.chanceSve.saveCscheme(pobj);
}
}
module.exports = ChanceCtl;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
const axios = require('axios')
class ChanceService extends ServiceBase {
constructor() {
super();
this.deliverSve = system.getObject("service.common.deliverSve");
this.orderSve = system.getObject("service.order.orderSve");
this.ALI_PRODUCT_CODE = "10020000";
}
/**
* TODO:这里需要一个方法去自动分配业务员
*
* 保存线索
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveClue(params) {
params.operator_id=params.deliver_user_id;
params.operator_path = params.deliver_user_path;
params.clue_type_id = this.trim(params.clue_type_id) || this.ALI_PRODUCT_CODE;
params.clue_type_name = this.trim(params.clue_type_name) || "个体户注册一体化";
return await this.callms("chance", "saveClue", params);
}
/**
* 关闭商机
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async closeClue(params) {
let res = await this.callms("chance", "closeClue", params);
if(res.status==0 && res.data.callback_url){
this.pushClue(params,res);
}else{
return res;
}
return system.getResultSuccess();
}
/**
* TODO: 这里需要推送到阿里(待完善)
* fn:消息推送
* @param params
* @param res
*/
async pushClue(params,res){
console.log("推送参数 params:" + JSON.stringify(params) + "===> res:" + JSON.stringify(res));
// let result = await axios({
// method: 'post',
// url: url,
// data: data
// });
}
/**
* fn:列表商机
* ps:需要将业务员的信息查询
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async listClue(params) {
let rs = await this.callms("chance", "listClue", params);
if (rs.status === 0 && rs.data) {
await this.setUcUser(rs.data.rows);
}
//格式化服务内容
let listProductRes = await this.orderSve.productDics({pid:this.ALI_PRODUCT_CODE});
if(listProductRes.status!=0 || listProductRes.data.length<=0){
return system.getResult(null, `获取数据失败 请联系管理员`);
}
let productMap = {};
for(let item of listProductRes.data){
productMap[item.id] = item.desc;
}
let temp = [],p_list=[];
for(let ele of rs.data.rows){
if(!rs.data.rows || rs.data.rows.length<=0 || !ele.cscheme.service_ids){
continue;
}
temp = ele.cscheme.service_ids.split(",");
//这里需要明天去噶哎
for (let r of temp) {
let _p = productMap[r] || {};
p_list.push({id:r,name:_p.desc})
}
ele.service_product = p_list;
}
return rs;
}
/**
* fn:查询操作员信息
* @param rows
* @returns {Promise<void>}
*/
async setUcUser(rows) {
if (!rows || rows.length == 0) {
return;
}
let ids = [];
for (let row of rows) {
if (row.operator_id) {
ids.push(row.operator_id);
}
}
let map = await this.deliverSve.mayByIds(ids);
for (let row of rows) {
let user = map[row.operator_id] || {};
row.operator_name = user.real_name || "";
}
}
/**
* 列表商机字典
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async clueStatusDict(params) {
return await this.callms("chance", "clueStatusDict", params);
}
/**
* 关闭商机字典
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async closeReasonDict(params) {
return await this.callms("chance", "closeReasonDict", params);
}
/**
* 根据线索ID查询详细
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async getClueById(params) {
return await this.callms("chance", "getClueById", params);
}
/**
* fn:保存跟进进度
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveCfollowLog(params) {
params.operator=params.deliver_user_id||"";
return await this.callms("chance", "saveCfollowLog", params);
}
/**
* 保存方案
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async saveCscheme(params) {
return await this.callms("chance", "saveCscheme", params);
}
}
module.exports = ChanceService;
\ No newline at end of file
......@@ -137,5 +137,43 @@ class DeliverService extends ServiceBase {
row.businessmenDivide = system.f2y(row.businessmenDivide);
}
}
/**
* fn:查询指定交付商下的所有用户
* @param params
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any|undefined>}
*/
async deliverUserAll(params){
return await this.callms("common", "deliverUserAll", {deliver_id: this.trim(params.deliver_id)});
}
/**
* fn:商机分配规则
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
// async chanceDistributionRule(params){
// let res = await this.callms("common", "deliverUserAll", {deliver_id: this.trim(params.deliver_id)});
// if(res.status!=0 || res.data.length<=0){
// return system.getResult(null, `暂无没有可分配的业务员`);
// }
// try{
//
// }catch (e) {
// console.log(e);
// return system.getResult(null, `系统错误 分配原业务员失败`);
// }
//
//
// let arrayList = [];
// for(let item of res.data){
// arrayList.push(item);
// }
//
//
//
//
// }
}
module.exports = DeliverService;
\ No newline at end of file
......@@ -202,6 +202,9 @@ class System {
// 发票服务
uc: domain2 + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path,
// 商机服务
chance: domain + ":3108" + path,
}
} else {
var odomain = "http://123.57.217.203"
......
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