Commit 7691c8c2 by linboxuan

Merge branch 'center-order' of http://gitlab.gongsibao.com/jiangyong/zhichan into center-order

parents 9ef60baf 4b57a3fd
......@@ -5,6 +5,7 @@ const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase {
constructor() {
this.execClientNew = system.getObject("util.execClientNew");
this.logCtl = system.getObject("service.common.oplogSve");
this.exTime = 2 * 3600;//缓存过期时间,2小时
}
......@@ -44,43 +45,49 @@ class APIBase {
isPassResult.requestId = "";
return isPassResult;
}
var rtn = await this[methodname](pobj, query, req);
var result = await this[methodname](pobj, query, req);
if (!result.requestId) {
result.requestId = pobj.RequestId ? pobj.RequestId : pobj.requestId || req.requestId;
}
this.logCtl.createDb({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
requestId: req.requestId,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
resultInfo: JSON.stringify(result),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
rtn.requestId = req.requestId;
return rtn;
var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : { status: result.status, message: result.message, requestId: result.requestId };
this.execClientNew.execLogs("center-order-doexecMethod-reqPath:" + req.path, pobj, "center-order-doexecMethod", tmpResult, null);
return result;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
const stackStr = e.stack ? e.stack : JSON.stringify(e);
console.log(stackStr, "api调用出现异常,请联系管理员..........")
this.logCtl.createDb({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
requestId: req.requestId,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(e.stack),
resultInfo: stackStr,
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api调用出现异常,请联系管理员error,appKey:" + settings.appKey,
});
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
requestId: req.requestId,
op: req.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
// this.logCtl.error({
// appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
// appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
// requestId: req.requestId,
// op: req.classname + "/" + methodname,
// content: e.stack,
// clientIp: pobj.clientIp,
// agent: req.uagent,
// optitle: "api调用出现异常,请联系管理员",
// });
this.execClientNew.execLogs("center-order-doexecMethod-reqPath异常:" + req.path, pobj, "center-channel-doexecMethod", null, stackStr);
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = req.requestId;
return rtnerror;
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class BaseAPI extends APIBase {
constructor() {
super();
this.aliyunqcSve = system.getObject("service.qcutils.aliyunqcSve");
this.baiduqcSve = system.getObject("service.qcutils.baiduqcSve");
this.baseqcSve = system.getObject("service.qcutils.baseqcSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
console.log("pobj",pobj)
var opResult = null;
switch (action_type) {
case "receiveProgrammeNo"://接收方案编号(方案推送至阿里后,接收保存方案信息)
opResult = await this.baseqcSve.receiveProgrammeNo(pobj);
break;
case "submitIcpProgramme"://icp方案提交
opResult = await this.baseqcSve.submitIcpProgramme(pobj);
break;
// case "submitIcpMaterial"://icp材料提交
// opResult = await this.baseqcSve.submitIcpMaterial(pobj);
// break;
case "acceptIcpPartnerNotification"://icp通知状态变更
opResult = await this.baseqcSve.acceptIcpPartnerNotification(pobj);
break;
case "abolishIcpProgramme"://服务商icp方案关闭
opResult = await this.baseqcSve.abolishIcpProgramme(pobj);
break;
case "getIcpProgrammeDetail"://获取icp方案
opResult = await this.baseqcSve.getIcpProgrammeDetail(pobj);
break;
case "getNeedSolutionDetailByUser"://获取方案详情
opResult = await this.baseqcSve.getNeedSolutionDetailByUser(pobj);
break;
case "receiveIcpStatusNotify"://接收渠道方案状态变更通知2.3
opResult = await this.baseqcSve.receiveIcpStatusNotify(pobj);
break;
case "receiveIcpFeedback"://接收icp用户方案反馈2.2
opResult = await this.baseqcSve.receiveIcpFeedback(pobj);
break;
case "getIcpProgrammeDetail"://获取方案详情(内部调用)
opResult = await this.baseqcSve.getIcpProgrammeDetail(pobj);
break;
case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
opResult = await this.baseqcSve.getProgrammeInfoByChannelNeedNo(pobj);
break;
case "serviceProviderSubmitMaterial"://交付商提交材料信息
opResult = await this.baseqcSve.serviceProviderSubmitMaterial(pobj);
break;
case "serviceProviderNotification"://交付商通知状态变更
opResult = await this.baseqcSve.serviceProviderNotification(pobj);
break;
case "closeOrderDelivery"://交付商关闭交付单
opResult = await this.baseqcSve.closeOrderDelivery(pobj);
break;
case "abolishIcpProgrammeByNeed"://前端关闭ICP需求及方案
opResult = await this.baseqcSve.abolishIcpProgrammeByNeed(pobj);
break;
case "receiveIcpConfirmUrl"://前端关闭ICP需求及方案
opResult = await this.baseqcSve.receiveIcpConfirmUrl(pobj);
break;
//-----------文网文-----------
case "serviceSubmitOption"://服务商提交服务操作
opResult = await this.baseqcSve.serviceSubmitOption(pobj);
break;
case "submitWangwenSolution"://提交方案
opResult = await this.baseqcSve.submitWangwenSolution(pobj);
break;
case "closeNeed"://关闭需求
opResult = await this.baseqcSve.closeNeed(pobj);
break;
case "recordLog"://提交沟通记录
opResult = await this.baseqcSve.recordLog(pobj);
break;
//-----------食品-----------
case "foodServiceSubmitOption"://服务商提交服务操作
opResult = await this.baseqcSve.foodServiceSubmitOption(pobj);
break;
case "submitFoodSolution"://提交方案
opResult = await this.baseqcSve.submitFoodSolution(pobj);
break;
case "foodCloseNeed"://关闭需求
opResult = await this.baseqcSve.foodCloseNeed(pobj);
break;
case "foodRecordLog"://提交沟通记录
opResult = await this.baseqcSve.foodRecordLog(pobj);
break;
case "receiveOrderStatusNotify"://接收订单状态推送 百度icp 2.3
opResult = await this.baiduqcSve.receiveOrderStatusNotify(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = BaseAPI;
\ No newline at end of file
......@@ -5,6 +5,7 @@ class IcAPI extends APIBase {
constructor() {
super();
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
}
/**
* 接口跳转-POST请求
......@@ -63,6 +64,9 @@ class IcAPI extends APIBase {
case "getUnCreated":// 获取需求列表
opResult = await this.needinfoSve.getUnCreated(pobj, pobj.actionBody, req);
break;
case "createSolution"://创建方案
opResult = await this.needsolutionSve.createNewSolution(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcAPI extends APIBase {
constructor() {
super();
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
this.needinfoSve2 = system.getObject("service.dbneed.needinfoSve2");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "submitNeed"://提交需求
opResult = await this.needinfoSve2.submitNeed(pobj, pobj.actionBody, req);
break;
case "submitNeedH5"://工商H5提交需求
opResult = await this.needinfoSve2.submitNeedH5(pobj, pobj.actionBody, req);
break;
case "getItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve2.getItemByNeedNo(pobj);
break;
case "getItemByChannelNeedNo"://获取需求详情
opResult = await this.needinfoSve2.getItemByChannelNeedNo(pobj);
break;
case "needClose"://需求关闭
opResult = await this.needinfoSve2.needClose(pobj, pobj.actionBody, req);
break;
case "getItemByChannelSolutionNo"://渠道方案号获取需求详情
opResult = await this.needinfoSve2.getItemByChannelSolutionNo(pobj, pobj.actionBody, req);
break;
case "writeCommunicationLog"://渠道方案号获取需求详情
opResult = await this.needinfoSve2.writeCommunicationLog(pobj, pobj.actionBody, req);
break;
case "submitIcpIntention":// 2020 0827 lin 新增 4.1 提交需求
opResult = await this.needinfoSve2.submitIcpIntention(pobj, pobj.actionBody, req);
break;
case "queryIntentionList":// 2020 0827 lin 新增 4.2 需求列表查询
opResult = await this.needinfoSve2.queryIntentionList(pobj, pobj.actionBody, req);
break;
case "confirmIcpIntention":// 2020 0827 lin 新增 4.3 用户需求确认
opResult = await this.needinfoSve2.confirmIcpIntention(pobj, pobj.actionBody, req);
break;
case "getUnCreated":// 获取需求列表
opResult = await this.needinfoSve2.getUnCreated(pobj, pobj.actionBody, req);
break;
case "queryExpertApplyCommunicationLogs":// 查询需求沟通记录 2020-10-28 laolan
opResult = await this.needinfoSve2.queryExpertApplyCommunicationLogs(pobj, pobj.actionBody, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcAPI;
\ No newline at end of file
......@@ -26,16 +26,17 @@ class OrderAPI extends APIBase {
var opResult = null;
switch (action_type) {
case "addOrder"://创建订单
this.execClientNew.execLogs("center-order-addOrder-info-1:" + req.path, pobj, "center-order-doexecMethod", null, null);
opResult = await this.addOrder(pobj, pobj.actionBody);
break;
case "getOrderInfo"://获取订单列表信息
opResult = await this.orderinfoSve.getOrderInfo(pobj, pobj.actionBody);
break;
case "getOrderListByOrderServiceNo"://根据合同号获取子订单
opResult = await this.orderinfoSve.getOrderListByOrderServiceNo(pobj,pobj.actionBody);
opResult = await this.orderinfoSve.getOrderListByOrderServiceNo(pobj, pobj.actionBody);
break;
case "getOrderServiceNoByOrderNo"://根据订单号获取合同号
opResult = await this.orderinfoSve.getOrderServiceNoByOrderNo(pobj,pobj.actionBody);
opResult = await this.orderinfoSve.getOrderServiceNoByOrderNo(pobj, pobj.actionBody);
break;
case "getOrderDetails"://获取订单详情信息
opResult = await this.orderinfoSve.getOrderDetails(pobj, pobj.actionBody);
......@@ -68,7 +69,7 @@ class OrderAPI extends APIBase {
opResult = await this.orderinfoSve.getOrderByChannelOrderNo(pobj, pobj.actionBody);
break;
case "updateOrder":
opResult = await this.orderinfoSve.updateOrderById(pobj,pobj.actionBody);
opResult = await this.orderinfoSve.updateOrderById(pobj, pobj.actionBody);
break;
case "channeldelOrder"://阿里工商注册退款
opResult = await this.orderinfoSve.channeldelOrder(pobj, pobj.actionBody);
......@@ -142,6 +143,7 @@ class OrderAPI extends APIBase {
return system.getResult(null, "产品接口参数方法信息有误,20050");
}
var params = [pobj];
this.execClientNew.execLogs("center-order-addOrder-reflexAction-info-2:", params, "center-order-doexecMethod", null, null);
refResult = await invokeObj[interface_info.method_name].apply(invokeObj, params);
}
else if (interface_info.interface_type == "yc") {
......
......@@ -112,6 +112,12 @@ class QcAPI extends APIBase {
case "receiveOrderStatusNotify"://接收订单状态推送 百度icp 2.3
opResult = await this.baiduqcSve.receiveOrderStatusNotify(pobj);
break;
case "icpOrderClose"://关闭ICP订单 百度icp 2.4
opResult = await this.baiduqcSve.icpOrderClose(pobj);
break;
case "addIcpSalesmanInfo"://添加业务员信息,用于直接下单的icp订单
opResult = await this.baiduqcSve.addIcpSalesmanInfo(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -15,6 +15,7 @@ class OrderInfoDao extends Dao {
"orderNo",
"channelServiceNo",
"channelOrderNo",
"orderServiceNo",
"channelUserId",
"ownerUserId",
"payTime",
......@@ -49,5 +50,10 @@ class OrderInfoDao extends Dao {
};
return await this.delete(sqlWhere);
}
async addOrderDelivery(data, orderNo, t) {//新增交付信息
const sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
await this.customInsert(sql, null, t);
}
}
module.exports = OrderInfoDao;
......@@ -4,6 +4,7 @@ const settings = require("../../config/settings");
const md5 = require("MD5");
class AppServiceBase {
constructor() {
this.execClientNew = system.getObject("util.execClientNew");
this.restClient = system.getObject("util.restClient");
this.execClient = system.getObject("util.execClient");
this.cacheManager = system.getObject("db.common.cacheManager");
......@@ -57,5 +58,18 @@ class AppServiceBase {
var result = JSON.parse(rtn.stdout);
return result;
}
/**
* 带超时时间的post请求
* @param {*} req 请求信息
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间
*/
async execPostByTimeOut(req, params, url, ContentType, headData, timeOut = 60) {
const result = await this.execClientNew.execPostTimeOutByBusiness('app.base', params, url, ContentType, headData, timeOut, req);
return result;
}
}
module.exports = AppServiceBase;
const system = require("../../../system");
const AppBase = require("../../app.base");
var settings = require("../../../../config/settings");
class Push360Service extends AppBase{
constructor() {
super()
this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.push360Url = settings.push360Url();
this.auth360Url = settings.auth360Url();
}
//推送数据至360
async pushTmStatus(actionBody,req) {
let status = 30;
if (actionBody.tmStatus == 3 || actionBody.tmStatus == "ROBOTPAY") {
status = 40;
}
let order_id = actionBody.orderNo;
var result, pushObj, url;
try {
let rtn = await this.execClient.exec360GetToken(this.auth360Url)
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
let tokenResult = JSON.parse(rtn.stdout);
let token = tokenResult.access_token;
url = this.push360Url + 'api/v1/eshop/GsbOrderUpdate?token=' + token;
pushObj = {
order_id: order_id,
status: status
}
result = await this.execPostByTimeOut(null,pushObj, url);
console.log(result,'--------------result')
if (result.status != 0) {
return result;
}
if (result.data.code != 200) {
return result.data;
}
return system.getResultSuccess(result.data.data);
} catch (e) {
this.execClientNew.execLogs({
opTitle:"360订单状态推送",
params:actionBody.orderNo,
identifyCode: "360TmStatus",
resultInfo:"",
errorInfo: e.stack
})
return system.getResultFail(-500, JSON.stringify(e.stack));
}
}
//发送短信
async sendMessage(actionBody) {
try {
let orderNo = actionBody.orderNo;
if(!actionBody.registNumInfo){
return system.getResultFail(-1,'')
}
if(!actionBody.officialInfo){
return system.getResultFail(-1,'')
}
//获取联系人信息
let item = await this.ordercontactsDao.getItemByOrderNo(actionBody.orderNo);
let deliveryInfo = actionBody.deliveryInfo;
if (!item) {
return system.getResultFail(-1, '获取联系人信息失败');
}
let mobile = item.mobile;//联系人手机号
let tmRegistNum = actionBody.registNumInfo.tmRegistNum;//申请号
let tmName = deliveryInfo.tm.tmName;//商标名称
let uploadFileName = actionBody.officialInfo.uploadFileName;//文件名
let oneNcl = deliveryInfo.nclones[0].code;//大类
let templateId = 1;
// let failType = {
// "2": "商标注册申请补正通知书",
// "4": "商标注册申请不予受理通知书",
// "5": "商标注册同日申请补送使用证据通知书",
// "7": "商标驳回通知书",
// "8": "商标部分驳回通知书",
// "201": "超时未补正"
// }
//
// if (failType.hasOwnProperty(actionBody.tmStatus)) {
// templateId = 2;
// }
let rtn = await this.execClient.exec360GetToken(this.auth360Url)
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
let tokenResult = JSON.parse(rtn.stdout);
let token = tokenResult.access_token;
let url = this.push360Url + 'api/v1/GsbSendsms';
let params = tmName + "|" + oneNcl + "|" + tmRegistNum + "|" + uploadFileName;
let subData = "token=" + token + "&mobile=" + mobile + "&templated=" + templateId + "&replaceContent=" + params;
let result = await this.execClient.execGet(subData, url);
this.execClientNew.execLogs({
opTitle:"360短信推送",
params:params,
identifyCode: "360Message",
resultInfo:result.data,
errorInfo: ""
})
return system.getResultSuccess()
} catch (e) {
this.execClientNew.execLogs({
opTitle:"360短信推送",
params:actionBody.orderNo,
identifyCode: "360Message",
resultInfo:"",
errorInfo: e.stack
})
return system.getResultFail(-500, JSON.stringify(e.stack));
}
}
}
module.exports = Push360Service;
......@@ -4,67 +4,67 @@ const uuidv4 = require('uuid/v4');
class InternalCallsNotifyService {
constructor() {
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.delivery_status={
"dqrfa": "待确认方案",
"fabtg": "方案不通过",
"dfwsfw": "待服务",
"dsccl": "待上传材料",
"dsh": "待审核",
"ddj": "待递交",
"ydj": "已递交",
"ywc": "已完成"
this.delivery_status = {
"dqrfa": "待确认方案",
"fabtg": "方案不通过",
"dfwsfw": "待服务",
"dsccl": "待上传材料",
"dsh": "待审核",
"ddj": "待递交",
"ydj": "已递交",
"ywc": "已完成"
};
this.statusContrast={
"WAITCONFIRM":{name:"待确认方案",value:"dqrfa"},
"CONFIRMFAIL":{name:"方案不通过",value:"fabtg"},
"READY":{name:"待上传材料",value:"dsccl"},
"WAITCOMMIT":{name:"待递交",value:"ddj"},
"WAITARTIFICIALEXAMINE":{name:"待审核",value:"dsh"},
"DOCFINISH": {name:"待审核",value:"dsh"},
"AWAITCHECK": {name:"待审核",value:"dsh"},
"COMMITED": {name:"已递交",value:"ydj"},
"ROBOT": {name:"已递交",value:"ydj"},
"ROBOTPAY": {name:"已递交",value:"ydj"},
"RECVCOMMIT": {name:"已递交",value:"ydj"},
this.statusContrast = {
"WAITCONFIRM": { name: "待确认方案", value: "dqrfa" },
"CONFIRMFAIL": { name: "方案不通过", value: "fabtg" },
"READY": { name: "待上传材料", value: "dsccl" },
"WAITCOMMIT": { name: "待递交", value: "ddj" },
"WAITARTIFICIALEXAMINE": { name: "待审核", value: "dsh" },
"DOCFINISH": { name: "待审核", value: "dsh" },
"AWAITCHECK": { name: "待审核", value: "dsh" },
"COMMITED": { name: "已递交", value: "ydj" },
"ROBOT": { name: "已递交", value: "ydj" },
"ROBOTPAY": { name: "已递交", value: "ydj" },
"RECVCOMMIT": { name: "已递交", value: "ydj" },
};
}
//接收辅助、担保商标注册信息
async receiveAssistTmData(pobj){
async receiveAssistTmData(pobj) {
var checkRes = await this.checkParams(pobj);
if(checkRes.status==0){
var deliveryData = await this.packagingTmDeliveryData(pobj,null);
if (checkRes.status == 0) {
var deliveryData = await this.packagingTmDeliveryData(pobj, null);
//获取交付信息
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo,pobj.serviceNo);
if(orderdeliveryRes && orderdeliveryRes.length>0){
return system.getResult(null,"保存商标订单交付信息失败,存在重复交付信息,不能重复提交,10300");
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo, pobj.serviceNo);
if (orderdeliveryRes && orderdeliveryRes.length > 0) {
return system.getResult(null, "保存商标订单交付信息失败,存在重复交付信息,不能重复提交,10300");
}
this.addOrderDelivery(deliveryData,deliveryData.sourceOrderNo);
await this.orderinfoDao.model.update({isSolution:1}, { where: { orderNo: pobj.sourceOrderNo }});
await this.orderinfoDao.addOrderDelivery(deliveryData, deliveryData.sourceOrderNo);
await this.orderinfoDao.model.update({ isSolution: 1 }, { where: { orderNo: pobj.sourceOrderNo } });
return system.getResultSuccess();
}else{
} else {
return checkRes;
}
}
//接收辅助、担保商标注册修改信息
async receiveEditAssistTmData(pobj){
async receiveEditAssistTmData(pobj) {
var checkRes = await this.checkParams(pobj);
if(checkRes.status==0){
if (checkRes.status == 0) {
//获取交付信息
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo,pobj.serviceNo);
if(!orderdeliveryRes || orderdeliveryRes.length<1){
return system.getResult(null,"未知交付信息,10150");
var orderdeliveryRes = await this.getOrderDelivery(pobj.sourceOrderNo, pobj.serviceNo);
if (!orderdeliveryRes || orderdeliveryRes.length < 1) {
return system.getResult(null, "未知交付信息,10150");
}
var orderdelivery = orderdeliveryRes[0];
var deliveryData = await this.packagingTmDeliveryData(pobj,orderdelivery.deliveryContent);
this.putOrderDelivery(deliveryData,deliveryData.sourceOrderNo,deliveryData.serviceNo);
await this.orderinfoDao.model.update({isSolution:1}, { where: { orderNo: pobj.sourceOrderNo }});
var deliveryData = await this.packagingTmDeliveryData(pobj, orderdelivery.deliveryContent);
this.putOrderDelivery(deliveryData, deliveryData.sourceOrderNo, deliveryData.serviceNo);
await this.orderinfoDao.model.update({ isSolution: 1 }, { where: { orderNo: pobj.sourceOrderNo } });
return system.getResultSuccess();
}else{
} else {
return checkRes;
}
}
//-----------------------------------------------------------------------------------------------------
async checkParams(pobj){//参数校验
//-----------------------------------------------------------------------------------------------------
async checkParams(pobj) {//参数校验
if (!pobj.serviceNo) {
return system.getResult(null, "业务单号不能为空不能为空,10100");
}
......@@ -72,9 +72,9 @@ class InternalCallsNotifyService {
return system.getResult(null, "来源单号不能为空,10110");
}
var orderinfo = await this.orderinfoDao.model.findOne({
where:{orderNo:pobj.sourceOrderNo},raw:true
where: { orderNo: pobj.sourceOrderNo }, raw: true
});
if(!orderinfo || !orderinfo.id){
if (!orderinfo || !orderinfo.id) {
return system.getResult(null, "未知订单,10120");
}
if (!pobj.tm) {
......@@ -124,15 +124,15 @@ class InternalCallsNotifyService {
}
return system.getResultSuccess(pobj);
}
async packagingTmDeliveryData(pobj,deliveryData) {//重新组装商标交付信息
async packagingTmDeliveryData(pobj, deliveryData) {//重新组装商标交付信息
var deliveryStatusList = [];
if(deliveryData && deliveryData.deliveryStatusList){
if (deliveryData && deliveryData.deliveryStatusList) {
deliveryStatusList = deliveryData.deliveryStatusList;
}
var nclOne = pobj.nclones[0];
if(nclOne.tmStatus){
if (nclOne.tmStatus) {
var deliveryStatusObj = this.statusContrast[nclOne.tmStatus];
if(deliveryStatusObj && deliveryStatusObj.value){
if (deliveryStatusObj && deliveryStatusObj.value) {
var deliveryStatus = deliveryStatusObj.value;
var deliveryStatusName = deliveryStatusObj.name;
deliveryStatusList.push({
......@@ -142,7 +142,7 @@ class InternalCallsNotifyService {
});
pobj.deliveryStatus = deliveryStatus;
pobj.deliveryStatusName = deliveryStatusName;
}else{
} else {
deliveryStatusList.push({
deliveryStatus: nclOne.tmStatus,
deliveryStatusName: nclOne.tmStatus,
......@@ -150,23 +150,23 @@ class InternalCallsNotifyService {
});
}
}
pobj.deliveryStatusList = deliveryStatusList;
pobj.deliveryStatusList = deliveryStatusList;
pobj.opNotes = ""; //操作备注
return pobj;
}
putOrderDelivery(data, orderNo, channelOrderNo) {//修改交付信息
var sql = "UPDATE `c_order_delivery` SET deliveryContent ='" + JSON.stringify(data) + "' where sourceOrderNo='" + orderNo + "'";
sql = sql + " and deliveryContent->'$.serviceNo' = '"+channelOrderNo+"'";
sql = sql + " and deliveryContent->'$.serviceNo' = '" + channelOrderNo + "'";
this.orderinfoDao.customUpdate(sql);
}
addOrderDelivery(data, orderNo) {//新增交付信息
addOrderDelivery(data, orderNo) {//新增交付信息--废弃,调用dao中的,20201102-sy
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
this.orderinfoDao.customQuery(sql);
}
async getOrderDelivery(orderNo,channelOrderNo) {//查询交付信息
async getOrderDelivery(orderNo, channelOrderNo) {//查询交付信息
var sql = "select * from `c_order_delivery` where sourceOrderNo='" + orderNo + "'";
sql = sql + " and deliveryContent->'$.serviceNo' = '"+channelOrderNo+"'";
sql = sql + " and deliveryContent->'$.serviceNo' = '" + channelOrderNo + "'";
return await this.orderinfoDao.customQuery(sql);
}
//----------------------------------------------------------------------------------------------------------
......
......@@ -6,6 +6,7 @@ class OrderInfoService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderInfoService));
this.flowlogDao = system.getObject("db.dbcorder.flowlogDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.orderproductDao = system.getObject("db.dbcorder.orderproductDao");
this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao");
this.orderReceiptVoucherDao = system.getObject("db.dbcpay.orderreceiptvoucherDao");
......@@ -82,7 +83,7 @@ class OrderInfoService extends ServiceBase {
quantity: actionBody.quantity,// 订单数量(即产品的倍数,默认值为1)
opPayType: "00",// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot: JSON.stringify(actionBody.product_info), //产品快照
orderSnapshot:JSON.stringify(actionBody.deliveryData.apply)
orderSnapshot: JSON.stringify(actionBody.deliveryData.apply)
};
var orderProduct = await this.orderproductDao.create(orderProductObj, t);//订单产品
var orderReceiptVoucherObj = {
......@@ -118,7 +119,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("ot" + pobj.appInfo.uapp_id);
if (pobj.actionBody.channelOrder && pobj.actionBody.channelOrder.channelOrderNo) {
var count = await self.dao.findCount({where: {channelOrderNo: pobj.actionBody.channelOrder.channelOrderNo}});
var count = await self.dao.findCount({ where: { channelOrderNo: pobj.actionBody.channelOrder.channelOrderNo } });
if (count > 0) {
return system.getResultFail(-1, "订单不能重复创建s");
}
......@@ -149,7 +150,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("re" + pobj.appInfo.uapp_id);
var item = await self.createOrder(pobj, orderNo, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
await self.orderinfoDao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -202,17 +203,17 @@ class OrderInfoService extends ServiceBase {
}
/**
* 新增交付信息
* 新增交付信息--废弃,从dao中调用,20201102-sy
* @param data
* @param orderNo
*/
addOrderDelivery(data, orderNo) {
try{
addOrderDelivery(data, orderNo, t) {
try {
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
this.customQuery(sql);
await this.customInsert(sql);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
......@@ -225,7 +226,7 @@ class OrderInfoService extends ServiceBase {
* @returns {Promise<{msg: *, data: (*|null), status: number}>}
*/
async submitReview(pobj, actionBody) {
try{
try {
var packagingTmResult = await this.packagingTmReDeliveryData(pobj, pobj.actionBody);
if (packagingTmResult.status != 0) {
return packagingTmResult;
......@@ -236,7 +237,7 @@ class OrderInfoService extends ServiceBase {
sql = sql.replace('\n', '');
const result = await this.customUpdate(sql);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
}
......@@ -296,11 +297,11 @@ class OrderInfoService extends ServiceBase {
sql += ` and json_extract(deliveryContent,'$.apply.askforId')='${actionBody.askforId}'`;
sqlCount += ` and json_extract(deliveryContent,'$.apply.askforId')='${actionBody.askforId}'`;
}
if(actionBody.applicantName){
if (actionBody.applicantName) {
sql += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
sqlCount += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
}
if(actionBody.status){
if (actionBody.status) {
sql += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`;
sqlCount += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`;
}
......@@ -332,7 +333,7 @@ class OrderInfoService extends ServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async getOfficialList(pobj,actionBody){
async getOfficialList(pobj, actionBody) {
let pageSize = Number(actionBody.pageSize || 20);
if (pageSize > 50) {
pageSize = 50;
......@@ -355,11 +356,11 @@ class OrderInfoService extends ServiceBase {
sql += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`;
sqlCount += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`;
}
if (actionBody.applicantName){
if (actionBody.applicantName) {
sql += ` and json_extract(officialInfo,'$.applicantName') like '%${actionBody.applicantName}%'`;
sqlCount += ` and json_extract(officialInfo,'$.applicantName') like'%${actionBody.applicantName}%'`;
}
if(actionBody.fileType){
if (actionBody.fileType) {
sql += ` and json_extract(officialInfo,'$.fileType')='${actionBody.fileType}'`;
sqlCount += ` and json_extract(officialInfo,'$.fileType')='${actionBody.fileType}'`;
}
......@@ -390,11 +391,11 @@ class OrderInfoService extends ServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async addOfficial(pobj,actionBody){
if(!actionBody.orderNo){
return system.getResult(null,'orderNo can not be empty');
async addOfficial(pobj, actionBody) {
if (!actionBody.orderNo) {
return system.getResult(null, 'orderNo can not be empty');
}
try{
try {
let orderSql = `select channelUserId from c_order_info where orderNo = '${actionBody.orderNo}'`;
let list = await this.customQuery(orderSql);
if (!list || list.length == 0) {
......@@ -403,14 +404,14 @@ class OrderInfoService extends ServiceBase {
let orderItem = list[0];
let data = {
serviceNo: actionBody.orderNo,
channelUserId:orderItem.channelUserId,
channelUserId: orderItem.channelUserId,
officialInfo: actionBody.officialData,
created_at: new Date(),
updated_at: new Date()
}
await this.officialDao.create(data);
return system.getResultSuccess();
}catch (e) {
} catch (e) {
return system.getResultFail();
}
......
......@@ -7,6 +7,7 @@ const sequelize = require('sequelize');
class OrderInfoService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderInfoService));
this.execClientNew = system.getObject("util.execClientNew");
this.flowlogDao = system.getObject("db.dbcorder.flowlogDao");
this.orderproductDao = system.getObject("db.dbcorder.orderproductDao");
this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao");
......@@ -14,10 +15,12 @@ class OrderInfoService extends ServiceBase {
this.moneyJourneyDao = system.getObject("db.dbcpay.moneyjourneyDao");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.orderRegionDao = system.getObject("db.dbcorder.orderregionDao");
this.push360Sve = system.getObject('service.common.push360Sve');
}
//----------------------订单创建-----------start----------------
async createOrder(pobj, orderNo, t) {
this.execClientNew.execLogs("center-order-createOrder-3", pobj, "center-order-doexecMethod-info", null, null);
var actionBody = pobj.actionBody;
var channelOrder = actionBody.channelOrder;
var orderContact = actionBody.orderContact;
......@@ -139,8 +142,8 @@ class OrderInfoService extends ServiceBase {
contactName: orderContact.contacts || "",//手机号
mobile: orderContact.mobile,//手机号
email: orderContact.email || "",
tel:orderContact.tel ||"", //座机
fax:orderContact.fax || "" //传真
tel: orderContact.tel || "", //座机
fax: orderContact.fax || "" //传真
};
await this.ordercontactsDao.create(customerContactObj, t);
}//渠道购买存在购买者手机号
......@@ -302,7 +305,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("tm" + pobj.appInfo.uapp_id);
var item = await self.createOrder(pobj, orderNo, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
await self.dao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -340,7 +343,7 @@ class OrderInfoService extends ServiceBase {
if (!deliveryData.tm.picUrl) {
return system.getResult(null, "商标图样不能为空,20210");
}
if(pobj.appInfo.uapp_id != 22 ){
if (pobj.appInfo.uapp_id != 22) {
if (!deliveryData.apply) {
return system.getResult(null, "申请信息不能为空,20230");
}
......@@ -450,9 +453,9 @@ class OrderInfoService extends ServiceBase {
}
var self = this;
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("tm" + pobj.appInfo.uapp_id);
var item = await self.createOrder(pobj, orderNo, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
const orderNo = (await self.getBusUid((pobj.actionBody.quantity > 1 ? "cntm" : "tm") + pobj.appInfo.uapp_id)).toUpperCase();
await self.createOrder(pobj, orderNo, t);
await self.dao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -511,7 +514,7 @@ class OrderInfoService extends ServiceBase {
return await self.db.transaction(async function (t) {
var orderNo = await self.getBusUid("logo" + pobj.appInfo.uapp_id);
var item = await self.createOrder(pobj, orderNo, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
await self.dao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -637,7 +640,7 @@ class OrderInfoService extends ServiceBase {
var item = await self.createOrder(pobj, orderNo, t);
// needsolutioninfo.status = "ywc";
await self.needsolutionDao.update({ id: needsolutioninfo.id, status: "dqr" }, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
self.dao.addOrderDelivery(pobj.actionBody.deliveryData, orderNo, t);
return system.getResultSuccess({
orderNo: orderNo,
channelServiceNo: pobj.actionBody.channelOrder.channelServiceNo || orderNo,
......@@ -705,10 +708,10 @@ class OrderInfoService extends ServiceBase {
mobile: actionBody.orderContact.mobile,//手机号
email: actionBody.orderContact.email || ""
};
if(actionBody.orderContact.tel){
if (actionBody.orderContact.tel) {
updateFields['tel'] = actionBody.orderContact.tel
}
if(actionBody.orderContact.fax){
if (actionBody.orderContact.fax) {
updateFields['fax'] = actionBody.orderContact.fax
}
this.ordercontactsDao.updateByWhere(updateFields, { where: { sourceOrderNo: actionBody.orderNo } });
......@@ -977,10 +980,8 @@ class OrderInfoService extends ServiceBase {
sql = sql.replace('\n', '');
this.customQuery(sql);
}
addOrderDelivery(data, orderNo) {//新增交付信息
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
orderNo + "','" + JSON.stringify(data) + "')";
this.customQuery(sql);
async addOrderDelivery(data, orderNo, t) {//新增交付信息
await this.dao.addOrderDelivery(data, orderNo, t);
}
async getOrderDelivery(orderNo) {//查询交付信息
var sql = "select * from `c_order_delivery` where sourceOrderNo='" + orderNo + "'";
......@@ -1018,7 +1019,7 @@ class OrderInfoService extends ServiceBase {
// 2020 0923 lin 新增 根据id修改orderStatus,目前用来商标交易更新订单状态
async updateOrderStatusById(pobj, actionBody) {
var orderInfo = await this.dao.model.update({orderStatus:actionBody.orderStatus},{ where: { id: actionBody.orderId } })
var orderInfo = await this.dao.model.update({ orderStatus: actionBody.orderStatus }, { where: { id: actionBody.orderId } })
if (!orderInfo) {
return system.getResult(null, "修改失败");
}
......@@ -1184,15 +1185,15 @@ class OrderInfoService extends ServiceBase {
}
//根据合同号,获取子订单
async getOrderListByOrderServiceNo(pobj){
async getOrderListByOrderServiceNo(pobj) {
let sql = "select `orderNo`,`channelServiceNo`,`channelOrderNo`,`channelUserId`,`ownerUserId`,`payTime`,`quantity`,`serviceQuantity`,`orderStatusName`,`orderStatus`,`totalSum`,`payTotalSum`,`refundSum`," +
" `itemCode','invoiceApplyStatus`,`opNotes`,`notes`,`channelItemCode`,`channelItemName`,`price`,priceDesc,priceTypeName,channelItemAppendName,`serviceItemCode`,`picUrl`,`serviceItemSnapshot`,`orderSnapshot`,created_at" +
" from v_order where uapp_id =:uapp_id and orderServiceNo =:orderServiceNo"
" `itemCode','invoiceApplyStatus`,`opNotes`,`notes`,`channelItemCode`,`channelItemName`,`price`,priceDesc,priceTypeName,channelItemAppendName,`serviceItemCode`,`picUrl`,`serviceItemSnapshot`,`orderSnapshot`,created_at" +
" from v_order where uapp_id =:uapp_id and orderServiceNo =:orderServiceNo"
let paramWhere = {
uapp_id : pobj.appInfo.uapp_id,
orderServiceNo : pobj.orderNo ? pobj.orderNo : pobj.actionBody.orderServiceNo
uapp_id: pobj.appInfo.uapp_id,
orderServiceNo: pobj.orderNo ? pobj.orderNo : pobj.actionBody.orderServiceNo
}
let list = await this.customQuery(sql,paramWhere);
let list = await this.customQuery(sql, paramWhere);
if (!list || list.length == 0) {
return system.getResult(null, "订单数据为空,30200");
}
......@@ -1425,13 +1426,20 @@ class OrderInfoService extends ServiceBase {
deliveryInfo.nclones[tbCodeIndex].tmStatusName = "待递交";
orderLog.opContent = "尊敬的用户,您的商标:“" + deliveryInfo.tm.tmName + "”第" + deliveryInfo.nclones[tbCodeIndex].code + "类,办理状态更新为【待递交】";
}//待提交
else if (actionBody.tmStatus == "ROBOT") {
else if (actionBody.tmStatus == "ROBOT" || actionBody.tmStatus == "ROBOTPAY") {
deliveryInfo.deliveryStatus = "ydj";
deliveryInfo.deliveryStatusName = "已递交";
deliveryInfo.nclones[tbCodeIndex].tmStatus = "ydj";
deliveryInfo.nclones[tbCodeIndex].tmStatusName = "已递交";
orderLog.opContent = "尊敬的用户,您的商标:“" + deliveryInfo.tm.tmName + "”第" + deliveryInfo.nclones[tbCodeIndex].code + "类,办理状态更新为【已递交】";
}//已提交--自己系统中存在此状态(升级后不存在,目前没有升级)
else if (actionBody.tmStatus == "FILLEXCEPTION") {
actionBody.submitTime = actionBody.submitTime || new Date();
deliveryInfo.deliveryStatus = "djyc";
deliveryInfo.deliveryStatusName = "递交异常";
deliveryInfo.nclones[tbCodeIndex].tmStatusName = "递交异常";
orderLog.opContent = "尊敬的用户,您的商标:“" + deliveryInfo.tm.tmName + "”第" + deliveryInfo.nclones[tbCodeIndex].code + "类,办理状态更新为【递交异常】";
}//已收提交
else if (actionBody.tmStatus == "RECVCOMMIT" || actionBody.tmStatus == "ydj") {
actionBody.submitTime = actionBody.submitTime || new Date();
updateOrderFields.orderStatus = 8;
......@@ -1475,7 +1483,12 @@ class OrderInfoService extends ServiceBase {
deliveryInfo.opNotes = actionBody.opNotes || "";
this.putOrderDelivery(deliveryInfo, actionBody.orderNo);
//商标状态推送 360
if (orderItem.uapp_id == 50) {
actionBody.deliveryInfo = deliveryInfo;
this.push360Sve.pushTmStatus(actionBody);
this.push360Sve.sendMessage(actionBody)
}
} catch (error) {
console.log("error------------------------", e.stack);
}
......@@ -1734,6 +1747,9 @@ class OrderInfoService extends ServiceBase {
if (item.orderStatus > 1) {
return system.getResultSuccess(null, "order status is pay!");
}
if(item.payTotalSum > parmas.payTotalSum){
return system.getResultFail(-1,'支付金额有误!')
}
var self = this;
await self.db.transaction(async function (t) {
await self.dao.updateByWhere({ orderStatus: 2, payTime: parmas.time_end }, { where: { orderNo: parmas.orderNo } }, t);
......@@ -1911,33 +1927,32 @@ class OrderInfoService extends ServiceBase {
}
//智能选择 尼斯类获取
async getNclByCode(pobj){
async getNclByCode(pobj) {
var sql = "select `business_code`,`ncl_content` from b_business_ncl where business_code=:business_code LIMIT 1";
var paramWhere = { business_code: pobj.actionBody.businessCode };
var result = await this.customQuery(sql, paramWhere);
if(Object.keys(result).length==0){
return system.getResultFail(-1,'find err');
if (Object.keys(result).length == 0) {
return system.getResultFail(-1, 'find err');
}
return system.getResult(result[0].ncl_content);
}
//智能选择 尼斯类获取
async getAllNcl(pobj){
async getAllNcl(pobj) {
var sql = "select `ncl_content` from b_business_ncl where business_code like '%类%'";
var result = await this.customQuery(sql);
if(Object.keys(result).length==0){
return system.getResultFail(-1,'find err');
if (Object.keys(result).length == 0) {
return system.getResultFail(-1, 'find err');
}
let ret = []
result.forEach(item =>{
let Arr=item.ncl_content.nclThree;
let arrNew=[];
result.forEach(item => {
let Arr = item.ncl_content.nclThree;
let arrNew = [];
for(var i=0;i<10;i++)
{
var _num = Math.floor(Math.random()*Arr.length)
for (var i = 0; i < 10; i++) {
var _num = Math.floor(Math.random() * Arr.length)
var mm = Arr[_num];
Arr.splice(_num,1)
Arr.splice(_num, 1)
arrNew.push(mm)
}
item.ncl_content.nclThree = arrNew;
......@@ -1947,23 +1962,23 @@ class OrderInfoService extends ServiceBase {
}
//修改订单信息 更新IC订单号
async updateOrderById(pobj,actionBody){
if(!actionBody.orderNo){
return system.getResultFail(-1,'订单号不能为空');
async updateOrderById(pobj, actionBody) {
if (!actionBody.orderNo) {
return system.getResultFail(-1, '订单号不能为空');
}
let sql = `update c_order_info set orderServiceNo = :orderServiceNo,channelOrderNo = :channelOrderNo,channelServiceNo=:channelServiceNo where orderNo = :orderNo`
let updateParams = {
orderNo:actionBody.orderNo,
orderServiceNo:actionBody.orderServiceNo,
channelOrderNo:actionBody.channelOrderNo,
channelServiceNo :actionBody.channelServiceNo
orderNo: actionBody.orderNo,
orderServiceNo: actionBody.orderServiceNo,
channelOrderNo: actionBody.channelOrderNo,
channelServiceNo: actionBody.channelServiceNo
}
let result = await this.customQuery(sql,updateParams)
let result = await this.customQuery(sql, updateParams)
return system.getResult(result);
}
//获取支付记录
async getPayRecords(pobj){
async getPayRecords(pobj) {
const userInfo = pobj.userInfo;
let sql = `select m.sourceOrderNo orderNo,json_extract(o.serviceItemSnapshot,'$.channel_item_name') productName,m.recvAmount totalSum,m.directionType directionType,m.updated_at payTime
from
......@@ -1971,11 +1986,11 @@ class OrderInfoService extends ServiceBase {
on m.sourceOrderNo = o.orderNo
where
m.channelUserId = :channelUserId and m.uapp_id = :uapp_id`
const searchWhere ={
channelUserId : userInfo.channel_userid,
uapp_id:pobj.appInfo.uapp_id
const searchWhere = {
channelUserId: userInfo.channel_userid,
uapp_id: pobj.appInfo.uapp_id
}
let seRet = await this.customQuery(sql,searchWhere);
let seRet = await this.customQuery(sql, searchWhere);
return system.getResultSuccess(seRet)
}
}
......
const uuidv4 = require('uuid/v4');
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
var moment = require('moment')
class NeedinfoService2 extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
}
async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
console.log(system.getResultSuccess(item));
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async getItemByChannelNeedNo(pobj) {
var item = await this.dao.getItemByChannelNeedNo(pobj.actionBody.needNo);
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async needinfo2fq(pobj) {
pobj.actionBody.needNo = await this.getBusUid("n");
pobj.actionBody.uapp_id = pobj.appInfo.id;
var needinfo = await this.dao.create(pobj.actionBody);
var pobj = {
"idempotentId": needinfo.needNo,
"idempotentSource": needinfo.chanceType_code,
"idempotentSourceName": pobj.appInfo.app_name + "_" + pobj.actionBody.chanceTypeName,
"phone": needinfo.publishMobile,
"remark": needinfo.notes,
"customerName": needinfo.publishName
};
var rc = system.getObject("util.aliyunClient");
var rtn = await rc.post("https://yunfuapi.gongsibao.com/crm/opportunity/submit", pobj);
console.log(rtn)
return system.getResultSuccess();
// var opResultstr = await this.execlient.execPost(pobj, "https://yunfuapi-dev.gongsibao.com/crm/opportunity/submit");
// opResult = JSON.parse(opResultstr.stdout)
// if (opResultstr) {
// return system.getResultSuccess();
// }
}
// intentionBizId
// mobile
// userName
// description
// area
// type
// ext
async submitNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
if (!actionBody.intentionBizId) {
return system.getResultFail(-5001, "intentionBizId不能为空");
}
if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空");
}
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess(ninfo);
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: actionBody.intentionBizId,
needNo: needNo,
channelUserId: actionBody.mobile,
publishName: actionBody.userName,
publishContent: actionBody.description,
publishMobile: actionBody.mobile,
city: actionBody.area,
// disposeNotes: actionBody.ext,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts",
level: actionBody.level || "",
probability: actionBody.probability || "",
notes: actionBody.notes
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city,
nobj.city = "";
}
var needInfo = await this.dao.create(nobj);
return system.getResultSuccess(needInfo);
}
/**
* 工商H5 免费咨询
* @param pobj
* @param actionBody
* @param req
* @returns {Promise<{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
*/
async submitNeedH5(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
var channelNeedNo = await this.getBusUid("i");
if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空");
}
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess();
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: channelNeedNo,
needNo: needNo,
channelUserId: actionBody.mobile,
publishName: actionBody.userName,
publishContent: actionBody.description,
publishMobile: actionBody.mobile,
city: actionBody.area,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts"
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city,
nobj.city = "";
}
await this.dao.create(nobj);
return system.getResultSuccess();
}
async needClose(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
async flowinfo(obj) {
}
async getItemByChannelSolutionNo(pobj) {
var solutionitem = await this.needsolutionDao.findOne({ channelSolutionNo: pobj.actionBody.bizId });
if (!solutionitem) {
return system.getResult(null, "需求数据为空,30210");
}
var item = await this.dao.getItemByNeedNo(solutionitem.needNo);
item.solutionProvince = solutionitem.solutionContent.solution.Area + `(${solutionitem.solutionContent.solution.ActionType})`//北京(新办);
item.solutionContent = solutionitem.solutionContent
item.channelSolutionNo = solutionitem.channelSolutionNo
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async writeCommunicationLog(pobj, actionBody) {
// 查询需求沟通记录
// 2020 0820 lin 修改channel传过来的参数 为 note/intentionBizId
actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", actionBody.note];
let needRes = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: actionBody.Note,
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
if (updateRes[1]) {
//2020-10-28 laolan start
var sql = "select uapp_id from n_need_ifno where channelNeedNo =:channelNeedNo ";
var where = {
channelNeedNo:actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
if(uappIdInfo){
var uappIds = uappIdInfo.data[0].uapp_id
}
return system.getResultSuccess(uappIds);
//2020-10-28 laolan end
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +actionBody.BizId +"\"" +" "
var paramWhere = {
Note: actionBody.Note,
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
if (updateRes[1]) {
//2020-10-28 laolan start
var sql = "select uapp_id from n_need_ifno where channelNeedNo =:channelNeedNo ";
var where = {
channelNeedNo:actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
if(uappIdInfo){
var uappIds = uappIdInfo.data[0].uapp_id
}
return system.getResultSuccess(uappIds);
//2020-10-28 laolan end
}
return system.getResult("添加记录失败");
}
}
//2020-10-28 laolan xin zeng 查询需求沟通记录
async queryExpertApplyCommunicationLogs(pobj){
if (!pobj.actionBody.intentionBizId) {
return system.getResult(null, "actionBody.intentionBizId can not be empty,100493");
}
if (!pobj.actionBody.userFeedBack) {
return system.getResult(null, "actionBody.userFeedBack can not be empty,100494");
}
var sql = "select uapp_id from n_need_ifno where channelNeedNo =:channelNeedNo ";
var where = {
channelNeedNo:pobj.actionBody.intentionBizId
}
var uappIdInfo = await this.customQuery(sql,where);
if(uappIdInfo){
uappIdInfo = uappIdInfo.data[0];
return system.getResultSuccess(uappIdInfo);
}
}
async submitIcpIntention(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
needNo: needNo,
channelUserId: pobj.userInfo.channel_userid,
publishName: actionBody.UserName,
publishContent: actionBody.Description,
publishMobile: actionBody.Mobile,
city: actionBody.Area,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts"
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city,
nobj.city = "";
}
await this.dao.create(nobj);
return system.getResultSuccess();
}
async queryIntentionList(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
async confirmIcpIntention(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
//查询未提交的需求
async getUnCreated (pobj, data, req) {
let stdate = new Date(pobj.actionBody.Begin);
let enddate = new Date(pobj.actionBody.End );
let query = {where:{}};
query.where["created_at"] = { [this.db.Op.between]: [stdate, enddate] };
try {
let res = await this.dao.model.findAndCountAll(query);
res = res.rows.map(n=>n.channelNeedNo);
res = pobj.actionBody.data.filter(ali=>!res.includes(ali.BizId));
return system.getResultSuccess(res)
} catch (error) {
return system.getResultFail(-1, error.message)
}
}
async produceNoticeAliEsp (pobj, actionBody) {
switch (actionBody.operationType) {
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
default:
return system.getResult(null, "operationType参数错误");
}
}
}
module.exports = NeedinfoService2;
// var a=new NeedinfoService();
// var b=a.getItemByChannelSolutionNo({actionBody:{bizId:"1593141330846"}});
\ No newline at end of file
......@@ -1251,7 +1251,54 @@ class NeedsolutionService extends ServiceBase {
}
// --------------庄冰2020.10.23-------百度Icp接入使用--------end------------------
//创建方案信息
async createNewSolution(pobj){
let ab = pobj.actionBody;
let app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.channelSolutionNo) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
let newNsObj={
orderNo:ab.orderNo,channelSolutionNo:ab.channelSolutionNo,solutionNo:ab.channelSolutionNo,
needNo:ab.bizId,channelNeedNo:ab.bizId,status:"ywc"
};
let newSolutionCount = {
"status": "USER_UPLOADED",
"bizType": ab.product_info && ab.product_info.channel_item_code?ab.product_info.channel_item_code:"",
"solution": {
"Area": ab.product_info.price_item.price_desc || "",
"IcpType": '',
"CompanyName": ab.companyName || "",
"CompanyAddress": ab.area || ""
},
"totalSum": ab.order_info.totalSum || "",
"typeCode": ab.product_info && ab.product_info.channel_item_code?ab.product_info.channel_item_code:"",
"typeName": ab.product_info && ab.product_info.channel_item_name?ab.product_info.channel_item_name:"",
"needStatus": "3",
"statusName": "用户支付",
"customerInfo": {
"publishName": "",
"publishMobile": ""
},
"customerRemark": "",
"needStatusName": "处理中",
"customerMaterial": {},
"solutionFlowList": [
{
"status": "PAID",
"statusName": "用户支付",
"updated_at": new Date()
}
]
};
newNsObj.solutionContent = JSON.stringify(newSolutionCount);
let ns = await this.dao.create(newNsObj);
return system.getResultSuccess(ns)
}
}
module.exports = NeedsolutionService;
// var task = new NeedsolutionService();
......
......@@ -425,9 +425,9 @@ class AliyunQcService {
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
// if (!needsolutioninfo.needNo) {
// return system.getResultFail(-401, "方案需求信息有误");
// }
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
......@@ -436,16 +436,16 @@ class AliyunQcService {
return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// var needinfo = await this.needinfoDao.model.findOne({
// where: { needNo: needsolutioninfo.needNo }, raw: true
// });
// if (!needinfo || !needinfo.id) {
// return system.getResultFail(-201, "未知需求信息");
// }
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (needinfo.status == "ygb") {
// return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
// }
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
......@@ -558,9 +558,9 @@ class AliyunQcService {
// }
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 507) {//完成账户注册
if (solutionContent.status != "USER_CONFIRMED") {
return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
// if (solutionContent.status != "USER_CONFIRMED") {
// return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
// }
solutionContent.ApplicationStatus = 507;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
......
......@@ -70,575 +70,6 @@ class BaiduQcService {
"CERT_GXB_REFUSE": "⼯商部不予受理"
};
}
//根据需求关闭ICP方案(关闭需求后调用)
async abolishIcpProgrammeByNeed(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.intentionBizId) {
return system.getResultFail(-101, "需求编号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo"],
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { needNo: needinfo.needNo, isInvalid: 0 }, raw: true
});
if (ns && ns.id) {
if (ns.status == "ywc") {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
}
var flowStatus = ns.solutionContent && ns.solutionContent.status ? ns.solutionContent.status : "";
if (flowStatus && ["GXB_REFUSE", "CLOSE"].indexOf(flowStatus) < 0) {
return system.getResultFail(-104, "⽅案状态为关闭或不予受理才可关闭需求");
}
}
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
var needObj = {
id: needinfo.id, status: "ygb", notes: ab.note
};
await self.needinfoDao.update(needObj, t);//关闭需求
if (ns && ns.id) {
await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃
return system.getResultSuccess(ns.orderNo);
}
return system.getResultSuccess();
})
}
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "需求号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-102, "未知需求信息");
}
var ns = await this.needsolutionDao.model.findAll({
where: { needNo: needinfo.needNo }, raw: true,
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
});
return system.getResultSuccess(ns);
}
//获取方案详情(内部调用)
async getIcpProgrammeDetail(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findAll({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
return system.getResultSuccess(ns);
}
//获取方案详情(前端调用)
async getNeedSolutionDetailByUser(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"]=user.id;
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, createUserId: user.id }, raw: true
});
if (ns && ns.needNo) {
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true,
attributes: ["publishName", "publishMobile", "channelUserId"]
});
ns.needinfo = needinfo;
}
return system.getResultSuccess(ns);
}
//提交方案
async submitIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "7") {//edi
ab.solutionContent.solution.IcpType = 2;
} else if (needinfo.channelTypeCode == "5") {//icp
ab.solutionContent.solution.IcpType = 1;
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.icpSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.icpSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "icp提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//交付商关闭交付单
async closeOrderDelivery(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
} else {
ab.Note = ab.note;
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.abolishIcpProgramme(pobj);
}
//服务商方案作废 -- abolishIcpProgramme
async abolishIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.Note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-300, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-400, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-401, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionContent = ns.solutionContent;
if (!solutionContent.status || ["USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", "MATERIAL_SUBMITTED"].indexOf(solutionContent.status) < 0) {
return system.getResultFail(-302, "方案流程状态错误,不能执行此操作");
}
solutionContent.serviceProviderNote = ab.Note;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent = JSON.stringify(solutionContent);
await this.needsolutionDao.update({ id: ns.id, status: "yzf", isInvalid: 1, solutionContent: solutionContent });//方案废弃
//获取方案信息
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.submitIcpMaterial(pobj);
}
//提交icp材料信息
async submitIcpMaterial(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if (!ab.material) {
return system.getResultFail(-102, "材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "needNo", "solutionContent"],
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.status != "USER_UPLOADED") {
return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
}
//CorporateName 法⼈名称
if (!material.hasOwnProperty("IncludeForeignInvestment")) {
return system.getResultFail(-102, "包含外贸参数不能为空");
}
if (!material.PartnerBusinessLicense) {
return system.getResultFail(-103, "营业执照不能为空");
}
if (!material.PartnerIdCardList || material.PartnerIdCardList.length < 1) {
return system.getResultFail(-105, "相关人员身份证不能为空");
}
if (!material.PartnerDomainCertificate) {
return system.getResultFail(-106, "域名证书不能为空");
}
solutionContent.material = ab.material;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "MATERIAL_UNCONFIRM", statusName: this.icpSolutionStatusReference.MATERIAL_UNCONFIRM, updated_at: new Date()
});
solutionContent.status = "MATERIAL_UNCONFIRM";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_UNCONFIRM;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
var new_needsolutioninfo = await self.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
return system.getResultSuccess(new_needsolutioninfo);
})
}
//交付商通知状态变更
async serviceProviderNotification(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "交付状态不能为空");
} else {
ab["ApplicationStatus"] = ab.status;
}
if (ab.officialFileURL) {
ab["OfficialFileURL"] = ab.officialFileURL;
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
ab["solutionNo"] = ns.solutionNo;
pobj.actionBody = ab;
return this.acceptIcpPartnerNotification(pobj);
}
//服务商通知状态变更
async acceptIcpPartnerNotification(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
// if (!ab.BizId) {
// return system.getResultFail(-101, "渠道方案编号不能为空");
// }
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "通知状态不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "status", "solutionContent", "needNo"],
where: { solutionNo: ab.solutionNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
}
if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 507) {//完成账户注册
if (solutionContent.status != "USER_CONFIRMED") {
return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionContent.ApplicationStatus = 507;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "ACCOUNT_REGISTERED";
solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
if (solutionContent.status != "ACCOUNT_REGISTERED") {
return system.getResultFail(-508, "交付流程错误,请先完成账户注册");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "MATERIAL_SUBMITTED", statusName: this.icpSolutionStatusReference.MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "MATERIAL_SUBMITTED";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 509) {//⼯商部已受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-509, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_ACCEPT", statusName: this.icpSolutionStatusReference.GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "GXB_ACCEPT";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_ACCEPT;
}
if (ab.ApplicationStatus == 510) {//⼯商部不予受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-510, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-511, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-512, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.icpApplicationStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//接收渠道方案状态变更通知
async receiveOrderStatusNotify(pobj) {
......@@ -649,7 +80,7 @@ class BaiduQcService {
if (!ab.status) {
return system.getResultFail(-102, "方案状态不能为空");
}
if(ab.isDirectBuy && ab.isDirectBuy==1){//直接下单,无方案 直接返回
if(ab.isDirectBuy && ab.isDirectBuy==1 && ab.status==1){//直接下单,无方案 直接返回
return system.getResultSuccess();
}
//获取方案信息
......@@ -668,9 +99,6 @@ class BaiduQcService {
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status == "yzf" || ns.status == "ywc") {
// return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作");
// }
var solutionContent = ns.solutionContent;
var checkStatus = {
ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
......@@ -771,1011 +199,83 @@ class BaiduQcService {
});
return system.getResultSuccess(ns);
}
//接收icp用户方案反馈
async receiveIcpFeedback(pobj) {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
}
if (!ab.description) {
return system.getResultFail(-102, "问题描述不能为空");
}
if (!ab.hasOwnProperty("intentionStatus")) {
return system.getResultFail(-103, "需求当前状态不能为空");
//关闭ICP订单 百度icp 2.4
async icpOrderClose(pobj) {
var ab = pobj;
if (!ab.channelOrderNo) {
return system.getResultFail(-101, "渠道订单号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId }, raw: true
var orderInfo = await this.orderinfoDao.model.findOne({
where:{channelOrderNo:ab.channelOrderNo},raw:true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
if (!orderInfo || !orderInfo.id) {
return system.getResultFail(-103, "未知订单");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, isInvalid: 0 }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if (ab.intentionStatus == 1) {
updateObj["status"] = "ybh";
updateObj["isInvalid"] = 1;
} else if (ab.intentionStatus == 2) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj) {
var ab = pobj.actionBody;
if (!ab.solutionBizId) {
return system.getResultFail(-101, "渠道方案业务编号不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
where: { orderNo: orderInfo.orderNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
await this.needsolutionDao.model.update({ channelSolutionNo: ab.solutionBizId }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
//接收确认方案后阿里返回链接
async receiveIcpConfirmUrl(pobj) {
var ab = pobj.actionBody;
if (!ab.confirmUrl) {
return system.getResultFail(-101, "confirmUrl不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
ns.solutionContent.confirmUrl = ab.confirmUrl;
var solutionContent = JSON.stringify(ns.solutionContent);
await this.needsolutionDao.model.update({ solutionContent: solutionContent }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
//接收渠道方案状态变更通知
async receiveEdiStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.operationType) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
// 2020 0929 lin 修改ab.BizId 改为 ab.solutionBizId
where: { channelSolutionNo: ab.solutionBizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionContent = ns.solutionContent;
var checkStatus = { ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单" };
var checkStatus = {
MATERIAL_UNCONFIRM:"服务商递交文件",
ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
};
if (solutionContent.status && checkStatus[solutionContent.status]) {
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.operationType == "USER_PAY_PRODUCE") {//⽤户已支付
solutionFlowList.push({
status: "USER_PAY_PRODUCE", statusName: this.ediSolutionStatusReference.USER_PAY_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_PAY_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_PAY_PRODUCE;
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.operationType == "USER_CONFIRM_PRODUCE") {//⽤户确认资料
solutionFlowList.push({
status: "USER_CONFIRM_PRODUCE", statusName: this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRM_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE;
} else if (ab.operationType == "USER_REFUSE_PRODUCE") {//资料退回修改
solutionFlowList.push({
status: "USER_REFUSE_PRODUCE", statusName: this.ediSolutionStatusReference.USER_REFUSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_REFUSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_REFUSE_PRODUCE;
} else if (ab.operationType == "USER_UPLOAD_PRODUCE") {//⽤户补充基本资料
solutionFlowList.push({
status: "USER_UPLOAD_PRODUCE", statusName: this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_UPLOAD_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE;
} else if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
solutionFlowList.push({
status: "ABC_CLOSE_PRODUCE", statusName: this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "ABC_CLOSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.extInfo) {
// 退回修改理由
var extInfoJson = JSON.parse(ab.extInfo);
if(extInfoJson.rejectReason) {
ab.rejectReason = extInfoJson.rejectReason,
solutionContent.rejectReason = extInfoJson.rejectReason
}
material.businessLicenseArr = ab.extInfo.businessLicenseArr;
material.idCardListArr = ab.idCardListArr;
if (ab.remark) {
solutionContent.customerRemark = ab.remark;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id,
solutionContent: solutionContent,
};
// 这里修改进去了
if(ab.bizId != ns.channelDeliverId) {
updateObj.channelDeliverId = ab.bizId
}
if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
}
// ---------------- 文网文 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (文网文)
*/
async serviceSubmitOption(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "交付状态不能为空");
}
if (!ab.channelType) {
return system.getResultFail(-103, "渠道来源不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 601) {//服务商提交资料
if (solutionContent.status == "USER_UPLOAD_PRODUCE" || solutionContent.status == "USER_REFUSE_PRODUCE") {
solutionContent.ApplicationStatus = 601;
solutionFlowList.push({
status: "PARTNER_SUBMIT_MATERIAL", statusName: this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL, updated_at: new Date()
});
solutionContent.status = "PARTNER_SUBMIT_MATERIAL";
solutionContent.statusName = this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL;
}else{
return system.getResultFail(-601, "交付流程错误,请先完成账户注册");
}
}
if (ab.ApplicationStatus == 602) {//完成账户注册
if (solutionContent.status != "USER_CONFIRM_PRODUCE") {
return system.getResultFail(-602, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_ACCOUNT_REGISTERED", statusName: this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "CERT_ACCOUNT_REGISTERED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 603) {//服务商完成提交资料到⼯信部
if (solutionContent.status != "CERT_ACCOUNT_REGISTERED") {
return system.getResultFail(-603, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_MATERIAL_SUBMITTED", statusName: this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "CERT_MATERIAL_SUBMITTED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 604) {//⼯商部已受理
if (solutionContent.status != "CERT_MATERIAL_SUBMITTED") {
return system.getResultFail(-604, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_ACCEPT", statusName: this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_ACCEPT";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT;
}
if (ab.ApplicationStatus == 605) {//⼯商部不予受理
if (solutionContent.status != "PARTNER_SUBMIT_MATERIAL") {
return system.getResultFail(-605, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_REFUSE", statusName: this.wangwenSolutionStatusReference.CERT_GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_REFUSE;
}
if (ab.ApplicationStatus == 606) {//⼯商部通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-606, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_SUCCESS", statusName: this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "CERT_GXB_SUCCESS";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS;
}
if (ab.ApplicationStatus == 607) {//⼯信部未通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-607, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_FAIL", statusName: this.wangwenSolutionStatusReference.CERT_GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.wangwenSolutionStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//提交方案
async submitWangwenSolution(pobj) {
console.log('wangwen提交方案',pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "esp.wangwen") {//esp.wangwen
ab.solutionContent.solution.IcpType = "wangwen";
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "企业名称不能为空");
}
if (!solution.licenseType) {
return system.getResultFail(-106, "网文类型不能为空");
}
if (!solution.actionType) {
return system.getResultFail(-106, "办理类型不能为空");
}
if (!solution.companyLocation) {
return system.getResultFail(-107, "区域不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.wangwenSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.wangwenSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
id: ns.id, solutionContent: solutionContent,status:"yzf",isInvalid:1
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "wangwen提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
await self.needsolutionDao.update(updateObj);//方案状态修改
// await this.orderinfoDao.update({id:orderInfo.id,orderStatus:16});//订单状态修改
var new_ns = await self.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
})
}
//关闭需求
async closeNeed(pobj) {
//添加业务员信息,用于直接下单的icp订单
async addIcpSalesmanInfo(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.needNo) {
return system.getResultFail(-101, "需求编号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo"],
where: { channelNeedNo: ab.needNo }, raw: true
var salesmanObj = ab.salesmanInfo;
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo, isInvalid: 0 }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var updateNeed = await this.needinfoDao.update(needObj);//关闭需求
if (!updateNeed) {
return system.getResultFail(-203, "关闭需求失败");
} else {
return system.getResultSuccess();
}
}
//提交沟通记录
async recordLog(pobj) {
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj.actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", pobj.actionBody.note];
let needRes = await this.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.needNo });
console.log('needRes',needRes)
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var paramWhere = {
Note: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var solutionContent = ns.solutionContent;
solutionContent.salesmanInfo=salesmanObj;
var updateObj = {id:ns.id,solutionContent:JSON.stringify(solutionContent)}
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess(solutionContent);
}
// ---------------- 食品 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (食品)
*/
async foodServiceSubmitOption(pobj) {
console.log(pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "交付状态不能为空");
}
if (!ab.channelType) {
return system.getResultFail(-102, "渠道来源不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 601) {//服务商提交资料
if (solutionContent.status == "USER_UPLOAD_PRODUCE" || solutionContent.status == "USER_REFUSE_PRODUCE") {
solutionContent.ApplicationStatus = 601;
solutionFlowList.push({
status: "PARTNER_SUBMIT_MATERIAL", statusName: this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL, updated_at: new Date()
});
solutionContent.status = "PARTNER_SUBMIT_MATERIAL";
solutionContent.statusName = this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL;
}else{
return system.getResultFail(-601, "交付流程错误,请先完成账户注册");
}
}
if (ab.ApplicationStatus == 602) {//完成账户注册
if (solutionContent.status != "USER_CONFIRM_PRODUCE") {
return system.getResultFail(-602, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_ACCOUNT_REGISTERED", statusName: this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "CERT_ACCOUNT_REGISTERED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 603) {//服务商完成提交资料到⼯信部
if (solutionContent.status != "CERT_ACCOUNT_REGISTERED") {
return system.getResultFail(-603, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_MATERIAL_SUBMITTED", statusName: this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "CERT_MATERIAL_SUBMITTED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 604) {//⼯商部已受理
if (solutionContent.status != "CERT_MATERIAL_SUBMITTED") {
return system.getResultFail(-604, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_ACCEPT", statusName: this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_ACCEPT";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT;
}
if (ab.ApplicationStatus == 605) {//⼯商部不予受理
if (solutionContent.status != "PARTNER_SUBMIT_MATERIAL") {
return system.getResultFail(-605, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_REFUSE", statusName: this.wangwenSolutionStatusReference.CERT_GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_REFUSE;
}
if (ab.ApplicationStatus == 606) {//⼯商部通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-606, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_SUCCESS", statusName: this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "CERT_GXB_SUCCESS";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS;
}
if (ab.ApplicationStatus == 607) {//⼯信部未通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-607, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_FAIL", statusName: this.wangwenSolutionStatusReference.CERT_GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.wangwenSolutionStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//提交方案
async submitFoodSolution(pobj) {
console.log('food提交方案',pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "esp.food") {//esp.food
ab.solutionContent.solution.IcpType = "food";
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "企业名称不能为空");
}
if (!solution.licenseType) {
return system.getResultFail(-106, "网文类型不能为空");
}
if (!solution.actionType) {
return system.getResultFail(-106, "办理类型不能为空");
}
if (!solution.companyLocation) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.solutionPrice) {
return system.getResultFail(-108, "办理价格不能为空");
}else{
solution.solutionPrice = solution.solutionPrice / 100;
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.wangwenSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.wangwenSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "food提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//关闭需求
async foodCloseNeed(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.needNo) {
return system.getResultFail(-101, "需求编号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo"],
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var updateNeed = await this.needinfoDao.update(needObj);//关闭需求
if (!updateNeed) {
return system.getResultFail(-203, "关闭需求失败");
} else {
return system.getResultSuccess();
}
}
//提交沟通记录
async foodRecordLog(pobj) {
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj.actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", pobj.actionBody.note];
let needRes = await this.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.needNo });
console.log('needRes',needRes)
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var paramWhere = {
Note: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
}
}
}
module.exports = BaiduQcService;
const system = require("../../../system");
const moment = require('moment');
/**
* 阿里云增值电信相关接口(ICP、EDI)
* created by zhuangbing
* created at 2020.07.27
*/
class BaseQcService {
constructor() {
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.icpSolutionStatusReference = {
SOLUTION_SUBMIT: "提交服务单",
UN_PAID: "未支付", PAID: "用户支付", USER_UPLOADED: "用户上传资料", MATERIAL_UNCONFIRM: "服务商递交⽂件"
, USER_CONFIRMED: "⽤户已确认递交⽂件", ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"
};
this.ediSolutionStatusReference = {
SOLUTION_SUBMIT: "服务单通知服务商",
USER_PAY_PRODUCE: "⽤户⽀付",
USER_CONFIRM_PRODUCE: "⽤户确认资料",
USER_REFUSE_PRODUCE: "资料退回修改",
ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单",
USER_UPLOAD_PRODUCE: "⽤户补充基本资料"
};
this.ediProduceStatus = {
110: "⽤户⽀付",
30: "待⽤户确认",
105: "账户已注册",
35: "待提交审核",
109: "管局已通过",
106: "材料已递交⼯信部",
10: "已⽀付",
108: "管局不予受理",
0: "初始状态",
50: "订单关闭",
25: "待⽤户提交材料",
107: "管局已受理"
};
this.icpApplicationStatusReference = {
507: "完成账户注册",
508: "服务商完成提交资料到⼯信部",
509: "⼯商部已受理",
510: "⼯商部不予受理",
511: "⼯商部通过",
512: "⼯商部未通过"
};
//(文网文状态2020-9-26)
this.wangwenStatusReference = {
601: "服务商提交资料",
602: "完成账户注册",
603: "服务商完成提交资料到⼯信部",
604: "⼯商部已受理",
605: "⼯商部不予受理",
606: "⼯商部通过",
607: "⼯商部未通过",
608: "用户驳回"
};
//(文网文状态2020-9-26)
this.wangwenSolutionStatusReference = {
"SOLUTION_SUBMIT": "提交服务单",
"PARTNER_SUBMIT_MATERIAL": "服务商提交资料",
"CERT_ACCOUNT_REGISTERED": "完成账户注册",
"CERT_MATERIAL_SUBMITTED": "服务商完成提交资料到⼯信部",
"CERT_GXB_ACCEPT": "⼯商部已受理",
"CERT_GXB_SUCCESS": "⼯商部通过",
"CERT_GXB_FAIL": "⼯商部未通过",
"CERT_GXB_REFUSE": "⼯商部不予受理"
};
}
//根据需求关闭ICP方案(关闭需求后调用)
async abolishIcpProgrammeByNeed(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.intentionBizId) {
return system.getResultFail(-101, "需求编号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo", "uapp_id"],//2020-10-29 laolan xinzeng uapp_id
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { needNo: needinfo.needNo, isInvalid: 0 }, raw: true
});
if (ns && ns.id) {
if (ns.status == "ywc") {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
}
var flowStatus = ns.solutionContent && ns.solutionContent.status ? ns.solutionContent.status : "";
if (flowStatus && ["GXB_REFUSE", "CLOSE"].indexOf(flowStatus) < 0) {
return system.getResultFail(-104, "⽅案状态为关闭或不予受理才可关闭需求");
}
}
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
var needObj = {
id: needinfo.id, status: "ygb", notes: ab.note
};
await self.needinfoDao.update(needObj, t);//关闭需求
if (ns && ns.id) {
await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃
return system.getResultSuccess(ns.orderNo);
}
//2020-10-29 laolan
ns['uapp_id'] = needinfo.uapp_id;
return system.getResultSuccess(ns);
// return system.getResultSuccess();
})
}
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "需求号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-102, "未知需求信息");
}
var ns = await this.needsolutionDao.model.findAll({
where: { needNo: needinfo.needNo }, raw: true,
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
});
return system.getResultSuccess(ns);
}
//获取方案详情(内部调用)
async getIcpProgrammeDetail(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findAll({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
return system.getResultSuccess(ns);
}
//获取方案详情(前端调用)
async getNeedSolutionDetailByUser(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"]=user.id;
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, createUserId: user.id }, raw: true
});
if (ns && ns.needNo) {
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true,
attributes: ["publishName", "publishMobile", "channelUserId"]
});
ns.needinfo = needinfo;
}
return system.getResultSuccess(ns);
}
//提交方案
async submitIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "7") {//edi
ab.solutionContent.solution.IcpType = 2;
} else if (needinfo.channelTypeCode == "5") {//icp
ab.solutionContent.solution.IcpType = 1;
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.ActionType) {
return system.getResultFail(-108, "办理类型不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.icpSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.icpSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "icp提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//交付商关闭交付单
async closeOrderDelivery(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
} else {
ab.Note = ab.note;
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.abolishIcpProgramme(pobj);
}
//服务商方案作废 -- abolishIcpProgramme
async abolishIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.Note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-300, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-400, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-401, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var solutionContent = ns.solutionContent;
if (!solutionContent.status || ["USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", "MATERIAL_SUBMITTED"].indexOf(solutionContent.status) < 0) {
return system.getResultFail(-302, "方案流程状态错误,不能执行此操作");
}
solutionContent.serviceProviderNote = ab.Note;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent = JSON.stringify(solutionContent);
await this.needsolutionDao.update({ id: ns.id, status: "yzf", isInvalid: 1, solutionContent: solutionContent });//方案废弃
//获取方案信息
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
//2020-10-26 laolan 添加渠道区分start
if(new_ns && needinfo){
new_ns['uapp_id'] = needinfo.uapp_id
}
//添加渠道区分end
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.submitIcpMaterial(pobj);
}
//提交icp材料信息
async submitIcpMaterial(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if (!ab.material) {
return system.getResultFail(-102, "材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "needNo", "solutionContent"],
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.status != "USER_UPLOADED") {
return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
}
//CorporateName 法⼈名称
if (!material.hasOwnProperty("IncludeForeignInvestment")) {
return system.getResultFail(-102, "包含外贸参数不能为空");
}
if (!material.PartnerBusinessLicense) {
return system.getResultFail(-103, "营业执照不能为空");
}
if (!material.PartnerIdCardList || material.PartnerIdCardList.length < 1) {
return system.getResultFail(-105, "相关人员身份证不能为空");
}
if (!material.PartnerDomainCertificate) {
return system.getResultFail(-106, "域名证书不能为空");
}
solutionContent.material = ab.material;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "MATERIAL_UNCONFIRM", statusName: this.icpSolutionStatusReference.MATERIAL_UNCONFIRM, updated_at: new Date()
});
solutionContent.status = "MATERIAL_UNCONFIRM";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_UNCONFIRM;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
var new_needsolutioninfo = await self.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
//2020-10-27 laolan start
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: new_needsolutioninfo.needNo }, raw: true
});
if(needinfo){
var uappIds = needinfo.uapp_id
}
new_needsolutioninfo['uapp_id'] = uappIds;
//2020-10-27 laolan end
return system.getResultSuccess(new_needsolutioninfo);
})
}
//交付商通知状态变更
async serviceProviderNotification(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "交付状态不能为空");
} else {
ab["ApplicationStatus"] = ab.status;
}
if (ab.officialFileURL) {
ab["OfficialFileURL"] = ab.officialFileURL;
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
ab["solutionNo"] = ns.solutionNo;
pobj.actionBody = ab;
return this.acceptIcpPartnerNotification(pobj);
}
//服务商通知状态变更
async acceptIcpPartnerNotification(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
// if (!ab.BizId) {
// return system.getResultFail(-101, "渠道方案编号不能为空");
// }
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "通知状态不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "status", "solutionContent", "needNo"],
where: { solutionNo: ab.solutionNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
}
if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 507) {//完成账户注册
if (solutionContent.status != "USER_CONFIRMED") {
return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionContent.ApplicationStatus = 507;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "ACCOUNT_REGISTERED";
solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
if (solutionContent.status != "ACCOUNT_REGISTERED") {
return system.getResultFail(-508, "交付流程错误,请先完成账户注册");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "MATERIAL_SUBMITTED", statusName: this.icpSolutionStatusReference.MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "MATERIAL_SUBMITTED";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 509) {//⼯商部已受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-509, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_ACCEPT", statusName: this.icpSolutionStatusReference.GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "GXB_ACCEPT";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_ACCEPT;
}
if (ab.ApplicationStatus == 510) {//⼯商部不予受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-510, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-511, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-512, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.icpApplicationStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
//2020-10-27 laolan start
var uappIds = needinfo.uapp_id
statusObj['uapp_id'] = uappIds;
//2020-10-27 laolan start
return system.getResultSuccess(statusObj);
})
}
//接收渠道方案状态变更通知
async receiveIcpStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status == "yzf" || ns.status == "ywc") {
// return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作");
// }
var solutionContent = ns.solutionContent;
var checkStatus = {
ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"
};
if (solutionContent.status && checkStatus[solutionContent.status]) {
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.status == "1") {//⽤户已支付
var afterStatusList=[//用户支付后的流程状态
"USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED",
"MATERIAL_SUBMITTED","GXB_ACCEPT","GXB_REFUSE","GXB_FAIL","GXB_SUCCESS","CLOSE"
];
if(!solutionContent.status || afterStatusList.indexOf(solutionContent.status)<0){
solutionFlowList.push({
status: "PAID", statusName: this.icpSolutionStatusReference.PAID, updated_at: new Date()
});
solutionContent.status = "PAID";
solutionContent.statusName = this.icpSolutionStatusReference.PAID;
}
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.status == "2") {//⽤户已上传
if (solutionContent.status == "USER_CONFIRMED") {//防止用户确认后又否决
return system.getResultFail(-112, "操作失败,⽤户已确认递交⽂件");
}
solutionFlowList.push({
status: "USER_UPLOADED", statusName: this.icpSolutionStatusReference.USER_UPLOADED, updated_at: new Date()
});
solutionContent.status = "USER_UPLOADED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_UPLOADED;
} else if (ab.status == "4") {//⽤户已确认
if (solutionContent.status != "MATERIAL_UNCONFIRM") {
return system.getResultFail(-113, "操作失败,服务商递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "USER_CONFIRMED", statusName: this.icpSolutionStatusReference.USER_CONFIRMED, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRMED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_CONFIRMED;
} else if (ab.status == "11") {//⽅案已关闭
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.remark) {
solutionContent.customerRemark = ab.remark;
}
if (ab.newbusinessLicense) {
material.businessLicense = ab.newbusinessLicense;
material.aliBusinessLicense = ab.businessLicense;
}
if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) {
material.idCardUrlList = ab.newidCardUrlList;
material.aliIdCardUrlList = ab.idCardUrlList;
}
if (ab.newuserPlan) {
material.userPlan = ab.newuserPlan;
material.aliUserPlan = ab.userPlan;
}
if (ab.newuserForeig) {
material.userForeig = ab.newuserForeig;
material.aliUserForeig = ab.userForeig;
}
if (ab.newuserLaw) {
material.userLaw = ab.newuserLaw;
material.aliUserLaw = ab.userLaw;
}
if (ab.newuserOtherList && ab.newuserOtherList.length > 0) {
material.userOtherList = ab.newuserOtherList;
material.aliUserOtherList = ab.userOtherList;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id, solutionContent: solutionContent
};
if (ab.status == "11") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(ns);
}
//接收icp用户方案反馈
async receiveIcpFeedback(pobj) {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
}
if (!ab.description) {
return system.getResultFail(-102, "问题描述不能为空");
}
if (!ab.hasOwnProperty("intentionStatus")) {
return system.getResultFail(-103, "需求当前状态不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, isInvalid: 0 }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if (ab.intentionStatus == 1) {
updateObj["status"] = "ybh";
updateObj["isInvalid"] = 1;
} else if (ab.intentionStatus == 2) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj) {
var ab = pobj.actionBody;
if (!ab.solutionBizId) {
return system.getResultFail(-101, "渠道方案业务编号不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
await this.needsolutionDao.model.update({ channelSolutionNo: ab.solutionBizId }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
//接收确认方案后阿里返回链接
async receiveIcpConfirmUrl(pobj) {
var ab = pobj.actionBody;
if (!ab.confirmUrl) {
return system.getResultFail(-101, "confirmUrl不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
ns.solutionContent.confirmUrl = ab.confirmUrl;
var solutionContent = JSON.stringify(ns.solutionContent);
await this.needsolutionDao.model.update({ solutionContent: solutionContent }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
//接收渠道方案状态变更通知
async receiveEdiStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.operationType) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
// 2020 0929 lin 修改ab.BizId 改为 ab.solutionBizId
where: { channelSolutionNo: ab.solutionBizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionContent = ns.solutionContent;
var checkStatus = { ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单" };
if (solutionContent.status && checkStatus[solutionContent.status]) {
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.operationType == "USER_PAY_PRODUCE") {//⽤户已支付
solutionFlowList.push({
status: "USER_PAY_PRODUCE", statusName: this.ediSolutionStatusReference.USER_PAY_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_PAY_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_PAY_PRODUCE;
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.operationType == "USER_CONFIRM_PRODUCE") {//⽤户确认资料
solutionFlowList.push({
status: "USER_CONFIRM_PRODUCE", statusName: this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRM_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE;
} else if (ab.operationType == "USER_REFUSE_PRODUCE") {//资料退回修改
solutionFlowList.push({
status: "USER_REFUSE_PRODUCE", statusName: this.ediSolutionStatusReference.USER_REFUSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_REFUSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_REFUSE_PRODUCE;
} else if (ab.operationType == "USER_UPLOAD_PRODUCE") {//⽤户补充基本资料
solutionFlowList.push({
status: "USER_UPLOAD_PRODUCE", statusName: this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_UPLOAD_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE;
} else if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
solutionFlowList.push({
status: "ABC_CLOSE_PRODUCE", statusName: this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "ABC_CLOSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.extInfo) {
// 退回修改理由
var extInfoJson = JSON.parse(ab.extInfo);
// var extInfoJson = ab.extInfo
if(extInfoJson.rejectReason) {
ab.rejectReason = extInfoJson.rejectReason,
solutionContent.rejectReason = extInfoJson.rejectReason
}
material.businessLicenseArr = extInfoJson.businessLicenseArr;
material.idCardListArr = extInfoJson.idCardListArr;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id,
solutionContent: solutionContent,
};
// 这里修改进去了
if(ab.bizId != ns.channelDeliverId) {
updateObj.channelDeliverId = ab.bizId
}
if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
var orderInfo = await this.orderinfoDao.model.findOne({
where: {orderNo: new_ns.orderNo}, raw: true
})
if(orderInfo) {
new_ns.channelOrderNo = orderInfo.channelOrderNo
}
return system.getResultSuccess(new_ns);
}
// ---------------- 文网文 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (文网文)
*/
async serviceSubmitOption(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "交付状态不能为空");
}
if (!ab.channelType) {
return system.getResultFail(-103, "渠道来源不能为空");
}
//获取方案信息
var orderinfo = await this.orderinfoDao.model.findOne({
where: { channelOrderNo: ab.orderNo }, raw: true
});
if(orderinfo){
var orderNo = orderinfo.orderNo;
if(orderNo){
var needsolutioninfo = await this.needsolutionDao.model.findOne({
where: { orderNo: orderNo }, raw: true
});
}
}
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 601) {//服务商提交资料
if (solutionContent.status == "USER_UPLOAD_PRODUCE" || solutionContent.status == "USER_REFUSE_PRODUCE") {
solutionContent.ApplicationStatus = 601;
solutionFlowList.push({
status: "PARTNER_SUBMIT_MATERIAL", statusName: this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL, updated_at: new Date()
});
solutionContent.status = "PARTNER_SUBMIT_MATERIAL";
solutionContent.statusName = this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL;
}else{
return system.getResultFail(-601, "交付流程错误,请先完成账户注册");
}
}
if (ab.ApplicationStatus == 602) {//完成账户注册
if (solutionContent.status != "USER_CONFIRM_PRODUCE") {
return system.getResultFail(-602, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_ACCOUNT_REGISTERED", statusName: this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "CERT_ACCOUNT_REGISTERED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 603) {//服务商完成提交资料到⼯信部
if (solutionContent.status != "CERT_ACCOUNT_REGISTERED") {
return system.getResultFail(-603, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_MATERIAL_SUBMITTED", statusName: this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "CERT_MATERIAL_SUBMITTED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 604) {//⼯商部已受理
if (solutionContent.status != "CERT_MATERIAL_SUBMITTED") {
return system.getResultFail(-604, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_ACCEPT", statusName: this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_ACCEPT";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT;
}
if (ab.ApplicationStatus == 605) {//⼯商部不予受理
if (solutionContent.status != "PARTNER_SUBMIT_MATERIAL") {
return system.getResultFail(-605, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_REFUSE", statusName: this.wangwenSolutionStatusReference.CERT_GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_REFUSE;
}
if (ab.ApplicationStatus == 606) {//⼯商部通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-606, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_SUCCESS", statusName: this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "CERT_GXB_SUCCESS";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS;
}
if (ab.ApplicationStatus == 607) {//⼯信部未通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-607, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_FAIL", statusName: this.wangwenSolutionStatusReference.CERT_GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.wangwenSolutionStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//提交方案
async submitWangwenSolution(pobj) {
console.log('wangwen提交方案',pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "esp.wangwen") {//esp.wangwen
ab.solutionContent.solution.IcpType = "wangwen";
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "企业名称不能为空");
}
if (!solution.licenseType) {
return system.getResultFail(-106, "网文类型不能为空");
}
if (!solution.actionType) {
return system.getResultFail(-106, "办理类型不能为空");
}
if (!solution.companyLocation) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.solutionPrice) {
return system.getResultFail(-108, "办理价格不能为空");
}else{
solution.solutionPrice = solution.solutionPrice / 100;
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.wangwenSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.wangwenSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "wangwen提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//关闭需求
async closeNeed(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.needNo) {
return system.getResultFail(-101, "需求编号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo"],
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var updateNeed = await this.needinfoDao.update(needObj);//关闭需求
if (!updateNeed) {
return system.getResultFail(-203, "关闭需求失败");
} else {
return system.getResultSuccess();
}
}
//提交沟通记录
async recordLog(pobj) {
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj.actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", pobj.actionBody.note];
let needRes = await this.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.needNo });
console.log('needRes',needRes)
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var paramWhere = {
Note: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
}
}
// ---------------- 食品 ----------------
/**
* 服务商提交服务操作
* 服务商通知状态变更
* (交付系统调用)
* (食品)
*/
async foodServiceSubmitOption(pobj) {
console.log(pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "交付状态不能为空");
}
if (!ab.channelType) {
return system.getResultFail(-102, "渠道来源不能为空");
}
//获取方案信息
var orderinfo = await this.orderinfoDao.model.findOne({
where: { channelOrderNo: ab.orderNo }, raw: true
});
if(orderinfo){
var orderNo = orderinfo.orderNo;
if(orderNo){
var needsolutioninfo = await this.needsolutionDao.model.findOne({
where: { orderNo: orderNo }, raw: true
});
}
}
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
// if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
// if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
// return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 601) {//服务商提交资料
if (solutionContent.status == "USER_UPLOAD_PRODUCE" || solutionContent.status == "USER_REFUSE_PRODUCE") {
solutionContent.ApplicationStatus = 601;
solutionFlowList.push({
status: "PARTNER_SUBMIT_MATERIAL", statusName: this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL, updated_at: new Date()
});
solutionContent.status = "PARTNER_SUBMIT_MATERIAL";
solutionContent.statusName = this.wangwenSolutionStatusReference.PARTNER_SUBMIT_MATERIAL;
}else{
return system.getResultFail(-601, "交付流程错误,请先完成账户注册");
}
}
if (ab.ApplicationStatus == 602) {//完成账户注册
if (solutionContent.status != "USER_CONFIRM_PRODUCE") {
return system.getResultFail(-602, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_ACCOUNT_REGISTERED", statusName: this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "CERT_ACCOUNT_REGISTERED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 603) {//服务商完成提交资料到⼯信部
if (solutionContent.status != "CERT_ACCOUNT_REGISTERED") {
return system.getResultFail(-603, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_MATERIAL_SUBMITTED", statusName: this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "CERT_MATERIAL_SUBMITTED";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 604) {//⼯商部已受理
if (solutionContent.status != "CERT_MATERIAL_SUBMITTED") {
return system.getResultFail(-604, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_ACCEPT", statusName: this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_ACCEPT";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_ACCEPT;
}
if (ab.ApplicationStatus == 605) {//⼯商部不予受理
if (solutionContent.status != "PARTNER_SUBMIT_MATERIAL") {
return system.getResultFail(-605, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
status: "CERT_GXB_REFUSE", statusName: this.wangwenSolutionStatusReference.CERT_GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_REFUSE;
}
if (ab.ApplicationStatus == 606) {//⼯商部通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-606, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_SUCCESS", statusName: this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "CERT_GXB_SUCCESS";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_SUCCESS;
}
if (ab.ApplicationStatus == 607) {//⼯信部未通过
if (solutionContent.status != "CERT_GXB_ACCEPT") {
return system.getResultFail(-607, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
status: "CERT_GXB_FAIL", statusName: this.wangwenSolutionStatusReference.CERT_GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "CERT_GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.wangwenSolutionStatusReference.CERT_GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.wangwenSolutionStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//提交方案
async submitFoodSolution(pobj) {
console.log('food提交方案',pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "esp.food") {//esp.food
ab.solutionContent.solution.IcpType = "food";
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "企业名称不能为空");
}
if (!solution.licenseType) {
return system.getResultFail(-106, "网文类型不能为空");
}
if (!solution.actionType) {
return system.getResultFail(-106, "办理类型不能为空");
}
if (!solution.companyLocation) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.solutionPrice) {
return system.getResultFail(-108, "办理价格不能为空");
}else{
solution.solutionPrice = solution.solutionPrice / 100;
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.wangwenSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.wangwenSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "food提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//关闭需求
async foodCloseNeed(pobj) {
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.needNo) {
return system.getResultFail(-101, "需求编号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo"],
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var updateNeed = await this.needinfoDao.update(needObj);//关闭需求
if (!updateNeed) {
return system.getResultFail(-203, "关闭需求失败");
} else {
return system.getResultSuccess();
}
}
//提交沟通记录
async foodRecordLog(pobj) {
// 查询需求沟通记录
// 修改channel传过来的参数 为 note/needNo
pobj.actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", pobj.actionBody.note];
let needRes = await this.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.needNo });
console.log('needRes',needRes)
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(pobj.actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +pobj.actionBody.BizId +"\"" +" "
var paramWhere = {
Note: pobj.actionBody.Note,
BizId: pobj.actionBody.needNo
};
var updateRes = await this.orderinfoDao.customUpdate(sql, paramWhere);
console.log('updateRes',updateRes)
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
}
}
}
module.exports = BaseQcService;
......@@ -7,7 +7,7 @@ class ExecClient {
this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}";
this.cmd360Token = "curl -u gongsibao:qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx -d '{data}' -X POST {url}"
}
getUUID() {
var uuid = uuidv4();
......@@ -41,6 +41,12 @@ class ExecClient {
console.log(cmd);
return cmd;
}
Fetch360TokenCmd(subData,url){
let cmd = this.cmd360Token.replace(
/\{data\}/g, subData).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
async execPost(subData, url) {
let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec(cmd);
......@@ -56,6 +62,29 @@ class ExecClient {
var result = await this.exec2(cmd);
return result;
}
async exec360GetToken(url){
const qs = require('qs')
let obj = {"scope":"smart_business","grant_type":"client_credentials"}
// if(settings.env == 'dev'){
// const rs = await axios({
// method: 'post',
// url: url,
// data:qs.stringify(obj),
// auth: {
// username:"gongsibao",
// password:"qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx"
// }
// })
// const ret ={
// stdout:JSON.stringify(rs.data)
// }
// return ret;
// }
let cmd = this.Fetch360TokenCmd(qs.stringify(obj),url);
console.log(cmd);
var result = await this.exec(cmd);
return result;
}
FetchGetCmd(subData, url) {
var cmd = this.cmdGetPattern.replace(
......
const childproc = require('child_process');
const system = require("../system");
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const settings = require("../../../app/config/settings");
const axios = require('axios');
const moment = require('moment');
const uuid = require('uuid');
class ExecClientNew {
constructor() {
this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}";
// this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'appkey:{appkey}' -d '{data}' {url}";
}
/**
* 带超时时间的post请求
* @param {*} execFile 执行文件
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间设置,单位秒
* @param {*} req 请求信息
*/
async execPostTimeOutByBusiness(execFile, params, url, ContentType, headData, timeOut = 60, req) {
var rtn = null;
var reqResult = null;
var requestId = null;
if (req && req.body && (req.body.RequestId || req.body.requestId)) {
requestId = req.body.RequestId || req.body.requestId;
} else {
if (req && req.query && (req.query.RequestId || req.query.requestId)) {
requestId = req.query.RequestId || req.query.requestId;
}
}
try {
if (settings.env === "localhost" || settings.env === "dev") {
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200) {
reqResult = system.getResultSuccess(result.data);
} else {
reqResult = system.getResult(null, "执行execPostTimeOutByBusiness存在错误");
}
reqResult.requestId = requestId || uuid.v1();
if (result.headers) {
delete result["headers"];
}
if (result.request) {
delete result["request"];
}
if (result.config) {
delete result["config"];
}
params.reqUrl = url;
this.execLogs(execFile + "执行execPostTimeOutByBusiness,errorInfo信息为请求的返回结果", params, params.identifyCode, reqResult, result);
return reqResult;
}
//方式二
rtn = await this.execPostTimeOut(params, url, ContentType, headData, timeOut);
params.reqUrl = url;
if (!rtn || !rtn.stdout) {
this.execLogs(execFile + "执行execPostTimeOutByBusiness返回的数据为空", params, params.identifyCode, null, null);
reqResult = system.getResult(null, "execPostTimeOut data is empty");
} else {
var result = JSON.parse(rtn.stdout);
reqResult = system.getResultSuccess(result);
}
reqResult.requestId = requestId || uuid.v1();
this.execLogs(execFile + "执行execPostTimeOutByBusiness,errorInfo信息为请求的返回结果", params, params.identifyCode, reqResult, rtn);
return reqResult;
} catch (error) {
console.log("执行execPostByTimeOut存在异常", error.stack);
reqResult = system.getResultFail(-200, execFile + "执行execPostByTimeOut存在异常");
reqResult.requestId = requestId || uuid.v1();
this.execLogs(execFile + "执行execPostByTimeOut存在异常", params, params.identifyCode, reqResult, error.stack);
return reqResult;
}
}
/**
* 记录日志信息
* @param {*} opTitle 操作的标题
* @param {*} params 参数
* @param {*} identifyCode 业务标识
* @param {*} resultInfo 返回结果
* @param {*} errorInfo 错误信息
*/
async execLogs(opTitle, params, identifyCode, resultInfo, errorInfo) {
var reqUrl = settings.opNewLogUrl();
params = typeof params === 'object' ? JSON.stringify(params) : params || "";
resultInfo = typeof resultInfo === 'object' ? JSON.stringify(resultInfo) : resultInfo || "";
errorInfo = typeof errorInfo === 'object' ? JSON.stringify(errorInfo) : errorInfo || "";
var tmpParams = {
opTitle: opTitle || "",
identifyCode: identifyCode || "",
messageBody: params,
resultInfo: resultInfo || "",
errorInfo: errorInfo || "",
requestId: resultInfo ? resultInfo.requestId || "" : "",
created_at: moment().format("YYYY-MM-DD HH:mm:ss:SSS"),
timestamp: Date.now()
}
this.execPostTimeOut(tmpParams, reqUrl, 'application/json', null, 20);
}
/**
* get请求
* @param {*} params 提交的数据-格式JSON
* @param {*} url
* @param {*} headData 请求信息,JSON格式
*/
async execGet(params, url, headData) {
let cmd = this.FetchGetCmd(params, url, headData);
var result = await this.exec(cmd);
return result;
}
/**
*
* @param {*} params 提交的数据JSON格式
* @param {*} url
* @param {*} headData 请求信息,JSON格式
* @param {*} timeOut 超时时间
*/
async execGetTimeOut(params, url, headData, timeOut = 5000) {
//timeOut,单位是毫秒
let cmd = this.FetchGetCmd(params, url, headData);
var options = {
timeout: timeOut,
};
const { stdout, stderr } = await exec(cmd, options);
return { stdout, stderr };
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/
async execPost(params, url, ContentType, headData) {
if (!ContentType) {
ContentType = "application/json";
}
let cmd = this.FetchPostCmd(params, url, ContentType, headData);
var options = {
maxBuffer: 1024 * 1024 * 15
};
var result = await this.exec(cmd, options, headData);
return result;
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间设置,单位秒
*/
async execPostTimeOut(params, url, ContentType, headData, timeOut = 5000) {
if (!ContentType) {
ContentType = "application/json";
}
let cmd = this.FetchPostCmd(params, url, ContentType, headData);
var options = {
timeout: timeOut,
maxBuffer: 1024 * 1024 * 15
};
var result = await this.exec(cmd, options);
return result;
}
//--------------------------------------------------辅助方法start-----------------
async exec(cmd) {
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
const { stdout, stderr } = await exec(cmd);
return { stdout, stderr };
}
FetchGetCmd(params, url, headData) {
var cmd = this.cmdGetPattern.replace(
/\{data\}/g, params).replace(/\{url\}/g, url);
return cmd;
}
FetchPostCmd(params, url, ContentType, headData) {
if (!ContentType) {
ContentType = "application/json";
}
var data = JSON.stringify(params);
// if (typeof params === 'object') {
// // 声明cache变量,便于匹配是否有循环引用的情况
// var cache = [];
// data = JSON.stringify(params, function (key, value) {
// if (typeof value === 'object' && value !== null) {
// if (cache.indexOf(value) !== -1) {
// // 移除
// return;
// }
// // 收集所有的值
// cache.push(value);
// }
// return value;
// });
// cache = null; // 清空变量,便于垃圾回收机制回收
// } else {
// data = params;
// }
var cmdStr = "curl --user admines:adminGSBes. -k -H 'Content-type:" + ContentType + "'";
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
cmdStr = cmdStr + " -H '" + indexKey + ":" + headValue + "'";
}
}
}
}
cmdStr = cmdStr + " -d '" + data + "' " + url;
console.log(cmdStr, ":cmdStr.................");
return cmdStr;
}
/**
* 返回20位业务订单号
* @param {*} prefix 业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/**
* 返回指定长度的字符串
* @param {*} len 返回长度
* @param {*} radix 参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
//--------------------------------------------------辅助方法end-----------------
}
module.exports = ExecClientNew;
......@@ -20,6 +20,13 @@ var settings = {
usertimeout: 3600,//单位秒
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4011,
//记录日志地址
opNewLogUrl() {
if (this.env == 'dev') {
return "http://43.247.184.94:7200/center_order_req_log/_doc?pretty";
}
return "http://43.247.184.94:7200/center_order_req_log/_doc?pretty";
},
reqTransferurl: function () {
if (this.env == "dev") {
return "http://192.168.18.61:3003/";
......@@ -42,6 +49,20 @@ var settings = {
return "http://gsb.qifu.gongsibao.com:4012/";
}
},
push360Url: function () {
if (this.env == 'dev') {
return "http://180.163.239.98:38086/";
} else {
return "https://tobadminapi.e.360.cn/";
}
},
auth360Url: function () {
if (this.env == 'dev') {
return "https://oauth2.e.360.cn/site/token";
} else {
return "https://oauth2.e.360.cn/site/token";
}
},
apiconfig: {
opLogUrl: function () {
return settings.reqEsAddr() + "center_order_log/_doc?pretty";
......@@ -50,7 +71,7 @@ var settings = {
return 1;
},
},
homePage: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
......@@ -100,8 +121,8 @@ var settings = {
};
}
},
addArr: function() {
return ["南海诸岛", "北京", "天津", "上海", "重庆", "河北", "河南", "云南", "辽宁", "黑龙江", "湖南", "安徽", "山东", "新疆", "江苏", "浙江", "江西", "湖北", "广西", "甘肃", "山西", "内蒙古", "陕西", "吉林", "福建", "贵州", "广东", "青海", "西藏", "四川", "宁夏", "海南", "台湾", "香港", "澳门"]
addArr: function () {
return ["南海诸岛", "北京", "天津", "上海", "重庆", "河北", "河南", "云南", "辽宁", "黑龙江", "湖南", "安徽", "山东", "新疆", "江苏", "浙江", "江西", "湖北", "广西", "甘肃", "山西", "内蒙古", "陕西", "吉林", "福建", "贵州", "广东", "青海", "西藏", "四川", "宁夏", "海南", "台湾", "香港", "澳门"]
}
};
module.exports = settings;
......@@ -15,6 +15,7 @@
"after": "^0.8.2",
"ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6",
"axios": "^0.21.0",
"babel-polyfill": "^6.26.0",
"base64id": "^1.0.0",
"bluebird": "^3.5.1",
......@@ -57,4 +58,4 @@
"element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0"
}
}
\ 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