| | |
| | | import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
|
| | | import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
|
| | | import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
|
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao;
|
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao;
|
| | | import com.xcong.excoin.modules.documentary.dao.FollowFollowerSettingDao;
|
| | | import com.xcong.excoin.modules.documentary.dao.FollowTraderInfoDao;
|
| | |
| | | import com.xcong.excoin.modules.documentary.dto.MyFollowOrderDto;
|
| | | import com.xcong.excoin.modules.documentary.dto.MyFollowTraderInfoDto;
|
| | | import com.xcong.excoin.modules.documentary.dto.UpdateDocumentaryOrderSetDto;
|
| | | import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity;
|
| | | import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
|
| | | import com.xcong.excoin.modules.documentary.entity.FollowFollowerSettingEntity;
|
| | | import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity;
|
| | |
| | | private MemberWalletContractDao memberWalletContractDao;
|
| | | @Resource
|
| | | private FollowFollowerSettingDao followFollowerSettingDao;
|
| | | @Resource
|
| | | private FollowFollowerOrderRelationDao followFollowerOrderRelationDao;
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | Page<HistoryOrderRecordsVo> page = new Page<>(historyOrderRecordsDto.getPageNum(), historyOrderRecordsDto.getPageSize());
|
| | | IPage<HistoryOrderRecordsVo> historyOrderRecordsVoList = followTraderProfitInfoDao.selectHistoryOrderRecords(page, memberId);
|
| | | List<HistoryOrderRecordsVo> records = historyOrderRecordsVoList.getRecords();
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | for(HistoryOrderRecordsVo historyOrderRecordsVo : records) {
|
| | | BigDecimal closingPrice = historyOrderRecordsVo.getClosingPrice().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | historyOrderRecordsVo.setClosingPrice(closingPrice);
|
| | | BigDecimal openingPrice = historyOrderRecordsVo.getOpeningPrice().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | historyOrderRecordsVo.setOpeningPrice(openingPrice);
|
| | | }
|
| | | }
|
| | | return Result.ok(historyOrderRecordsVoList);
|
| | | }
|
| | |
|
| | |
| | | List<FollowRecordsVo> records = historyOrderRecordsVoList.getRecords();
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | for(FollowRecordsVo followRecordsVo : records) {
|
| | | |
| | | BigDecimal totalPrincipal = followRecordsVo.getTotalPrincipal().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | followRecordsVo.setTotalPrincipal(totalPrincipal);
|
| | | BigDecimal totalProfit = followRecordsVo.getTotalProfit().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | followRecordsVo.setTotalProfit(totalProfit);
|
| | | |
| | | Long memberIds = followRecordsVo.getMemberId();
|
| | | MemberEntity MemberEntity = memberDao.selectById(memberIds);
|
| | | String phone = MemberEntity.getPhone();
|
| | |
| | | totalProfits = totalProfits.add(totalProfit);
|
| | | }
|
| | | }
|
| | | followInfoVo.setTotalPrincipal(totalPrincipals.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | followInfoVo.setTotalProfit(totalProfits.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | followInfoVo.setTotalPrincipal(totalPrincipals.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | followInfoVo.setTotalProfit(totalProfits.setScale(2, BigDecimal.ROUND_DOWN));
|
| | |
|
| | | return Result.ok(followInfoVo);
|
| | | }
|
| | |
| | | public Result getHistoryMyFollowOrderRecords(@Valid MyFollowOrderDto myFollowOrderDto) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | Page<MyFollowOrderVo> result = new Page<>();
|
| | | List<MyFollowOrderVo> myFollowOrderVos = result.getRecords();
|
| | | List<MyFollowOrderVo> myFollowOrderVos = new ArrayList<>();
|
| | | //历史跟单
|
| | | Page<ContractOrderEntity> page = new Page<>(myFollowOrderDto.getPageNum(), myFollowOrderDto.getPageSize());
|
| | | IPage<ContractOrderEntity> contractOrderEntitys = followFollowerProfitDao.getMyFollowOrderHistoryRecords(page, memberId);
|
| | |
| | | myFollowOrderVo.setOrderType(orderType);
|
| | | int leverRatio = contractOrderEntity.getLeverRatio();
|
| | | myFollowOrderVo.setLeverRatio(leverRatio);
|
| | | BigDecimal rewardAmount = contractOrderEntity.getRewardAmount().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal rewardAmount = contractOrderEntity.getRewardAmount().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setRewardAmount(rewardAmount);
|
| | | BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal rewardRatio = contractOrderEntity.getRewardRatio().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setRewardRatio(rewardRatio);
|
| | | int symbolCnt = contractOrderEntity.getSymbolCnt();
|
| | | myFollowOrderVo.setSymbolCnt(symbolCnt);
|
| | | BigDecimal bondAmount = contractOrderEntity.getBondAmount().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal bondAmount = contractOrderEntity.getBondAmount().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setBondAmount(bondAmount);
|
| | | BigDecimal openingPrice = contractOrderEntity.getOpeningPrice().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal openingPrice = contractOrderEntity.getOpeningPrice().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setOpeningPrice(openingPrice);
|
| | | BigDecimal closingPrice = contractOrderEntity.getClosingPrice().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal closingPrice = contractOrderEntity.getClosingPrice().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setClosingPrice(closingPrice);
|
| | | Date openingTime = contractOrderEntity.getOpeningTime();
|
| | | myFollowOrderVo.setOpeningTime(openingTime);
|
| | |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | MemberEntity member = memberDao.selectById(memberId);
|
| | |
|
| | | Page<MyFollowOrderVo> result = new Page<>();
|
| | | List<MyFollowOrderVo> myFollowOrderVos = result.getRecords();
|
| | | List<MyFollowOrderVo> myFollowOrderVos = new ArrayList<>();
|
| | | //当前跟单
|
| | | Page<ContractHoldOrderEntity> page = new Page<>(myFollowOrderDto.getPageNum(), myFollowOrderDto.getPageSize());
|
| | | IPage<ContractHoldOrderEntity> contractHoldOrderEntitys = followFollowerProfitDao.getMyFollowOrderNowRecords(page, memberId);
|
| | |
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | for(ContractHoldOrderEntity contractHoldOrderEntity : records) {
|
| | | MyFollowOrderVo myFollowOrderVo = new MyFollowOrderVo();
|
| | | //获取交易员信息
|
| | | Long orderId = contractHoldOrderEntity.getId();
|
| | | FollowFollowerOrderRelationEntity FollowFollowerOrderRelation = followFollowerOrderRelationDao.selectOneByorderIdandMemberId(orderId,memberId);
|
| | | Long tradeId = FollowFollowerOrderRelation.getTradeId();
|
| | | FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(tradeId);
|
| | | String nickname = followTraderInfoEntity.getNickname();
|
| | | myFollowOrderVo.setNickname(nickname);
|
| | | |
| | | String symbol = contractHoldOrderEntity.getSymbol();
|
| | | myFollowOrderVo.setSymbol(symbol);
|
| | | int orderType = contractHoldOrderEntity.getOpeningType();
|
| | |
| | | myFollowOrderVo.setLeverRatio(leverRatio);
|
| | | int symbolCnt = contractHoldOrderEntity.getSymbolCnt();
|
| | | myFollowOrderVo.setSymbolCnt(symbolCnt);
|
| | | BigDecimal bondAmount = contractHoldOrderEntity.getBondAmount().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal bondAmount = contractHoldOrderEntity.getBondAmount().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setBondAmount(bondAmount);
|
| | | BigDecimal openingPrice = contractHoldOrderEntity.getOpeningPrice().setScale(4, BigDecimal.ROUND_DOWN);
|
| | | BigDecimal openingPrice = contractHoldOrderEntity.getOpeningPrice().setScale(2, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setOpeningPrice(openingPrice);
|
| | | String orderNo = contractHoldOrderEntity.getOrderNo();
|
| | | myFollowOrderVo.setOrderNo(orderNo);
|
| | |
| | |
|
| | | // 获取最新价
|
| | | BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(contractHoldOrderEntity.getSymbol())));
|
| | | myFollowOrderVo.setNewPrice(newPrice);
|
| | | |
| | | BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(contractHoldOrderEntity.getSymbol());
|
| | | // 盈亏
|
| | | BigDecimal rewardRatio = BigDecimal.ZERO;
|
| | |
| | | rewardRatio = rewardRatio.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
|
| | | }
|
| | | }
|
| | | myFollowOrderVo.setRewardAmount(rewardRatio.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | myFollowOrderVo.setRewardAmount(rewardRatio.setScale(2, BigDecimal.ROUND_DOWN));
|
| | |
|
| | | // 回报率
|
| | | BigDecimal returnRate = rewardRatio.divide(contractHoldOrderEntity.getBondAmount().subtract(contractHoldOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
|
| | | myFollowOrderVo.setRewardRatio(returnRate.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | myFollowOrderVo.setRewardRatio(returnRate.setScale(2, BigDecimal.ROUND_DOWN));
|
| | |
|
| | | myFollowOrderVos.add(myFollowOrderVo);
|
| | | }
|
| | |
| | | BigDecimal totalPrincipal = FollowFollowerProfitEntity.getTotalPrincipal();
|
| | | myFollowTraderInfoVo.setTotalPrincipal(totalPrincipal);
|
| | | BigDecimal totalProfit = FollowFollowerProfitEntity.getTotalProfit();
|
| | | myFollowTraderInfoVo.setTotalProfit(totalProfit.setScale(4, BigDecimal.ROUND_DOWN));
|
| | | myFollowTraderInfoVo.setTotalProfit(totalProfit.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | myFollowOrderVos.add(myFollowTraderInfoVo);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | return Result.ok(MessageSourceUtils.getString("member_service_0024"));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Result getFollowTraderProfit(long traderId) {
|
| | | FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(traderId);
|
| | | Long memberId = followTraderInfoEntity.getMemberId();
|
| | | FollowTraderProfitInfoVo followTraderProfitInfoVo = followTraderProfitInfoDao.selectOneByMemberId(memberId);
|
| | | String avatar = followTraderInfoEntity.getAvatar();
|
| | | String nickname = followTraderInfoEntity.getNickname();
|
| | | String declaration = followTraderInfoEntity.getDeclaration();
|
| | | Integer isAll = followTraderInfoEntity.getIsAll();
|
| | | followTraderProfitInfoVo.setAvatar(avatar);
|
| | | followTraderProfitInfoVo.setNickname(nickname);
|
| | | followTraderProfitInfoVo.setDeclaration(declaration);
|
| | | followTraderProfitInfoVo.setIsAll(isAll);
|
| | | return Result.ok(followTraderProfitInfoVo);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Result beTrader() {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | MemberEntity memberEntity = memberDao.selectById(memberId);
|
| | | Integer certifyStatus = memberEntity.getCertifyStatus();
|
| | | if(MemberEntity.CERTIFY_STATUS_Y != certifyStatus) {
|
| | | return Result.ok(MessageSourceUtils.getString("member_controller_0009"));
|
| | | }
|
| | | //新增【交易员信息表】数据
|
| | | FollowTraderInfoEntity followTraderInfoEntity = new FollowTraderInfoEntity();
|
| | | followTraderInfoEntity.setMemberId(memberId);
|
| | | followTraderInfoEntity.setAvatar(FollowTraderInfoEntity.AVATAR_DEFAULT);
|
| | | String phone = memberEntity.getPhone();
|
| | | String email = memberEntity.getEmail();
|
| | | if(StrUtil.isNotEmpty(phone)) {
|
| | | followTraderInfoEntity.setNickname(phone);
|
| | | }else {
|
| | | followTraderInfoEntity.setNickname(email);
|
| | | }
|
| | | followTraderInfoEntity.setDeclaration(FollowTraderInfoEntity.DECLARATION_DEFAULT);
|
| | | followTraderInfoEntity.setIsAll(FollowTraderInfoEntity.IS_ALL_N);
|
| | | followTraderInfoEntity.setProfitRatio(BigDecimal.ZERO);
|
| | | followTraderInfoEntity.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_ING);
|
| | | followTraderInfoEntity.setIsOpen(FollowTraderInfoEntity.ISOPEN_Y);
|
| | | followTraderInfoDao.insert(followTraderInfoEntity);
|
| | | return Result.ok(MessageSourceUtils.getString("member_service_0024"));
|
| | | }
|
| | |
|
| | |
|
| | |
|