Commit 15aa0d9b by 孙亚楠

d

parent 92cf8d08
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class BusinessscopeCtl extends CtlBase {
constructor() {
......@@ -21,6 +18,14 @@ class BusinessscopeCtl extends CtlBase {
}
}
/**
* fn:获取说有经营范围(没有分页)
* @returns {Promise<*>}
*/
async listbusinessscopeAll(pobj, pobj2, req){
return await this.businessscopeSve.listbusinessscopeAll(pobj);
}
async info(pobj, pobj2, req) {
try {
return await this.businessscopeSve.info(pobj);
......
......@@ -9,6 +9,7 @@ class OrderCtl extends CtlBase {
this.deliverSve = system.getObject("service.common.deliverSve");
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.ALI_PRODUCT_CODE = "10020000";
}
async processList(pobj, pobj2, req) {
......@@ -62,7 +63,7 @@ class OrderCtl extends CtlBase {
}
}
async orderInfo(pobj, pobj2, req) {
async orderInfo(pobj, pobj2, req) {
try {
return await this.orderSve.orderInfoAll({id: this.trim(pobj.id)});
} catch (e) {
......@@ -72,7 +73,7 @@ class OrderCtl extends CtlBase {
}
async orderChooseProducts(pobj, pobj2, req) {
let orderId = this.trim(pobj.id);
let orderId = this.trim(pobj.id) || this.ALI_PRODUCT_CODE;
let order = await this.orderSve.orderInfo({id: orderId});
if(!order.data || !order.data.product_id) {
......@@ -90,6 +91,24 @@ class OrderCtl extends CtlBase {
}
}
/**
* fn:阿里可选择订单(为商机提供服务)
* @param pobj
* @param pobj2
* @param req
* @returns {Promise<{msg: *, data: *, status: *}|*|{msg: string, data, bizmsg: *|string, status: number}|undefined>}
*/
async aliProductForClue(pobj, pobj2, req) {
try {
pobj.pid=this.ALI_PRODUCT_CODE;
pobj.is_choose=true;
return this.orderSve.aliProductForClue(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 分配业务员
......
......@@ -7,6 +7,8 @@ class ChanceService extends ServiceBase {
this.deliverSve = system.getObject("service.common.deliverSve");
this.orderSve = system.getObject("service.order.orderSve");
this.ALI_PRODUCT_CODE = "10020000";
this.CHANCE_DISTRIBUTION_RULE_KEY = "CHANCE_DELIVER_USER_QUEUE";
this.redisClient = system.getObject("util.redisClient");
}
/**
......@@ -17,11 +19,36 @@ class ChanceService extends ServiceBase {
* @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);
try{
// if(await this.redisClient.exists(this.CHANCE_DISTRIBUTION_RULE_KEY)){
// await this.redisClient.delete(this.CHANCE_DISTRIBUTION_RULE_KEY);
// }
let ishave = await this.redisClient.exists(this.CHANCE_DISTRIBUTION_RULE_KEY);
if(!ishave){//如果没有这个key则需要重新导入所有的交付商用户
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, `分配业务员失败 请联系管理员`);
}
for(let item of res.data){
let temp = {id:item.id,real_name:item.real_name,org_path:item.org_path,ucname:item.ucname};
await this.redisClient.rpush(this.CHANCE_DISTRIBUTION_RULE_KEY,JSON.stringify(temp));
}
}
let operationtor = await this.redisClient.lpop(this.CHANCE_DISTRIBUTION_RULE_KEY);
operationtor = JSON.parse(operationtor);
console.log(`chanceSve-->saveClue->分配业务员 `+JSON.stringify(operationtor));
params.operator_id=operationtor.id;
params.operator_path = operationtor.org_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);
return system.getResultSuccess();
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
}
/**
......@@ -76,18 +103,18 @@ class ChanceService extends ServiceBase {
for(let item of listProductRes.data){
productMap[item.id] = item.desc;
}
let temp = [],p_list=[];
let 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(",");
ele.cscheme.service_ids = ele.cscheme.service_ids.split(",");
//这里需要明天去噶哎
for (let r of temp) {
for (let r of ele.cscheme.service_ids) {
let _p = productMap[r] || {};
p_list.push({id:r,name:_p.desc})
p_list.push({id:r,name:_p})
}
ele.service_product = p_list;
ele.cscheme.service_product = p_list;
}
return rs;
}
......@@ -140,7 +167,33 @@ class ChanceService extends ServiceBase {
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|*|undefined>}
*/
async getClueById(params) {
return await this.callms("chance", "getClueById", params);
try{
let res = await this.callms("chance", "getClueById", params);
if(res.status!=0){
return system.getResult(null, `线索【${params.id}】不存在`);
}
let bean =res.data;
//格式化服务内容
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 p_list=[];
bean.cscheme.service_ids = bean.cscheme.service_ids.split(",");
for (let r of bean.cscheme.service_ids) {
let _p = productMap[r] || {};
p_list.push({id:r,name:_p})
}
bean.cscheme.service_product = p_list;
return system.getResult(bean);
}catch (e) {
console.log(e);
return system.getResult(null, `获取数据失败`);
}
}
/**
......
......@@ -11,6 +11,10 @@ class BusinessscopeService extends ServiceBase {
return await this.callms("common", "businessscopePage", params);
}
async listbusinessscopeAll(params){
return await this.callms("common", "listbusinessscopeAll",params);
}
async info(params) {
return await this.callms("common", "businessscopeInfo", params);
}
......
......@@ -34,6 +34,16 @@ class OrderService extends ServiceBase {
return rs;
}
/**
* fn:查询商机可选择的产品
* @param params
* @returns {Promise<void>}
*/
async aliProductForClue(params){
var rs = await this.callms("order", "productDics", params);
return rs;
}
async orderAndDeliver(params) {
var rs = await this.callms("order", "orderAndDeliver", params);
return rs;
......
......@@ -185,7 +185,7 @@ class System {
var domain2 = "http://39.107.234.14";
return {
// 公共服务
common: domain2 + ":3102" + path,
common: domain + ":3109" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务
......@@ -193,8 +193,8 @@ class System {
// merchant: "http://127.0.0.1:3101" + path,
// 订单服务
// order: domain + ":3103" + path,
order: domain2 + ":3103"+ path,
order: domain + ":3103" + path,
// order: domain2 + ":3103"+ path,
// 发票服务
invoice: domain2 + ":3105" + path,
......
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