| | |
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.validation.Valid;
|
| | |
|
| | | import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
|
| | | import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
|
| | | import com.xcong.excoin.modules.coin.mapper.MemberAccountMoneyChangeMapper;
|
| | | import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto;
|
| | | import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.CoinInListVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.ContractSymbolListVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
|
| | |
| | | import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
|
| | | import com.xcong.excoin.modules.coin.service.CoinService;
|
| | | import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao;
|
| | | import com.xcong.excoin.modules.member.dao.MemberCoinWithdrawDao;
|
| | | import com.xcong.excoin.modules.member.dao.MemberDao;
|
| | | import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
|
| | | import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
|
| | | import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
|
| | | import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity;
|
| | | import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity;
|
| | | import com.xcong.excoin.modules.member.entity.MemberEntity;
|
| | | import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
|
| | | import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
|
| | |
| | | import cn.hutool.core.collection.CollUtil;
|
| | | import cn.hutool.core.util.ObjectUtil;
|
| | | import cn.hutool.core.util.StrUtil;
|
| | | import jnr.ffi.Struct.int16_t;
|
| | |
|
| | | @Service
|
| | | public class CoinServiceImpl extends ServiceImpl<MemberWalletCoinDao, MemberWalletCoinEntity> implements CoinService {
|
| | |
| | | MemberWalletAgentDao memberWalletAgentDao;
|
| | | @Resource
|
| | | MemberDao memberDao;
|
| | | @Resource
|
| | | MemberCoinChargeDao memberCoinChargeDao;
|
| | | @Resource
|
| | | MemberCoinWithdrawDao memberCoinWithdrawDao;
|
| | | @Resource
|
| | | RedisUtils redisUtils;
|
| | |
|
| | |
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
|
| | | BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
|
| | | |
| | | Map<String, Object> columnMap = new HashMap<String, Object>();
|
| | | columnMap.put("member_id", memberId);
|
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | map.put("wallet_code", "USDT");
|
| | | columnMap.put("wallet_code", "USDT");
|
| | | List<MemberWalletContractEntity> selectByMap = memberWalletContractDao.selectByMap(columnMap);
|
| | | MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
|
| | | if(CollUtil.isNotEmpty(selectByMap)) {
|
| | | for(MemberWalletContractEntity memberWalletContractEntity : selectByMap) {
|
| | | memberWalletContractInfoVo.setFrozenBalance(memberWalletContractEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setAvailableBalance(memberWalletContractEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setTotalBalance(memberWalletContractEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setTotalRMBBalance(memberWalletContractEntity.getTotalBalance().multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setTotalCoin(memberWalletContractEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setAvailableCoin(memberWalletContractEntity.getTotalBalance().multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
|
| | | memberWalletContractInfoVo.setWalletCode(memberWalletContractEntity.getWalletCode()+"/USDT");
|
| | | }
|
| | | }
|
| | |
| | | String symbolIns = symbolIn+"/USDT";
|
| | | ThreadPoolUtils.sendWholeForceClosingPrice(symbolIns, memberEntity);
|
| | |
|
| | | ThreadPoolUtils.sendWholePrice(memberId);
|
| | | |
| | | //添加币币资金划转历史记录
|
| | | MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
|
| | | memberAccountRecord.setContent("转出至合约"+symbolIn+"账户");
|
| | |
| | |
|
| | | return Result.ok(MessageSourceUtils.getString("member_service_0006"));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Result coinInList(@Valid CoinInListDto coinInListDto) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | int type = coinInListDto.getType();
|
| | | //充币记录
|
| | | if(type == 1) {
|
| | | Page<MemberCoinChargeEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | MemberCoinChargeEntity memberCoinChargeEntity = new MemberCoinChargeEntity();
|
| | | memberCoinChargeEntity.setMemberId(memberId);
|
| | | IPage<MemberCoinChargeEntity> memberCoinCharge = memberCoinChargeDao.findMemberCoinChargeInPage(page, memberCoinChargeEntity);
|
| | | List<MemberCoinChargeEntity> records = memberCoinCharge.getRecords();
|
| | |
|
| | | Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | ArrayList<CoinInListVo> arrayList = new ArrayList<>();
|
| | | for(MemberCoinChargeEntity memberCoinChargeEntitys : records) {
|
| | | CoinInListVo coinInListVo = new CoinInListVo();
|
| | | coinInListVo.setSymbol(memberCoinChargeEntitys.getSymbol());
|
| | | coinInListVo.setAmount(memberCoinChargeEntitys.getAmount());
|
| | | coinInListVo.setContent("充币");
|
| | | coinInListVo.setStatus(memberCoinChargeEntitys.getStatus());
|
| | | coinInListVo.setUpdateTime(memberCoinChargeEntitys.getUpdateTime());
|
| | | arrayList.add(coinInListVo);
|
| | | }
|
| | | responsePage.setRecords(arrayList);
|
| | | }
|
| | | return Result.ok(responsePage);
|
| | | }
|
| | | //提币记录
|
| | | if(type == 2) {
|
| | | Page<MemberCoinWithdrawEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
|
| | | memberCoinWithdrawEntity.setMemberId(memberId);
|
| | | IPage<MemberCoinWithdrawEntity> memberCoinWithdraw = memberCoinWithdrawDao.findMemberCoinWithdrawInPage(page, memberCoinWithdrawEntity);
|
| | | List<MemberCoinWithdrawEntity> records = memberCoinWithdraw.getRecords();
|
| | | |
| | | Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | ArrayList<CoinInListVo> arrayList = new ArrayList<>();
|
| | | for(MemberCoinWithdrawEntity memberCoinWithdrawEntitys : records) {
|
| | | CoinInListVo coinInListVo = new CoinInListVo();
|
| | | coinInListVo.setSymbol(memberCoinWithdrawEntitys.getSymbol());
|
| | | coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount());
|
| | | coinInListVo.setContent("提币");
|
| | | int status = memberCoinWithdrawEntitys.getStatus();
|
| | | int statusOut = 0;
|
| | | if(status == 1) {
|
| | | statusOut = 0;
|
| | | }
|
| | | if(status == 2) {
|
| | | statusOut = 1;
|
| | | }
|
| | | if(status == 3) {
|
| | | statusOut = 2;
|
| | | }
|
| | | coinInListVo.setStatus(statusOut);
|
| | | coinInListVo.setUpdateTime(memberCoinWithdrawEntitys.getUpdateTime());
|
| | | coinInListVo.setIsInside(memberCoinWithdrawEntitys.getIsInside());
|
| | | arrayList.add(coinInListVo);
|
| | | }
|
| | | responsePage.setRecords(arrayList);
|
| | | }
|
| | | return Result.ok(responsePage);
|
| | | }
|
| | | //划转记录
|
| | | if(type == 3) {
|
| | | Page<MemberAccountMoneyChange> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
|
| | | memberAccountMoneyChange.setMemberId(memberId);
|
| | | IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.coinInList(page, memberAccountMoneyChange);
|
| | | List<MemberAccountMoneyChange> records = list.getRecords();
|
| | | |
| | | Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | ArrayList<CoinInListVo> arrayList = new ArrayList<>();
|
| | | for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
|
| | | CoinInListVo coinInListVo = new CoinInListVo();
|
| | | coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
|
| | | coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
|
| | | coinInListVo.setContent(memberAccountMoneyChanges.getContent());
|
| | | coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
|
| | | coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
|
| | | arrayList.add(coinInListVo);
|
| | | }
|
| | | responsePage.setRecords(arrayList);
|
| | | }
|
| | | return Result.ok(responsePage);
|
| | | }
|
| | | //其他记录
|
| | | if(type == 4) {
|
| | | Page<OrderCoinsDealEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
|
| | | memberAccountMoneyChange.setMemberId(memberId);
|
| | | IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(page, memberAccountMoneyChange);
|
| | | List<MemberAccountMoneyChange> records = list.getRecords();
|
| | | |
| | | Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
|
| | | if(CollUtil.isNotEmpty(records)) {
|
| | | ArrayList<CoinInListVo> arrayList = new ArrayList<>();
|
| | | for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
|
| | | CoinInListVo coinInListVo = new CoinInListVo();
|
| | | coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
|
| | | coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
|
| | | coinInListVo.setContent(memberAccountMoneyChanges.getContent());
|
| | | coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
|
| | | coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
|
| | | arrayList.add(coinInListVo);
|
| | | }
|
| | | responsePage.setRecords(arrayList);
|
| | | }
|
| | | return Result.ok(responsePage);
|
| | | }
|
| | | |
| | | return Result.fail(MessageSourceUtils.getString("member_controller_0005"));
|
| | | |
| | | }
|
| | |
|
| | |
|
| | |
|