Commit 57f71c3c by 庄冰

zhuangbing

parent 658ebb40
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcAPI extends APIBase {
constructor() {
super();
// this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
}
/**
* 接口跳转-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 "submitProgramme"://提交公司注册方案
opResult = await this.needsolutionSve.submitProgramme(pobj);
break;
case "getProgrammeInfoByNeedNo"://根据需求查看方案列表
opResult = await this.needsolutionSve.getProgrammeInfoByNeedNo(pobj);
break;
case "receiveFeedback"://接收方案反馈信息(即方案作废)
opResult = await this.needsolutionSve.receiveFeedback(pobj);
break;
case "abolishProgramme"://服务商方案作废
opResult = await this.needsolutionSve.abolishProgramme(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcAPI;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class NeedsolutionDao extends Dao{
constructor(){
super(Dao.getModelName(NeedsolutionDao));
}
}
module.exports=NeedsolutionDao;
......@@ -72,6 +72,8 @@ module.exports = {
"push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单" },
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'行政措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
"solution_status":{"ytj":"已提交","yfk":"已付款","yzf":"已作废","ytk":"已退款"},
},
}
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("needsolution", {
channelNeedNo: DataTypes.STRING(128), //渠道需求号(页面中列表中显示该需求号)
needNo: DataTypes.STRING(128), //需求号--用于服务商或需求表中创建订单
channelNeedNo: DataTypes.STRING(128), //渠道需求号(页面中列表中显示该需求号
solutionNo: DataTypes.STRING(128), //方案号
channelSolutionNo: DataTypes.STRING(128), //渠道方案号(页面中列表中显示该单号)
orderNo: DataTypes.STRING(128), //自己订单表中的orderNo
solutionContent: DataTypes.STRING,//
status: {
//"solution_status":{"ytj":"已提交","yfk":"已付款","yzf":"已作废","ytk":"已退款"},
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.solution_status),
set: function (val) {
this.setDataValue("status", val);
this.setDataValue("statusName", uiconfig.config.pdict.solution_status[val]);
}
},
statusName: DataTypes.STRING(50), //状态名称
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'n_need_solution',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class Push2aliService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(Push2aliService));
this.pushlogDao=system.getObject("db.common.pushlogDao");
this.pushAliUrl = settings.centerChannelUrl();
}
//推送数据至阿里
async pushData2Ali(obj){
if(!obj.url){
return system.getResultFail(-501,"推送url不能为空");
}
var rtn = "";
var url = this.pushAliUrl + "tradetransfer/aliclienttransfer";
var action = obj.url;
var pushObj = obj.pushObj;
try {
var rc = system.getObject("util.execClient");
var actionBody = {action:action,reqbody:pushObj};
rtn = await rc.execPost({actionBody:actionBody},url);
var logObj ={
appid: obj.appInfo ? obj.appInfo.uapp_id : "",
appkey: obj.appInfo ? obj.appInfo.uapp_key : "",
op: url,
content: JSON.stringify(obj),
resultInfo: rtn?JSON.stringify(rtn):""
};
if (!rtn || !rtn.stdout) {
logObj["returnType"]="0";
logObj["opTitle"]="数据推送ali返回失败";
this.pushlogDao.create(logObj);
return system.getResultFail(-502,"execPost data is empty");
}else{
logObj["returnType"]="1";
logObj["opTitle"]="数据推送ali返回成功";
this.pushlogDao.create(logObj);
var stdout = JSON.parse(rtn.stdout);
return system.getResultSuccess(stdout);
}
} catch (e) {
this.pushlogDao.create({
appid: obj.appInfo ? obj.appInfo.uapp_id : "",
appkey: obj.appInfo ? obj.appInfo.uapp_key : "",
logLevel:"3",
op: url,
content:JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
returnType:"0",
opTitle:"数据推送ali---异常"
});
return system.getResultFail(-500,JSON.stringify(e.stack));
}
}
}
module.exports = Push2aliService;
const uuidv4 = require('uuid/v4');
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class NeedsolutionService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedsolutionService));
this.execlient = system.getObject("util.execClient");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
// this.push2aliSve = system.getObject("service.common.push2aliSve");
}
//提交方案
async submitProgramme(pobj){
var ab = pobj.actionBody;
if(!ab.needNo){
return system.getResultFail(-101,"需求号不能为空");
}
if(!ab.solutionContent){
return system.getResultFail(-102,"方案信息有误");
}
var bizType = ab.solutionContent.bizType || "";//业务类型
// bizType取值如下:
// 商标交易:esp.trademark_trade
// 财税代账:esp.bookkeeping
// 普通公司注册:esp.companyreg
// 云上公司注册:esp.companyreg_cloud
if(!bizType){
return system.getResultFail(-103,"业务类型不能为空");
}
if(!ab.solutionContent.solution){
return system.getResultFail(-104,"业务方案信息不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where:{needNo:ab.needNo},raw:true
});
if(!needinfo || !needinfo.id){
return system.getResultFail(-201,"未知需求信息");
}
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "ytj";
var od = await this.dao.create(ab);
if(od && od.id){
// //推送数据至阿里(暂无)
// var pushObj = {
// intentionBizId:needinfo.channelNeedNo,bizType:bizType,solution:ab.solutionContent.solution
// };
// var pushRes = await this.push2aliSve.pushData2Ali({url:"xxx/xxx/asdasd",pushObj:pushObj,appInfo:pobj.appInfo});
// //推送后获取方案id 存到方案
// if(pushRes && pushRes.status==0 && pushRes.data && pushRes.data.SolutionBizId){
// await this.dao.update({channelSolutionNo:pushRes.data.SolutionBizId,id:od.id});//保存渠道方案id
// }
return system.getResultSuccess(od);
}else{
return system.getResultFail(-202, "提交方案失败");
}
}
//根据需求查看方案列表
async getProgrammeInfoByNeedNo(pobj){
var ab = pobj.actionBody;
if(!ab.needNo){
return system.getResultFail(-101,"需求号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where:{needNo:ab.needNo},raw:true
});
if(!needinfo || !needinfo.id){
return system.getResultFail(-102,"未知需求信息");
}
var ns = await this.dao.model.findAll({
where:{needNo:ab.needNo},raw:true
});
return system.getResultSuccess(ns);
}
//接收方案反馈信息(即方案作废)
async receiveFeedback(pobj){
var ab = pobj.actionBody;
if(!ab.solutionBizId){
return system.getResultFail(-101,"方案业务编号不能为空");
}
if(!ab.operateType){
return system.getResultFail(-102,"操作类型不能为空");
}
var ns = await this.dao.model.findOne({
where:{channelSolutionNo:ab.solutionBizId},raw:true
});
if(!ns || !ns.id){
return system.getResultFail(-103,"未知方案");
}
var solutionContent = ns.solutionContent?JSON.parse(ns.solutionContent):"";
var status = "";
if(ab.operateType=="INVALID"){// INVALID:作废
status="yzf";
}else if(ab.operateType=="REFUND"){// REFUND:退款
status="ytk";
}else if(ab.operateType=="PAID"){// PAID:支付
status="yfk";
}else{
return system.getResultFail(-104,"操作类型有误");
}
var solution_status={"ytj":"已提交","yfk":"已付款","yzf":"已作废","ytk":"已退款"};
solutionContent["deliveryStatus"] = status;
solutionContent["deliveryStatusName"] = solution_status[status];
solutionContent["updated"] = new Date();
if(ab.note){
solutionContent["notes"] = ab.note;
}
solutionContent = JSON.stringify(solutionContent);
var reqObj={
status:status,solutionContent:solutionContent
};
await this.dao.model.update(reqObj, { where: { id: ns.id }});//修改方案信息
return system.getResultSuccess();
}
//服务商方案作废
async abolishProgramme(pobj){
var ab = pobj.actionBody;
if(!ab.solutionNo){
return system.getResultFail(-101,"方案号不能为空");
}
//获取方案信息
var ns = await this.dao.model.findOne({
where:{solutionNo:ab.solutionNo},raw:true
});
if(!ns || !ns.id){
return system.getResultFail(-102,"未知方案");
}
await this.dao.update({id:ns.id,status:"yzf"});//方案废弃
// //推送至阿里
// var pushObj = {
// solutionBizId:ns.channelSolutionNo,note:ab.note||""
// };
// var pushRes = await this.push2aliSve.pushData2Ali({url:"xxx/xxx/asdasd",pushObj:pushObj,appInfo:pobj.appInfo});
return system.getResultSuccess();
}
}
module.exports = NeedsolutionService;
\ No newline at end of file
......@@ -110,7 +110,7 @@ class PolicyinfoService extends ServiceBase {
}
async addPolicyByExcel(){
var workbook = xl.readFile("policy8.xls");
var workbook = xl.readFile("policy.xls");
const sheetNames = workbook.SheetNames; // 返回 ['sheet1', 'sheet2']
const worksheet = workbook.Sheets[sheetNames[0]];
var dataa =xl.utils.sheet_to_json(worksheet);
......
......@@ -35,6 +35,13 @@ var settings = {
return "http://43.247.184.94:7200/";
}
},
centerChannelUrl: function () {
if (this.env == "dev") {
return "http://gsb.qifu.gongsibao.com:4012/";//localsettings.reqEsDevUrl;
} else {
return "http://gsb.qifu.gongsibao.com:4012/";
}
},
apiconfig: {
opLogUrl: function () {
return settings.reqEsAddr() + "center_order_log/_doc?pretty";
......
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