Commit ba71042a by 孙亚楠

d

parent 99793a7f
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/zhichan.iml" filepath="$PROJECT_DIR$/.idea/zhichan.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
const axios = require("axios");
class ProductAPI extends WEBBase {
constructor() {
super();
this.restClient = system.getObject("util.restClient");
this.redisClient = system.getObject("util.redisClient");
this.zzzApi = {
"industryOne":"/gsb/api/industry_one", //一级大类列表
"industryTwo":"/gsb/api/industry_two", //二级大类列表
"getQualificationByIndustry":"/gsb/api/qualifications", //根据行业ID 查询所有相关的资质
"recommendationBusiness":"/gsb/api/recommendation_business", //立即查看结果
// "industryOne":"/gsb/api/industry_one", //一级大类列表
}
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "getIndustries": //获取一级大类列表
try {
console.log(`获取一级大类列表 参数:` + JSON.stringify(pobj.actionBody));
let _industryOne =await this.redisClient.get("industryOne");
if(_industryOne){
opResult = system.getResult(JSON.parse(_industryOne));
console.log("redis数据:" + _industryOne);
}else{
// opResult =await axios.post(settings.zzzdUrl()+this.zzzApi.industryOne, pobj);
opResult =await axios.post("http://192.168.200.101:80"+this.zzzApi.industryOne, pobj);
opResult= opResult.data;
await this.redisClient.setWithEx("industryOne",JSON.stringify(opResult.data),45*60);
console.log(`获取一级大类列表 结果` + JSON.stringify(opResult));
}
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
break;
case "getSecondIndustries": //获取二级大类列表
console.log(`获取二级大类列表 参数:` + JSON.stringify(pobj.actionBody));
if(!pobj.actionBody.industryId){
return system.getResult(null,`一级行业ID不能为空`)
}
try {
let _industryTwo =await this.redisClient.get(`industryTwo:${pobj.actionBody.industryId}`);
if(_industryTwo){
opResult = system.getResult(JSON.parse(_industryTwo));
console.log("redis数据:" + _industryTwo);
}else{
// opResult =await axios.post(settings.zzzdUrl()+this.zzzApi.industryTwo, {
// "industryId":pobj.actionBody.industryId
// });
opResult =await axios.post("http://192.168.200.101:80"+this.zzzApi.industryTwo, {
"industryId":pobj.actionBody.industryId
});
opResult= opResult.data;
await this.redisClient.setWithEx(`industryTwo:${pobj.actionBody.industryId}`,JSON.stringify(opResult.data),45*60);
console.log(`获取二级大类列表 结果` + JSON.stringify(opResult));
}
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
break;
case "getQualificationByIndustry": //根据行业获取资质
try {
console.log(`根据行业获取资质 参数:` + JSON.stringify(pobj.actionBody));
if(!pobj.actionBody.hasOwnProperty("isImports")){
return system.getResult(null,`参数错误 是否进口不能为空`)
}
if(!pobj.actionBody.hasOwnProperty("storeTypeId") &&!pobj.actionBody.storeTypeId ){
return system.getResult(null,`参数错误 店铺类型ID不能为空`)
}
if(!pobj.actionBody.industryId){
return system.getResult(null,`一级行业ID不能为空`)
}
if(!pobj.actionBody.secondIndustry && pobj.actionBody.secondIndustry.length>0){
return system.getResult(null,`二级行业不能为空`)
}
// opResult =await axios.post(settings.zzzdUrl()+this.zzzApi.getQualificationByIndustry, pobj.actionBody);
opResult =await axios.post("http://192.168.200.101:80"+this.zzzApi.getQualificationByIndustry, pobj.actionBody);
opResult= opResult.data;
console.log(`根据行业获取资质 结果` + JSON.stringify(opResult));
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
break;
case "check": //立即查看结果
if(!pobj.actionBody.industryId){
return system.getResult(null,`行业ID不能为空`)
}
if(!pobj.actionBody.mobile){
return system.getResult(null, `电话不能为空`);
}
if(!pobj.actionBody.enterprise){
return system.getResult(null, `企业名称不能为空`);
}
if(!pobj.actionBody.data){
return system.getResult(null, `资质列表不能为空`);
}
try {
// opResult = await this.restClient.getQualificationByIndustry(pobj, pobj.actionBody);
// return system.getResult(opResult);
opResult =await axios.post(settings.zzzdUrl()+this.zzzApi.recommendationBusiness, pobj.actionBody);
opResult= opResult.data;
console.log(`根据行业获取资质 结果` + JSON.stringify(opResult));
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
break;
case "counselling": //免费咨询
if(!action_body.id){
return system.getResult(null,`业务ID不能为空`)
}
if(!action_body.mobile){
return system.getResult(null, `电话不能为空`);
}
try {
opResult = await this.restClient.getQualificationByIndustry(pobj, pobj.actionBody);
// return system.getResult(opResult);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
...@@ -211,7 +211,7 @@ module.exports = function (app) { ...@@ -211,7 +211,7 @@ module.exports = function (app) {
res.end(JSON.stringify(result)); res.end(JSON.stringify(result));
return; return;
} }
if (["getAppTokenByHosts", "getAppTokenByAppKey", "test"].indexOf(req.body.actionType) >= 0) { if (["getAppTokenByHosts", "getAppTokenByAppKey", "test","getIndustries","getSecondIndustries","getQualificationByIndustry","check"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host; req.body.actionBody.appHosts = req.host;
next(); next();
return; return;
......
...@@ -72,6 +72,14 @@ var settings = { ...@@ -72,6 +72,14 @@ var settings = {
return "http://center-app-service/"; return "http://center-app-service/";
} }
}, },
zzzdUrl: function () {
if (this.env == "dev") {
// return "http://192.168.200.101:80";
return "http://192.168.200.133:8080";
} else {
return "http://center-app-service/";
}
},
centerChannelUrl: function () { centerChannelUrl: function () {
if (this.env == "dev") { if (this.env == "dev") {
return "http://60.205.209.94:4012/" return "http://60.205.209.94:4012/"
......
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