| | |
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.yeshi.fanli.exception.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.AccountDetailsFactory;
|
| | | import com.yeshi.fanli.util.factory.msg.MsgAccountDetailFactory;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | |
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountMsgNotificationService userAccountMsgNotificationService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public LoginResult login(HttpSession session, Boolean first, String appId, String code, String phone,
|
| | | public LoginResult login(HttpServletRequest request, Boolean first, String appId, String code, String phone,
|
| | | UserInfo tbUserInfo, boolean wxinstall, int loginType) throws UserAccountException {
|
| | |
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | | logInfo.put("code", code);
|
| | | logInfo.put("phone", phone);
|
| | | if (tbUserInfo != null)
|
| | | logInfo.put("tbUserInfo", tbUserInfo.getId());
|
| | | logInfo.put("loginType", loginType);
|
| | | LogHelper.lgoinInfo(logInfo.toString());
|
| | |
|
| | | HttpSession session = request.getSession();
|
| | | if (first != null && first == true)
|
| | | session.removeAttribute("LAST_LOGIN_USER");
|
| | | // 会话中上次登录的用户
|
| | |
| | | updateUserInfo.setPortrait(weiXinUser.getHeadimgurl());
|
| | | updateUserInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | updateUserInfo.setWxName(weiXinUser.getNickname());
|
| | | // 设置登录时间与登录类型
|
| | | updateUserInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | updateUserInfo.setLoginType(loginType);
|
| | | updateUserInfo.setLastLoginIp(request.getRemoteHost());
|
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | // 删除邀请图片
|
| | | spreadUserImgService.deleteImgUrl(userInfo.getId());
|
| | |
| | | userInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | userInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | addUser(userInfo);
|
| | |
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | |
| | | // 绑定关系
|
| | | UserInfo updateUserInfo = new UserInfo(userInfo.getId());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(lastUser.getPhone()))
|
| | | if (!StringUtil.isNullOrEmpty(lastUser.getPhone())) {
|
| | | updateUserInfo.setPhone(lastUser.getPhone());
|
| | |
|
| | | userAccountMsgNotificationService.bindingSuccess(userInfo.getId(),
|
| | | MsgAccountDetailFactory.TYPE_PHONE);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(lastUser.getOpenid())) {
|
| | | updateUserInfo.setOpenid(lastUser.getOpenid());
|
| | | updateUserInfo.setTbName(lastUser.getTbName());
|
| | | updateUserInfo.setTbPic(lastUser.getTbPic());
|
| | | userAccountMsgNotificationService.bindingSuccess(userInfo.getId(),
|
| | | MsgAccountDetailFactory.TYPE_TB);
|
| | | }
|
| | | updateUserInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
| | | userInfo.setTbPic(lastUser.getTbPic());
|
| | | }
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | addUser(userInfo);
|
| | | session.removeAttribute("LAST_LOGIN_USER");
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | |
| | | @Override
|
| | | public LoginResult loginNoInstallWX(String appId, String code, String phone, UserInfo tbUserInfo, int loginType)
|
| | | throws UserAccountException {
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | | logInfo.put("code", code);
|
| | | logInfo.put("phone", phone);
|
| | | if (tbUserInfo != null)
|
| | | logInfo.put("tbUserInfo", tbUserInfo.getId());
|
| | | logInfo.put("loginType", loginType);
|
| | | LogHelper.lgoinInfo(logInfo.toString());
|
| | |
|
| | | UserInfo userInfo = null;
|
| | | WeiXinUser weiXinUser = null;
|
| | | switch (loginType) {
|
| | |
| | | moneyRecordMapper.insertSelective(moneyRecord);
|
| | | }
|
| | |
|
| | | userAccountMsgNotificationService.connectSuccess(mainUser.getId(), lessUser.getId());
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param unionId
|
| | | * @return
|
| | | */
|
| | | public UserInfo getUserInfoByWXUnionId(String appId, String unionId) {
|
| | | public UserInfo getUserInfoByWXUnionId(String appId, String unionId) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | if (StringUtil.isNullOrEmpty(unionId))
|
| | | throw new UserAccountException(2, "unionId为空");
|
| | |
|
| | | return userInfoMapper.getUserInfoByAppIdAndWXUnionId(appId, unionId);
|
| | | }
|
| | |
|
| | |
| | | * @param openId
|
| | | * @return
|
| | | */
|
| | | public UserInfo getUserInfoByTaoBaoOpenId(String appId, String openId) {
|
| | |
|
| | | public UserInfo getUserInfoByTaoBaoOpenId(String appId, String openId) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | if (StringUtil.isNullOrEmpty(openId))
|
| | | throw new UserAccountException(2, "openId为空");
|
| | | return userInfoMapper.getUserInfoByAppIdAndTaoBaoOpenId(appId, openId);
|
| | | }
|
| | |
|
| | |
| | | * @param phone
|
| | | * @return
|
| | | */
|
| | | public UserInfo getUserInfoByPhone(String appId, String phone) {
|
| | |
|
| | | public UserInfo getUserInfoByPhone(String appId, String phone) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | if (StringUtil.isNullOrEmpty(phone))
|
| | | throw new UserAccountException(2, "phone为空");
|
| | | return userInfoMapper.getUserInfoByAppIdAndPhone(appId, phone);
|
| | | }
|
| | |
|
| | |
| | | UserInfo update = new UserInfo(user.getId());
|
| | | update.setPhone(phone);
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | UserInfo updateUserInfo = new UserInfo(uid);
|
| | | updateUserInfo.setPhone("");
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userAccountMsgNotificationService.unBindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | update.setPortrait(tbPortrait);
|
| | | }
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_TB);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | userAccountMsgNotificationService.unBindingSuccess(uid, MsgAccountDetailFactory.TYPE_TB);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | updateUserInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | }
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | | userAccountMsgNotificationService.changeBindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX);
|
| | | }
|
| | |
|
| | | @Override
|