From 9a968ba186af5280fcc29cc3eb04412eff204ba7 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 27 May 2021 16:37:33 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java | 303 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 256 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java index 591f214..a0fc791 100644 --- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.contants.AppContants; @@ -13,25 +14,23 @@ 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.activity.dao.ActivityMainDao; +import com.xcong.excoin.modules.activity.dao.ActivityMemberDetailDao; +import com.xcong.excoin.modules.activity.dao.ActivityReceiveRecordDao; +import com.xcong.excoin.modules.activity.dao.ActivitySubDao; +import com.xcong.excoin.modules.activity.entity.ActivityMain; +import com.xcong.excoin.modules.activity.entity.ActivityMemberDetail; +import com.xcong.excoin.modules.activity.entity.ActivityReceiveRecord; +import com.xcong.excoin.modules.activity.entity.ActivitySub; import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao; import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange; +import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity; 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.MemberSubmitCoinApplyInDto; -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; @@ -42,12 +41,14 @@ import com.xcong.excoin.utils.ThreadPoolUtils; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.Put; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -98,6 +99,9 @@ @Resource MemberCoinAddressDao memberCoinAddressDao; + + @Resource + MemberCoinAddressInDao memberCoinAddressInDao; @Resource private CommonService commonservice; @@ -107,6 +111,16 @@ @Resource AppVersionDao appVersionDao; + + @Resource + ActivityMainDao activityMainDao; + @Resource + ActivityMemberDetailDao activityMemberDetailDao; + @Resource + ActivityReceiveRecordDao activityReceiveRecordDao; + @Resource + ActivitySubDao activitySubDao; + @Resource private MemberSettingDao memberSettingDao; @@ -157,12 +171,13 @@ member.setCertifyStatus(MemberEntity.CERTIFY_STATUS_UN_SUBMIT); member.setIsForce(1); member.setIsProfit(0); + member.setContractPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ALL); memberDao.insert(member); MemberSettingEntity memberSettingEntity = new MemberSettingEntity(); - memberSettingEntity.setSpread(BigDecimal.ONE); - memberSettingEntity.setClosingSpread(BigDecimal.valueOf(5)); - memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0030)); + memberSettingEntity.setSpread(BigDecimal.valueOf(0.5)); + memberSettingEntity.setClosingSpread(BigDecimal.valueOf(2)); + memberSettingEntity.setForceParam(BigDecimal.valueOf(0.0085)); memberSettingEntity.setMemberId(member.getId()); memberSettingDao.insert(memberSettingEntity); @@ -195,18 +210,17 @@ walletContractSimulate.setWalletCode(CoinTypeEnum.USDT.name()); memberWalletContractSimulateDao.insert(walletContractSimulate); + //初始化合约钱包 + MemberWalletContractEntity walletContract = new MemberWalletContractEntity(); + walletContract.setMemberId(member.getId()); + walletContract.setAvailableBalance(AppContants.INIT_MONEY); + walletContract.setFrozenBalance(AppContants.INIT_MONEY); + walletContract.setTotalBalance(AppContants.INIT_MONEY); + walletContract.setBorrowedFund(AppContants.INIT_MONEY); + walletContract.setWalletCode(CoinTypeEnum.USDT.name()); + memberWalletContractDao.insert(walletContract); for (CoinTypeEnum coinTypeEnum : CoinTypeEnum.values()) { - //初始化合约钱包 - MemberWalletContractEntity walletContract = new MemberWalletContractEntity(); - walletContract.setMemberId(member.getId()); - walletContract.setAvailableBalance(AppContants.INIT_MONEY); - walletContract.setFrozenBalance(AppContants.INIT_MONEY); - walletContract.setTotalBalance(AppContants.INIT_MONEY); - walletContract.setBorrowedFund(AppContants.INIT_MONEY); - walletContract.setWalletCode(coinTypeEnum.name()); - memberWalletContractDao.insert(walletContract); - // 初始化币币钱包 MemberWalletCoinEntity walletCoin = new MemberWalletCoinEntity(); walletCoin.setWalletCode(coinTypeEnum.name()); @@ -230,6 +244,42 @@ levelRate.setMemberId(member.getId()); levelRate.setSymbol(symbolEnum.getValue()); memberLevelRateDao.insert(levelRate); + } + /** + * 初始化活动信息 + */ + //获取开始中的活动 + ActivityMain activityMain = activityMainDao.selectById(1); + if(ObjectUtil.isNotEmpty(activityMain)) { + if(ActivityMain.STATE_START == activityMain.getState()) { + //新增【活动记录表】信息 + ActivityReceiveRecord activityReceiveRecord = new ActivityReceiveRecord(); + activityReceiveRecord.setMemberId(member.getId()); + activityReceiveRecord.setMainId(activityMain.getId()); + activityReceiveRecord.setReceiveCoinAmount(BigDecimal.ZERO); + activityReceiveRecord.setReceiveState(ActivityReceiveRecord.RECEIVESTATE_TWO); + Date startTime = new Date(); + Date date = new Date(startTime.getTime() + ActivityReceiveRecord.DAYS*24*60*60*1000); + activityReceiveRecord.setInvalidTime(date); + Map<String, Object> activitySubMap = new HashMap<>(); + activitySubMap.put("main_id", activityMain.getId()); + List<ActivitySub> activitySubs = activitySubDao.selectByMap(activitySubMap ); + if(CollUtil.isNotEmpty(activitySubs)) { + for(ActivitySub ActivitySub : activitySubs) { + Long subId = ActivitySub.getId(); + activityReceiveRecord.setSubId(subId); + activityReceiveRecordDao.insert(activityReceiveRecord); + } + } + //新增【活动个人详情表】信息 + ActivityMemberDetail activityMemberDetail = new ActivityMemberDetail(); + activityMemberDetail.setMainId(activityMain.getId()); + activityMemberDetail.setBurstUsdt(BigDecimal.ZERO); + activityMemberDetail.setReceivedUsdt(BigDecimal.ZERO); + activityMemberDetail.setSurplusUsdt(activityMain.getAmount()); + activityMemberDetail.setMemberId(member.getId()); + activityMemberDetailDao.insert(activityMemberDetail); + } } return Result.ok(MessageSourceUtils.getString("home_service_0009")); @@ -490,6 +540,10 @@ Long memberId = LoginUserUtils.getAppLoginUser().getId(); MemberEntity member = memberDao.selectById(memberId); +// if (!MemberPaymentMethodEntity.PAYMENTTYPE_CARD.toString().equals(memberPaymethodDto.getPaymentType())) { +// return Result.fail("只能绑定银行卡"); +// } + if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) { return Result.fail(MessageSourceUtils.getString("member_service_0077")); } @@ -503,6 +557,12 @@ return Result.fail(MessageSourceUtils.getString("member_service_0097")); } } + } + + String isDefault = "1"; + MemberPaymentMethodEntity defaultMethod = memberPaymentMethodDao.selectDefualtMethod(memberId, null, "1"); + if (defaultMethod != null) { + isDefault = "2"; } String account = memberPaymethodDto.getAccount(); String bank = memberPaymethodDto.getBank(); @@ -518,6 +578,7 @@ memberPaymentMethodEntity.setPaymentQrcode(paymentQrcode); memberPaymentMethodEntity.setPaymentType(paymentType); memberPaymentMethodEntity.setSubBank(subBank); + memberPaymentMethodEntity.setIsDefualt(isDefault); memberPaymentMethodDao.insert(memberPaymentMethodEntity); return Result.ok(MessageSourceUtils.getString("member_service_0024")); } @@ -528,6 +589,17 @@ //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); Long id = memberDelPaymethodDto.getId(); + + MemberPaymentMethodEntity paymentMethodEntity = memberPaymentMethodDao.selectById(id); + if ("1".equals(paymentMethodEntity.getIsDefualt())) { + return Result.fail("不能删除默认收款方式"); + } + + List<MemberPaymentMethodEntity> list = memberPaymentMethodDao.selectByMemberId(memberId); + if (list.size() == 1) { + return Result.fail("必须保留一个收款方式"); + } + Map<String, Object> columnMap = new HashMap<>(); columnMap.put("id", id); columnMap.put("member_id", memberId); @@ -572,6 +644,7 @@ memberPaymethodDetailVo.setPaymentQrcode(memberPaymentMethodEntity.getPaymentQrcode()); memberPaymethodDetailVo.setPaymentType(memberPaymentMethodEntity.getPaymentType()); memberPaymethodDetailVo.setSubBank(memberPaymentMethodEntity.getSubBank()); + memberPaymethodDetailVo.setIsDefault(memberPaymentMethodEntity.getIsDefualt()); arrayList.add(memberPaymethodDetailVo); } } @@ -579,6 +652,29 @@ MemberPaymethodDetailListVo memberPaymethodDetailListVo = new MemberPaymethodDetailListVo(); memberPaymethodDetailListVo.setMemberPaymethodDetailVo(arrayList); return Result.ok(memberPaymethodDetailListVo); + } + + @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 @@ -685,10 +781,10 @@ Long memberId = LoginUserUtils.getAppLoginUser().getId(); String address = memberAddCoinAddressDto.getAddress(); String isBiyict = memberAddCoinAddressDto.getIsBiyict(); - Long symbolscoinId = memberAddCoinAddressDto.getSymbolscoinId(); + String symbol = memberAddCoinAddressDto.getSymbol(); String remark = memberAddCoinAddressDto.getRemark(); - - PlatformSymbolsCoinEntity platformSymbolsCoinEntity = platformSymbolsCoinDao.selectById(symbolscoinId); + PlatformSymbolsCoinEntity platformSymbolsCoinEntity = platformSymbolsCoinDao.selectOneBySymbol(symbol); + Long symbolscoinId = platformSymbolsCoinEntity.getId(); MemberCoinAddressEntity memberCoinAddressEntity = new MemberCoinAddressEntity(); memberCoinAddressEntity.setAddress(address); @@ -798,6 +894,16 @@ memberPersonCenterInfoVo.setTradeAgingSetting(MemberPersonCenterInfoVo.PWD_NEED_NO); } + if (StrUtil.isEmpty(member.getName())) { + memberPersonCenterInfoVo.setNickName(2); + } else { + memberPersonCenterInfoVo.setNickName(1); + } + + Integer fingerprintState = member.getFingerprintState(); + memberPersonCenterInfoVo.setFingerprintState(fingerprintState); + + memberPersonCenterInfoVo.setIsMb(member.getIsTrader()); return Result.ok(memberPersonCenterInfoVo); } @@ -820,7 +926,7 @@ } @Override - public Result memberAvivableCoinInfo(String symbol) { + public Result memberAvivableCoinInfo(String symbol,String lable) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol); @@ -831,7 +937,7 @@ List<MemberAvivableCoinInfoVo> arrayList = new ArrayList<>(); - List<PlatformFeeSettingEntity> feeSettingByTypeAndSymbolLable = platformFeeSettingDao.getFeeSettingsByTypeAndSymbol(2, symbol); + List<PlatformFeeSettingEntity> feeSettingByTypeAndSymbolLable = platformFeeSettingDao.getFeeSettingsByTypeAndSymbol(2, symbol,lable); if (CollUtil.isEmpty(feeSettingByTypeAndSymbolLable)) { return Result.fail(MessageSourceUtils.getString("member_service_0087")); } @@ -904,6 +1010,7 @@ memberCoinWithdrawEntity.setFeeAmount(memberSubmitCoinApplyDto.getFeeAmount()); memberCoinWithdrawEntity.setSymbol(memberSubmitCoinApplyDto.getSymbol()); memberCoinWithdrawEntity.setMemberId(memberId); + memberCoinWithdrawEntity.setLabel(memberSubmitCoinApplyDto.getLable()); memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); Map<String, Object> columnMap = new HashMap<>(); @@ -963,7 +1070,7 @@ @Override public Result getAppVersionInfo() { - MemberEntity memberEntity = LoginUserUtils.getAppLoginUser(); +// MemberEntity memberEntity = LoginUserUtils.getAppLoginUser(); Map<String, Object> columnMap = new HashMap<>(); List<AppVersionEntity> selectByMap = appVersionDao.selectByMap(columnMap); @@ -971,15 +1078,16 @@ if (CollUtil.isNotEmpty(selectByMap)) { for (AppVersionEntity appVersionEntity : selectByMap) { AppVersionVo appVersionVo = new AppVersionVo(); - if ("37059551".equals(memberEntity.getInviteId())) { - appVersionVo.setAddress("www.baidu.com"); - appVersionVo.setType(appVersionEntity.getType()); - appVersionVo.setVersion(appVersionEntity.getVersion()); - } else { - appVersionVo.setAddress(appVersionEntity.getAddress()); - appVersionVo.setType(appVersionEntity.getType()); - appVersionVo.setVersion(appVersionEntity.getVersion()); - } +// if ("37059551".equals(memberEntity.getInviteId())) { +// appVersionVo.setAddress("www.baidu.com"); +// appVersionVo.setType(appVersionEntity.getType()); +// appVersionVo.setVersion(appVersionEntity.getVersion()); +// } else { +// +// } + appVersionVo.setAddress(appVersionEntity.getAddress()); + appVersionVo.setType(appVersionEntity.getType()); + appVersionVo.setVersion(appVersionEntity.getVersion()); arrayList.add(appVersionVo); } } @@ -1032,16 +1140,19 @@ } 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 ); + List<MemberCoinAddressEntity> selectByMap2 = memberCoinAddressDao.selectByMap(columnMapAddress); if(CollUtil.isEmpty(selectByMap2)) { - return Result.fail(MessageSourceUtils.getString("member_service_0087")); - } - MemberCoinAddressEntity memberCoinAddressEntity = selectByMap2.get(0); - String addressIn = memberCoinAddressEntity.getAddress(); +// return Result.fail(MessageSourceUtils.getString("member_service_0087")); + addressIn = address; + } else { + MemberCoinAddressEntity memberCoinAddressEntity = selectByMap2.get(0); + addressIn = memberCoinAddressEntity.getAddress(); + } MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, memberSubmitCoinApplyInDto.getSymbol()); BigDecimal availableBalance = walletCoin.getAvailableBalance(); @@ -1057,6 +1168,7 @@ 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); @@ -1084,6 +1196,103 @@ return Result.fail(MessageSourceUtils.getString("member_service_0039")); } } + + @Override + public Result memberAddCoinAddressIn(@Valid 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 + public Result memberDelCoinAddressIn(@Valid 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"); + } + + @Override + 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 + public Result memberFingerprintState(@Valid MemberFingerprintStateDto memberFingerprintStateDto) { + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + + String password = SecureUtil.md5(memberFingerprintStateDto.getPassword()); + MemberEntity member = memberDao.selectById(memberId); + + if(password.equals(member.getPassword())){ + Integer fingerprintState = memberFingerprintStateDto.getFingerprintState(); + MemberEntity memberEntity = memberDao.selectById(memberId); + memberEntity.setFingerprintState(fingerprintState); + memberDao.updateById(memberEntity); + return Result.ok(MessageSourceUtils.getString("member_service_0024")); + }else{ + return Result.fail(MessageSourceUtils.getString("home_service_0005")); + } + } + + @Override + @Transactional + public Result memberMessageReminder() { + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + MemberMessageReminderVo memberMessageReminderVo = new MemberMessageReminderVo(); + MemberSettingEntity selectById = memberSettingDao.selectMemberSettingByMemberId(memberId); + if(ObjectUtil.isNotEmpty(selectById)) { + memberMessageReminderVo.setMessageReminder(selectById.getMessageReminder()); + } + return Result.ok(memberMessageReminderVo); + } + + @Override + public Result findDefaultWay() { + //获取用户ID + Long memberId = LoginUserUtils.getAppLoginUser().getId(); +// Long memberId = 446L; + + 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); + } + } -- Gitblit v1.9.1