Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
dec1aeff
Commit
dec1aeff
authored
Apr 30, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add transferCustomerService
parent
1d732172
Pipeline
#22613
passed with stage
in 3 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
+19
-7
test.js
app/controller/common/test.js
+12
-5
user.js
app/service/course/v5/user.js
+1
-1
wechat.js
app/service/course/v5/wechat.js
+6
-1
No files found.
app/controller/common/test.js
View file @
dec1aeff
'use strict'
;
'use strict'
;
const
xml2js
=
require
(
'xml2js'
);
const
Controller
=
require
(
'egg'
).
Controller
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
TestController
extends
Controller
{
class
TestController
extends
Controller
{
async
test
()
{
async
test
()
{
const
{
service
,
ctx
}
=
this
;
this
.
ctx
.
set
(
'content-type'
,
'text/xml'
);
const
from
=
{
lng
:
120.069206
,
lat
:
30.291121
};
const
data
=
{
const
to
=
{
lng
:
120.212997
,
lat
:
30.29133
};
MsgType
:
'transfer_customer_service'
,
const
ret
=
await
service
.
course
.
lbs
.
getLBSDistance
(
'walking'
,
from
,
[
to
,
to
]);
ToUserName
:
'to'
,
ctx
.
success
(
ret
);
FromUserName
:
'from'
,
CreateTime
:
parseInt
(
new
Date
()
/
1000
),
};
const
builder
=
new
xml2js
.
Builder
();
const
xml
=
builder
.
buildObject
(
data
);
this
.
ctx
.
body
=
xml
;
console
.
log
(
this
.
ctx
);
}
}
}
}
module
.
exports
=
TestController
;
module
.
exports
=
TestController
;
app/service/course/v5/user.js
View file @
dec1aeff
...
@@ -124,6 +124,7 @@ class UserService extends Service {
...
@@ -124,6 +124,7 @@ class UserService extends Service {
if
(
ctx
.
isEmpty
(
userInfo
))
{
if
(
ctx
.
isEmpty
(
userInfo
))
{
const
uuid
=
uuidV4
();
const
uuid
=
uuidV4
();
userInfo
=
await
ctx
.
classModel
.
V5
.
CourseUser
.
findOrCreate
({
where
:
{
openid
,
is_deleted
:
0
},
defaults
:
{
uuid
,
openid
}
});
userInfo
=
await
ctx
.
classModel
.
V5
.
CourseUser
.
findOrCreate
({
where
:
{
openid
,
is_deleted
:
0
},
defaults
:
{
uuid
,
openid
}
});
userInfo
=
await
ctx
.
classModel
.
V5
.
CourseUser
.
findOne
({
where
:
{
openid
,
is_deleted
:
0
}
});
}
}
// 存储缓存标识
// 存储缓存标识
...
@@ -138,7 +139,6 @@ class UserService extends Service {
...
@@ -138,7 +139,6 @@ class UserService extends Service {
await
app
.
memcache
.
set
(
key
,
value
,
7
*
24
*
3600
);
await
app
.
memcache
.
set
(
key
,
value
,
7
*
24
*
3600
);
const
authToken
=
await
this
.
service
.
jwt
.
apply
({
user_uuid
:
userInfo
.
uuid
,
openid
:
userInfo
.
openid
});
const
authToken
=
await
this
.
service
.
jwt
.
apply
({
user_uuid
:
userInfo
.
uuid
,
openid
:
userInfo
.
openid
});
await
app
.
memcache
.
set
(
'course_auth_token_'
+
userInfo
.
uuid
,
authToken
,
7
*
24
*
3600
);
await
app
.
memcache
.
set
(
'course_auth_token_'
+
userInfo
.
uuid
,
authToken
,
7
*
24
*
3600
);
JSON
.
s
;
const
ret
=
{
const
ret
=
{
user_uuid
:
userInfo
.
uuid
,
user_uuid
:
userInfo
.
uuid
,
openid
:
userInfo
.
openid
,
openid
:
userInfo
.
openid
,
...
...
app/service/course/v5/wechat.js
View file @
dec1aeff
...
@@ -5,6 +5,7 @@ const SECRET = 'a1b2d32b018988176181497bd74a0b7d';
...
@@ -5,6 +5,7 @@ const SECRET = 'a1b2d32b018988176181497bd74a0b7d';
const
fs
=
require
(
'fs'
);
const
fs
=
require
(
'fs'
);
const
request
=
require
(
'request'
);
const
request
=
require
(
'request'
);
const
crypto
=
require
(
'crypto'
);
const
crypto
=
require
(
'crypto'
);
const
xml2js
=
require
(
'xml2js'
);
class
WechatService
extends
Service
{
class
WechatService
extends
Service
{
async
getAccessToken
()
{
async
getAccessToken
()
{
...
@@ -49,12 +50,16 @@ class WechatService extends Service {
...
@@ -49,12 +50,16 @@ class WechatService extends Service {
}
}
if
(
!
flag
)
{
if
(
!
flag
)
{
return
{
this
.
ctx
.
set
(
'content-type'
,
'text/xml'
);
let
xml
=
{
MsgType
:
'transfer_customer_service'
,
MsgType
:
'transfer_customer_service'
,
ToUserName
:
data
.
FromUserName
,
ToUserName
:
data
.
FromUserName
,
FromUserName
:
data
.
ToUserName
,
FromUserName
:
data
.
ToUserName
,
CreateTime
:
parseInt
(
new
Date
()
/
1000
),
CreateTime
:
parseInt
(
new
Date
()
/
1000
),
};
};
const
builder
=
new
xml2js
.
Builder
();
xml
=
builder
.
buildObject
(
xml
);
this
.
ctx
.
body
=
xml
;
}
}
return
;
return
;
}
}
...
...
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