Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
黄奎
mall.oytour.com
Commits
f6b795a6
Commit
f6b795a6
authored
Jun 04, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取小程序token
parent
4541dcc5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
AppletLoginController.cs
Mall.WebApi/Controllers/User/AppletLoginController.cs
+41
-0
No files found.
Mall.WebApi/Controllers/User/AppletLoginController.cs
View file @
f6b795a6
...
@@ -19,6 +19,7 @@ using JWT.Algorithms;
...
@@ -19,6 +19,7 @@ using JWT.Algorithms;
using
JWT.Serializers
;
using
JWT.Serializers
;
using
Mall.Common.Enum
;
using
Mall.Common.Enum
;
using
Mall.CacheKey
;
using
Mall.CacheKey
;
using
Mall.Common.Pay.WeChatPat
;
namespace
Mall.WebApi.Controllers.User
namespace
Mall.WebApi.Controllers.User
{
{
...
@@ -193,6 +194,46 @@ namespace Mall.WebApi.Controllers.User
...
@@ -193,6 +194,46 @@ namespace Mall.WebApi.Controllers.User
}
}
}
}
/// <summary>
/// 获取小程序token
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetMallToken
(
object
requestMsg
)
{
var
requestParm
=
JsonConvert
.
DeserializeObject
<
RequestParm
>(
requestMsg
.
ToString
());
if
(
requestParm
.
TenantId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递商户号"
);
}
if
(
requestParm
.
MallBaseId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递小程序id"
);
}
var
appletWeChatModel
=
programModule
.
GetMiniProgramModule
(
new
RB_MiniProgram_Extend
()
{
MallBaseId
=
requestParm
.
MallBaseId
});
if
(
appletWeChatModel
==
null
)
{
return
ApiResult
.
ParamIsNull
(
"小程序不存在"
);
}
if
(
appletWeChatModel
.
TenantId
!=
requestParm
.
TenantId
)
{
return
ApiResult
.
ParamIsNull
(
"商户号错误"
);
}
string
token
=
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Get
(
appletWeChatModel
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
TokenHelper
.
GetLXYToken
(
token
,
appletWeChatModel
.
MiniAppId
,
appletWeChatModel
.
MiniAppSecret
);
Task
.
Run
(()
=>
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Set
(
appletWeChatModel
.
MiniAppId
,
token
));
}
if
(!
string
.
IsNullOrEmpty
(
token
))
{
return
ApiResult
.
Success
(
""
,
token
);
}
else
{
return
ApiResult
.
Failed
();
}
}
#
endregion
#
endregion
}
}
}
}
\ No newline at end of file
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