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
05763a49
Commit
05763a49
authored
Oct 12, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增UnionId解析
parent
4f11ca23
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
11 deletions
+59
-11
AppletUserInfo.cs
Mall.Common/API/AppletUserInfo.cs
+8
-0
UserInfo.cs
Mall.Common/API/UserInfo.cs
+5
-0
WeiXinHelper.cs
Mall.Common/Plugin/WeiXinHelper.cs
+7
-4
RB_Member_User.cs
Mall.Model/Entity/User/RB_Member_User.cs
+5
-0
UserModule.cs
Mall.Module.User/UserModule.cs
+24
-0
MallController.cs
Mall.WebApi/Controllers/Mall/MallController.cs
+2
-6
AppletLoginController.cs
Mall.WebApi/Controllers/User/AppletLoginController.cs
+8
-1
No files found.
Mall.Common/API/AppletUserInfo.cs
View file @
05763a49
...
...
@@ -58,6 +58,14 @@ namespace Mall.Common
set
;
}
/// <summary>
/// UnionId
/// </summary>
public
string
Unoinid
{
get
;
set
;
}
/// <summary>
///
///
...
...
Mall.Common/API/UserInfo.cs
View file @
05763a49
...
...
@@ -165,5 +165,10 @@ namespace Mall.Common
/// 用户OpenId
/// </summary>
public
string
UserOpenId
{
get
;
set
;
}
/// <summary>
/// 用户UnionId
/// </summary>
public
string
UserUnoinid
{
get
;
set
;
}
}
}
Mall.Common/Plugin/WeiXinHelper.cs
View file @
05763a49
...
...
@@ -40,10 +40,10 @@ namespace Mall.Common.Plugin
/// <param name="AppSecret"></param>
/// <param name="Code"></param>
/// <returns></returns>
public
static
string
GetWeChatOpenId
(
string
AppId
,
string
AppSecret
,
string
Code
)
public
static
MiniAppUserCache
GetWeChatOpenId
(
string
AppId
,
string
AppSecret
,
string
Code
)
{
MiniAppUserCache
miniAppUserCache
=
new
MiniAppUserCache
();
string
result
=
""
;
string
openid
=
""
;
try
{
//请求路径
...
...
@@ -52,7 +52,8 @@ namespace Mall.Common.Plugin
if
(
result
!=
null
&&
!
string
.
IsNullOrEmpty
(
result
))
{
JObject
jObj
=
JObject
.
Parse
(
result
);
openid
=
jObj
[
"openid"
].
ToString
();
miniAppUserCache
.
UserOpenId
=
jObj
[
"openid"
].
ToString
();
miniAppUserCache
.
UserUnoinid
=
jObj
[
"unionid"
].
ToString
();
}
}
catch
(
Exception
ex
)
...
...
@@ -64,9 +65,11 @@ namespace Mall.Common.Plugin
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetWeChatOpenId:result={0}&&Code={1}"
,
result
,
Code
));
}
}
return
openid
;
return
miniAppUserCache
;
}
/// <summary>
/// 验证OpenId是否有效
/// </summary>
...
...
Mall.Model/Entity/User/RB_Member_User.cs
View file @
05763a49
...
...
@@ -264,5 +264,10 @@ namespace Mall.Model.Entity.User
/// 查看次数
/// </summary>
public
int
LookTimes
{
get
;
set
;
}
/// <summary>
/// UnionId唯一Id
/// </summary>
public
string
Unoinid
{
get
;
set
;
}
}
}
Mall.Module.User/UserModule.cs
View file @
05763a49
...
...
@@ -312,6 +312,30 @@ namespace Mall.Module.User
return
result
;
}
/// <summary>
/// 更新用户UnionId
/// </summary>
/// <param name="UnionId"></param>
/// <param name="Id"></param>
/// <returns></returns>
public
bool
UpdateMemberUserUnionId
(
string
UnionId
,
int
Id
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User_Extend
.
Unoinid
),
UnionId
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_User
.
Id
),
FiledValue
=
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
bool
flag
=
member_UserRepository
.
Update
(
fileds
,
wheres
);
return
flag
;
}
/// <summary>
/// 验证用户是否存在
/// </summary>
...
...
Mall.WebApi/Controllers/Mall/MallController.cs
View file @
05763a49
...
...
@@ -714,20 +714,16 @@ namespace Mall.WebApi.Controllers.MallBase
{
JObject
parms
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
string
code
=
parms
.
GetStringValue
(
"Code"
);
string
openId
=
""
;
MiniAppUserCache
miniAppUserCache
=
new
MiniAppUserCache
()
;
if
(
RequestParm
.
MiniAppId
!=
null
&&
!
string
.
IsNullOrWhiteSpace
(
RequestParm
.
MiniAppId
))
{
var
miniProgram
=
programModule
.
GetMiniProgramModule
(
new
Model
.
Extend
.
User
.
RB_MiniProgram_Extend
()
{
MiniAppId
=
RequestParm
.
MiniAppId
});
if
(
miniProgram
!=
null
&&
miniProgram
.
MallBaseId
>
0
)
{
openId
=
Common
.
Plugin
.
WeiXinHelper
.
GetWeChatOpenId
(
miniProgram
.
MiniAppId
,
miniProgram
.
MiniAppSecret
,
code
);
miniAppUserCache
=
Common
.
Plugin
.
WeiXinHelper
.
GetWeChatOpenId
(
miniProgram
.
MiniAppId
,
miniProgram
.
MiniAppSecret
,
code
);
}
}
var
newGuid
=
"MiniAppOpenId_"
+
Guid
.
NewGuid
().
ToString
();
var
miniAppUserCache
=
new
MiniAppUserCache
()
{
UserOpenId
=
openId
};
UserReidsCache
.
SetMiniAppUsetOpenId
(
newGuid
,
miniAppUserCache
);
return
ApiResult
.
Success
(
data
:
newGuid
);
}
...
...
Mall.WebApi/Controllers/User/AppletLoginController.cs
View file @
05763a49
...
...
@@ -136,6 +136,7 @@ namespace Mall.WebApi.Controllers.User
{
UserReidsCache
.
DeleteMiniAppUsetOpenId
(
demodel
.
OpenId
);
demodel
.
OpenId
=
opcache
.
UserOpenId
;
demodel
.
Unoinid
=
opcache
.
UserUnoinid
;
}
else
{
...
...
@@ -282,6 +283,7 @@ namespace Mall.WebApi.Controllers.User
TenantId
=
demodel
.
TenantId
,
Name
=
demodel
.
Name
,
OpenId
=
demodel
.
OpenId
,
Unoinid
=
demodel
.
Unoinid
,
Photo
=
demodel
.
Photo
,
MemberGradeId
=
demodel
.
MemberGrade
??
0
,
Source
=
demodel
.
Source
,
...
...
@@ -356,11 +358,15 @@ namespace Mall.WebApi.Controllers.User
{
return
ApiResult
.
Failed
(
"账号已被冻结,请联系运营商"
);
}
//更新用户UnionId
if
(
string
.
IsNullOrEmpty
(
umodel
.
Unoinid
)
&&
!
string
.
IsNullOrEmpty
(
demodel
.
Unoinid
))
{
userModule
.
UpdateMemberUserUnionId
(
demodel
.
Unoinid
,
umodel
.
Id
);
}
//自动发放新人优惠券 2020-12-31 Add By:W
if
(
demodel
.
CounponPassword
==
5
&&
!
string
.
IsNullOrWhiteSpace
(
demodel
.
KeyWord
))
{
couponResult
=
couponModule
.
AutoCoupon
(
new
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
{
UserId
=
umodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
TriggerType
=
5
,
KeyWord
=
demodel
.
KeyWord
});
if
(
couponResult
!=
null
&&
couponResult
.
ID
>
0
)
{
couponName
=
couponResult
.
Name
;
...
...
@@ -385,6 +391,7 @@ namespace Mall.WebApi.Controllers.User
TenantId
=
umodel
.
TenantId
,
Name
=
umodel
.
Name
,
OpenId
=
umodel
.
OpenId
,
Unoinid
=!
string
.
IsNullOrEmpty
(
umodel
.
Unoinid
)?
umodel
.
Unoinid
:
demodel
.
Unoinid
,
Photo
=
umodel
.
Photo
,
MemberGradeId
=
umodel
.
MemberGrade
??
0
,
Source
=
demodel
.
Source
,
...
...
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