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
b064bf4c
Commit
b064bf4c
authored
Sep 22, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
d774bc62
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
3 deletions
+111
-3
UserReidsCache.cs
Mall.CacheManager/User/UserReidsCache.cs
+55
-0
UserInfo.cs
Mall.Common/API/UserInfo.cs
+8
-0
WeiXinHelper.cs
Mall.Common/Plugin/WeiXinHelper.cs
+35
-1
AppletSchoolController.cs
Mall.WebApi/Controllers/Education/AppletSchoolController.cs
+1
-0
MallController.cs
Mall.WebApi/Controllers/Mall/MallController.cs
+12
-2
No files found.
Mall.CacheManager/User/UserReidsCache.cs
View file @
b064bf4c
...
@@ -86,6 +86,61 @@ namespace Mall.CacheManager.User
...
@@ -86,6 +86,61 @@ namespace Mall.CacheManager.User
/// </summary>
/// </summary>
private
static
readonly
Repository
.
User
.
RB_Login_LogRepository
login_LogRepository
=
new
Repository
.
User
.
RB_Login_LogRepository
();
private
static
readonly
Repository
.
User
.
RB_Login_LogRepository
login_LogRepository
=
new
Repository
.
User
.
RB_Login_LogRepository
();
/// <summary>
/// 缓存用户OpenId
/// </summary>
/// <param name="TenantId">商户Id</param>
/// <returns></returns>
public
static
void
SetMiniAppUsetOpenId
(
string
cacheKey
,
MiniAppUserCache
cacheModel
)
{
try
{
TimeSpan
ts
=
GetExpirTime
(
Config
.
JwtExpirTime
);
redis
.
StringSet
<
MiniAppUserCache
>(
cacheKey
,
cacheModel
,
ts
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"SetMiniAppUsetOpenId"
);
}
}
/// <summary>
/// 获取缓存用户OpenId
/// </summary>
/// <param name="TenantId">商户Id</param>
/// <returns></returns>
public
static
MiniAppUserCache
GetMiniAppUsetOpenId
(
string
cacheKey
)
{
MiniAppUserCache
miniAppUserCache
=
null
;
try
{
miniAppUserCache
=
redis
.
StringGet
<
MiniAppUserCache
>(
cacheKey
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"SetMiniAppUsetOpenId"
);
}
return
miniAppUserCache
;
}
/// <summary>
/// 删除OpenId缓存
/// </summary>
/// <param name="TenantId">商户Id</param>
/// <returns></returns>
public
static
void
DeleteMiniAppUsetOpenId
(
string
cacheKey
)
{
try
{
redis
.
KeyDelete
(
cacheKey
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"DeleteMiniAppUsetOpenId"
);
}
}
/// <summary>
/// <summary>
/// 获取用户登录信息
/// 获取用户登录信息
/// </summary>
/// </summary>
...
...
Mall.Common/API/UserInfo.cs
View file @
b064bf4c
...
@@ -158,4 +158,12 @@ namespace Mall.Common
...
@@ -158,4 +158,12 @@ namespace Mall.Common
public
int
ERPGroupId
{
get
;
set
;
}
public
int
ERPGroupId
{
get
;
set
;
}
}
}
public
class
MiniAppUserCache
{
/// <summary>
/// 用户OpenId
/// </summary>
public
string
UserOpenId
{
get
;
set
;
}
}
}
}
Mall.Common/Plugin/WeiXinHelper.cs
View file @
b064bf4c
...
@@ -47,7 +47,7 @@ namespace Mall.Common.Plugin
...
@@ -47,7 +47,7 @@ namespace Mall.Common.Plugin
{
{
//请求路径
//请求路径
string
url
=
"https://api.weixin.qq.com/sns/jscode2session?appid="
+
AppId
+
"&secret="
+
AppSecret
+
"&js_code="
+
Code
+
"&grant_type=authorization_code"
;
string
url
=
"https://api.weixin.qq.com/sns/jscode2session?appid="
+
AppId
+
"&secret="
+
AppSecret
+
"&js_code="
+
Code
+
"&grant_type=authorization_code"
;
result
=
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
url
);
result
=
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
url
);
if
(
result
!=
null
&&
!
string
.
IsNullOrEmpty
(
result
))
if
(
result
!=
null
&&
!
string
.
IsNullOrEmpty
(
result
))
{
{
JObject
jObj
=
JObject
.
Parse
(
result
);
JObject
jObj
=
JObject
.
Parse
(
result
);
...
@@ -66,6 +66,40 @@ namespace Mall.Common.Plugin
...
@@ -66,6 +66,40 @@ namespace Mall.Common.Plugin
return
openid
;
return
openid
;
}
}
/// <summary>
/// 验证OpenId是否有效
/// </summary>
/// <param name="AppId"></param>
/// <param name="AppSecret"></param>
/// <param name="OpenId"></param>
/// <returns></returns>
public
static
int
ValidateOpenId
(
string
AppId
,
string
AppSecret
,
string
OpenId
)
{
string
result
=
""
;
string
access_token
=
""
;
try
{
//请求路径
string
url
=
string
.
Format
(
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}"
,
AppId
,
AppSecret
);
result
=
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
url
);
if
(
result
!=
null
&&
!
string
.
IsNullOrEmpty
(
result
))
{
JObject
jObj
=
JObject
.
Parse
(
result
);
access_token
=
jObj
[
"access_token"
].
ToString
();
}
if
(!
string
.
IsNullOrWhiteSpace
(
access_token
))
{
string
TestUrl
=
string
.
Format
(
"https://api.weixin.qq.com/sns/auth?access_token={0}&openid={1}"
,
access_token
,
OpenId
);
result
=
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
TestUrl
);
}
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"GetWeChatAccessToken:result="
+
result
);
}
return
1
;
}
/// <summary>
/// <summary>
/// 获取微信订阅消息模板
/// 获取微信订阅消息模板
/// </summary>
/// </summary>
...
...
Mall.WebApi/Controllers/Education/AppletSchoolController.cs
View file @
b064bf4c
...
@@ -566,6 +566,7 @@ namespace Mall.WebApi.Controllers.Education
...
@@ -566,6 +566,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
[
HttpPost
]
[
HttpPost
]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
public
ApiResult
GetEducationStartUpModel
(
object
requestMsg
)
public
ApiResult
GetEducationStartUpModel
(
object
requestMsg
)
{
{
var
parms
=
JsonConvert
.
DeserializeObject
<
RequestParm
>(
requestMsg
.
ToString
());
var
parms
=
JsonConvert
.
DeserializeObject
<
RequestParm
>(
requestMsg
.
ToString
());
...
...
Mall.WebApi/Controllers/Mall/MallController.cs
View file @
b064bf4c
...
@@ -4,6 +4,7 @@ using System.Linq;
...
@@ -4,6 +4,7 @@ using System.Linq;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Dnc.Api.Throttle
;
using
Dnc.Api.Throttle
;
using
Mall.CacheManager.User
;
using
Mall.CacheManager.User
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Common.Plugin
;
using
Mall.Model.Entity.BaseSetUp
;
using
Mall.Model.Entity.BaseSetUp
;
...
@@ -481,7 +482,8 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -481,7 +482,8 @@ namespace Mall.WebApi.Controllers.MallBase
/// <returns></returns>
/// <returns></returns>
[
HttpGet
]
[
HttpGet
]
[
HttpPost
]
[
HttpPost
]
[
AllowAnonymous
]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
[
AllowAnonymous
]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
public
ApiResult
GetAppConfig
()
public
ApiResult
GetAppConfig
()
{
{
string
MiniAppId
=
""
;
string
MiniAppId
=
""
;
...
@@ -713,8 +715,16 @@ namespace Mall.WebApi.Controllers.MallBase
...
@@ -713,8 +715,16 @@ namespace Mall.WebApi.Controllers.MallBase
{
{
openId
=
Common
.
Plugin
.
WeiXinHelper
.
GetWeChatOpenId
(
miniProgram
.
MiniAppId
,
miniProgram
.
MiniAppSecret
,
code
);
openId
=
Common
.
Plugin
.
WeiXinHelper
.
GetWeChatOpenId
(
miniProgram
.
MiniAppId
,
miniProgram
.
MiniAppSecret
,
code
);
}
}
//string newOpenId = "oyEzY5J8llEXYMeC2O7Y06g2SO4M";
//Common.Plugin.WeiXinHelper.GetWeChat(miniProgram.MiniAppId, miniProgram.MiniAppSecret, newOpenId);
}
}
return
ApiResult
.
Success
(
data
:
openId
);
var
newGuid
=
Guid
.
NewGuid
().
ToString
();
var
miniAppUserCache
=
new
MiniAppUserCache
()
{
UserOpenId
=
openId
};
UserReidsCache
.
SetMiniAppUsetOpenId
(
newGuid
,
miniAppUserCache
);
return
ApiResult
.
Success
(
data
:
newGuid
);
}
}
/// <summary>
/// <summary>
...
...
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