| | |
| | | return Result.succeed(data); |
| | | } |
| | | |
| | | private String validateParam(String username, String verifcode, String password, String type) { |
| | | private String validateParam(String phone,String username, String verifcode, String password,String usercode, String type) { |
| | | |
| | | if (StringUtils.isEmptyString(username)) { |
| | | return "用户名不能为空"; |
| | | } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // return "验证码不能为空"; |
| | | // } |
| | | if (StringUtils.isEmptyString(phone)) { |
| | | return "手机号不能为空"; |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | return "验证码不能为空"; |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | return "登录密码不能为空"; |
| | | } |
| | |
| | | // // 只能输入数字 |
| | | // return "登陆密码不符合设定"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(this.usercode)) { |
| | | // return "推荐码不能为空"; |
| | | // } |
| | | if (StringUtils.isEmptyString(usercode)) { |
| | | return "推荐码不能为空"; |
| | | } |
| | | if (StringUtils.isEmptyString(type) || !Arrays.asList("1", "2").contains(type)) { |
| | | return "类型不能为空"; |
| | | } |
| | |
| | | * 手机/邮箱注册接口 |
| | | */ |
| | | @RequestMapping("register") |
| | | public Object register(String username, String password, String safeword, String verifcode, String usercode, String type) { |
| | | public Object register(String username, String password, String phone,String safeword, String verifcode, String usercode, String type) { |
| | | // 注册类型:1/手机;2/邮箱; |
| | | String error = this.validateParam(username, verifcode, password, type); |
| | | String error = this.validateParam(phone,username, verifcode, password, usercode,type); |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | throw new YamiShopBindException(error); |
| | | } |
| | |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | } |
| | | userService.saveRegister(username, password, usercode, safeword, verifcode, type); |
| | | userService.saveRegister(username, password,phone, usercode, safeword, verifcode, type); |
| | | User secUser = userService.findByUserName(username); |
| | | Log log = new Log(); |
| | | log.setCategory(Constants.LOG_CATEGORY_SECURITY); |
| | |
| | | df2.setRoundingMode(RoundingMode.FLOOR); |
| | | // String partyId ="dcc0dd35a49c383dadabc4dc030afe70"; |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | CapitaltWallet usdt = null; |
| | | Wallet usdt = null; |
| | | if (StringUtils.isNotEmpty(partyId)) { |
| | | // usdt = this.walletService.saveWalletByPartyId(partyId); |
| | | usdt = capitaltWalletService.getUserIdWallet(partyId); |
| | | usdt = this.walletService.saveWalletByPartyId(partyId); |
| | | // usdt = capitaltWalletService.getUserIdWallet(partyId); |
| | | } |
| | | if (null == usdt) { |
| | | usdt = new CapitaltWallet(); |
| | | usdt = new Wallet(); |
| | | usdt.setMoney(new BigDecimal(0)); |
| | | usdt.setLockMoney(new BigDecimal(0)); |
| | | usdt.setFreezeMoney(new BigDecimal(0)); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yami.trading.bean.model.CapitaltWallet; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.bean.model.Withdraw; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.CapitaltWalletService; |
| | | import com.yami.trading.service.SessionTokenService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.WithdrawService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | | import com.yami.trading.service.user.UserService; |
| | |
| | | protected WalletLogService walletLogService; |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | @Autowired |
| | | WalletService walletService; |
| | | /** |
| | | * 首次进入页面,传递session_token |
| | | */ |
| | |
| | | |
| | | // 获取资金账户(capital) |
| | | if(channel.contains("USDT")){ |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | Wallet capitaltWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, partyId).last(" limit 1 ")); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | if(capitaltWallet.getMoney().compareTo(new BigDecimal(amount)) < 0){ |
| | | throw new YamiShopBindException("Insufficient available balance for withdrawal!"); |
| | | } |
| | |
| | | Map<String, Object> parities = parities(symbol, symbol_to, volume_temp); |
| | | Object getVolume = parities.get("get_volume"); |
| | | if(symbol.equals("usdt")){ |
| | | CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | Wallet userIdWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, partyId).last(" limit 1 ")); |
| | | // CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | if(userIdWallet.getMoney().compareTo(new BigDecimal(volume_temp)) < 0){ |
| | | throw new YamiShopBindException("not sufficient funds"); |
| | | } |
| | | Double value = Double.valueOf(volume_temp); |
| | | capitaltWalletService.update(userIdWallet, -value); |
| | | walletService.update(userIdWallet.getUserId(), -value); |
| | | |
| | | WalletExtend walletExtend = walletExtendService.getOne(new LambdaQueryWrapper<>(WalletExtend.class) |
| | | .eq(WalletExtend::getWallettype, symbol_to) |
| | |
| | | walletExtend.setAmount(walletExtend.getAmount() - valueOf); |
| | | walletExtendService.update(walletExtend,new LambdaUpdateWrapper<WalletExtend>().eq(UUIDEntity::getUuid,walletExtend.getUuid())); |
| | | |
| | | |
| | | CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | capitaltWalletService.update(userIdWallet,Double.valueOf(getVolume.toString())); |
| | | // |
| | | // CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | // capitaltWalletService.update(userIdWallet,Double.valueOf(getVolume.toString())); |
| | | Wallet userIdWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, partyId).last(" limit 1 ")); |
| | | walletService.update(partyId,Double.valueOf(getVolume.toString())); |
| | | }else{ |
| | | WalletExtend walletExtend = walletExtendService.getOne(new LambdaQueryWrapper<>(WalletExtend.class) |
| | | .eq(WalletExtend::getWallettype, symbol) |
| | |
| | | public Result openview() { |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | // Wallet wallet = walletService.saveWalletByPartyId(partyId); |
| | | CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | Wallet userIdWallet = walletService.saveWalletByPartyId(partyId); |
| | | // CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(partyId); |
| | | // 账户剩余资金 |
| | | DecimalFormat df = new DecimalFormat("#.##"); |
| | | df.setRoundingMode(RoundingMode.FLOOR);// 向下取整 |
| | |
| | | spring: |
| | | datasource: |
| | | # url: jdbc:mysql://127.0.0.1:6306/8.4?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Europe/Paris&useLegacyDatetimeCode=false |
| | | url: jdbc:mysql://127.0.0.1:6306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Europe/Paris&useLegacyDatetimeCode=false |
| | | url: jdbc:mysql://127.0.0.1:6306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=America/Mexico_City&nullCatalogMeansCurrent=true |
| | | username: root |
| | | password: Err;2[eoGFUriwdgr |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | properties: |
| | | hibernate: |
| | | jdbc: |
| | | time_zone: Europe/Paris |
| | | time_zone: America/Mexico_City |
| | | jackson: |
| | | time-zone: Europe/Paris |
| | | time-zone: America/Mexico_City |
| | | cache: |
| | | type: redis |
| | | redis: |
| | |
| | | */ |
| | | @ApiModelProperty("userCode") |
| | | private String userCode; |
| | | |
| | | /** |
| | | * 手机号码 |
| | | */ |
| | | |
| | | private String userMobile; |
| | | /** |
| | | * USDT账户余额 |
| | | */ |
| | |
| | | /** |
| | | * 加上杠杆 |
| | | */ |
| | | //25x手续费3.75% 50x手续费7.5% 100x手续费15% 200x手续费30% |
| | | if(order.getLeverRate().doubleValue() == 25){ |
| | | item.setUnitFee(new BigDecimal("0.0375")); |
| | | }else if(order.getLeverRate().doubleValue() == 50){ |
| | | item.setUnitFee(new BigDecimal("0.075")); |
| | | }else if(order.getLeverRate().doubleValue() == 100){ |
| | | item.setUnitFee(new BigDecimal("0.15")); |
| | | }else if(order.getLeverRate().doubleValue() == 200){ |
| | | item.setUnitFee(new BigDecimal("0.30")); |
| | | } |
| | | |
| | | BigDecimal fee = order.getDeposit().multiply(order.getLeverRate()).multiply(item.getUnitFee()); |
| | | fee = fee.setScale(4, RoundingMode.DOWN); // 保留两位小数 |
| | |
| | | double amount = Arith.mul(sub, realtime.getClose().doubleValue()); |
| | | order.setCloseTime(new Date()); |
| | | order.setClosePrice(realtime.getClose().doubleValue()); |
| | | // Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | Wallet capitaltWallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | double amount_before = capitaltWallet.getMoney().doubleValue(); |
| | | // this.walletService.update(userIdWallet.getUserId().toString(), amount); |
| | | this.capitaltWalletService.update(capitaltWallet, amount); |
| | | this.walletService.update(capitaltWallet.getUserId(), amount); |
| | | |
| | | /* |
| | | * 保存资金日志 |
| | |
| | | // 可以买的数量 |
| | | double amount = Arith.div(sub, order.getClosePrice(), 8); |
| | | order.setSymbolValue(amount); |
| | | // Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | Wallet userIdWallet = this.walletService.saveWalletByPartyId(order.getPartyId()); |
| | | // CapitaltWallet userIdWallet = capitaltWalletService.getUserIdWallet(order.getPartyId()); |
| | | double amount_before = userIdWallet.getMoney().doubleValue(); |
| | | // 如果是计划委托,则先不扣钱 |
| | | if (order.isTriggerOrder()) { |
| | |
| | | if (userIdWallet.getMoney().doubleValue() < order.getVolume().doubleValue()) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | } |
| | | // this.walletService.update(userIdWallet.getUserId().toString(), Arith.sub(0, order.getVolume())); |
| | | capitaltWalletService.update(userIdWallet, Arith.sub(0, order.getVolume())); |
| | | this.walletService.update(userIdWallet.getUserId().toString(), Arith.sub(0, order.getVolume())); |
| | | // capitaltWalletService.update(userIdWallet, Arith.sub(0, order.getVolume())); |
| | | /* |
| | | * 保存资金日志 |
| | | */ |
| | |
| | | // double amount_before = wallet.getMoney().doubleValue(); |
| | | // |
| | | // walletService.update(wallet.getUserId(), amount1); |
| | | |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, recharge.getPartyId()).last(" limit 1 ")); |
| | | Wallet capitaltWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, recharge.getPartyId()).last(" limit 1 ")); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, recharge.getPartyId()).last(" limit 1 ")); |
| | | double amount_before = capitaltWallet.getMoney().doubleValue(); |
| | | capitaltWalletService.update(capitaltWallet,amount1); |
| | | walletService.update(capitaltWallet.getUserId(),amount1); |
| | | |
| | | // 保存资金日志 |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveRegister(String username, String password, String usercode, String safeword, String verifcode, String type) { |
| | | public void saveRegister(String username, String password,String phone, String usercode, String safeword, String verifcode, String type) { |
| | | username = username.trim(); |
| | | password = password.trim(); |
| | | if (!"null".equals(safeword) && !StringUtils.isEmptyString(safeword)) { |
| | |
| | | party.setUserLevel(userLevel); |
| | | party.setSafePassword(this.passwordEncoder.encode(safeword)); |
| | | party.setRoleName(Constants.SECURITY_ROLE_MEMBER); |
| | | party.setUserMobile(phone); |
| | | save(party); |
| | | // if (reg.getUsername().indexOf("@") == -1) { |
| | | if (type.equals("1")) { |
| | |
| | | // walletService.update(wallet.getUserId().toString(), |
| | | // Arith.add(withdraw.getAmount(), withdraw.getAmountFee())); |
| | | |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | Wallet capitaltWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class) |
| | | .eq(Wallet::getUserId, wallet.getUserId().toString()).last(" limit 1 ")); |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | throw new YamiShopBindException("用户资金账户不存在!"); |
| | | } |
| | | capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>() |
| | | .set(CapitaltWallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney(), withdraw.getVolume()))) |
| | | .eq(CapitaltWallet::getUserId,wallet.getUserId())); |
| | | walletService.update(new LambdaUpdateWrapper<Wallet>() |
| | | .set(Wallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney(), withdraw.getVolume()))) |
| | | .eq(Wallet::getUserId,wallet.getUserId())); |
| | | |
| | | |
| | | /* |
| | |
| | | throw new YamiShopBindException("Your account has been frozen"); |
| | | } |
| | | |
| | | // Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId()); |
| | | |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, withdraw.getUserId()).last(" limit 1 ")); |
| | | Wallet capitaltWallet = walletService.saveWalletByPartyId(withdraw.getUserId()); |
| | | // |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, withdraw.getUserId()).last(" limit 1 ")); |
| | | if (capitaltWallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) { |
| | | throw new YamiShopBindException("not sufficient funds"); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | //固定手续费10u |
| | | fee = 10; |
| | | withdraw.setAmountFee(new BigDecimal(fee)); |
| | | withdraw.setAmount(new BigDecimal(Arith.sub(withdraw.getVolume().doubleValue(), fee))); |
| | | if (channel.indexOf("USDT") != -1) { |
| | |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | throw new YamiShopBindException("The user's funds account does not exist!"); |
| | | } |
| | | capitaltWalletService.update(capitaltWallet,-withdraw.getVolume().doubleValue()); |
| | | // walletService.update(capitaltWallet,-withdraw.getVolume().doubleValue()); |
| | | walletService.update(capitaltWallet.getUserId(),-withdraw.getVolume().doubleValue()); |
| | | |
| | | |
| | | save(withdraw); |
| | | |
| | |
| | | */ |
| | | public User findPartyByVerifiedEmail(String email); |
| | | |
| | | void saveRegister(String username, String password, String usercode, String safeword, String verifcode, String type); |
| | | void saveRegister(String username, String password,String phone, String usercode, String safeword, String verifcode, String type); |
| | | |
| | | void logout(String userId); |
| | | |
| | |
| | | data.put("freeze_amount",null==wallet?0:wallet.getFreezeMoney().setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | result.add(0,data); |
| | | |
| | | Map<String,Object> capitaldata = new HashMap<String,Object>(); |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, targetPartyId).last(" limit 1 ")); |
| | | capitaldata.put("capitalttype", "capitalusdt"); |
| | | capitaldata.put("amount",null==capitaltWallet?0:new BigDecimal(capitaltWallet.getMoney().doubleValue()).setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | capitaldata.put("lock_amount",null==capitaltWallet?0:capitaltWallet.getLockMoney().setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | capitaldata.put("freeze_amount",null==capitaltWallet?0:capitaltWallet.getFreezeMoney().setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | result.add(0,capitaldata); |
| | | // Map<String,Object> capitaldata = new HashMap<String,Object>(); |
| | | // CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | // .eq(CapitaltWallet::getUserId, targetPartyId).last(" limit 1 ")); |
| | | // capitaldata.put("capitalttype", "capitalusdt"); |
| | | // capitaldata.put("amount",null==capitaltWallet?0:new BigDecimal(capitaltWallet.getMoney().doubleValue()).setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | // capitaldata.put("lock_amount",null==capitaltWallet?0:capitaltWallet.getLockMoney().setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | // capitaldata.put("freeze_amount",null==capitaltWallet?0:capitaltWallet.getFreezeMoney().setScale(8, RoundingMode.FLOOR).toPlainString() ); |
| | | // result.add(0,capitaldata); |
| | | return result; |
| | | } |
| | | } |