Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
d91ee44e
Commit
d91ee44e
authored
Mar 27, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增补微信绑定动作的log
parent
feccc210
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
20 deletions
+31
-20
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+31
-20
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
d91ee44e
...
...
@@ -27,7 +27,6 @@ import cn.quantgroup.xyqb.util.IPUtil;
import
cn.quantgroup.xyqb.util.MqUtils
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -470,32 +469,44 @@ public class UserController implements IBaseController {
}
}
/**
* 绑定微信
* @param openId - 微信openId
* @return
*/
@RequestMapping
(
"/associate_wechat"
)
public
JsonResult
associateWithWechat
(
String
openId
)
{
User
user
=
getCurrentUserFromRedis
();
Long
userId
=
user
.
getId
();
WechatUserInfo
userInfo
=
wechatService
.
findWechatUserInfoFromDb
(
openId
);
LOGGER
.
info
(
"微信关联openId,user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
if
(
Objects
.
isNull
(
userInfo
)
&&
!
Objects
.
isNull
(
userId
))
{
if
(
Objects
.
isNull
(
userInfo
)
&&
Objects
.
nonNull
(
userId
))
{
userInfo
=
wechatService
.
queryByUserId
(
userId
);
}
if
(
userInfo
==
null
||
StringUtils
.
isNotEmpty
(
userInfo
.
getPhoneNo
()))
{
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
// 未绑定信用钱包用户
if
(
userInfo
.
getUserId
()
==
null
)
{
userInfo
.
setUserId
(
userId
);
userInfo
.
setPhoneNo
(
user
.
getPhoneNo
());
try
{
wechatService
.
saveWechatUserInfo
(
userInfo
);
}
catch
(
Exception
ex
)
{
// 不做绑定
return
JsonResult
.
buildErrorStateResult
(
"该手机号已绑定其他微信号码"
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
LOGGER
.
info
(
"微信关联:user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
// 无微信信息
if
(
userInfo
==
null
)
{
LOGGER
.
warn
(
"微信关联失败,缺少微信信息:user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
return
JsonResult
.
buildErrorStateResult
(
"还没有保存微信信息"
,
null
);
}
// 排他性 - 先入为主
if
(
Objects
.
nonNull
(
userInfo
.
getUserId
())
&&
userInfo
.
getUserId
()>
0
&&
!
Objects
.
equals
(
userId
,
userInfo
.
getUserId
()))
{
LOGGER
.
warn
(
"微信关联失败,该微信已经被其他用户绑定:user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
return
JsonResult
.
buildErrorStateResult
(
"该微信已经被其他用户绑定"
,
null
);
}
/*
* 未绑定信用钱包用户
*/
userInfo
.
setUserId
(
userId
);
userInfo
.
setPhoneNo
(
user
.
getPhoneNo
());
try
{
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
LOGGER
.
info
(
"微信关联成功:user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
}
catch
(
Exception
ex
)
{
// 不做绑定
LOGGER
.
warn
(
"微信关联失败,该手机号已绑定其他微信号码:user:[{}],openId:[{}],wechatUserInfo:[{}]"
,
user
,
openId
,
userInfo
);
return
JsonResult
.
buildErrorStateResult
(
"该手机号已绑定其他微信号码"
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
"微信关联成功"
,
null
);
}
/**
...
...
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