| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.lang.Console; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.yami.trading.api.UD.*; |
| | | import com.yami.trading.bean.ico.domain.Ico; |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.bean.model.ChannelBlockchain; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.model.Withdraw; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.util.ApplicationContextUtils; |
| | | import com.yami.trading.common.util.StringUtils; |
| | | import com.yami.trading.common.util.*; |
| | | import com.yami.trading.huobi.data.internal.KlineInitService; |
| | | import com.yami.trading.security.common.enums.CryptoCurrencyEnum; |
| | | import com.yami.trading.security.common.enums.SysTypeEnum; |
| | | import com.yami.trading.security.common.manager.PasswordCheckManager; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.IdentifyingCodeService; |
| | | import com.yami.trading.service.WithdrawService; |
| | | import com.yami.trading.service.ico.IcoService; |
| | | import com.yami.trading.service.item.ItemService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | //@Scheduled(cron = "*/5 * * * * ?") |
| | | public void test() { |
| | | String coin = "usdt"; |
| | | List<ChannelBlockchain> data = new ArrayList<ChannelBlockchain>(); |
| | | Map<String, List<CryptoCurrencyEnum>> allGroupedByCoin = CryptoCurrencyEnum.getAllGroupedByCoin(); |
| | | List<CryptoCurrencyEnum> currencyEnums = allGroupedByCoin.get(coin); |
| | | try { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | //获取u盾地址 |
| | | //获取商户支持币种 |
| | | List<Coin> coinList = udunClient.listSupportCoin(false); |
| | | @Autowired |
| | | WithdrawService withdrawService; |
| | | |
| | | currencyEnums.forEach((currencyEnum) -> { |
| | | String coinName = currencyEnum.getName(); |
| | | Coin c = coinList.stream().filter(x -> x.getName().equals(coinName)).findFirst().orElse(null); |
| | | if (c != null) { |
| | | ChannelBlockchain rechargeAddressVo = new ChannelBlockchain(); |
| | | //创建地址 |
| | | Address address; |
| | | String ress = (String)redisTemplate.opsForValue().get(partyId + coinName); |
| | | if(StringUtils.isNotEmpty(ress)){ |
| | | rechargeAddressVo.setAddress(ress); |
| | | rechargeAddressVo.setCoin(coinName); |
| | | rechargeAddressVo.setBlockchain_name(coinName); |
| | | rechargeAddressVo.setAuto(false); |
| | | rechargeAddressVo.setImg(null); |
| | | }else{ |
| | | address = udunClient.createAddress(c.getMainCoinType(),null,null); |
| | | rechargeAddressVo.setAddress(address.getAddress()); |
| | | rechargeAddressVo.setCoin(coinName); |
| | | rechargeAddressVo.setBlockchain_name(coinName); |
| | | rechargeAddressVo.setAuto(false); |
| | | rechargeAddressVo.setImg(null); |
| | | redisTemplate.opsForValue().set(partyId + coinName, address.getAddress()); |
| | | } |
| | | data.add(rechargeAddressVo); |
| | | } |
| | | }); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.error("获取充值地址错误:",e); |
| | | @Autowired |
| | | IdentifyingCodeService identifyingCodeService; |
| | | @Autowired |
| | | UserService userService; |
| | | @Autowired |
| | | PasswordCheckManager passwordCheckManager; |
| | | |
| | | private double getRandomValue(int value) { |
| | | double addValue; |
| | | if (value > 0) { |
| | | int count = 0; |
| | | while (value > 0) { |
| | | value = value / 10; |
| | | count++; |
| | | } |
| | | // 个 |
| | | if (count == 1) { |
| | | addValue = RandomUtil.randomFloat(0.01, 0.1999, 4); |
| | | return addValue; |
| | | } |
| | | // 十 |
| | | if (count == 2) { |
| | | addValue = RandomUtil.randomFloat(0.1, 0.5999, 4); |
| | | return addValue; |
| | | } |
| | | // 百 |
| | | if (count == 3) { |
| | | addValue = RandomUtil.randomFloat(0.1, 2.9999, 4); |
| | | return addValue; |
| | | } |
| | | // 千 |
| | | if (count == 4) { |
| | | addValue = RandomUtil.randomFloat(1, 3.9999, 4); |
| | | return addValue; |
| | | } |
| | | // 万 |
| | | if (count == 5) { |
| | | addValue = RandomUtil.randomFloat(1, 5.9999, 4); |
| | | return addValue; |
| | | } |
| | | // 十万 |
| | | else { |
| | | addValue = RandomUtil.randomFloat(1, 5.9999, 4); |
| | | return addValue; |
| | | } |
| | | } else { |
| | | addValue = RandomUtil.randomFloat(0.01, 0.2999, 4); |
| | | return addValue; |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(cron = "*/5 * * * * ?") |
| | | public void test() throws Exception { |
| | | double amt = 0.005215; |
| | | double addPriceValue = getRandomValue((int)amt); |
| | | double price = Arith.add(amt, addPriceValue); |
| | | |
| | | String format = ""; |
| | | format = "#."; |
| | | for (int j = 0; j < 6; j++) { |
| | | format = format + "#"; |
| | | } |
| | | |
| | | DecimalFormat df = new DecimalFormat(format); |
| | | df.setRoundingMode(RoundingMode.FLOOR);// 向下取整 |
| | | |
| | | System.out.println(df.format(price)); |
| | | System.out.println("dd"); |
| | | } |
| | | /** |
| | | * ico转入产品 |
| | |
| | | /** |
| | | * K线数据修正 |
| | | */ |
| | | @Scheduled(cron = "0 */1 * * * ?") |
| | | //@Scheduled(cron = "0 */5 * * * ?") |
| | | public void klineInit() { |
| | | List<Item> items = ApplicationContextUtils.getApplicationContext().getBean(ItemService.class).list(); |
| | | if (CollectionUtil.isNotEmpty(items)) { |