Commit 7e3af1e1 by 庄冰

hebing

parents f4abece9 da7129e0
var WEBBase = require("../../web.base"); var WEBBase = require("../../web.base");
var system = require("../../../system"); var system = require("../../../system");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
class NameAPI extends WEBBase{ class NameAPI extends WEBBase {
constructor() { constructor() {
super(); super();
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
...@@ -29,17 +29,17 @@ class NameAPI extends WEBBase{ ...@@ -29,17 +29,17 @@ class NameAPI extends WEBBase{
opResult = await this.getCache(); opResult = await this.getCache();
break; break;
case "getPreference"://偏好 case "getPreference"://偏好
opResult=await this.getPreference(); opResult = await this.getPreference();
break; break;
case "createName"://起名 case "createName"://起名
opResult =await this.addOrderDelivery(pobj,pobj.actionBody); opResult = await this.addOrderDelivery(pobj, pobj.actionBody);
break; break;
case "getNameDetail"://详情 case "getNameDetail"://详情
opResult = await this.getNameDetail(pobj); opResult = await this.getNameDetail(pobj);
break; break;
case "getNames"://详情 case "getNames"://详情
opResult = await this.getNames(pobj,pobj.actionBody); opResult = await this.getNames(req, pobj.actionBody);
break; break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
...@@ -51,7 +51,7 @@ class NameAPI extends WEBBase{ ...@@ -51,7 +51,7 @@ class NameAPI extends WEBBase{
* 获取行业类别数据 後期可提出為一個service文件 * 获取行业类别数据 後期可提出為一個service文件
* @returns {Promise<{}>} * @returns {Promise<{}>}
*/ */
async getCache(){ async getCache() {
let cacheResult = {}; let cacheResult = {};
cacheResult.cache = cacheJson cacheResult.cache = cacheJson
return system.getResult(cacheResult); return system.getResult(cacheResult);
...@@ -61,17 +61,17 @@ class NameAPI extends WEBBase{ ...@@ -61,17 +61,17 @@ class NameAPI extends WEBBase{
* 获取偏好信息 後期可提出為一個service文件 * 获取偏好信息 後期可提出為一個service文件
* @returns {Promise<{}>} * @returns {Promise<{}>}
*/ */
async getPreference(){ async getPreference() {
let preResult = {}; let preResult = {};
const key = 'qmbpreference'; const key = 'qmbpreference';
let result = await this.redisClient.get(key) let result = await this.redisClient.get(key)
if(result){ if (result) {
preResult.preference = JSON.parse(result); preResult.preference = JSON.parse(result);
return system.getResult(preResult); return system.getResult(preResult);
}else{ } else {
const data = await this.restPostUrl({},this.centerCacheUrl+"preference_select"); const data = await this.restPostUrl({}, this.centerCacheUrl + "preference_select");
if(data.code == 200){ if (data.code == 200) {
await this.redisClient.set(key,JSON.stringify(data.data),2*3600) await this.redisClient.set(key, JSON.stringify(data.data), 2 * 3600)
preResult.preference = data.data preResult.preference = data.data
return system.getResult(preResult); return system.getResult(preResult);
} }
...@@ -84,7 +84,7 @@ class NameAPI extends WEBBase{ ...@@ -84,7 +84,7 @@ class NameAPI extends WEBBase{
* @param actionBody * @param actionBody
* @returns {Promise<{msg: string, data: (*|null), bizmsg: *, status: number}|{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>} * @returns {Promise<{msg: string, data: (*|null), bizmsg: *, status: number}|{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
*/ */
async addOrderDelivery(pobj,actionBody){ async addOrderDelivery(pobj, actionBody) {
if (!actionBody.orderId) { if (!actionBody.orderId) {
return system.getResult(null, "orderId参数不能为空"); return system.getResult(null, "orderId参数不能为空");
} }
...@@ -106,46 +106,43 @@ class NameAPI extends WEBBase{ ...@@ -106,46 +106,43 @@ class NameAPI extends WEBBase{
if (!actionBody.preference) { if (!actionBody.preference) {
return system.getResult(null, "preference参数不能为空"); return system.getResult(null, "preference参数不能为空");
} }
await this.redisClient.set("ch"+JSON.stringify(actionBody.orderId),JSON.stringify(actionBody)); await this.redisClient.set("ch" + JSON.stringify(actionBody.orderId), JSON.stringify(actionBody));
return system.getResultSuccess(); return system.getResultSuccess();
} }
//获取取名结果,并保存到数据库 //获取取名结果,并保存到数据库
async getNameDetail(pobj){ async getNameDetail(pobj) {
pobj.actionType = 'getOrderDeliveryInfo'; pobj.actionType = 'getOrderDeliveryInfo';
const opResult = await this.utilsOrderSve.getOrderDeliveryInfo(pobj, pobj.actionBody); const opResult = await this.utilsOrderSve.getOrderDeliveryInfo(pobj, pobj.actionBody);
if(opResult.status != 0){ if (opResult.status != 0) {
return system.getResult(null,opResult.msg); return system.getResult(null, opResult.msg);
} }
if(opResult.data.hasOwnProperty('result_name')){ if (opResult.data.hasOwnProperty('result_name')) {
return system.getResult(opResult.data,'操作成功'); return system.getResult(opResult.data, '操作成功');
} }
let actionBody =await this.redisClient.get('ch'+ JSON.stringify(pobj.actionBody.orderNo)); let actionBody = await this.redisClient.get('ch' + JSON.stringify(pobj.actionBody.orderNo));
if(!actionBody){ if (!actionBody) {
return system.getResult(null) return system.getResult(null)
} }
let nameResult = await this.restPostUrl(JSON.parse(actionBody),this.centerCacheUrl+"treasure_name"); let nameResult = await this.restPostUrl(JSON.parse(actionBody), this.centerCacheUrl + "treasure_name");
if(nameResult.code == 200){ if (nameResult.code == 200) {
pobj.actionType = 'addOrderDelivery'; pobj.actionType = 'addOrderDelivery';
pobj.actionBody = nameResult.data; pobj.actionBody = nameResult.data;
//取名结果存储 //取名结果存储
let result = await this.restPostUrl(pobj,this.centerOrderUrl + "action/nameOrder/springBoard"); let result = await this.restPostUrl(pobj, this.centerOrderUrl + "action/nameOrder/springBoard");
return system.getResult(nameResult.data,"操作成功"); return system.getResult(nameResult.data, "操作成功");
} }
return system.getResult(null,'try again'); return system.getResult(null, 'try again');
} }
async getNames(pobj,actionBody){ async getNames(req, actionBody) {
let rtn = await this.restClient.execPost(actionBody,this.aliGetNamesjavaUrl); const result = await this.execPostByTimeOut(req, actionBody, this.aliGetNamesjavaUrl);
if (!rtn.stdout) { if (result.status != 0) {
return system.getResultFail(); return result;
} }
var result = JSON.parse(rtn.stdout); const tmpData = result.data ? result.data.companyName : [];
if(result) { return system.getResultSuccess(tmpData);
return system.getResultSuccess(result);
}
return system.getResultFail(result);
} }
} }
...@@ -153,7 +150,7 @@ const cacheJson = { ...@@ -153,7 +150,7 @@ const cacheJson = {
"科技类": ["网络科技", "电子商务", "信息技术", "游戏", "电子", "软件", "新材料", "生物科技", "教育科技", "环保科技", "信息科技"], "科技类": ["网络科技", "电子商务", "信息技术", "游戏", "电子", "软件", "新材料", "生物科技", "教育科技", "环保科技", "信息科技"],
"许可类": ["投资管理", "金融", "资产", "商业保理", "融资租赁", "医疗器械", "人力资源", "食品", "劳务派遣"], "许可类": ["投资管理", "金融", "资产", "商业保理", "融资租赁", "医疗器械", "人力资源", "食品", "劳务派遣"],
"服务类": ["广告", "文化传媒", "建筑装潢", "设计", "美容美发", "房地产中介", "物业管理", "商务咨询", "企业管理"], "服务类": ["广告", "文化传媒", "建筑装潢", "设计", "美容美发", "房地产中介", "物业管理", "商务咨询", "企业管理"],
"其他": ["贸易","实业","制造","服饰","化妆品","工程","农业","餐饮管理","物流"], "其他": ["贸易", "实业", "制造", "服饰", "化妆品", "工程", "农业", "餐饮管理", "物流"],
} }
......
...@@ -5,6 +5,7 @@ const md5 = require("MD5"); ...@@ -5,6 +5,7 @@ const md5 = require("MD5");
class WEBBase { class WEBBase {
constructor() { constructor() {
this.restClient = system.getObject("util.restClient"); this.restClient = system.getObject("util.restClient");
this.execClientNew = system.getObject("util.execClientNew");
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("service.common.oplogSve"); this.logCtl = system.getObject("service.common.oplogSve");
this.toolSve = system.getObject("service.trademark.toolSve"); this.toolSve = system.getObject("service.trademark.toolSve");
...@@ -68,10 +69,23 @@ class WEBBase { ...@@ -68,10 +69,23 @@ class WEBBase {
async restPostUrl(pobj, url) { async restPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url); var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty"); return system.getResult(null, "restPost data is empty");
} }
var result = JSON.parse(rtn.stdout); var result = JSON.parse(rtn.stdout);
return result; 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('sve.base', params, url, ContentType, headData, timeOut, req);
return result;
}
} }
module.exports = WEBBase; module.exports = WEBBase;
...@@ -1252,17 +1252,6 @@ class UtilsOrderService extends AppServiceBase { ...@@ -1252,17 +1252,6 @@ class UtilsOrderService extends AppServiceBase {
if (actionBody.quantity !=actionBody.deliveryData.nclones.length || Number(actionBody.quantity) !=actionBody.deliveryData.nclones.length) { if (actionBody.quantity !=actionBody.deliveryData.nclones.length || Number(actionBody.quantity) !=actionBody.deliveryData.nclones.length) {
return system.getResult(null, "订单数量有误,100030"); return system.getResult(null, "订单数量有误,100030");
} }
pobj.actionType = "getProductDetail";
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemResult = await this.restPostUrl(pobj, url);
if (productItemResult.status != 0) {
return productItemResult;
}
pobj.actionBody.product_info = productItemResult.data;
pobj.actionType = "getProductInterface";
pobj.actionBody.product_id = productItemResult.data.id;
var productItemInterfaceResult = await this.restPostUrl(pobj, url);
pobj.actionBody.product_info.interface_info = productItemInterfaceResult.data;
let nclones = actionBody.deliveryData.nclones;//大项集合 let nclones = actionBody.deliveryData.nclones;//大项集合
let product_item = [];//产品项 let product_item = [];//产品项
for(let i = 0;i < nclones.length ; i ++){ for(let i = 0;i < nclones.length ; i ++){
...@@ -1276,7 +1265,6 @@ class UtilsOrderService extends AppServiceBase { ...@@ -1276,7 +1265,6 @@ class UtilsOrderService extends AppServiceBase {
actionBody.totalSum = 0; actionBody.totalSum = 0;
actionBody.quantity = 1; actionBody.quantity = 1;
actionBody.deliveryData.nclones = [nclone] actionBody.deliveryData.nclones = [nclone]
var verifyResult = await this.isOrderVerify(pobj, pobj.actionBody);
actionBody.payTotalSum = actionBody.totalSum; actionBody.payTotalSum = actionBody.totalSum;
let saveResult = await this.addOrder(pobj,actionBody); let saveResult = await this.addOrder(pobj,actionBody);
if(saveResult.status !=0){ if(saveResult.status !=0){
......
...@@ -204,10 +204,12 @@ module.exports = function (app) { ...@@ -204,10 +204,12 @@ module.exports = function (app) {
app.use('/orderNotify/channelPayNotify', async function (req, res) { app.use('/orderNotify/channelPayNotify', async function (req, res) {
try { try {
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
if (req.body.orderNo.startWith('CN')) { let result ={};
var result = await utilsOrderSve.channelOrdersPayNotify(req.body, client_ip); const orderNo = req.body.orderNo;
} else { if(orderNo.indexOf('CN') ==0){
var result = await utilsOrderSve.channelPayNotify(req.body, client_ip); result = await utilsOrderSve.channelOrdersPayNotify(req.body,client_ip);
}else{
result = await utilsOrderSve.channelPayNotify(req.body, client_ip);
} }
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道支付订单通知 api层", optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道支付订单通知 api层",
...@@ -648,7 +650,7 @@ module.exports = function (app) { ...@@ -648,7 +650,7 @@ module.exports = function (app) {
//icp需求推送 //icp需求推送
app.post('/icp/consultation/submit', function (req, res) { app.post('/icp/consultation/submit', function (req, res) {
var p = null; var p = null;
var params = ["icpnotify", "icpSubmitNeed", req.body, req.query, req]; var params = ["icpnotify","icpSubmitNeed",req.body,req.query,req];
// gname, methodname, pobj, query, req // gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify"); var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) { if (invokeObj["doexecMethod"]) {
...@@ -662,7 +664,7 @@ module.exports = function (app) { ...@@ -662,7 +664,7 @@ module.exports = function (app) {
app.post('/icp/feedback/submit', function (req, res) { app.post('/icp/feedback/submit', function (req, res) {
var p = null; var p = null;
req.body.action_type = "icpFeedbackSubmit"; req.body.action_type = "icpFeedbackSubmit";
var params = ["icpnotify", "icpFeedbackSubmit", req.body, req.query, req]; var params = ["icpnotify","icpFeedbackSubmit",req.body,req.query,req];
// gname, methodname, pobj, query, req // gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify"); var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) { if (invokeObj["doexecMethod"]) {
...@@ -676,7 +678,7 @@ module.exports = function (app) { ...@@ -676,7 +678,7 @@ module.exports = function (app) {
app.post('/icp/order/notify', function (req, res) { app.post('/icp/order/notify', function (req, res) {
var p = null; var p = null;
req.body.action_type = "icpNotify"; req.body.action_type = "icpNotify";
var params = ["icpnotify", "icpNotify", req.body, req.query, req]; var params = ["icpnotify","icpNotify",req.body,req.query,req];
// gname, methodname, pobj, query, req // gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify"); var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) { if (invokeObj["doexecMethod"]) {
......
...@@ -60,7 +60,7 @@ var settings = { ...@@ -60,7 +60,7 @@ var settings = {
}, },
aliGetNamesjavaUrl: function () { aliGetNamesjavaUrl: function () {
if (this.env == "dev") { if (this.env == "dev") {
return "192.168.210.240:80/getNames"; return "http://localhost:80/getNames";
} else { } else {
return "http://aliossjava-service/getNames"; return "http://aliossjava-service/getNames";
} }
......
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