| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.Serializable;
|
| | | import java.math.BigDecimal;
|
| | |
| | | import org.hibernate.Query;
|
| | | import org.hibernate.SQLQuery;
|
| | | import org.hibernate.Session;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.orm.hibernate4.HibernateCallback;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.FileUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
|
| | | import com.yeshi.fanli.dao.user.UserInfoDao;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.InviteUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.exception.ThreeSaleException;
|
| | | import com.yeshi.fanli.exception.user.ForbiddenUserIdentifyCodeException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.BindingAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | |
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.user.UserInfoVO;
|
| | |
|
| | | import net.coobird.thumbnailator.Thumbnails;
|
| | |
|
| | | @Service
|
| | | public class UserInfoServiceImpl implements UserInfoService {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private UserInfoDao userInfoDao;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | @Resource
|
| | | private BindingAccountService bindingAccountService;
|
| | |
|
| | | public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
|
| | | List<UserInfo> list = null;
|
| | |
| | | userInfoVO.setLastLoginTime(null);
|
| | | }
|
| | |
|
| | | /*
|
| | | * 显示用户微信 淘宝 老版本存在 String wxUnionId = userInfoVO.getWxUnionId(); if
|
| | | * (wxUnionId == null || wxUnionId.trim().length() == 0) {
|
| | | * userInfoVO.setWxName(null); }
|
| | | * |
| | | * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null
|
| | | * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
|
| | | */
|
| | | |
| | | //显示用户微信 淘宝 老版本存在 |
| | | String wxUnionId = userInfoVO.getWxUnionId(); |
| | | if (wxUnionId == null || wxUnionId.trim().length() == 0) {
|
| | | userInfoVO.setWxName(null); |
| | | }
|
| | | |
| | | // 是否绑定支付宝(购买 + 分享权限)
|
| | | String taoBaoUid = userInfoVO.getTaoBaoUid(); |
| | | String tbSpecialId = userInfoVO.getTbSpecialId();
|
| | | String tbRelationId = userInfoVO.getTbRelationId();
|
| | | if (StringUtil.isNullOrEmpty(taoBaoUid) || StringUtil.isNullOrEmpty(tbSpecialId) || StringUtil.isNullOrEmpty(tbRelationId)) { |
| | | userInfoVO.setTbName(null); |
| | | userInfoVO.setTaoBaoUid(null); |
| | | }
|
| | |
|
| | | Long uid = userInfoVO.getId();
|
| | |
|
| | | /* 绑定收款账号信息 */
|
| | | List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
|
| | | if (account != null && account.size() > 0) {
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void uploadPortrait(MultipartFile file, Long uid) throws UserInfoException, IOException {
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | throw new UserInfoException(1, "用户不存在");
|
| | | }
|
| | |
|
| | | // 谷歌压缩图片
|
| | | String targetPath = FileUtil.getCacheDir() + "/uploadPortrait_" + uid + "_" + System.currentTimeMillis()
|
| | | + ".jpg";
|
| | | Thumbnails.of(file.getInputStream()).size(200, 200).toFile(targetPath);
|
| | |
|
| | | // 执行上传
|
| | | String filePath = "/img/user/" + 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 portrait = userInfo.getPortrait();
|
| | |
|
| | | // 更新信息
|
| | | userInfo.setPortrait(fileLink);
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | |
|
| | | // 删除原头像
|
| | | if (!StringUtil.isNullOrEmpty(portrait) && portrait.contains("/img/user/")) {
|
| | | COSManager.getInstance().deleteFile(portrait);
|
| | | }
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | // 删除分享头像信息
|
| | | spreadUserImgService.deleteImgUrl(uid);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void saveUserInfo(String nickName, Long uid) throws UserInfoException {
|
| | | UserInfo userInfo = userInfoMapper.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | throw new UserInfoException(1, "用户不存在");
|
| | | }
|
| | |
|
| | | userInfo.setNickName(nickName);
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | | }
|
| | |
|
| | | }
|