Commit b55b0072 by xsren@gongsibao.com

保存用户选项,详情获取数据中心数据,保存到数据库

parent c647c0cc
...@@ -5,8 +5,9 @@ class NameAPI extends WEBBase{ ...@@ -5,8 +5,9 @@ class NameAPI extends WEBBase{
constructor() { constructor() {
super(); super();
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.centerOrderUrl = settings.centerOrderUrl(); this.centerOrderUrl = settings.centerOrderUrl();
this.centerCacheUrl = "http://123.57.217.203:30005/"; this.centerCacheUrl = settings.centerCacheUrl();
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -32,6 +33,9 @@ class NameAPI extends WEBBase{ ...@@ -32,6 +33,9 @@ class NameAPI extends WEBBase{
case "createName"://起名 case "createName"://起名
opResult =await this.addOrderDelivery(pobj,pobj.actionBody); opResult =await this.addOrderDelivery(pobj,pobj.actionBody);
break; break;
case "getNameDetail":
opResult = await this.getNameDetail(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
...@@ -77,7 +81,6 @@ class NameAPI extends WEBBase{ ...@@ -77,7 +81,6 @@ class NameAPI extends WEBBase{
* @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){
var nameResult = {};
if (!actionBody.orderId) { if (!actionBody.orderId) {
return system.getResult(null, "orderId参数不能为空"); return system.getResult(null, "orderId参数不能为空");
} }
...@@ -99,20 +102,35 @@ class NameAPI extends WEBBase{ ...@@ -99,20 +102,35 @@ 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));
nameResult = await this.restPostUrl(actionBody,this.centerCacheUrl+"treasure_name"); return system.getResultSuccess();
if(nameResult.code == 200){ }
pobj.actionType = 'addOrderDelivery'
pobj.actionBody = nameResult.data;
//取名结果存储 //获取取名结果,并保存到数据库
var reut = await this.restPostUrl(pobj,this.centerOrderUrl + "action/nameOrder/springBoard"); async getNameDetail(pobj){
if(reut.status === 0){ pobj.actionType = 'getOrderDeliveryInfo';
return system.getResultSuccess(); const opResult = await this.utilsOrderSve.getOrderDeliveryInfo(pobj, pobj.actionBody);
if(opResult.status == 0){
if(!opResult.data.hasOwnProperty('result_name')){
const actionBody =await this.redisClient.get('ch'+ JSON.stringify(pobj.actionBody.orderNo));
if(actionBody != null){
const nameResult = await this.restPostUrl(JSON.parse(actionBody),this.centerCacheUrl+"treasure_name");
if(nameResult.code == 200){
pobj.actionType = 'addOrderDelivery'
pobj.actionBody = nameResult.data;
//取名结果存储
await this.restPostUrl(pobj,this.centerOrderUrl + "action/nameOrder/springBoard");
return system.getResult(nameResult.data,"操作成功")
}
}else{
return system.getResult()
}
}else{ }else{
return system.getResultFail(-1,reut.msg) return system.getResult(opResult.data,'操作成功')
} }
}else{ }else {
await this.addOrderDelivery(pobj); return system.getResultFail('',opResult.msg);
} }
} }
} }
......
...@@ -114,7 +114,7 @@ module.exports = function (app) { ...@@ -114,7 +114,7 @@ module.exports = function (app) {
"addOrder", "getH5PayUrl", "getOrderQrCode", "queryOrderStatus", "getOrderInfo", "getOrderDeliveryInfo", "getOrderDetails", "addOrder", "getH5PayUrl", "getOrderQrCode", "queryOrderStatus", "getOrderInfo", "getOrderDeliveryInfo", "getOrderDetails",
"getOrderDeliveryFlowInfo", "getOrderDeliveryFlowList", "getOrderLogInfo", "updateContacts", "updateTmOrder", "delOrder", "getOrderDeliveryFlowInfo", "getOrderDeliveryFlowList", "getOrderLogInfo", "updateContacts", "updateTmOrder", "delOrder",
"submitProgramme", "getProgrammeListByUser", "getProgrammeInfoByNeedNo", "abolishProgramme", "getAliPayInfo", "submitProgramme", "getProgrammeListByUser", "getProgrammeInfoByNeedNo", "abolishProgramme", "getAliPayInfo",
"getPaidLogoListByUser","getCollectibleLogoListByUser","collectLogo","getLogoMaterial","cancelCollectLogo","icpNotify","createName" "getPaidLogoListByUser","getCollectibleLogoListByUser","collectLogo","getLogoMaterial","cancelCollectLogo","icpNotify","createName","getNameDetail"
]; ];
if (lst.indexOf(req.body.actionType) >= 0) { if (lst.indexOf(req.body.actionType) >= 0) {
var userpin = req.headers["userpin"] || ""; var userpin = req.headers["userpin"] || "";
......
...@@ -90,7 +90,13 @@ var settings = { ...@@ -90,7 +90,13 @@ var settings = {
return "http://igirl-service/"; return "http://igirl-service/";
} }
}, },
centerCacheUrl:function(){
if(this.env=='dev'){
return "http://123.57.217.203:30005/";
}else{
return "http://specialname-service/"
}
},
reqTransferurl: function () { reqTransferurl: function () {
if (this.env == "dev") { if (this.env == "dev") {
return "http://192.168.18.61:3003/"; return "http://192.168.18.61:3003/";
......
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