Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
179b856a
Commit
179b856a
authored
Feb 26, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
0cdb75c6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
72 deletions
+144
-72
center-order/app/base/api/impl/action/order.js
+33
-24
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
+1
-1
center-order/app/base/service/impl/utilsSve/utilsFqAliyunSve.js
+101
-0
center-order/app/base/utils/aliyunClient.js
+9
-47
No files found.
center-order/app/base/api/impl/action/order.js
View file @
179b856a
...
@@ -27,7 +27,8 @@ class OrderAPI extends APIBase {
...
@@ -27,7 +27,8 @@ class OrderAPI extends APIBase {
switch
(
action_type
)
{
switch
(
action_type
)
{
case
"addOrder"
:
//创建订单
case
"addOrder"
:
//创建订单
opResult
=
await
this
.
addOrder
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
addOrder
(
pobj
,
pobj
.
actionBody
);
await
this
.
pushOrder
(
opResult
,
pobj
,
pobj
.
actionBody
);
await
this
.
pushInfo
(
orderResult
,
pobj
,
pobj
.
actionBody
,
"pushOrder"
);
await
this
.
pushInfo
(
orderResult
,
pobj
,
pobj
.
actionBody
,
"pushBusiness"
);
break
;
break
;
case
"getOrderInfo"
:
//获取订单列表信息
case
"getOrderInfo"
:
//获取订单列表信息
opResult
=
await
this
.
orderinfoSve
.
getOrderInfo
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
orderinfoSve
.
getOrderInfo
(
pobj
,
pobj
.
actionBody
);
...
@@ -49,6 +50,8 @@ class OrderAPI extends APIBase {
...
@@ -49,6 +50,8 @@ class OrderAPI extends APIBase {
}
}
return
opResult
;
return
opResult
;
}
}
async
addOrder
(
pobj
,
actionBody
)
{
async
addOrder
(
pobj
,
actionBody
)
{
if
(
!
actionBody
.
product_info
)
{
if
(
!
actionBody
.
product_info
)
{
return
system
.
getResult
(
null
,
"产品信息有误,20010"
);
return
system
.
getResult
(
null
,
"产品信息有误,20010"
);
...
@@ -65,7 +68,7 @@ class OrderAPI extends APIBase {
...
@@ -65,7 +68,7 @@ class OrderAPI extends APIBase {
interface_info
=
{
interface_info
=
{
interface_type
:
"bd"
,
interface_type
:
"bd"
,
interface_url
:
"service.dbcorder.orderinfoSve"
,
interface_url
:
"service.dbcorder.orderinfoSve"
,
params
:
"createOtherOrder"
method_name
:
"createOtherOrder"
};
};
}
//使用默认的其他订单
}
//使用默认的其他订单
...
@@ -78,40 +81,47 @@ class OrderAPI extends APIBase {
...
@@ -78,40 +81,47 @@ class OrderAPI extends APIBase {
if
(
!
interface_info
.
interface_url
)
{
if
(
!
interface_info
.
interface_url
)
{
return
system
.
getResult
(
null
,
"产品接口地址信息有误,20080"
);
return
system
.
getResult
(
null
,
"产品接口地址信息有误,20080"
);
}
}
var
opResult
=
null
;
var
opResult
=
await
this
.
reflexAction
(
interface_info
,
pobj
);
return
opResult
;
}
async
pushOrder
(
orderResult
,
pobj
,
actionBody
,
opType
)
{
if
(
opResult
.
status
!=
0
)
{
return
""
;
}
var
interface_list
=
actionBody
.
product_info
.
interface_info
;
if
(
!
interface_list
)
{
return
""
;
}
var
interface_info
=
null
;
var
interface_list_temp
=
interface_list
.
filter
(
f
=>
f
.
op_type
==
opType
)
if
(
interface_list_temp
&&
interface_list_temp
.
length
>
0
)
{
interface_info
=
interface_list_temp
[
0
];
}
if
(
!
interface_info
)
{
return
""
;
}
pobj
.
orderResult
=
orderResult
;
var
opResult
=
this
.
reflexAction
(
interface_info
,
pobj
);
return
opResult
;
}
async
reflexAction
(
interface_info
,
pobj
)
{
if
(
interface_info
.
interface_type
==
"bd"
)
{
if
(
interface_info
.
interface_type
==
"bd"
)
{
if
(
!
interface_info
.
params
)
{
if
(
!
interface_info
.
method_name
)
{
return
system
.
getResult
(
null
,
"产品接口参数信息有误,20110"
);
return
system
.
getResult
(
null
,
"产品接口参数信息有误,20110"
);
}
//操作的方法名称
}
//操作的方法名称
var
invokeObj
=
system
.
getObject
(
interface_info
.
interface_url
);
var
invokeObj
=
system
.
getObject
(
interface_info
.
interface_url
);
if
(
!
invokeObj
[
interface_info
.
params
])
{
if
(
!
invokeObj
[
interface_info
.
method_name
])
{
return
system
.
getResult
(
null
,
"产品接口参数方法信息有误,20130"
);
return
system
.
getResult
(
null
,
"产品接口参数方法信息有误,20130"
);
}
}
pobj
.
interface_params
=
interface_info
.
params
;
var
params
=
[
pobj
];
var
params
=
[
pobj
];
opResult
=
await
invokeObj
[
interface_info
.
params
].
apply
(
invokeObj
,
params
);
opResult
=
await
invokeObj
[
interface_info
.
method_name
].
apply
(
invokeObj
,
params
);
}
}
else
if
(
interface_info
.
interface_type
==
"yc"
)
{
else
if
(
interface_info
.
interface_type
==
"yc"
)
{
}
}
return
opResult
;
return
opResult
;
}
}
async
pushOrder
(
opResult
,
pobj
,
actionBody
)
{
if
(
opResult
.
status
!=
0
)
{
return
""
;
}
var
interface_info
=
null
;
var
interface_list
=
actionBody
.
product_info
.
interface_info
;
if
(
interface_list
)
{
var
interface_list_temp
=
interface_list
.
filter
(
f
=>
f
.
op_type
==
"pushOrder"
)
if
(
interface_list_temp
&&
interface_list_temp
.
length
>
0
)
{
interface_info
=
interface_list_temp
[
0
];
}
}
if
(
!
interface_info
)
{
return
""
;
}
//TODO:推送订单
}
}
}
module
.
exports
=
OrderAPI
;
module
.
exports
=
OrderAPI
;
\ No newline at end of file
center-order/app/base/service/impl/dbcorder/orderinfoSve.js
View file @
179b856a
...
@@ -269,7 +269,7 @@ class OrderInfoService extends ServiceBase {
...
@@ -269,7 +269,7 @@ class OrderInfoService extends ServiceBase {
}
}
//-------------------------------服务商通知订单流程-------------start----------------
//-------------------------------服务商通知订单流程-------------start----------------
async
icOrderStatusNotify
(
pobj
,
actionBody
)
{
//
获取订单交付信息
async
icOrderStatusNotify
(
pobj
,
actionBody
)
{
//
峰擎通知工商办理状态
var
item
=
await
this
.
dao
.
getItemStatusByOrderNo
(
actionBody
.
orderNo
);
var
item
=
await
this
.
dao
.
getItemStatusByOrderNo
(
actionBody
.
orderNo
);
if
(
!
item
)
{
if
(
!
item
)
{
return
system
.
getResult
(
null
,
"order data is empty!"
);
return
system
.
getResult
(
null
,
"order data is empty!"
);
...
...
center-order/app/base/service/impl/utilsSve/utilsFqAliyunSve.js
0 → 100644
View file @
179b856a
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
aliyunClient
=
system
.
getObject
(
"util.aliyunClient"
);
// //aliyunClient
// this.fqReqUrl = "https://yunfuapi.gongsibao.com";//线上域名
// // this.fqReqUrl = "https://yunfuapi-dev.gongsibao.com";//dev域名
// // const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');//开发
// const client = new Client('203763771', 'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu');//线上
class
UtilsFqAliyunSve
extends
AppServiceBase
{
constructor
()
{
super
();
}
async
pushBusinessDev
(
pobj
)
{
this
.
logCtl
.
info
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
.
requestId
||
""
,
op
:
"center-order/service/impl/utilsSve/utilsFqAliyunSve.js/pushBusinessDev"
,
content
:
"请求地址:"
+
reqUrl
+
",参数:"
+
JSON
.
stringify
(
body
)
+
",返回结果:"
+
JSON
.
stringify
(
rtn
),
clientIp
:
pobj
.
clientIp
,
optitle
:
"推送订单商机到FQ信息--again"
,
});
}
async
pushBusinessOnline
(
pobj
)
{
this
.
logCtl
.
info
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
.
requestId
||
""
,
op
:
"center-order/service/impl/utilsSve/utilsFqAliyunSve.js/pushBusinessOnline"
,
content
:
"请求地址:"
+
reqUrl
+
",参数:"
+
JSON
.
stringify
(
body
)
+
",返回结果:"
+
JSON
.
stringify
(
rtn
),
clientIp
:
pobj
.
clientIp
,
optitle
:
"推送订单商机到FQ信息--again"
,
});
}
async
opAliyunClientPost
(
pobj
)
{
try
{
}
catch
(
e
)
{
//日志记录
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
.
uapp_id
,
appkey
:
pobj
.
appInfo
.
uappKey
,
requestId
:
req
.
requestId
||
""
,
op
:
"igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness"
,
content
:
"error:"
+
e
.
stack
,
clientIp
:
pobj
.
clientIp
,
optitle
:
"推送订单商机到FQ出错--again"
,
});
}
}
// var rc = system.getObject("util.aliyunClient");
// var rtn = null;
// var reqUrl = this.fqReqUrl + "/crm/order/submit";
// var body = pobj.actionBody;
// try {
// rtn = await rc.post(reqUrl, body);
// this.logCtl.info({
// appid: req.app.id,
// appkey: req.app.uappKey,
// requestId: req.requestId || "",
// op: "igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness",
// content: "请求地址:" + reqUrl + ",参数:" + JSON.stringify(body) + ",返回结果:" + JSON.stringify(rtn),
// clientIp: pobj.clientIp,
// optitle: "推送订单商机到FQ信息--again",
// });
// if (rtn.code != 200 && rtn.success != true) {
// return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + req.requestId + ",requestId=" + rtn.requestId);
// }
// return system.getResultSuccess(null, "推送成功");
// } catch (e) {
// //日志记录
// this.logCtl.error({
// appid: req.app.id,
// appkey: req.app.uappKey,
// requestId: req.requestId || "",
// op: "igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness",
// content: "error:" + e.stack,
// clientIp: pobj.clientIp,
// optitle: "推送订单商机到FQ出错--again",
// });
// }
}
module
.
exports
=
UtilsFqAliyunSve
;
center-order/app/base/utils/aliyunClient.js
View file @
179b856a
const
Client
=
require
(
'aliyun-api-gateway'
).
Client
;
const
Client
=
require
(
'aliyun-api-gateway'
).
Client
;
var
RPCClient
=
require
(
'@alicloud/pop-core'
).
RPCClient
;
// const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');//开发
const
client
=
new
Client
(
'203763771'
,
'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu'
);
//线上
class
aliyunClient
{
class
aliyunClient
{
constructor
()
{
constructor
()
{
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
this
.
aliclient
=
new
RPCClient
({
accessKeyId
:
'LTAI4FmyipY1wuLHjLhMWiPa'
,
accessKeySecret
:
'hp4FF18IDCSym1prqzxrAjnnhNH3ju'
,
endpoint
:
'https://trademark.aliyuncs.com'
,
apiVersion
:
'2018-07-24'
});
}
}
async
post
(
aliReqUrl
,
actionBody
)
{
async
post
(
aliReqUrl
,
key
,
secret
,
actionBody
)
{
// var reqParam = {};
const
client
=
new
Client
(
key
,
secret
);
// reqParam["ActionProcess"] = "AliTm";
// reqParam["ActionType"] = actionType;
// reqParam["ActionBody"] = actionBody;
// if (!actionBody.reqOnlyCode) {
// actionBody["reqOnlyCode"] = await this.getCreateOrderNum();
// }
var
param
=
{
var
param
=
{
data
:
actionBody
,
data
:
actionBody
,
timeout
:
20000
,
timeout
:
20000
,
...
@@ -36,10 +18,15 @@ class aliyunClient {
...
@@ -36,10 +18,15 @@ class aliyunClient {
}
}
//阿里接口
//阿里接口
async
reqbyget
(
obj
,
cbk
)
{
async
reqbyget
(
obj
,
cbk
)
{
var
self
=
this
;
const
aliclient
=
new
RPCClient
({
accessKeyId
:
'LTAI4FmyipY1wuLHjLhMWiPa'
,
accessKeySecret
:
'hp4FF18IDCSym1prqzxrAjnnhNH3ju'
,
endpoint
:
'https://trademark.aliyuncs.com'
,
apiVersion
:
'2018-07-24'
});
var
action
=
obj
.
action
;
var
action
=
obj
.
action
;
var
reqbody
=
obj
.
reqbody
;
var
reqbody
=
obj
.
reqbody
;
return
self
.
aliclient
.
request
(
action
,
reqbody
,
{
return
this
.
aliclient
.
request
(
action
,
reqbody
,
{
timeout
:
3000
,
// default 3000 ms
timeout
:
3000
,
// default 3000 ms
formatAction
:
true
,
// default true, format the action to Action
formatAction
:
true
,
// default true, format the action to Action
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
...
@@ -48,30 +35,5 @@ class aliyunClient {
...
@@ -48,30 +35,5 @@ class aliyunClient {
});
});
}
}
// async getCreateOrderNum() {
// var createOrderNum = await this.getUidStr(5, 36);//====================订单号生成
// return createOrderNum + "" + Date.now();
// }
// async getUidStr(len, radix) {
// var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
// var uuid = [], i;
// radix = radix || chars.length;
// if (len) {
// for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
// } else {
// var r;
// uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
// uuid[14] = '4';
// for (i = 0; i < 36; i++) {
// if (!uuid[i]) {
// r = 0 | Math.random() * 16;
// uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
// }
// }
// }
// return uuid.join('');
// }
}
}
module
.
exports
=
aliyunClient
;
module
.
exports
=
aliyunClient
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment