| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xcong.excoin.common.LoginUserUtils; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | |
| | | import com.xcong.excoin.common.system.dto.RegisterDto; |
| | | import com.xcong.excoin.common.system.service.CommonService; |
| | | import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao; |
| | | import com.xcong.excoin.modules.coin.dao.ZhiYaDao; |
| | | import com.xcong.excoin.modules.coin.dao.ZhiYaRecordDao; |
| | | import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange; |
| | | import com.xcong.excoin.modules.coin.entity.ZhiYaEntity; |
| | | import com.xcong.excoin.modules.coin.entity.ZhiYaRecordEntity; |
| | | import com.xcong.excoin.modules.coin.entity.ZhiYaTeam; |
| | | import com.xcong.excoin.modules.coin.parameter.vo.ZhiyaInfoVo; |
| | | import com.xcong.excoin.modules.member.dao.*; |
| | | import com.xcong.excoin.modules.member.entity.*; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberAddCoinAddressDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberAuthenticationDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberBindEmailDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberBindPhoneDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberDelCoinAddressDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberDelPaymethodDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberForgetPwdDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberPaymethodDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberSubmitCoinApplyDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberUpdatePwdDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradePwdDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.MemberUpdateTradersPwdTimeDto; |
| | | import com.xcong.excoin.modules.member.parameter.dto.*; |
| | | import com.xcong.excoin.modules.member.parameter.vo.*; |
| | | import com.xcong.excoin.modules.member.service.MemberService; |
| | | import com.xcong.excoin.modules.member.vo.DefaultWayVo; |
| | | import com.xcong.excoin.modules.platform.dao.PlatformFeeSettingDao; |
| | | import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao; |
| | | import com.xcong.excoin.modules.platform.entity.PlatformFeeSettingEntity; |
| | |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.web3j.abi.datatypes.Int; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | |
| | | private MemberDao memberDao; |
| | | |
| | | @Resource |
| | | private ZhiYaRecordDao zhiYaRecordDao; |
| | | |
| | | @Resource |
| | | private MemberWalletAgentDao memberWalletAgentDao; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private MemberWalletCoinDao memberWalletCoinDao; |
| | | |
| | | @Resource |
| | | private MemberCoinAddressInDao memberCoinAddressInDao; |
| | | |
| | | @Resource |
| | | private ZhiYaDao zhiYaDao; |
| | | |
| | | @Resource |
| | | private MemberLevelRateDao memberLevelRateDao; |
| | |
| | | walletCoin.setBorrowedFund(AppContants.INIT_MONEY); |
| | | memberWalletCoinDao.insert(walletCoin); |
| | | } |
| | | |
| | | //初始化质押 |
| | | ZhiYaEntity zhiYaEntity = new ZhiYaEntity(); |
| | | zhiYaEntity.setMemberId(member.getId()); |
| | | zhiYaEntity.setAvailableBalance(AppContants.INIT_MONEY); |
| | | zhiYaEntity.setFrozenBalance(AppContants.INIT_MONEY); |
| | | zhiYaEntity.setTotalBalance(AppContants.INIT_MONEY); |
| | | zhiYaDao.insert(zhiYaEntity); |
| | | |
| | | // 初始化代理佣金钱包 |
| | | MemberWalletAgentEntity walletAgent = new MemberWalletAgentEntity(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result setDefaultPaymethod(Long id) { |
| | | MemberEntity member = LoginUserUtils.getAppLoginUser(); |
| | | MemberPaymentMethodEntity defualtMethod = this.memberPaymentMethodDao.selectDefualtMethod(member.getId(), null, "1"); |
| | | |
| | | if (defualtMethod != null) { |
| | | if (id.equals(defualtMethod.getId())) { |
| | | return Result.fail("不能关闭默认收款方式"); |
| | | } |
| | | } |
| | | |
| | | MemberPaymentMethodEntity paymentMethodEntity = new MemberPaymentMethodEntity(); |
| | | paymentMethodEntity.setId(id); |
| | | paymentMethodEntity.setIsDefualt("1"); |
| | | this.memberPaymentMethodDao.updateById(paymentMethodEntity); |
| | | |
| | | if (defualtMethod != null) { |
| | | defualtMethod.setIsDefualt("2"); |
| | | this.memberPaymentMethodDao.updateById(defualtMethod); |
| | | } |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result memberBindPhone(@Valid MemberBindPhoneDto memberBindPhoneDto) { |
| | | //获取用户ID |
| | |
| | | memberPersonCenterInfoVo.setTradeAgingSetting(MemberPersonCenterInfoVo.PWD_NEED_NO); |
| | | } |
| | | |
| | | if (StrUtil.isEmpty(member.getName())) { |
| | | memberPersonCenterInfoVo.setNickName(2); |
| | | } else { |
| | | memberPersonCenterInfoVo.setNickName(1); |
| | | } |
| | | |
| | | memberPersonCenterInfoVo.setIsMb(member.getIsTrader()); |
| | | return Result.ok(memberPersonCenterInfoVo); |
| | | } |
| | | |
| | |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | String golden_limit_transfer = redisUtils.getString("GOLDEN_LIMIT_TRANSFER"); |
| | | // 判断是否限制 |
| | | if(StringUtils.isNotBlank(golden_limit_transfer) && golden_limit_transfer.contains(member.getPhone())){ |
| | | if(StringUtils.isNotBlank(member.getPhone()) &&StringUtils.isNotBlank(golden_limit_transfer) && golden_limit_transfer.contains(member.getPhone())){ |
| | | return Result.fail("此账号有财务问题,需联系客服"); |
| | | } |
| | | if(StringUtils.isNotBlank(member.getEmail()) &&StringUtils.isNotBlank(golden_limit_transfer) && golden_limit_transfer.contains(member.getEmail())){ |
| | | return Result.fail("此账号有财务问题,需联系客服"); |
| | | } |
| | | if (member.getCertifyStatus() != MemberEntity.CERTIFY_STATUS_Y) { |
| | |
| | | } |
| | | return Result.ok(arrayList); |
| | | } |
| | | |
| | | @Override |
| | | public Result memberTeam(MemberTeamRecordsPageDto memberTeamRecordsPageDto) { |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | MemberTeamVo memberTeamVo = memberDao.selectAllTeamByInviteIdInPage(memberId,member.getInviteId()); |
| | | List<TeamVo> teamVos = new ArrayList<>(); |
| | | //直属会员 |
| | | List<MemberEntity> memberZhiShu = memberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | if(ObjectUtil.isEmpty(memberTeamVo)){ |
| | | MemberTeamVo memberTeamVoNull = new MemberTeamVo(); |
| | | Integer teamCnt = memberDao.selectMemberCountByInvitedId(member.getInviteId()); |
| | | memberTeamVoNull.setTeamCnt(teamCnt); |
| | | memberTeamVoNull.setZhiyaCnt(BigDecimal.ZERO); |
| | | memberTeamVoNull.setRewardCnt(BigDecimal.ZERO); |
| | | //直属会员 |
| | | if(CollUtil.isNotEmpty(memberZhiShu)){ |
| | | for(MemberEntity zhishu : memberZhiShu){ |
| | | TeamVo teamVo = new TeamVo(); |
| | | String phone = zhishu.getPhone(); |
| | | if(StrUtil.isNotEmpty(phone)){ |
| | | String result = phone.substring(phone.length()-4,phone.length()); |
| | | teamVo.setAccount(result); |
| | | } |
| | | int memberCnt = memberDao.selectMemberCountByInvitedId(zhishu.getInviteId()); |
| | | teamVo.setTeamCnt(memberCnt); |
| | | teamVo.setZhiyaCnt(BigDecimal.ZERO); |
| | | teamVo.setRewardCnt(BigDecimal.ZERO); |
| | | teamVos.add(teamVo); |
| | | } |
| | | memberTeamVoNull.setTeamVo(teamVos); |
| | | } |
| | | return Result.ok(memberTeamVoNull); |
| | | } |
| | | if(CollUtil.isNotEmpty(memberZhiShu)){ |
| | | for(MemberEntity zhishu : memberZhiShu){ |
| | | Long zhiShuMemberId = zhishu.getId(); |
| | | ZhiYaTeam zhiYaTeam = memberDao.selectZhiYaTeamRecordByMemberId(zhiShuMemberId); |
| | | TeamVo teamVo = new TeamVo(); |
| | | String phone = zhishu.getPhone(); |
| | | if(StrUtil.isNotEmpty(phone)){ |
| | | String result = phone.substring(phone.length()-4,phone.length()); |
| | | teamVo.setAccount(result); |
| | | } |
| | | int memberCnt = memberDao.selectMemberCountByInvitedId(zhishu.getInviteId()); |
| | | teamVo.setTeamCnt(memberCnt); |
| | | |
| | | Long aLong = zhiYaRecordDao.selectSumZhiyaCntByMemberIdAndOrderStatus(zhiShuMemberId, 1); |
| | | Long rLong = zhiYaRecordDao.selectSumRewardCntByMemberId(zhiShuMemberId); |
| | | teamVo.setZhiyaCnt(new BigDecimal(aLong)); |
| | | teamVo.setRewardCnt(new BigDecimal(rLong)); |
| | | if(ObjectUtil.isNotEmpty(zhiYaTeam)){ |
| | | teamVo.setZhiyaCnt((zhiYaTeam.getZhiyaCnt() == null ? BigDecimal.ZERO : zhiYaTeam.getZhiyaCnt()).add(new BigDecimal(aLong))); |
| | | teamVo.setRewardCnt(zhiYaTeam.getRewardCnt() == null ?BigDecimal.ZERO : zhiYaTeam.getRewardCnt().add(new BigDecimal(rLong))); |
| | | } |
| | | teamVos.add(teamVo); |
| | | } |
| | | memberTeamVo.setTeamVo(teamVos); |
| | | } |
| | | return Result.ok(memberTeamVo); |
| | | } |
| | | |
| | | @Override |
| | | public Result findDefaultWay() { |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | |
| | | DefaultWayVo defaultWayVo = new DefaultWayVo(); |
| | | MemberPaymentMethodEntity defualtMethod = this.memberPaymentMethodDao.selectDefualtMethod(memberId, null, "1"); |
| | | if (ObjectUtil.isNotEmpty(defualtMethod)) { |
| | | String paymentType = defualtMethod.getPaymentType(); |
| | | defaultWayVo.setPaymentType(paymentType); |
| | | } |
| | | return Result.ok(defaultWayVo); |
| | | } |
| | | |
| | | public Result memberCoinAddressInList() { |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | |
| | | Map<String, Object> columnMap = new HashMap<>(); |
| | | columnMap.put("member_id", memberId); |
| | | List<MemberCoinAddressInEntity> selectByMap = memberCoinAddressInDao.selectByMap(columnMap ); |
| | | List<MemberCoinAddressInListVo> arrayList = new ArrayList<>(); |
| | | if (CollUtil.isNotEmpty(selectByMap)) { |
| | | for (MemberCoinAddressInEntity memberCoinAddressInEntity : selectByMap) { |
| | | MemberCoinAddressInListVo memberCoinAddressInListVo = new MemberCoinAddressInListVo(); |
| | | memberCoinAddressInListVo.setId(memberCoinAddressInEntity.getId()); |
| | | memberCoinAddressInListVo.setAccount(memberCoinAddressInEntity.getAccount()); |
| | | memberCoinAddressInListVo.setContent(memberCoinAddressInEntity.getContent()); |
| | | arrayList.add(memberCoinAddressInListVo); |
| | | } |
| | | } |
| | | return Result.ok(arrayList); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result memberAddCoinAddressIn(MemberAddCoinAddressInDto memberAddCoinAddressDto) { |
| | | |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | String address = memberAddCoinAddressDto.getAddress(); |
| | | String remark = memberAddCoinAddressDto.getRemark(); |
| | | |
| | | MemberCoinAddressInEntity memberCoinAddressInEntity = new MemberCoinAddressInEntity(); |
| | | memberCoinAddressInEntity.setAccount(address); |
| | | memberCoinAddressInEntity.setMemberId(memberId); |
| | | memberCoinAddressInEntity.setContent(remark); |
| | | memberCoinAddressInDao.insert(memberCoinAddressInEntity); |
| | | return Result.ok(MessageSourceUtils.getString("member_service_0024")); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result memberSubmitCoinApplyIn(@Valid MemberSubmitCoinApplyInDto memberSubmitCoinApplyInDto) { |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | if (member.getCertifyStatus() != MemberEntity.CERTIFY_STATUS_Y) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0077")); |
| | | } |
| | | if (StrUtil.isEmpty(member.getTradePassword())) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0081")); |
| | | } |
| | | if (member.getTradePassword() == null) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0082")); |
| | | } |
| | | if (!member.getTradePassword().equals(SecureUtil.md5(memberSubmitCoinApplyInDto.getTradePassword()))) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0082")); |
| | | } |
| | | |
| | | boolean flag = commonservice.verifyCode(memberSubmitCoinApplyInDto.getAccount(), memberSubmitCoinApplyInDto.getCode()); |
| | | if (flag) { |
| | | //获取到账地址 |
| | | String address = memberSubmitCoinApplyInDto.getAddress(); |
| | | //根据账号获取会员信息 |
| | | MemberEntity selectMemberInfoByAccount = memberDao.selectMemberInfoByAccount(address); |
| | | if(ObjectUtil.isEmpty(selectMemberInfoByAccount)) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0087")); |
| | | } |
| | | Long memberInfoId = selectMemberInfoByAccount.getId(); |
| | | String symbol = memberSubmitCoinApplyInDto.getSymbol(); |
| | | |
| | | String addressIn = ""; |
| | | Map<String, Object> columnMapAddress = new HashMap<>(); |
| | | columnMapAddress.put("member_id", memberInfoId); |
| | | columnMapAddress.put("symbol", symbol); |
| | | List<MemberCoinAddressEntity> selectByMap2 = memberCoinAddressDao.selectByMap(columnMapAddress); |
| | | if(CollUtil.isEmpty(selectByMap2)) { |
| | | // return Result.fail(MessageSourceUtils.getString("member_service_0087")); |
| | | addressIn = address; |
| | | } else { |
| | | MemberCoinAddressEntity memberCoinAddressEntity = selectByMap2.get(0); |
| | | if(StrUtil.isEmpty(memberCoinAddressEntity.getAddress())){ |
| | | addressIn = selectMemberInfoByAccount.getInviteId(); |
| | | }else{ |
| | | addressIn = memberCoinAddressEntity.getAddress(); |
| | | } |
| | | } |
| | | |
| | | MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, memberSubmitCoinApplyInDto.getSymbol()); |
| | | BigDecimal availableBalance = walletCoin.getAvailableBalance(); |
| | | BigDecimal coinNumber = memberSubmitCoinApplyInDto.getCoinNumber(); |
| | | if (availableBalance.compareTo(BigDecimal.ZERO) > 0 |
| | | && availableBalance.compareTo(coinNumber) >= 0) { |
| | | //新增提币记录 |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdrawEntity.setAddress(addressIn); |
| | | memberCoinWithdrawEntity.setAmount(coinNumber); |
| | | memberCoinWithdrawEntity.setFeeAmount(BigDecimal.ZERO); |
| | | memberCoinWithdrawEntity.setSymbol(memberSubmitCoinApplyInDto.getSymbol()); |
| | | memberCoinWithdrawEntity.setMemberId(memberId); |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES); |
| | | memberCoinWithdrawEntity.setLabel(memberSubmitCoinApplyInDto.getLable()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdrawEntity); |
| | | BigDecimal subtract = walletCoin.getAvailableBalance().subtract(coinNumber); |
| | | walletCoin.setAvailableBalance(subtract); |
| | | BigDecimal add = walletCoin.getFrozenBalance().add(coinNumber); |
| | | walletCoin.setFrozenBalance(add); |
| | | memberWalletCoinDao.updateById(walletCoin); |
| | | |
| | | MemberAccountMoneyChange accountRecord = new MemberAccountMoneyChange(); |
| | | accountRecord.setContent("提币"); |
| | | accountRecord.setMemberId(memberId); |
| | | accountRecord.setAmount(coinNumber); |
| | | accountRecord.setWithdrawId(memberCoinWithdrawEntity.getId()); |
| | | accountRecord.setStatus(MemberAccountMoneyChange.STATUS_WAIT_INTEGER); |
| | | accountRecord.setSymbol(memberSubmitCoinApplyInDto.getSymbol()); |
| | | accountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN); |
| | | memberAccountMoneyChangeDao.insert(accountRecord); |
| | | |
| | | ThreadPoolUtils.sendDingTalk(3); |
| | | return Result.ok(MessageSourceUtils.getString("member_service_0086")); |
| | | } else { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0005")); |
| | | } |
| | | |
| | | } else { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0039")); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Result memberDelCoinAddressIn(MemberDelCoinAddressDto memberDelCoinAddressDto) { |
| | | //获取用户ID |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId(); |
| | | MemberEntity member = memberDao.selectById(memberId); |
| | | if (ObjectUtil.isNotEmpty(member)) { |
| | | Long id = memberDelCoinAddressDto.getId(); |
| | | memberCoinAddressInDao.deleteById(id); |
| | | } |
| | | return Result.ok("success"); |
| | | } |
| | | } |
| | | |
| | | |