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
c4e61a5a
Commit
c4e61a5a
authored
Jun 13, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel
parents
0e911d38
b1b548a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
196 additions
and
0 deletions
+196
-0
center-channel/app/base/api/impl/action/newName.js
+40
-0
center-channel/app/base/api/impl/action/ucommune.js
+42
-0
center-channel/app/base/service/app.base.js
+29
-0
center-channel/app/base/service/impl/utilsSve/utilsUcommuneSve.js
+64
-0
center-channel/app/base/utils/restClient.js
+14
-0
center-channel/app/config/settings.js
+7
-0
No files found.
center-channel/app/base/api/impl/action/newName.js
0 → 100644
View file @
c4e61a5a
var
WEBBase
=
require
(
"../../web.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
ProductAPI
extends
WEBBase
{
constructor
()
{
super
();
this
.
utilsUcommuneSve
=
system
.
getObject
(
"service.utilsSve.utilsUcommuneSve"
);
}
/**
* 优客工厂
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
await
this
.
opActionProcess
(
pobj
,
pobj
.
actionType
,
req
);
return
result
;
}
async
opActionProcess
(
pobj
,
action_type
,
req
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
case
"getIndustryInfo"
:
// 获取行业信息
opResult
=
await
this
.
utilsUcommuneSve
.
getUserInfo
(
pobj
,
pobj
.
actionBody
);
break
;
case
"placeOrder"
:
// 提交订单
opResult
=
await
this
.
utilsUcommuneSve
.
getOrderList
(
pobj
,
pobj
.
actionBody
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
}
return
opResult
;
}
}
module
.
exports
=
ProductAPI
;
\ No newline at end of file
center-channel/app/base/api/impl/action/ucommune.js
0 → 100644
View file @
c4e61a5a
var
WEBBase
=
require
(
"../../web.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
ProductAPI
extends
WEBBase
{
constructor
()
{
super
();
this
.
utilsUcommuneSve
=
system
.
getObject
(
"service.utilsSve.utilsUcommuneSve"
);
}
/**
* 优客工厂
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async
springBoard
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
actionType
)
{
return
system
.
getResult
(
null
,
"actionType参数不能为空"
);
}
var
result
=
await
this
.
opActionProcess
(
pobj
,
pobj
.
actionType
,
req
);
return
result
;
}
async
opActionProcess
(
pobj
,
action_type
,
req
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
case
"getUserInfo"
:
// 根据优客token获取用户信息,生成userPin返回前端
opResult
=
await
this
.
utilsUcommuneSve
.
getUserInfo
(
pobj
,
pobj
.
actionBody
);
break
;
case
"orderConfirm"
:
// addOrder后调取支付
opResult
=
await
this
.
utilsUcommuneSve
.
orderConfirm
(
pobj
,
pobj
.
actionBody
);
case
"getOrderList"
:
// 优客调取订单列表用
opResult
=
await
this
.
utilsUcommuneSve
.
getOrderList
(
pobj
,
pobj
.
actionBody
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
}
return
opResult
;
}
}
module
.
exports
=
ProductAPI
;
\ No newline at end of file
center-channel/app/base/service/app.base.js
View file @
c4e61a5a
...
...
@@ -2,6 +2,7 @@ const system = require("../system");
const
moment
=
require
(
'moment'
)
const
settings
=
require
(
"../../config/settings"
);
const
md5
=
require
(
"MD5"
);
const
uuidv4
=
require
(
'uuid/v4'
);
class
AppServiceBase
{
constructor
()
{
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
...
...
@@ -93,6 +94,29 @@ class AppServiceBase {
return
system
.
getResult
(
null
,
errorMsg
);
}
}
async
restPostWithHAuthorizationUrl
(
pobj
,
userToken
,
url
)
{
//curl请求带请求头信息
try
{
var
rtn
=
await
this
.
restClient
.
restPostWithHAuthorizationUrl
(
userToken
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPostWithHAuthorizationUrl data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
catch
(
e
)
{
var
errorMsg
=
"error:"
+
e
.
stack
;
//日志记录
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"service/app.base.js/restPostWithHAuthorizationUrl"
,
content
:
errorMsg
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常->restPostWithHAuthorizationUrl"
,
});
return
system
.
getResult
(
null
,
errorMsg
);
}
}
async
execPostUrl
(
pobj
,
url
)
{
try
{
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
...
...
@@ -378,5 +402,10 @@ class AppServiceBase {
}
return
uuid
.
join
(
''
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
}
module
.
exports
=
AppServiceBase
;
center-channel/app/base/service/impl/utilsSve/utilsUcommuneSve.js
0 → 100644
View file @
c4e61a5a
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
//产品操作类
class
UtilsUcommuneService
extends
AppServiceBase
{
constructor
()
{
super
();
this
.
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
}
//--------------------------------优客工厂相关接口-start-----------------------------------------------------
/**
* 根据优客token获取用户信息,生成userPin返回前端
* @param {*} pobj
* @param {*} actionBody userToken 为优客工厂的userToken
*/
async
getUserInfo
(
pobj
,
actionBody
)
{
if
(
!
actionBody
.
userToken
)
{
return
system
.
getResult
(
null
,
"actionBody.token can not be empty,100410"
);
}
var
url
=
settings
.
ucommuneUrl
()
+
"third/getUserInfo"
;
// 调用优客工场接口 获取用户信息
// 拼接规则curl -k -H 'Content-type: application/json' -H 'authorization:{token}' -X POST {url} pobj作为发生错误时记录日志用
let
result
=
await
this
.
restPostWithHAuthorizationUrl
(
pobj
,
actionBody
.
userToken
,
url
);
if
(
result
.
retCode
==
0
)
{
// 0成功 1失败
pobj
.
actionType
=
"getLoginByUserName"
;
pobj
.
actionBody
.
channelUserId
=
result
.
data
.
mobile
;
pobj
.
actionBody
.
userpin
=
pobj
.
actionBody
.
userpin
||
this
.
getUUID
();
var
tmpOpResult
=
await
this
.
utilsAuthSve
.
getLoginByUserName
(
pobj
,
pobj
.
actionBody
);
if
(
tmpOpResult
.
status
!=
0
&&
tmpOpResult
.
status
!=
2060
)
{
return
tmpOpResult
;
}
return
system
.
getResultSuccess
({
userpin
:
tmpOpResult
.
data
.
userpin
})
}
else
{
// 获取用户信息失败
return
system
.
getResult
(
null
,
"Failed to get user information, 100420"
);
}
}
/**
* 优客调取订单列表用
* @param {*} pobj
* @param {*} actionBody
*/
async
getOrderList
(
pobj
,
actionBody
)
{
var
reqUrl
=
this
.
centerOrderUrl
+
"action/order/springBoard"
;
var
result
=
await
this
.
restPostUrl
(
pobj
,
reqUrl
);
return
result
;
}
/**
* addOrder后前端调取支付用
* @param {*} pobj
* @param {*} actionBody channelItemCode 渠道产品编码
*/
async
orderConfirm
(
pobj
,
actionBody
)
{
}
//--------------------------------优客工厂相关接口--end----------------------------------------------------
}
module
.
exports
=
UtilsUcommuneService
;
center-channel/app/base/utils/restClient.js
View file @
c4e61a5a
...
...
@@ -17,6 +17,8 @@ class RestClient {
this
.
cmdPostPattern2
=
"curl -k -H 'Content-type: application/x-www-form-urlencoded' -d '{data}' {url}"
;
// form-data形式post data参数类型 md5=2&data=1
this
.
cmdPostPattern5
=
"curl -k --data '{data}' {url}"
;
// authorization=[token]
this
.
cmdPostpatternToken
=
"curl -k -H 'Content-type: application/json' -H 'authorization:{token}' -X POST {url}"
}
getUUID
()
{
...
...
@@ -48,6 +50,10 @@ class RestClient {
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
ak
\}
/g
,
hValue
);
return
cmd
;
}
FetchrestPostWithHAuthorizationUrl
(
userToken
,
url
)
{
var
cmd
=
this
.
cmdPostpatternToken
.
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
token
\}
/g
,
userToken
);
return
cmd
;
}
FetchPostCmd2
(
subData
,
url
)
{
var
data
=
subData
;
var
cmd
=
this
.
cmdPostPattern2
.
replace
(
/
\{
data
\}
/g
,
...
...
@@ -122,6 +128,14 @@ class RestClient {
});
return
result
;
}
async
restPostWithHAuthorizationUrl
(
userToken
,
url
)
{
let
cmd
=
this
.
FetchrestPostWithHAuthorizationUrl
(
userToken
,
url
);
console
.
log
(
cmd
,
"cmd............"
);
var
result
=
await
this
.
exec
(
cmd
,
{
maxBuffer
:
1024
*
1024
*
15
});
return
result
;
}
async
execPost2
(
subData
,
url
)
{
let
cmd
=
this
.
FetchPostCmd2
(
subData
,
url
);
console
.
log
(
cmd
);
...
...
center-channel/app/config/settings.js
View file @
c4e61a5a
...
...
@@ -126,6 +126,13 @@ var settings = {
return
"https://fqgirl.gongsibao.com/"
;
}
},
ucommuneUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"https://m-dev.ucommune.com/"
// 优客测试环境
}
else
{
return
"https://m.ucommune.com/"
// 优客正式环境
}
},
apiconfig
:
{
opLogUrl
:
function
()
{
return
settings
.
reqEsAddr
()
+
"center_channel_log/_doc?pretty"
;
...
...
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