| | |
| | | import com.xcong.excoin.common.response.Result; |
| | | 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.entity.MemberAccountMoneyChange; |
| | | 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.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; |
| | |
| | | |
| | | @Resource |
| | | private MemberWalletAgentDao memberWalletAgentDao; |
| | | |
| | | @Resource |
| | | MemberAccountMoneyChangeDao memberAccountMoneyChangeDao; |
| | | |
| | | @Resource |
| | | private MemberWalletContractDao memberWalletContractDao; |
| | |
| | | |
| | | @Resource |
| | | private CommonService commonservice; |
| | | |
| | | @Resource |
| | | MemberCoinWithdrawDao memberCoinWithdrawDao; |
| | | |
| | | @Resource |
| | | private MemberWalletContractSimulateDao memberWalletContractSimulateDao; |
| | |
| | | return Result.ok("success"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result memberSubmitCoinApply(@Valid MemberSubmitCoinApplyDto memberSubmitCoinApplyDto) { |
| | | //获取用户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(memberSubmitCoinApplyDto.getTradePassword()))) { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0082")); |
| | | } |
| | | |
| | | boolean flag = commonservice.verifyCode(memberSubmitCoinApplyDto.getAccount(), memberSubmitCoinApplyDto.getCode()); |
| | | if (flag) { |
| | | MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, memberSubmitCoinApplyDto.getSymbol()); |
| | | BigDecimal availableBalance = walletCoin.getAvailableBalance(); |
| | | BigDecimal coinNumber = memberSubmitCoinApplyDto.getCoinNumber().add(memberSubmitCoinApplyDto.getFeeAmount()); |
| | | if(availableBalance.compareTo(BigDecimal.ZERO) > 0 |
| | | && availableBalance.compareTo(coinNumber) > 0) { |
| | | //新增提币记录 |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdrawEntity.setAddress(memberSubmitCoinApplyDto.getAddress()); |
| | | memberCoinWithdrawEntity.setAmount(coinNumber); |
| | | memberCoinWithdrawEntity.setFeeAmount(memberSubmitCoinApplyDto.getFeeAmount()); |
| | | memberCoinWithdrawEntity.setSymbol(memberSubmitCoinApplyDto.getSymbol()); |
| | | memberCoinWithdrawEntity.setMemberId(memberId); |
| | | memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | |
| | | Map<String,Object> columnMap = new HashMap<>(); |
| | | columnMap.put("symbol", memberSubmitCoinApplyDto.getSymbol()); |
| | | columnMap.put("address", memberSubmitCoinApplyDto.getAddress()); |
| | | List<MemberCoinAddressEntity> selectByMap = memberCoinAddressDao.selectByMap(columnMap); |
| | | if(CollUtil.isEmpty(selectByMap)) { |
| | | memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_NO); |
| | | }else { |
| | | memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES); |
| | | } |
| | | 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(memberSubmitCoinApplyDto.getCoinNumber()); |
| | | accountRecord.setStatus(MemberAccountMoneyChange.STATUS_WAIT_INTEGER); |
| | | accountRecord.setSymbol(memberSubmitCoinApplyDto.getSymbol()); |
| | | accountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN); |
| | | memberAccountMoneyChangeDao.insert(accountRecord); |
| | | /** |
| | | * TODO dingtalk |
| | | Constant.excutor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | DingTalkUtils.sendActionCard(3); |
| | | } |
| | | }); |
| | | */ |
| | | return Result.ok(MessageSourceUtils.getString("member_service_0086")); |
| | | }else { |
| | | return Result.fail(MessageSourceUtils.getString("order_service_0040")); |
| | | } |
| | | |
| | | }else { |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0039")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |