| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRankRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.bus.user.notify.UserActivedRecord;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.user.ThreeSaleException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInviteRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.notify.UserActivedRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.InviteCodeFilterUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInviteRecordService userInviteRecordService;
|
| | |
|
| | | @Resource
|
| | | @Lazy
|
| | | private UserActivedRecordService userActivedRecordService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | |
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | |
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | |
|
| | | userActivedRecordService.add(new UserActivedRecord(uid));
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | |
| | | userInfoExtraMapper.updateAutoExtract(days);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void updateInviteCodeVip(String inviteCodeVip, Long uid) throws UserInfoExtraException {
|
| | | if (inviteCodeVip == null || inviteCodeVip.length() < 4 || inviteCodeVip.length() > 12)
|
| | |
| | | update.setInviteCodeVip(inviteCodeVip);
|
| | | update.setUpdateTime(new Date());
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(update);
|
| | | |
| | | if(!Constant.IS_TEST) { //发送邀请码更改成功的消息
|
| | |
|
| | | if (!Constant.IS_TEST) { // 发送邀请码更改成功的消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate,
|
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip, new Date())));
|
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip,
|
| | | new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void uploadERCode(MultipartFile file, Long uid) {
|
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra == null)
|
| | | return;
|
| | | |
| | |
|
| | | // 压缩
|
| | | String targetPath = FileUtil.getCacheDir() + "/erCode_" + uid + "_" + System.currentTimeMillis()+ ".jpg";
|
| | | String targetPath = FileUtil.getCacheDir() + "/erCode_" + uid + "_" + System.currentTimeMillis() + ".jpg";
|
| | | try {
|
| | | Thumbnails.of(file.getInputStream()).size(200, 200).toFile(targetPath);
|
| | | } catch (IOException e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 执行上传
|
| | | String filePath = FilePathEnum.userERcode.getPath() + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String fileLink = COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl();
|
| | | |
| | |
|
| | | // 删除本地图片
|
| | | if (new File(targetPath).exists()) {
|
| | | new File(targetPath).delete();
|
| | |
| | |
|
| | | // 原二维码
|
| | | String erCode = extra.getErCode();
|
| | | |
| | |
|
| | | UserInfoExtra update = new UserInfoExtra();
|
| | | update.setId(extra.getId());
|
| | | update.setErCode(fileLink);
|
| | |
| | | COSManager.getInstance().deleteFile(erCode);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|