| | |
| | | import cn.hutool.core.date.DateUtil;
|
| | | import com.xcong.excoin.modules.coin.dao.ZhiYaDao;
|
| | | import com.xcong.excoin.modules.coin.dao.ZhiYaRecordDao;
|
| | | import com.xcong.excoin.modules.coin.entity.ZhiYaEntity;
|
| | | import com.xcong.excoin.modules.coin.entity.ZhiYaRecordEntity;
|
| | | import com.xcong.excoin.modules.coin.dao.ZhiyaRewardDao;
|
| | | import com.xcong.excoin.modules.coin.entity.*;
|
| | | import com.xcong.excoin.modules.coin.parameter.dto.ZhiyaRewardRecordsPageDto;
|
| | | import com.xcong.excoin.modules.coin.parameter.vo.*;
|
| | | import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
|
| | | import com.xcong.excoin.common.response.Result;
|
| | | import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
|
| | | 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.RecordsPageDto;
|
| | | import com.xcong.excoin.modules.coin.service.CoinService;
|
| | |
| | | MemberWalletAgentDao memberWalletAgentDao;
|
| | | @Resource
|
| | | ZhiYaRecordDao zhiYaRecordDao;
|
| | | @Resource
|
| | | ZhiyaRewardDao zhiyaRewardDao;
|
| | | @Resource
|
| | | ZhiYaDao zhiYaDao;
|
| | | @Resource
|
| | |
| | | memberWalletCoinlist.add(coin);
|
| | | // coin.setWalletCode(CoinTypeEnum.GUSD.toString());
|
| | | // memberWalletCoinlist.add(coin);
|
| | | coin.setWalletCode(CoinTypeEnum.GOLDRICE.toString());
|
| | | coin.setWalletCode(CoinTypeEnum.GRICE.toString());
|
| | | memberWalletCoinlist.add(coin);
|
| | |
|
| | | MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Result usdtToGusd(BigDecimal balance,Integer type) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Result zhiYaGusd(BigDecimal balance) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0096"));
|
| | | }
|
| | | //产生质押单,当前有的话,累加质押数量
|
| | | ZhiYaRecordEntity zhiYaRecord = zhiYaRecordDao.selectByMemberIdAndOrderStatus(memberId,1);
|
| | | if(ObjectUtil.isEmpty(zhiYaRecord)){
|
| | | // ZhiYaRecordEntity zhiYaRecord = zhiYaRecordDao.selectByMemberIdAndOrderStatus(memberId,1);
|
| | | // if(ObjectUtil.isEmpty(zhiYaRecord)){
|
| | | //产生一条质押记录
|
| | | ZhiYaRecordEntity zhiYaRecordEntity = new ZhiYaRecordEntity();
|
| | | zhiYaRecordEntity.setMemberId(memberId);
|
| | |
| | | Date newDate = DateUtil.offsetDay(date, 1);
|
| | | zhiYaRecordEntity.setEffectDate(newDate);
|
| | | zhiYaRecordDao.insert(zhiYaRecordEntity);
|
| | | }else{
|
| | | zhiYaRecord.setZhiyaCnt(zhiYaRecord.getZhiyaCnt().add(balance));
|
| | | Date date = new Date();
|
| | | Date newDate = DateUtil.offsetDay(date, 1);
|
| | | zhiYaRecord.setEffectDate(newDate);
|
| | | zhiYaRecordDao.updateById(zhiYaRecord);
|
| | | }
|
| | | // }else{
|
| | | // zhiYaRecord.setZhiyaCnt(zhiYaRecord.getZhiyaCnt().add(balance));
|
| | | // Date date = new Date();
|
| | | // Date newDate = DateUtil.offsetDay(date, 1);
|
| | | // zhiYaRecord.setEffectDate(newDate);
|
| | | // zhiYaRecordDao.updateById(zhiYaRecord);
|
| | | // }
|
| | | //更新团队算力表
|
| | | //只计算直属团队的算力信息
|
| | |
|
| | |
|
| | | return Result.ok(MessageSourceUtils.getString("member_service_0024"));
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public Result shuhuiGusd(BigDecimal balance,Long id) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
| | | if(balance.compareTo(zhiyaCnt) > 0){
|
| | | return Result.fail(MessageSourceUtils.getString("zhiya_service_0004"));
|
| | | }
|
| | | zhiYaRecordEntity.setZhiyaCnt(zhiyaCnt.subtract(balance));
|
| | | if(zhiyaCnt.compareTo(balance) == 0){
|
| | | zhiYaRecordEntity.setOrderStatus(2);
|
| | | // zhiYaRecordEntity.setZhiyaCnt(zhiyaCnt.subtract(balance));
|
| | | if(zhiyaCnt.compareTo(balance) != 0){
|
| | | return Result.fail(MessageSourceUtils.getString("zhiya_service_0001"));
|
| | | }
|
| | | zhiYaRecordEntity.setOrderStatus(2);
|
| | | zhiYaRecordDao.updateById(zhiYaRecordEntity);
|
| | | //赎回Gusd,质押数量进入可用余额,
|
| | | ZhiYaEntity zhiya = zhiYaDao.selectByMemberId(memberId);
|
| | |
| | | return Result.ok(lists);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void grantZhiyaAmount() {
|
| | | //获取每日总产出
|
| | | BigDecimal gusdReward = new BigDecimal(redisUtils.getString("GUSDREWARD"));
|
| | | //获取每日质押总数
|
| | | Long totalGusd = zhiYaRecordDao.selectTotalGusdByStatueAndTime(1,new Date());
|
| | | BigDecimal totalGusdBigDecimal = new BigDecimal(totalGusd);
|
| | | if(totalGusdBigDecimal.compareTo(BigDecimal.ZERO) > 0){
|
| | | //平均一个获取奖励数量
|
| | | BigDecimal divide = gusdReward.divide(totalGusdBigDecimal,2, BigDecimal.ROUND_HALF_UP);
|
| | | //获取今天之前满足发放奖励的全部质押单
|
| | | //生效时间小于当前时间
|
| | | //状态为生效中
|
| | | List<ZhiYaRecordEntity> lists = zhiYaRecordDao.selectZhiYaRewardByStatueAndTime(1,new Date());
|
| | | if(CollUtil.isNotEmpty(lists)){
|
| | | for(ZhiYaRecordEntity zhiYaRecordEntity : lists){
|
| | | ZhiyaRewardEntity zhiyaRewardEntity = new ZhiyaRewardEntity();
|
| | | zhiyaRewardEntity.setRecordId(zhiYaRecordEntity.getId());
|
| | | zhiyaRewardEntity.setRecordNo(zhiYaRecordEntity.getOrderNo());
|
| | | zhiyaRewardEntity.setMemberId(zhiYaRecordEntity.getMemberId());
|
| | | zhiyaRewardEntity.setRewardAmout(divide.multiply(zhiYaRecordEntity.getZhiyaCnt()));
|
| | | zhiyaRewardDao.insert(zhiyaRewardEntity);
|
| | |
|
| | | //给团队上级发送奖励goldrice
|
| | | //给账户的冻结
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Result getZhiyaReward(ZhiyaRewardRecordsPageDto recordsPageDto) {
|
| | |
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | |
|
| | | Page<ZhiyaRewardVo> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
|
| | | ZhiyaRewardEntity zhiyaRewardEntity = new ZhiyaRewardEntity();
|
| | | zhiyaRewardEntity.setMemberId(memberId);
|
| | | zhiyaRewardEntity.setRecordNo(recordsPageDto.getOrderNo());
|
| | | IPage<ZhiyaRewardVo> lists = zhiYaRecordDao.selectZhiyaRewardByMemberIdInPage(page, zhiyaRewardEntity);
|
| | | return Result.ok(lists);
|
| | | }
|
| | |
|
| | | public String generateSimpleSerialno(String userId) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|