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
534f27c8
Commit
534f27c8
authored
May 29, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户转移
parent
c959be65
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
256 additions
and
6 deletions
+256
-6
TokenHelper.cs
Mall.Common/Pay/WeChatPat/TokenHelper.cs
+51
-2
HttpHelper.cs
Mall.Common/Plugin/HttpHelper.cs
+5
-1
RB_Member_User_Extend.cs
Mall.Model/Extend/User/RB_Member_User_Extend.cs
+9
-0
GoodsImport.cs
Mall.Model/Query/GoodsImport.cs
+17
-1
UserModule.cs
Mall.Module.User/UserModule.cs
+104
-0
RB_Member_UserRepository.cs
Mall.Repository/User/RB_Member_UserRepository.cs
+12
-2
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+58
-0
No files found.
Mall.Common/Pay/WeChatPat/TokenHelper.cs
View file @
534f27c8
...
@@ -12,8 +12,6 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -12,8 +12,6 @@ namespace Mall.Common.Pay.WeChatPat
public
class
TokenHelper
public
class
TokenHelper
{
{
/// <summary>
/// <summary>
/// 获取token
/// 获取token
/// </summary>
/// </summary>
...
@@ -41,7 +39,58 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -41,7 +39,58 @@ namespace Mall.Common.Pay.WeChatPat
return
token
;
return
token
;
}
}
/// <summary>
/// 获取微信用户头像
/// </summary>
/// <param name="access_token"></param>
/// <param name="openid"></param>
/// <returns></returns>
public
static
string
GetWeiXinUserPhoto
(
string
access_token
,
string
openid
)
{
openid
=
openid
.
Replace
(
"/t"
,
""
);
string
url
=
"https://api.weixin.qq.com/cgi-bin/user/info?access_token="
+
access_token
+
"&openid="
+
openid
+
"&lang=zh_CN"
;
//string url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + "&lang=zh_CN";
string
type
=
"utf-8"
;
Mall
.
Common
.
Plugin
.
GetUsersHelper
GetUsersHelper
=
new
Mall
.
Common
.
Plugin
.
GetUsersHelper
();
string
wenXinResult
=
string
.
Empty
;
string
Photo
=
""
;
try
{
wenXinResult
=
GetUsersHelper
.
GetUrltoHtml
(
url
,
type
);
var
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
Photo
=
jo
[
"headimgurl"
].
ToString
();
}
catch
(
Exception
ex
)
{
Plugin
.
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetWx:GetWeiXinUserPhoto:{0}"
,
wenXinResult
));
}
return
Photo
;
}
/// <summary>
/// 获取赞羊下级用户
/// </summary>
/// <param name="UserId"></param>
/// <returns></returns>
public
static
string
GetZYUserInfo
(
int
UserId
,
string
cookie
)
{
string
url
=
"http://wx.weibaoge.cn/web/index.php?r=mall%2Fshare%2Fteam&status=1&id="
+
UserId
;
string
wenXinResult
=
string
.
Empty
;
string
data
=
""
;
try
{
wenXinResult
=
Mall
.
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
url
,
System
.
Text
.
Encoding
.
UTF8
,
""
,
cookie
);
var
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
if
(
jo
[
"code"
].
ToString
()
==
"0"
)
{
data
=
jo
[
"data"
].
ToString
();
}
}
catch
(
Exception
ex
)
{
Plugin
.
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetZYUserInfo:{0}"
,
wenXinResult
));
}
return
data
;
}
}
}
...
...
Mall.Common/Plugin/HttpHelper.cs
View file @
534f27c8
...
@@ -65,13 +65,17 @@ namespace Mall.Common.Plugin
...
@@ -65,13 +65,17 @@ namespace Mall.Common.Plugin
/// <param name="encode">编码方式</param>
/// <param name="encode">编码方式</param>
/// <param name="Source">来源</param>
/// <param name="Source">来源</param>
/// <returns></returns>
/// <returns></returns>
public
static
string
HttpGet
(
string
url
,
Encoding
encode
,
string
Source
)
public
static
string
HttpGet
(
string
url
,
Encoding
encode
,
string
Source
,
string
cookie
=
""
)
{
{
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
if
(!
string
.
IsNullOrEmpty
(
Source
))
if
(!
string
.
IsNullOrEmpty
(
Source
))
{
{
myRequest
.
Referer
=
Source
;
myRequest
.
Referer
=
Source
;
}
}
if
(!
string
.
IsNullOrEmpty
(
cookie
))
{
myRequest
.
Headers
.
Add
(
"cookie"
,
cookie
);
}
myRequest
.
Method
=
"GET"
;
myRequest
.
Method
=
"GET"
;
HttpWebResponse
myResponse
=
null
;
HttpWebResponse
myResponse
=
null
;
try
try
...
...
Mall.Model/Extend/User/RB_Member_User_Extend.cs
View file @
534f27c8
...
@@ -13,6 +13,10 @@ namespace Mall.Model.Extend.User
...
@@ -13,6 +13,10 @@ namespace Mall.Model.Extend.User
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Member_User_Extend
:
RB_Member_User
public
class
RB_Member_User_Extend
:
RB_Member_User
{
{
/// <summary>
/// 是否用户头像为空 1是 2否
/// </summary>
public
int
?
IsEmptyUserPhoto
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 会员等级名称
/// 会员等级名称
/// </summary>
/// </summary>
...
@@ -28,6 +32,11 @@ namespace Mall.Model.Extend.User
...
@@ -28,6 +32,11 @@ namespace Mall.Model.Extend.User
/// </summary>
/// </summary>
public
string
UserIds
{
get
;
set
;
}
public
string
UserIds
{
get
;
set
;
}
/// <summary>
/// 获取用户
/// </summary>
public
int
?
MinUserId
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 用户名str
/// 用户名str
/// </summary>
/// </summary>
...
...
Mall.Model/Query/GoodsImport.cs
View file @
534f27c8
...
@@ -104,7 +104,7 @@ namespace Mall.Model.Query
...
@@ -104,7 +104,7 @@ namespace Mall.Model.Query
/// 赞羊区域导入
/// 赞羊区域导入
/// </summary>
/// </summary>
[
Serializable
]
[
Serializable
]
public
class
GoodsAreaListImport
{
public
class
GoodsAreaListImport
{
/// <summary>
/// <summary>
/// 列表
/// 列表
/// </summary>
/// </summary>
...
@@ -127,4 +127,20 @@ namespace Mall.Model.Query
...
@@ -127,4 +127,20 @@ namespace Mall.Model.Query
public
string
name
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
}
}
/// <summary>
/// 用户下级
/// </summary>
[
Serializable
]
public
class
UserSuperiorImport
{
/// <summary>
/// 昵称
/// </summary>
public
string
nickname
{
get
;
set
;
}
/// <summary>
/// 加入时间
/// </summary>
public
string
junior_at
{
get
;
set
;
}
}
}
}
Mall.Module.User/UserModule.cs
View file @
534f27c8
...
@@ -16,6 +16,8 @@ using Newtonsoft.Json;
...
@@ -16,6 +16,8 @@ using Newtonsoft.Json;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Common.Enum.User
;
using
Mall.Common.Enum.User
;
using
Mall.Common.API
;
using
Mall.Common.API
;
using
Newtonsoft.Json.Linq
;
using
System.Threading
;
namespace
Mall.Module.User
namespace
Mall.Module.User
{
{
...
@@ -2665,6 +2667,108 @@ namespace Mall.Module.User
...
@@ -2665,6 +2667,108 @@ namespace Mall.Module.User
#
endregion
#
endregion
#
region
用户转移
/// <summary>
/// 更新用户微信头像
/// </summary>
/// <param name="userId"></param>
/// <param name="count"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
bool
UpdateUserPhotoForWeiXin
(
int
userId
,
int
count
,
int
tenantId
,
int
mallBaseId
)
{
var
list
=
member_UserRepository
.
GetPageList
(
1
,
count
,
out
long
rcount
,
new
RB_Member_User_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
Id
=
userId
,
Source
=
UserSourceEnum
.
WeiXin
,
IsEmptyUserPhoto
=
1
});
var
appletWeChatModel
=
miniProgramRepository
.
GetEntity
(
mallBaseId
);
string
token
=
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Get
(
appletWeChatModel
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetLXYToken
(
token
,
appletWeChatModel
.
MiniAppId
,
appletWeChatModel
.
MiniAppSecret
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
CacheManager
.
AppletWeChat
.
WeiXinReidsCache
.
Set
(
appletWeChatModel
.
MiniAppId
,
token
));
}
foreach
(
var
item
in
list
)
{
string
photo
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetWeiXinUserPhoto
(
token
,
item
.
OpenId
);
if
(!
string
.
IsNullOrEmpty
(
photo
))
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User
.
Photo
),
photo
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_User
.
Id
),
FiledValue
=
item
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
member_UserRepository
.
Update
(
keyValues
,
wheres
);
}
}
return
true
;
}
/// <summary>
/// 更新用户上下级关系
/// </summary>
/// <param name="userId"></param>
/// <param name="count"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
int
UpdateUserSuperiorForWeiXin
(
int
userId
,
int
count
,
int
tenantId
,
int
mallBaseId
)
{
string
cookie
=
"__login_route=%2Fadmin%2Fpassport%2Flogin; __login_role=admin; search={'keyword':'','status':' - 1','sort_prop':'','sort_type':'','cats'[],'date_start':null,'date_end':null}; HJ_SESSION_ID=kmmormovvm2u9qh5drkgsbj1ta; _csrf=7a980bb65eabe0ac3d77199092030044b17ae9779de00eaed628c8095ab2fe0ca%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22rsnZWVWkZkpfvVhLBXu8sGG3px0Dgcsx%22%3B%7D"
;
var
list
=
member_UserRepository
.
GetPageList
(
1
,
count
,
out
long
rcount
,
new
RB_Member_User_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
MinUserId
=
userId
,
Source
=
UserSourceEnum
.
WeiXin
});
foreach
(
var
item
in
list
)
{
string
data
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetZYUserInfo
(
item
.
Id
,
cookie
);
if
(!
string
.
IsNullOrEmpty
(
data
))
{
var
data1
=
Encoding
.
GetEncoding
(
"GBK"
).
GetBytes
(
data
);
data
=
Encoding
.
GetEncoding
(
"GBK"
).
GetString
(
data1
);
var
jdata
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
data
);
var
List
=
jdata
[
"list"
].
ToString
();
if
(
List
!=
""
&&
List
!=
"[]"
)
{
//根据用户名 查询一次用户列表
List
<
Model
.
Query
.
UserSuperiorImport
>
UserList
=
JsonConvert
.
DeserializeObject
<
List
<
Model
.
Query
.
UserSuperiorImport
>>(
List
);
foreach
(
var
uitem
in
UserList
)
{
uitem
.
nickname
=
uitem
.
nickname
.
Replace
(
"'"
,
"\""
);
uitem
.
nickname
=
uitem
.
nickname
.
Replace
(
"??"
,
"?"
);
if
(
uitem
.
nickname
.
Length
>
20
)
{
uitem
.
nickname
=
"'"
+
uitem
.
nickname
[..
20
]
+
"'"
;
}
else
{
uitem
.
nickname
=
"'"
+
uitem
.
nickname
.
Replace
(
"'"
,
""
)
+
"\t'"
;
}
}
string
UserNameStr
=
string
.
Join
(
","
,
UserList
.
Select
(
x
=>
x
.
nickname
));
var
uList
=
member_UserRepository
.
GetList
(
new
RB_Member_User_Extend
()
{
UserNameStr
=
UserNameStr
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
foreach
(
var
qitem
in
uList
)
{
if
(
qitem
.
SuperiorId
==
0
)
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User
.
SuperiorId
),
item
.
Id
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_User
.
Id
),
FiledValue
=
qitem
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
member_UserRepository
.
Update
(
keyValues
,
wheres
);
}
}
}
}
}
return
list
.
Max
(
x
=>
x
.
Id
);
}
#
endregion
#
region
数据统计
-
分销排行
#
region
数据统计
-
分销排行
/// <summary>
/// <summary>
/// 分页列表
/// 分页列表
...
...
Mall.Repository/User/RB_Member_UserRepository.cs
View file @
534f27c8
...
@@ -33,7 +33,7 @@ namespace Mall.Repository.User
...
@@ -33,7 +33,7 @@ namespace Mall.Repository.User
}
}
if
(
dmodel
.
Id
>
0
)
{
if
(
dmodel
.
Id
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Member_User
.
Id
)}
=
{
dmodel
.
Id
}
"
;
where
+=
$@" and
{
nameof
(
RB_Member_User
.
Id
)}
=
{
dmodel
.
Id
}
"
;
}
}
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
Name
))
{
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
Name
))
{
where
+=
$@" and
{
nameof
(
RB_Member_User
.
Name
)}
like '%
{
dmodel
.
Name
}
%'"
;
where
+=
$@" and
{
nameof
(
RB_Member_User
.
Name
)}
like '%
{
dmodel
.
Name
}
%'"
;
}
}
...
@@ -52,8 +52,18 @@ namespace Mall.Repository.User
...
@@ -52,8 +52,18 @@ namespace Mall.Repository.User
if
(
dmodel
.
SuperiorId
>
0
)
{
if
(
dmodel
.
SuperiorId
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Member_User
.
SuperiorId
)}
=
{
dmodel
.
SuperiorId
}
"
;
where
+=
$@" and
{
nameof
(
RB_Member_User
.
SuperiorId
)}
=
{
dmodel
.
SuperiorId
}
"
;
}
}
if
(
dmodel
.
IsEmptyUserPhoto
==
1
)
{
where
+=
$@" and IFNULL(
{
nameof
(
RB_Member_User
.
Photo
)}
,'')=''"
;
}
string
orderBy
=
"CreateDate desc"
;
if
(
dmodel
.
MinUserId
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Member_User
.
Id
)}
>
{
dmodel
.
MinUserId
}
"
;
orderBy
=
"Id asc"
;
}
string
sql
=
$@"
string
sql
=
$@"
select * from RB_Member_User where
{
where
}
order by
CreateDate desc
select * from RB_Member_User where
{
where
}
order by
{
orderBy
}
"
;
"
;
return
GetPage
<
RB_Member_User_Extend
>(
pageIndex
,
pageSize
,
out
rowCount
,
sql
).
ToList
();
return
GetPage
<
RB_Member_User_Extend
>(
pageIndex
,
pageSize
,
out
rowCount
,
sql
).
ToList
();
}
}
...
...
Mall.WebApi/Controllers/User/UserController.cs
View file @
534f27c8
...
@@ -2130,5 +2130,63 @@ namespace Mall.WebApi.Controllers.User
...
@@ -2130,5 +2130,63 @@ namespace Mall.WebApi.Controllers.User
}
}
#
endregion
#
endregion
#
region
用户转移
/// <summary>
/// 更新微信用户头像
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
UpdateUserPhotoForWeiXin
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
Count
=
parms
.
GetInt
(
"Count"
,
1
);
int
UserId
=
parms
.
GetInt
(
"UserId"
,
0
);
if
(
Count
==
0
)
{
Count
=
1
;
}
if
(
UserId
<=
0
&&
Count
==
0
)
{
return
ApiResult
.
ParamIsNull
();
}
bool
flag
=
userModule
.
UpdateUserPhotoForWeiXin
(
UserId
,
Count
,
req
.
TenantId
,
req
.
MallBaseId
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
/// <summary>
/// 更新用户上下级关系
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
UpdateUserSuperiorForWeiXin
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
Count
=
parms
.
GetInt
(
"Count"
,
1
);
int
UserId
=
parms
.
GetInt
(
"UserId"
,
0
);
if
(
Count
==
0
)
{
Count
=
1
;
}
if
(
UserId
<=
0
&&
Count
==
0
)
{
return
ApiResult
.
ParamIsNull
();
}
int
MaxId
=
userModule
.
UpdateUserSuperiorForWeiXin
(
UserId
,
Count
,
req
.
TenantId
,
req
.
MallBaseId
);
if
(
MaxId
>
0
)
{
return
ApiResult
.
Success
(
""
,
MaxId
);
}
else
{
return
ApiResult
.
Failed
();
}
}
#
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