| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.BindingAccountMapper;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
|
| | | import com.yeshi.fanli.dao.user.UserInfoDao;
|
| | | import com.yeshi.fanli.entity.admin.UserInfoAdmin;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.InviteUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.exception.ThreeSaleException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | |
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | | import com.yeshi.fanli.vo.user.UserInfoVO;
|
| | |
|
| | | @Service
|
| | | public class UserInfoServiceImpl implements UserInfoService {
|
| | |
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoService hongBaoService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BindingAccountMapper bindingAccountMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private PayInfoMapper payInfoMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ScanHistoryMapper scanHistoryMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ShareMapper shareMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | @Resource
|
| | | private UserRankService userRankService;
|
| | |
|
| | |
|
| | | public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
|
| | |
| | | list = userInfoDao.list("from UserInfo u where u.wxUnionId=? and u.appId = ? ",
|
| | | new Serializable[] { openid, appid });
|
| | | }
|
| | |
|
| | | if (list != null)
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() == UserInfo.STATE_DELETE
|
| | | || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | return list.get(0);
|
| | | }
|
| | |
| | | return form;
|
| | | }
|
| | |
|
| | | if (form.getSystem().getId() != 7)
|
| | | hongBaoService.setNewUserHongBao(form, 1);
|
| | | LogHelper.userInfo("添加用户:" + form);
|
| | | if (form.getLoginType() == Constant.WEIXIN) {
|
| | | // final UserInfo temp = form;
|
| | |
| | | }
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | | UserInfo find = getUserByLoginTypeAndOpenId(Constant.WEIXIN, wxUnionId, Constant.APPID);
|
| | |
|
| | | if (find == null) {
|
| | | find = new UserInfo();
|
| | | find.setAppId(Constant.APPID);
|
| | | find.setWxUnionId(weiXinUser.getUnionid());
|
| | | String wxHeadImg = COSManager.getInstance().uploadFile(
|
| | | HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString()).getUrl();
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | find.setPortrait(wxHeadImg);
|
| | | find.setWxPic(wxHeadImg);
|
| | | find.setNickName(weiXinUser.getNickname());
|
| | |
| | | find.setLoginType(Constant.WEIXIN);
|
| | | find.setRank(0);
|
| | | find.setWxOpenId(weiXinUser.getOpenid());
|
| | | System system = new System(Constant.FANLI);
|
| | | BusinessSystem system = new BusinessSystem(Constant.FANLI);
|
| | | system.setPlatform(1);
|
| | | find.setSystem(system);
|
| | | UserInfo addUser = null;
|
| | | synchronized (UserInfo.class) {
|
| | | addUser = addUser(find, Constant.APPID);
|
| | | if (addUser != null && addUser.getId() > 1) {
|
| | | threeSaleSerivce.bind(find, inviter);
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | try {
|
| | | threeSaleSerivce.bind(find, inviter);
|
| | | return true;
|
| | | } catch (ThreeSaleException e) {
|
| | | e.printStackTrace();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | |
| | | List list = session
|
| | | .createSQLQuery(
|
| | | "SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT t.* FROM `yeshi_ec_threesale` t "
|
| | | + "WHERE t.`boss_id`=? AND (t.expire = 0 OR t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
|
| | | + "WHERE t.`boss_id`=? AND (t.expire = 0 OR t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
|
| | | .setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
|
| | | return covertToInviteUserList(list);
|
| | | }
|
| | |
| | | List list = session
|
| | | .createSQLQuery(
|
| | | "SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT tt.* FROM `yeshi_ec_threesale` t LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id` "
|
| | | + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0 OR tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
|
| | | + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0 OR tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
|
| | | .setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
|
| | | return covertToInviteUserList(list);
|
| | | }
|
| | |
| | | @Override
|
| | | public long getFriendsListCount(long id, int type) {
|
| | | if (type == 1)
|
| | | return userInfoDao
|
| | | .getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t WHERE t.`boss_id`= " + id +" AND (t.expire = 0 OR t.expire IS NULL)");
|
| | | return userInfoDao.getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t WHERE t.`boss_id`= " + id
|
| | | + " AND (t.expire = 0 OR t.expire IS NULL)");
|
| | | else
|
| | | return userInfoDao.getCountSQL(
|
| | | "SELECT COUNT(tt.id) FROM `yeshi_ec_threesale` t LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id` WHERE t.`boss_id`="
|
| | |
| | |
|
| | | @Override
|
| | | public UserInfo getUserByIdWithMybatis(long uid) {
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | | UserInfo user = userInfoMapper.selectByPKey(uid);
|
| | | return UserUtil.filterForClientUser(user);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<UserInfoAdmin> query(long start, int count, String key, Integer userType, |
| | | Integer days, String startTime, String endTime, Integer orderField,Integer orderMode) {
|
| | | public long queryCount( Integer userState, String key, Integer keyType, String userRank, Integer days, String startTime, String endTime) {
|
| | | return userInfoMapper.queryCount(userState, key, keyType, userRank, days, startTime, endTime);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<UserInfoVO> query(long start, int count, Integer userState, String key, Integer keyType, |
| | | String userRank, Integer days, String startTime, String endTime, Integer orderField, Integer orderMode) {
|
| | |
|
| | | List<UserInfoAdmin> adminList = new ArrayList<UserInfoAdmin>();
|
| | |
|
| | | List<UserInfo> userList = userInfoMapper.query(start, count, key, userType, days,
|
| | | startTime, endTime, orderField,orderMode);
|
| | | List<UserInfoVO> userList = userInfoMapper.query(start, count,userState, key, keyType, userRank, days, startTime, endTime,
|
| | | orderField, orderMode);
|
| | | |
| | | if (userList == null || userList.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | for (UserInfo userInfo : userList) {
|
| | |
|
| | | UserInfoAdmin userInfoAdmin = new UserInfoAdmin();
|
| | | |
| | | Long lastLoginTime = userInfo.getLastLoginTime();
|
| | | if (lastLoginTime == null) {
|
| | | userInfo.setLastLoginTime(0L);
|
| | | } |
| | | |
| | | |
| | | userInfoAdmin.setUserInfo(userInfo);
|
| | | |
| | | String wxName = userInfo.getWxName();
|
| | | if (StringUtil.isNullOrEmpty(wxName)) {
|
| | | userInfoAdmin.setWxNameState(1);
|
| | | } else {
|
| | | userInfoAdmin.setWxNameState(2);
|
| | | }
|
| | | |
| | | String phone = userInfo.getPhone();
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | userInfoAdmin.setPhoneState(1);
|
| | | } else {
|
| | | userInfoAdmin.setPhoneState(2);
|
| | | }
|
| | | |
| | | String tbName = userInfo.getTbName();
|
| | | if (StringUtil.isNullOrEmpty(tbName)) {
|
| | | userInfoAdmin.setTbNameState(1);
|
| | | } else {
|
| | | userInfoAdmin.setTbNameState(2);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | Long uid = userInfo.getId();
|
| | |
|
| | | /* 绑定账号信息 */
|
| | | List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
|
| | | if (account != null && account.size() > 0) {
|
| | | BindingAccount bindingAccount = account.get(0);
|
| | | Integer type = bindingAccount.getType();
|
| | | if (type != null && type == 1) {
|
| | | // 支付宝
|
| | | userInfoAdmin.setAccountAlipay(bindingAccount.getAccount());
|
| | | userInfoAdmin.setAccountName(bindingAccount.getName());
|
| | | userInfoAdmin.setAccountBindId(bindingAccount.getId());
|
| | | |
| | | } else if (type != null && type == 2) {
|
| | | // 微信
|
| | | userInfoAdmin.setAccountWX(bindingAccount.getAccount());
|
| | | userInfoAdmin.setAccountNameWX(bindingAccount.getName());
|
| | | userInfoAdmin.setAccountBindIdWX(bindingAccount.getId());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | // 最后一次下单时间
|
| | | Long lastOrderTime = hongBaoService.getLastOrderTime(uid);
|
| | | if (lastOrderTime == null) {
|
| | | userInfoAdmin.setLastOrderTime(0);
|
| | | } else {
|
| | | userInfoAdmin.setLastOrderTime(lastOrderTime);
|
| | | }
|
| | | |
| | | |
| | | // 历史总订单
|
| | | long totalOrder = hongBaoService.countByUidSelf(uid, null, null);
|
| | | // 今日总订单
|
| | | long todayOrder = hongBaoService.countByUidSelf(uid, 1, null);
|
| | | // 本月总订单
|
| | | long monthOrder = hongBaoService.countByUidSelf(uid, null, 1);
|
| | |
|
| | | userInfoAdmin.setTotalOrder(totalOrder);
|
| | | userInfoAdmin.setTodayOrder(todayOrder);
|
| | | userInfoAdmin.setMonthOrder(monthOrder);
|
| | |
|
| | | // 支付宝账号 累计转账总金额
|
| | | double totalMoney = payInfoMapper.sumMoneyByUid(uid);
|
| | | userInfoAdmin.setTotalMoney(totalMoney);
|
| | | |
| | | // 累计提现 (暂未计入微信)
|
| | | userInfoAdmin.setTotalExtract(totalMoney);
|
| | |
|
| | | // 未领取红包 待入账金额
|
| | | double unaccountedMoney = hongBaoService.countForecastMoneysByUid(uid);
|
| | | userInfoAdmin.setUnaccountedMoney(unaccountedMoney);
|
| | |
|
| | | // 历史总收益
|
| | | double totalMoneyHistory = hongBaoService.countReceiveMoneysByUid(uid);
|
| | | userInfoAdmin.setTotalMoneyHistory(totalMoneyHistory);
|
| | | |
| | | |
| | | // 统计分享个数
|
| | | long countUserShares = userShareGoodsHistoryMapper.countUserShares(uid);
|
| | | userInfoAdmin.setCountUserShares(countUserShares);
|
| | | |
| | | // 统计浏览足迹
|
| | | long countScanHistory = scanHistoryMapper.countUserScanHistory(uid);
|
| | | userInfoAdmin.setCountScanHistory(countScanHistory);
|
| | | |
| | | // 一度队员数量
|
| | | int firstTeamCount = shareMapper.myFirstTeamCount(uid +"");
|
| | | userInfoAdmin.setCountLevelOne(firstTeamCount);
|
| | | |
| | | // 二度队员数量
|
| | | int secondTeamCount = shareMapper.mySecondTeamCount(uid +"");
|
| | | userInfoAdmin.setCountLevelTwo(secondTeamCount);
|
| | | adminList.add(userInfoAdmin);
|
| | | |
| | | for (UserInfoVO userInfoVO : userList) {
|
| | | // 数据加工处理
|
| | | convertUserInfoVOData(userInfoVO);
|
| | | }
|
| | |
|
| | | return adminList;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long queryCount(String key, Integer userType, Integer days, String startTime, String endTime) {
|
| | | return userInfoMapper.queryCount(key, userType, days, startTime, endTime);
|
| | | return userList;
|
| | | }
|
| | |
|
| | | public void convertUserInfoVOData(UserInfoVO userInfoVO) {
|
| | | |
| | | String rankName = userInfoVO.getRankName();
|
| | | if (rankName == null || rankName.trim().length() == 0) {
|
| | | userInfoVO.setRankName("青铜");
|
| | | userInfoVO.setRankPicture("http://img.flqapp.com/resource/rank/rank_picture_new_1.png");
|
| | | }
|
| | | |
| | | String f_alipayAccount = userInfoVO.getAlipayAccountInvalid();
|
| | | if (f_alipayAccount != null && f_alipayAccount.trim().length() > 0) {
|
| | | userInfoVO.setAlipayAccountState(1);
|
| | | }
|
| | | |
| | | String f_phone = userInfoVO.getPhoneInvalid();
|
| | | if (f_phone != null && f_phone.trim().length() > 0) {
|
| | | userInfoVO.setPhoneState(1);
|
| | | }
|
| | | |
| | | String f_taobaoUid = userInfoVO.getTaobaoUidInvalid();
|
| | | if (f_taobaoUid != null && f_taobaoUid.trim().length() > 0) {
|
| | | userInfoVO.setTaobaoUidState(1);
|
| | | }
|
| | | |
| | | String f_wxUnionId = userInfoVO.getWxUnionIdInvalid();
|
| | | if (f_wxUnionId != null && f_wxUnionId.trim().length() > 0) {
|
| | | userInfoVO.setWxUnionIdState(1);
|
| | | }
|
| | | |
| | | // 最近登录时间
|
| | | Long lastLoginTime = userInfoVO.getLastLoginTime();
|
| | | if (lastLoginTime != null && lastLoginTime == 0) {
|
| | | 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); }
|
| | | */
|
| | | |
| | | |
| | | Long uid = userInfoVO.getId();
|
| | | |
| | | |
| | | /* 绑定收款账号信息 */
|
| | | List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
|
| | | if (account != null && account.size() > 0) {
|
| | | BindingAccount bindingAccount = account.get(0);
|
| | | Integer type = bindingAccount.getType();
|
| | | if (type != null && type == 1) {
|
| | | // 支付宝
|
| | | userInfoVO.setAccountAlipay(bindingAccount.getAccount());
|
| | | userInfoVO.setAccountName(bindingAccount.getName());
|
| | | userInfoVO.setAccountBindId(bindingAccount.getId());
|
| | |
|
| | | } else if (type != null && type == 2) {
|
| | | // 微信
|
| | | userInfoVO.setAccountWX(bindingAccount.getAccount());
|
| | | userInfoVO.setAccountNameWX(bindingAccount.getName());
|
| | | userInfoVO.setAccountBindIdWX(bindingAccount.getId());
|
| | | }
|
| | | }
|
| | | |
| | | // 最近一次下单时间
|
| | | Date lastOrderTime = hongBaoV2CountService.getLastHongBaoTime(uid);
|
| | | if (lastOrderTime != null && lastOrderTime.getTime() != 0) {
|
| | | userInfoVO.setLastOrderTime(lastOrderTime.getTime());
|
| | | }
|
| | |
|
| | | // 今日总订单
|
| | | long todayOrder = hongBaoV2CountService.countValidNumberByUid(uid, 1);
|
| | | userInfoVO.setTodayOrder(todayOrder);
|
| | |
|
| | | // 未领取红包 待入账金额
|
| | | BigDecimal unaccountedMoney = hongBaoV2CountService.countWillGetMoneyByUid(uid);
|
| | | if (unaccountedMoney == null) {
|
| | | unaccountedMoney = new BigDecimal(0);
|
| | | }
|
| | | userInfoVO.setUnaccountedMoney(unaccountedMoney.toString());
|
| | |
|
| | | // 历史总收益
|
| | | BigDecimal totalMoneyHistory = hongBaoV2CountService.countMoneyByUidAndState(uid, 3);
|
| | | if (totalMoneyHistory == null) {
|
| | | totalMoneyHistory = new BigDecimal(0);
|
| | | }
|
| | | userInfoVO.setTotalMoneyHistory(totalMoneyHistory.toString());
|
| | |
|
| | | // 支付宝账号 累计转账总金额
|
| | | double totalMoney = payInfoMapper.sumMoneyByUid(uid);
|
| | | userInfoVO.setTotalMoney(totalMoney);
|
| | |
|
| | | // 累计提现 (暂未计入微信)
|
| | | userInfoVO.setTotalExtract(totalMoney);
|
| | |
|
| | | // 统计分享个数
|
| | | long countUserShares = userShareGoodsHistoryMapper.countUserShares(uid);
|
| | | userInfoVO.setCountUserShares(countUserShares);
|
| | |
|
| | | // 统计浏览足迹
|
| | | long countScanHistory = scanHistoryMapper.countUserScanHistory(uid);
|
| | | userInfoVO.setCountScanHistory(countScanHistory);
|
| | |
|
| | | // 一度队员数量
|
| | | int firstTeamCount = shareMapper.myFirstTeamCount(uid + "");
|
| | | userInfoVO.setCountLevelOne(firstTeamCount);
|
| | |
|
| | | // 二度队员数量
|
| | | int secondTeamCount = shareMapper.mySecondTeamCount(uid + "");
|
| | | userInfoVO.setCountLevelTwo(secondTeamCount);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public double querySumMoney(String key, Integer userType, Integer days, String startTime, String endTime) {
|
| | | return userInfoMapper.querySumMoney(key, userType, days, startTime, endTime);
|
| | |
| | | public UserInfo selectByPKey(Long id) {
|
| | | return userInfoMapper.selectByPKey(id);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(UserInfo record) {
|
| | | return userInfoMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void deleteBindInfo(UserInfo user, int type) {
|
| | |
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(user);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public List<Long> longTimeNoLogin(int daysNum, List<Long> list ) {
|
| | | public List<Long> longTimeNoLogin(int daysNum, List<Long> list) {
|
| | | return userInfoMapper.longTimeNoLogin(daysNum, list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据电话号码、邀请码获取邀请用户
|
| | | * |
| | | * @param phone
|
| | | * @param inviteCode
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public UserInfo getInfoByPhoneOrInviteCode(String phone, String inviteCode) {
|
| | | return userInfoMapper.getInfoByPhoneOrInviteCode(phone, inviteCode);
|
| | | }
|
| | | |
| | | }
|