Commit 5c12ee5b by wkliang

fix

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