| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
| | | userInfoExtra.setFirstLoginTime(new Date());
|
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtra.setUpdateTime(new Date());
|
| | | userInfoExtra.setActiveTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | // 获取微信信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | |
| | | String headimgurl = weiXinUser.getHeadimgurl();
|
| | | InputStream asInputStream = HttpUtil.getAsInputStream(headimgurl);
|
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " +weiXinUser.getUnionid()+ " " + headimgurl);
|
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | "/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | | LogHelper.test("微信头像上传失败: " +weiXinUser.getUnionid()+ " " + headimgurl);
|
| | | LogHelper.test("微信头像上传失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | }
|
| | | }
|
| | | updateUserInfo.setPortrait(headimgurl);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void activeInviteWX(Long uid, WeiXinUser weiXinUser) throws UserInfoExtraException {
|
| | | if (uid == null || weiXinUser == null) {
|
| | |
| | | String headimgurl = weiXinUser.getHeadimgurl();
|
| | | InputStream asInputStream = HttpUtil.getAsInputStream(headimgurl);
|
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " +weiXinUser.getUnionid()+ " " + headimgurl);
|
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | "/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | | LogHelper.test("微信头像上传失败: " +weiXinUser.getUnionid()+ " " + headimgurl);
|
| | | LogHelper.test("微信头像上传失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | }
|
| | | }
|
| | | updateUserInfo.setPortrait(headimgurl);
|
| | |
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void updateActiveTime(Long uid, Date date) {
|
| | | UserInfoExtra userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(new UserInfo(uid));
|
| | | userInfoExtra.setActiveTime(date);
|
| | | userInfoExtraMapper.updateInfoExtraByUid(userInfoExtra);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserInfoExtra getUserInfoExtra(Long uid) {
|
| | | return userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserInfoExtra getUserALLInfo(Long uid) {
|
| | | return userInfoExtraMapper.gerUserRank(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserInfoExtra getByUidForUpdate(Long uid) {
|
| | | return userInfoExtraMapper.getByUidForUpdate(uid);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void updateGoldCoin(Long id, Integer goldCoin) {
|
| | | userInfoExtraMapper.updateGoldCoin(id, goldCoin);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public UserInfoExtraVO getInfoExtraVOByUid(Long uid) {
|
| | | return userInfoExtraMapper.getInfoExtraVOByUid(uid);
|
| | |
| | | }
|
| | | return inviter;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void updateAutoExtract(Integer days) {
|
| | | userInfoExtraMapper.updateAutoExtract(days);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void updateInviteCode(String inviteCode, Long uid) throws UserInfoExtraException {
|
| | | if (inviteCode.length() >= 6 && inviteCode.length() <= 12) {
|
| | | UserInfoExtra extra = getUserInfoExtra(uid);
|
| | | if (extra == null) {
|
| | | throw new UserInfoExtraException(2, "用户信息不存在");
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(extra.getInviteCode())) {
|
| | | throw new UserInfoExtraException(3, "邀请码尚未激活");
|
| | | }
|
| | |
|
| | | if (extra.getInviteCodeState() == null
|
| | | || extra.getInviteCodeState() != UserInfoExtra.INVITE_CODE_SATTE_VALID_NO_UPDATE) {
|
| | | throw new UserInfoExtraException(4, "只能修改一次");
|
| | | }
|
| | |
|
| | | if (inviteCode.equalsIgnoreCase(extra.getInviteCode())) {
|
| | | throw new UserInfoExtraException(5, "不能为原邀请码");
|
| | | }
|
| | | UserInfoExtra update = new UserInfoExtra();
|
| | | update.setId(extra.getId());
|
| | |
|
| | | extra = userInfoExtraMapper.selectByInviteCode(inviteCode);
|
| | | if (extra != null) {
|
| | | throw new UserInfoExtraException(6, "邀请码已存在");
|
| | | }
|
| | |
|
| | | update.setInviteCode(inviteCode);
|
| | | update.setInviteCodeState(UserInfoExtra.INVITE_CODE_SATTE_VALID_UPDATED);
|
| | | update.setUpdateTime(new Date());
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(update);
|
| | | } else {
|
| | | throw new UserInfoExtraException(1, "邀请码必须为6到12位");
|
| | | }
|
| | |
|
| | | }
|
| | | }
|