xiaoyong931011
2020-06-05 68bfb0e22f518b4f328ce96889f3dce0a80be560
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -13,9 +13,12 @@
import javax.annotation.Resource;
import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
@@ -41,6 +44,7 @@
import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao;
import com.xcong.excoin.modules.platform.dao.TradeSettingDao;
import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
import com.xcong.excoin.utils.CoinTypeConvert;
@@ -71,6 +75,8 @@
   MemberAccountFlowEntityDao memberAccountFlowEntityDao;
    @Resource
    RedisUtils redisUtils;
    @Resource
    PlatformSymbolsCoinDao platformSymbolsCoinDao;
   
   @Override
   public String generateSimpleSerialno(String userId) {
@@ -371,9 +377,9 @@
                  //如果是限价卖出,撤单将对应的钱包冻结金额返回
                  MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
                  if (ObjectUtil.isNotEmpty(walletCoin)) {
                     //返还金额=开仓价*未成交数量
                     BigDecimal returnBalance = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
                     walletCoin.setAvailableBalance(returnBalance.setScale(4, BigDecimal.ROUND_DOWN));
                     BigDecimal returnBalance = orderCoinsEntity.getEntrustCnt();
                     walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
                     walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
                     memberWalletCoinDao.updateById(walletCoin);
                     // 流水记录
@@ -476,4 +482,35 @@
      return Result.ok(findCollectListVo);
   }
   @Override
   public Result searchSymbolResultList() {
      //获取用户ID
      Long memberId = LoginUserUtils.getAppLoginUser().getId();
      FindCollectListVo findCollectListVo = new FindCollectListVo();
      List<MemberSelectSymbolsVo> list = new ArrayList<>();
      Map<String, Object> columnMap = new HashMap<>();
      List<PlatformSymbolsCoinEntity> selectByMap = platformSymbolsCoinDao.selectByMap(columnMap);
      List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
      for(PlatformSymbolsCoinEntity platformSymbolsCoinEntity : selectByMap) {
         MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
         memberSelectSymbolsVo.setSymbol(platformSymbolsCoinEntity.getName());
         if(CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) {
            for(MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectSymbolByMemIdAndSymbol) {
               if(platformSymbolsCoinEntity.getName().equals(memberSelectSymbolsEntity.getSymbol())) {
                  memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES);
               }else {
                  memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO);
               }
            }
         }else {
            memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO);
         }
         list.add(memberSelectSymbolsVo);
      }
      findCollectListVo.setMemberSelectSymbolsVo(list);
      return Result.ok(findCollectListVo);
   }
}