Commit 5c12ee5b by wkliang

fix

parent 680b3aff
......@@ -4,7 +4,7 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.accountSve = system.getObject("service.account.accountSve");
this.productSve = system.getObject("service.product.productSve")
}
/**
* 接口跳转
......@@ -12,7 +12,7 @@ class ActionAPI extends APIBase {
* action_type 执行的类型
* action_body 执行的参数
*/
async springboard(pobj, qobj, req) {
async springboard (pobj, qobj, req) {
var result;
if (!pobj.action_process) {
return system.getResult(null, "action_process参数不能为空");
......@@ -21,57 +21,57 @@ class ActionAPI extends APIBase {
return system.getResult(null, "action_type参数不能为空");
}
try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) {
console.log(error);
}
return result;
}
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
async handleRequest (action_process, action_type, action_body) {
let result
switch (action_type) {
// 测试
case "test":
opResult = await this.accountSve.test(action_body);
break;
// 创建账户
case "accountCreate":
opResult = await this.accountSve.createAccount(action_body);
break;
// 账户余额查询
case "accountInfo":
opResult = await this.accountSve.accountInfo(action_body);
break;
// 账户充值
case "accountRecharge":
opResult = await this.accountSve.accountRecharge(action_body);
break;
// 账户充值
case "accountRefund":
opResult = await this.accountSve.accountRefund(action_body);
break;
case "accountTrade":
opResult = await this.accountSve.accountTrade(action_body);
break;
case "accountTradePage":
opResult = await this.accountSve.accountTradePage(action_body);
break;
// 账户交易
case "test4":
opResult = await this.accountSve.test(action_body);
break;
case 'getPage':
result = await this.productSve.getPage(action_body.page, action_body.limit,
action_body.types, action_body.keywords)
break
case 'createOrUpdate':
if (action_body.product_type == 0 && action_body.items) {
return system.getResult(null, '单产品不能有子产品')
}
if (action_body.product_type == 1 && (!action_body.items || action_body.items.length == 0)) {
return system.getResult(null, '未选择子产品')
}
if (action_body.product_type == 1) {
let checkRes = await this.productSve.checkSitem(action_body.items)
if (!checkRes) {
return system.getResult(null, '不能选择组合产品为子产品')
}
}
result = await this.productSve.createOrUpdate(action_body)
break
case 'getAllDic':
result = await this.productSve.getAllDic(action_body.types)
break
case 'getByIds':
if (!action_body.ids) {
return system.getResult(null, 'id列表不能为空')
}
result = await this.productSve.getByIds(action_body.ids)
break
case 'getItems':
result = await this.productSve.getItems(action_body.id)
break
default:
opResult = system.getResult(null, "action_type参数错误");
break;
break
}
return opResult;
return system.getResultSuccess(result)
}
exam() {
exam () {
return `<pre><pre/>`;
}
classDesc() {
classDesc () {
return {
groupName: "op",
groupDesc: "元数据服务包",
......@@ -80,7 +80,7 @@ class ActionAPI extends APIBase {
exam: "",
};
}
methodDescs() {
methodDescs () {
return [
{
methodDesc: `<pre><pre/>`,
......
......@@ -8,38 +8,38 @@ class ProductAPI extends APIBase {
}
async etag (pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空")
if (!pobj.action_type) {
return system.getResult(null, "action_type参数不能为空")
}
let result
switch (pobj.actionType) {
switch (pobj.action_type) {
case 'getPage':
result = await this.productSve.getPage(pobj.actionBody.page, pobj.actionBody.limit,
pobj.actionBody.types, pobj.actionBody.keywords)
result = await this.productSve.getPage(pobj.action_body.page, pobj.action_body.limit,
pobj.action_body.types, pobj.action_body.keywords)
return system.getResultSuccess(result)
case 'createOrUpdate':
if (pobj.actionBody.product_type == 0 && pobj.actionBody.items) {
if (pobj.action_body.product_type == 0 && pobj.action_body.items) {
return system.getResult(null, '单产品不能有子产品')
}
if (pobj.actionBody.product_type == 1 && (!pobj.actionBody.items || pobj.actionBody.items.length == 0)) {
if (pobj.action_body.product_type == 1 && (!pobj.action_body.items || pobj.action_body.items.length == 0)) {
return system.getResult(null, '未选择子产品')
}
if (pobj.actionBody.product_type == 1) {
let checkRes = await this.productSve.checkSitem(pobj.actionBody.items)
if (pobj.action_body.product_type == 1) {
let checkRes = await this.productSve.checkSitem(pobj.action_body.items)
if (!checkRes) {
return system.getResult(null, '不能选择组合产品为子产品')
}
}
result = await this.productSve.createOrUpdate(pobj.actionBody)
result = await this.productSve.createOrUpdate(pobj.action_body)
return system.getResultSuccess(result)
case 'getAllDic':
result = await this.productSve.getAllDic(pobj.actionBody.types)
result = await this.productSve.getAllDic(pobj.action_body.types)
return system.getResultSuccess(result)
case 'getByIds':
result = await this.productSve.getByIds(pobj.actionBody.ids)
result = await this.productSve.getByIds(pobj.action_body.ids)
return system.getResultSuccess(result)
case 'getItems':
result = await this.productSve.getItems(pobj.actionBody.id)
result = await this.productSve.getItems(pobj.action_body.id)
return system.getResultSuccess(result)
default:
break
......
......@@ -16,7 +16,7 @@
#### 接口地址 `/api/op/product/etag`
#### actionType `getPage`
#### action_type `getPage`
#### 参数说明
......@@ -75,7 +75,7 @@
#### 接口地址 `/api/op/product/etag`
#### actionType `getAllDic`
#### action_type `getAllDic`
#### 参数说明
......@@ -118,7 +118,7 @@
#### 接口地址 `/api/op/product/etag`
#### actionType `getByIds`
#### action_type `getByIds`
#### 参数说明
......@@ -182,7 +182,7 @@
#### 接口地址 `/api/op/product/etag`
#### actionType `getItems`
#### action_type `getItems`
#### 参数说明
......
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