39 files modified
9 files added
| | |
| | | } |
| | | news.setTitle(model.getTitle()); |
| | | news.setImgJumpUrl(model.getImgJumpUrl()); |
| | | news.setImgUrl(model.getImgUrl()); |
| | | news.setImgUrl(Constants.IMAGES_HTTP+model.getImgUrl()); |
| | | news.setClick(model.isClick()); |
| | | news.setPopUp(model.isPopUp()); |
| | | news.setIndexTop(model.isIndex()); |
| | |
| | | news.setImgJumpUrl(model.getImgJumpUrl()); |
| | | news.setClick(model.isClick()); |
| | | news.setPopUp(model.isPopUp()); |
| | | news.setImgUrl(model.getImgUrl()); |
| | | news.setImgUrl(Constants.IMAGES_HTTP+model.getImgUrl()); |
| | | news.setIndexTop(model.isIndex()); |
| | | news.setLanguage(model.getLanguage()); |
| | | news.setStartTime(model.getStartTime()); |
| | |
| | | @PostMapping("manualReceipt") |
| | | @SysLog("USDT充值订单-手动到账") |
| | | public Result<?> manualReceipt(@RequestBody @Valid ManualReceiptModel model){ |
| | | SysUser user = sysUserService.getSysUserById( SecurityUtils.getSysUser().getUserId()); |
| | | SysUser user = sysUserService.getSysUserById( SecurityUtils.getSysUser().getUserId()); |
| | | sysUserService.checkSafeWord(model.getSafePasssword()); |
| | | rechargeBlockchainOrderService.manualReceipt(model.getId(),model.getAmount(),user.getUsername()); |
| | | rechargeBlockchainOrderService.manualReceipt(2,model.getId(),model.getAmount(),user.getUsername()); |
| | | return Result.ok(null); |
| | | } |
| | | |
| | |
| | | @Min(0) |
| | | private BigDecimal moneyRevise; |
| | | |
| | | @ApiModelProperty("登录人资金密码") |
| | | @NotBlank |
| | | private String safePassword; |
| | | } |
| | |
| | | } |
| | | |
| | | klineLoadCache.loadCache(); |
| | | // String symbols = items.stream().map(Item::getSymbol).collect(Collectors.joining(",")); |
| | | String symbols = items.stream().map(Item::getSymbol).collect(Collectors.joining(",")); |
| | | // 数据有问题初始化一下 |
| | | // klineInitService.klineInit(symbols); 外汇 |
| | | klineInitService.klineInit(symbols); |
| | | // 高低修正 |
| | | highLowHandleJob.start(); |
| | | // stockGetMarketJob.start(); |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | |
| | | public class Address { |
| | | private String address; |
| | | private int coinType; |
| | | |
| | | public String getAddress() { |
| | | return address; |
| | | } |
| | | |
| | | public void setAddress(String address) { |
| | | this.address = address; |
| | | } |
| | | |
| | | public int getCoinType() { |
| | | return coinType; |
| | | } |
| | | |
| | | public void setCoinType(int coinType) { |
| | | this.coinType = coinType; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "Address{" + |
| | | "address='" + address + '\'' + |
| | | ", coinType=" + coinType + |
| | | '}'; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | public class ApiPath { |
| | | public final static String CREATE_ADDRESS = "/mch/address/create"; |
| | | public final static String WITHDRAW = "/mch/withdraw"; |
| | | public final static String TRANSACTION = "/mch/transaction"; |
| | | public final static String AUTO_WITHDRAW = "/mch/withdraw/proxypay"; |
| | | public final static String SUPPORT_COIN = "/mch/support-coins"; |
| | | public final static String CHECK_PROXY = "/mch/check-proxy"; |
| | | public final static String CHECK_ADDRESS = "/mch/check/address"; |
| | | public final static String CREATE_BATCH_ADDRESS = "/mch/address/create/batch"; |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class Coin { |
| | | private String name; |
| | | private String symbol; |
| | | private String mainCoinType; |
| | | private String coinType; |
| | | private String decimals; |
| | | private Integer tokenStatus; |
| | | private String mainSymbol; |
| | | private BigDecimal balance; |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getSymbol() { |
| | | return symbol; |
| | | } |
| | | |
| | | public void setSymbol(String symbol) { |
| | | this.symbol = symbol; |
| | | } |
| | | |
| | | public String getMainCoinType() { |
| | | return mainCoinType; |
| | | } |
| | | |
| | | public void setMainCoinType(String mainCoinType) { |
| | | this.mainCoinType = mainCoinType; |
| | | } |
| | | |
| | | public String getCoinType() { |
| | | return coinType; |
| | | } |
| | | |
| | | public void setCoinType(String coinType) { |
| | | this.coinType = coinType; |
| | | } |
| | | |
| | | public String getDecimals() { |
| | | return decimals; |
| | | } |
| | | |
| | | public void setDecimals(String decimals) { |
| | | this.decimals = decimals; |
| | | } |
| | | |
| | | public Integer getTokenStatus() { |
| | | return tokenStatus; |
| | | } |
| | | |
| | | public void setTokenStatus(Integer tokenStatus) { |
| | | this.tokenStatus = tokenStatus; |
| | | } |
| | | |
| | | public String getMainSymbol() { |
| | | return mainSymbol; |
| | | } |
| | | |
| | | public void setMainSymbol(String mainSymbol) { |
| | | this.mainSymbol = mainSymbol; |
| | | } |
| | | |
| | | public BigDecimal getBalance() { |
| | | return balance; |
| | | } |
| | | |
| | | public void setBalance(BigDecimal balance) { |
| | | this.balance = balance; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | public class ResultMsg { |
| | | private Integer code; |
| | | private String message; |
| | | private String data; |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(Integer code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | |
| | | public void setMessage(String message) { |
| | | this.message = message; |
| | | } |
| | | |
| | | public String getData() { |
| | | return data; |
| | | } |
| | | |
| | | public void setData(String data) { |
| | | this.data = data; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "ResultMsg{" + |
| | | "code=" + code + |
| | | ", message='" + message + '\'' + |
| | | ", data='" + data + '\'' + |
| | | '}'; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | public interface UdunApi { |
| | | /** |
| | | * 创建币种地址,别名和钱包编号默认,回调地址使用统一配置 |
| | | * |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @return 地址 |
| | | */ |
| | | Address createAddress(String mainCoinType) throws UdunException; |
| | | |
| | | /** |
| | | * 创建币种地址,别名和钱包编号自定义,回调地址使用统一配置 |
| | | * |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param alias 地址别名 |
| | | * @param walletId 钱包编号 |
| | | * @return 地址 |
| | | */ |
| | | Address createAddress(String mainCoinType, String alias, String walletId) throws UdunException; |
| | | |
| | | /** |
| | | * 创建币种地址,别名和钱包编号自定义,回调地址自定义 |
| | | * |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param alias 地址别名 |
| | | * @param walletId 钱包编号 |
| | | * @param callUrl 回调地址 |
| | | * @return 地址 |
| | | */ |
| | | Address createAddress(String mainCoinType, String alias, String walletId, String callUrl) throws UdunException; |
| | | |
| | | |
| | | /** |
| | | * 提币,回调地址使用统一配置 |
| | | * |
| | | * @param address 提币地址 |
| | | * @param amount 提币数量 |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param coinType 子币种编号,使用获取商户币种信息接口 |
| | | * @param businessId 业务编号,必须保证该字段在系统内唯一,如果重复,则该笔提币钱包将不会进行接收 |
| | | * @param memo 备注,XRP和EOS,这两种币的提币申请该字段可选,其他类型币种不填 |
| | | * @return 返回信息 |
| | | */ |
| | | ResultMsg withdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo); |
| | | |
| | | /** |
| | | * 提币,回调地址自定义 |
| | | * |
| | | * @param address 提币地址 |
| | | * @param amount 提币数量 |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param coinType 子币种编号,使用获取商户币种信息接口 |
| | | * @param businessId 业务编号,必须保证该字段在系统内唯一,如果重复,则该笔提币钱包将不会进行接收 |
| | | * @param memo 备注,XRP和EOS,这两种币的提币申请该字段可选,其他类型币种不填 |
| | | * @param callUrl 回调地址 |
| | | * @return 返回信息 |
| | | */ |
| | | ResultMsg withdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo, String callUrl); |
| | | |
| | | /** |
| | | * 代付,回调地址使用统一配置 |
| | | * |
| | | * @param address 提币地址 |
| | | * @param amount 提币数量 |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param coinType 子币种编号,使用获取商户币种信息接口 |
| | | * @param businessId 业务编号,必须保证该字段在系统内唯一,如果重复,则该笔提币钱包将不会进行接收 |
| | | * @param memo 备注,XRP和EOS,这两种币的提币申请该字段可选,其他类型币种不填 |
| | | * @return 返回信息 |
| | | */ |
| | | ResultMsg autoWithdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo); |
| | | |
| | | /** |
| | | * 代付,回调地址自定义 |
| | | * |
| | | * @param address 提币地址 |
| | | * @param amount 提币数量 |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param coinType 子币种编号,使用获取商户币种信息接口 |
| | | * @param businessId 业务编号,必须保证该字段在系统内唯一,如果重复,则该笔提币钱包将不会进行接收 |
| | | * @param memo 备注,XRP和EOS,这两种币的提币申请该字段可选,其他类型币种不填 |
| | | * @param callUrl 回调地址 |
| | | * @return 返回信息 |
| | | */ |
| | | ResultMsg autoWithdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo, String callUrl); |
| | | |
| | | /** |
| | | * 检验地址合法性 |
| | | * |
| | | * @param mainCoinType 主币种编号,使用获取商户币种信息接口 |
| | | * @param address 币种地址 |
| | | * @return 是否合法 |
| | | */ |
| | | boolean checkAddress(String mainCoinType, String address); |
| | | |
| | | /** |
| | | * 获取商户支持的币种,以及余额 |
| | | * |
| | | * @param showBalance 是否显示余额 |
| | | * @return 支持币种列表 |
| | | */ |
| | | List<Coin> listSupportCoin(boolean showBalance); |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | import cn.hutool.core.lang.Console; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import cn.hutool.json.JSONUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class UdunClient implements UdunApi { |
| | | private static Logger logger = LoggerFactory.getLogger(UdunClient.class); |
| | | |
| | | /** |
| | | * UDUN API Gateway |
| | | */ |
| | | private final String gateway; |
| | | |
| | | /** |
| | | * UDUN Merchant Number |
| | | */ |
| | | private final String merchantId; |
| | | |
| | | /** |
| | | * UDUN Merchant Key |
| | | */ |
| | | private final String merchantKey; |
| | | |
| | | /** |
| | | * Callback to business system |
| | | */ |
| | | private final String defaultCallBackUrl; |
| | | |
| | | public UdunClient(String gateway, String merchantId, String merchantKey, String defaultCallBackUrl) { |
| | | this.gateway = gateway; |
| | | this.merchantId = merchantId; |
| | | this.merchantKey = merchantKey; |
| | | this.defaultCallBackUrl = defaultCallBackUrl; |
| | | } |
| | | |
| | | @Override |
| | | public Address createAddress(String mainCoinType) throws UdunException { |
| | | return createAddress(mainCoinType, "", "", defaultCallBackUrl); |
| | | } |
| | | |
| | | @Override |
| | | public Address createAddress(String mainCoinType, String alias, String walletId) throws UdunException{ |
| | | return createAddress(mainCoinType, alias, walletId, defaultCallBackUrl); |
| | | } |
| | | |
| | | @Override |
| | | public Address createAddress(String mainCoinType, String alias, String walletId, String callUrl) throws UdunException{ |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("merchantId", merchantId); |
| | | params.put("coinType", mainCoinType); |
| | | params.put("callUrl", callUrl); |
| | | params.put("walletId", walletId); |
| | | params.put("alias", alias); |
| | | |
| | | ResultMsg result = JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.CREATE_ADDRESS, StrUtil.format("[{}]", JSONUtil.toJsonStr(params))), ResultMsg.class); |
| | | if (result.getCode() != HttpStatus.HTTP_OK) { |
| | | logger.error("createAddress:{}",JSONUtil.toJsonStr(result)); |
| | | throw new UdunException(result.getCode(), result.getMessage()); |
| | | } |
| | | return JSONUtil.toBean(result.getData(), Address.class); |
| | | } |
| | | |
| | | @Override |
| | | public ResultMsg withdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo) { |
| | | return withdraw(address, amount, mainCoinType, coinType, businessId, memo, defaultCallBackUrl); |
| | | } |
| | | |
| | | @Override |
| | | public ResultMsg withdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo, String callUrl) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("address", address); |
| | | params.put("amount", amount); |
| | | params.put("merchantId", merchantId); |
| | | params.put("mainCoinType", mainCoinType); |
| | | params.put("coinType", coinType); |
| | | params.put("callUrl", callUrl); |
| | | params.put("businessId", businessId); |
| | | params.put("memo", memo); |
| | | return JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.WITHDRAW, StrUtil.format("[{}]", JSONUtil.toJsonStr(params))), ResultMsg.class); |
| | | } |
| | | |
| | | @Override |
| | | public ResultMsg autoWithdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo) { |
| | | return autoWithdraw(address, amount, mainCoinType, coinType, businessId, memo, defaultCallBackUrl); |
| | | } |
| | | |
| | | @Override |
| | | public ResultMsg autoWithdraw(String address, BigDecimal amount, String mainCoinType, String coinType, String businessId, String memo, String callUrl) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("address", address); |
| | | params.put("amount", amount); |
| | | params.put("merchantId", merchantId); |
| | | params.put("mainCoinType", mainCoinType); |
| | | params.put("coinType", coinType); |
| | | params.put("callUrl", callUrl); |
| | | params.put("businessId", businessId); |
| | | params.put("memo", memo); |
| | | return JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.AUTO_WITHDRAW, StrUtil.format("[{}]", JSONUtil.toJsonStr(params))), ResultMsg.class); |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkAddress(String mainCoinType, String address) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("merchantId", merchantId); |
| | | params.put("mainCoinType", mainCoinType); |
| | | params.put("address", address); |
| | | ResultMsg result = JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.CHECK_ADDRESS, StrUtil.format("[{}]", JSONUtil.toJsonStr(params))), ResultMsg.class); |
| | | return result.getCode() == HttpStatus.HTTP_OK; |
| | | } |
| | | |
| | | @Override |
| | | public List<Coin> listSupportCoin(boolean showBalance) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("merchantId", merchantId); |
| | | params.put("showBalance", showBalance); |
| | | ResultMsg result = JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.SUPPORT_COIN, JSONUtil.toJsonStr(params)), ResultMsg.class); |
| | | if (result.getCode() != HttpStatus.HTTP_OK) { |
| | | Console.error(JSONUtil.toJsonStr(result)); |
| | | return null; |
| | | } |
| | | return JSONUtil.toList(JSONUtil.parseArray(result.getData()), Coin.class); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | public class UdunException extends RuntimeException { |
| | | private Integer code; |
| | | private String message; |
| | | |
| | | public UdunException(Integer code, String message) { |
| | | this.code = code; |
| | | this.message = message; |
| | | } |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(Integer code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | |
| | | public void setMessage(String message) { |
| | | this.message = message; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.api.UD; |
| | | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | |
| | | public class UdunUtils { |
| | | private static Logger logger = LoggerFactory.getLogger(UdunUtils.class); |
| | | |
| | | public static String post(String gateway, String merchantKey, String path, String body) { |
| | | try { |
| | | // 创建 URL 对象 |
| | | URL url = new URL(gateway+path); |
| | | |
| | | // 打开连接 |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | |
| | | // 设置请求方法为 POST |
| | | connection.setRequestMethod("POST"); |
| | | |
| | | // 设置请求头 |
| | | connection.setRequestProperty("Content-Type", "application/json"); |
| | | connection.setRequestProperty("Accept", "application/json"); |
| | | |
| | | // 启用输入输出流 |
| | | connection.setDoOutput(true); |
| | | |
| | | String rawBody = parseParams(merchantKey, body); |
| | | |
| | | // 写入请求体 |
| | | try (OutputStream os = connection.getOutputStream()) { |
| | | byte[] input = rawBody.getBytes("utf-8"); |
| | | os.write(input, 0, input.length); |
| | | } |
| | | |
| | | // 获取响应代码 |
| | | int responseCode = connection.getResponseCode(); |
| | | |
| | | // 读取响应 |
| | | try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { |
| | | String inputLine; |
| | | StringBuilder response = new StringBuilder(); |
| | | while ((inputLine = in.readLine()) != null) { |
| | | response.append(inputLine); |
| | | } |
| | | return response.toString(); |
| | | } |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String parseParams(String merchantKey, String body) { |
| | | Map<String, String> params = new HashMap<>(); |
| | | String timestamp = System.currentTimeMillis() + ""; |
| | | String nonce = RandomUtil.randomString(6); |
| | | String sign = sign(merchantKey, timestamp, nonce, body); |
| | | params.put("timestamp", timestamp); |
| | | params.put("nonce", nonce); |
| | | params.put("sign", sign); |
| | | params.put("body", body); |
| | | return JSONUtil.toJsonStr(params); |
| | | } |
| | | |
| | | public static String sign(String key, String timestamp, String nonce, String body) { |
| | | String raw = body + key + nonce + timestamp; |
| | | return SecureUtil.md5(raw); |
| | | } |
| | | |
| | | public static boolean checkSign(String key, String timestamp, String nonce, String body, String sign) { |
| | | String checkSign = sign(key, timestamp, nonce, body); |
| | | return checkSign.equals(sign); |
| | | } |
| | | } |
| | |
| | | import com.yami.trading.admin.model.UpdateWalltModel; |
| | | import com.yami.trading.bean.contract.domain.ContractOrder; |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.bean.model.CapitaltWallet; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.common.annotation.SysLog; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.BusinessException; |
| | |
| | | import com.yami.trading.common.web.ResultObject; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.CapitaltWalletService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.contract.ContractOrderService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import com.yami.trading.sys.service.SysUserService; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | * @create: 2025-01-08 17:57 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("api/wallet") |
| | | @RequestMapping("/api/wallet") |
| | | @Api(tags = "合约账户") |
| | | public class ApiCapitaltWalletWalletController { |
| | | |
| | |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | @Autowired |
| | | WalletService walletService; |
| | | |
| | | @Autowired |
| | | private ContractOrderService contractOrderService; |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "划转") |
| | | @PostMapping("transfer.action") |
| | | public Result updateWallt(@Valid @RequestBody TransferModel model) { |
| | | @PostMapping("/transfer.action") |
| | | public Result updateWallt(@Valid TransferModel model) { |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if(!StringUtils.isNotEmpty(partyId)){ |
| | | throw new YamiShopBindException("请登录!"); |
| | | } |
| | | boolean b = sysUserService.checkSafeWord(model.getSafePassword()); |
| | | if(!b){ |
| | | throw new YamiShopBindException("资金密码错误"); |
| | | } |
| | | return capitaltWalletService.updateWallt(partyId,model.getDeductAccount(),model.getReceiveAccount(),model.getMoneyRevise()); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取资产") |
| | | @PostMapping("/getassets.action") |
| | | public Result updateWallt() { |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if(!StringUtils.isNotEmpty(partyId)){ |
| | | throw new YamiShopBindException("请登录!"); |
| | | } |
| | | // 获取合约账户(contract) |
| | | Wallet wallet = walletService.saveWalletByPartyId(partyId); |
| | | // 获取资金账户(capital) |
| | | CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class) |
| | | .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 ")); |
| | | |
| | | Map<String, BigDecimal> assets = new HashMap<>(); |
| | | assets.put("contract",wallet.getMoney()); |
| | | assets.put("capital",capitaltWallet.getMoney()); |
| | | return Result.succeed(assets); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | order.setOrderPriceType(openAction.getPrice_type()); |
| | | order.setState(ContractApplyOrder.STATE_SUBMITTED); |
| | | order.setMoney(openAction.getAmount()); |
| | | order.setLocationType(openAction.getLocationType()); |
| | | |
| | | contractApplyOrderService.saveCreate(order); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yami.trading.bean.cms.News; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.DateUtils; |
| | |
| | | news.setShow(news.getUserId().equals(SecurityUtils.getCurrentUserId())); |
| | | } |
| | | if (StringUtils.isNotEmpty(news.getImgUrl())) { |
| | | news.setImgUrl(awsS3OSSFileService.getUrl(news.getImgUrl())); |
| | | news.setImgUrl(news.getImgUrl()); |
| | | } |
| | | |
| | | } |
| | |
| | | map.put("idName", record.getIdName()); |
| | | map.put("idNumber", record.getIdNumber()); |
| | | map.put("name", record.getName()); |
| | | map.put("idFrontImg", record.getIdFrontImg()); |
| | | map.put("idBackImg", record.getIdBackImg()); |
| | | map.put("idFrontImg", Constants.IMAGES_HTTP+record.getIdFrontImg()); |
| | | map.put("idBackImg", Constants.IMAGES_HTTP+record.getIdBackImg()); |
| | | map.put("status", record.getStatus()); |
| | | map.put("kyc_status", record.getStatus()); |
| | | map.put("msg", record.getMsg()); |
| | | map.put("handheldPhoto", record.getHandheldPhoto()); |
| | | map.put("handheldPhoto", Constants.IMAGES_HTTP+record.getHandheldPhoto()); |
| | | map.put("idname", record.getIdName()); |
| | | map.put("idnumber", record.getIdNumber()); |
| | | map.put("idimg_1_path", awsS3OSSFileService.getUrl(record.getIdFrontImg())); |
| | | map.put("idimg_2_path", awsS3OSSFileService.getUrl(record.getIdBackImg())); |
| | | map.put("idimg_3_path", awsS3OSSFileService.getUrl(record.getHandheldPhoto())); |
| | | map.put("idimg_1", record.getIdFrontImg()); |
| | | map.put("idimg_2", record.getIdBackImg()); |
| | | map.put("idimg_3", record.getHandheldPhoto()); |
| | | map.put("idimg_1_path", Constants.IMAGES_HTTP+record.getIdFrontImg()); |
| | | map.put("idimg_2_path", Constants.IMAGES_HTTP+record.getIdBackImg()); |
| | | map.put("idimg_3_path", Constants.IMAGES_HTTP+record.getHandheldPhoto()); |
| | | map.put("idimg_1", Constants.IMAGES_HTTP+record.getIdFrontImg()); |
| | | map.put("idimg_2", Constants.IMAGES_HTTP+record.getIdBackImg()); |
| | | map.put("idimg_3", Constants.IMAGES_HTTP+record.getHandheldPhoto()); |
| | | return Result.succeed(map); |
| | | } |
| | | |
| | |
| | | package com.yami.trading.api.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yami.trading.bean.model.CapitaltWallet; |
| | | 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.common.util.DateUtils; |
| | | import com.yami.trading.common.util.StringUtils; |
| | | 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.WithdrawService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | |
| | | private SysparaService sysparaService; |
| | | @Autowired |
| | | protected WalletLogService walletLogService; |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | /** |
| | | * 首次进入页面,传递session_token |
| | |
| | | String amount, String from, String currency, |
| | | String channel){ |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | boolean lock = false; |
| | | String error = this.verif(amount); |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | throw new YamiShopBindException(error); |
| | |
| | | throw new YamiShopBindException("资金密码错误"); |
| | | } |
| | | } |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | |
| | | // 获取资金账户(capital) |
| | | 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("可提现余额不足!"); |
| | | } |
| | | |
| | | this.sessionTokenService.del(session_token); |
| | | // if (null == object || !SecurityUtils.getUser().getUserId().equals((String) object)) { |
| | | // throw new YamiShopBindException("请稍后再试"); |
| | | // } |
| | | Withdraw withdraw = new Withdraw(); |
| | | withdraw.setUserId(partyId); |
| | | withdraw.setVolume(new BigDecimal(amount_double)); |
| | |
| | | package com.yami.trading.api.controller.exchange; |
| | | |
| | | 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.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.yami.trading.api.UD.*; |
| | | import com.yami.trading.api.UD.Address; |
| | | import com.yami.trading.bean.exchange.PartyBlockchain; |
| | | import com.yami.trading.bean.model.ChannelBlockchain; |
| | | import com.yami.trading.bean.model.RechargeBlockchainOrder; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.vo.RechargeAddressVo; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | |
| | | import com.yami.trading.common.util.StringUtils; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.ChannelBlockchainService; |
| | | import com.yami.trading.service.RechargeBlockchainOrderService; |
| | | import com.yami.trading.service.exchange.PartyBlockchainService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import com.yami.trading.sys.model.SysUser; |
| | | import com.yami.trading.sys.service.SysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import okhttp3.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | UserService userService; |
| | | @Autowired |
| | | PartyBlockchainService partyBlockchainService; |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | private SysUserService sysUserService; |
| | | @Autowired |
| | | RechargeBlockchainOrderService rechargeBlockchainOrderService; |
| | | |
| | | private final String gateway = "https://sig11.udun.io"; |
| | | private final String merchantKey = "7fd79e4ed59e7c31e1fa2e13d64f7e6c"; |
| | | private final String merchantId = "319563"; |
| | | private final String defaultCallBackUrl = "https://openapi.yanshiz.com/api/channelBlockchain!rechargeCallback.action"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取所有链地址 |
| | |
| | | return cbc; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | //后台设置地址 |
| | | if (data.isEmpty()) data = this.channelBlockchainService.findByCoin(coin.toLowerCase()); |
| | | for (int i = 0; i < data.size(); i++) { |
| | | data.get(i).setBlockchain_name(data.get(i).getBlockchainName()); |
| | |
| | | data.get(i).setAddress(null); |
| | | } |
| | | } |
| | | |
| | | // String partyId =SecurityUtils.getUser().getUserId(); |
| | | // if(!StringUtils.isNotEmpty(partyId)){ |
| | | // throw new YamiShopBindException("请登录!"); |
| | | // } |
| | | // if (0 == this.sysparaService.find("can_recharge").getInteger()) { |
| | | // return Result.failed("请联系客服充值"); |
| | | // } |
| | | // RechargeAddressVo rechargeAddressVo = new RechargeAddressVo(); |
| | | // |
| | | // //获取u盾地址 |
| | | // //获取商户支持币种 |
| | | // List<Coin> coinList = listSupportCoin(merchantId,false); |
| | | // //创建地址 |
| | | // coinList.forEach(f->{ |
| | | // Address address = new Address(); |
| | | // if(f.getName().equals("BTC")){ |
| | | // String ress = (String)redisTemplate.opsForValue().get(partyId + "BTC"); |
| | | // if(StringUtils.isNotEmpty(ress)){ |
| | | // rechargeAddressVo.setAddress(ress); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // }else{ |
| | | // address = createAddress(f.getMainCoinType(),null,null,null); |
| | | // rechargeAddressVo.setAddress(address.getAddress()); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // redisTemplate.opsForValue().set(partyId + "BTC",address.getAddress()); |
| | | // } |
| | | // }else if(f.getName().equals("ETH")){ |
| | | // String ress = (String)redisTemplate.opsForValue().get(partyId + "ETH"); |
| | | // if(StringUtils.isNotEmpty(ress)){ |
| | | // rechargeAddressVo.setAddress(ress); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // }else{ |
| | | // address = createAddress(f.getMainCoinType(),null,null,null); |
| | | // rechargeAddressVo.setAddress(address.getAddress()); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // redisTemplate.opsForValue().set(partyId + "ETH",address.getAddress()); |
| | | // } |
| | | // }else if(f.getName().equals("USDT")){ |
| | | // String ress = (String)redisTemplate.opsForValue().get(partyId + "USDT"); |
| | | // if(StringUtils.isNotEmpty(ress)){ |
| | | // rechargeAddressVo.setAddress(ress); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // }else{ |
| | | // address = createAddress(f.getMainCoinType(),null,null,null); |
| | | // rechargeAddressVo.setAddress(address.getAddress()); |
| | | // rechargeAddressVo.setCoin(coin); |
| | | // rechargeAddressVo.setBlockchainName(coin); |
| | | // redisTemplate.opsForValue().set(partyId + "USDT",address.getAddress()); |
| | | // } |
| | | // } |
| | | // }); |
| | | // return Result.succeed(rechargeAddressVo); |
| | | return Result.succeed(data); |
| | | } |
| | | |
| | | public List<Coin> listSupportCoin(String merchantId , boolean showBalance) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("merchantId", merchantId); |
| | | params.put("showBalance", showBalance); |
| | | ResultMsg result = JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.SUPPORT_COIN, JSONUtil.toJsonStr(params)), ResultMsg.class); |
| | | if (result.getCode() != HttpStatus.HTTP_OK) { |
| | | Console.error(JSONUtil.toJsonStr(result)); |
| | | return null; |
| | | } |
| | | return JSONUtil.toList(JSONUtil.parseArray(result.getData()), Coin.class); |
| | | } |
| | | |
| | | public Address createAddress(String mainCoinType, String alias, String walletId, String callUrl) throws UdunException { |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("merchantId", merchantId); |
| | | params.put("coinType", mainCoinType); |
| | | params.put("callUrl", defaultCallBackUrl); |
| | | params.put("walletId", walletId); |
| | | params.put("alias", alias); |
| | | |
| | | ResultMsg result = JSONUtil.toBean(UdunUtils.post(gateway, merchantKey, ApiPath.CREATE_ADDRESS, StrUtil.format("[{}]", JSONUtil.toJsonStr(params))), ResultMsg.class); |
| | | if (result.getCode() != HttpStatus.HTTP_OK) { |
| | | throw new UdunException(result.getCode(), result.getMessage()); |
| | | } |
| | | return JSONUtil.toBean(result.getData(), Address.class); |
| | | } |
| | | |
| | | @RequestMapping(action +"rechargeCallback.action") |
| | | public ResultMsg rechargeCallback(HttpServletRequest request){ |
| | | String timestamp = request.getParameter("timestamp"); |
| | | String nonce = request.getParameter("nonce"); |
| | | String sign = request.getParameter("sign"); |
| | | String body = request.getParameter("body"); |
| | | try{ |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Map<String, Object> map = objectMapper.readValue(body, HashMap.class); |
| | | double amounts = Double.parseDouble(map.get("amount").toString()); // 假设 amount 的值为 1000 |
| | | double decimals = Double.parseDouble(map.get("decimals").toString()); |
| | | double success_amount = amounts / Math.pow(10, decimals); |
| | | String address = map.get("address").toString(); |
| | | |
| | | |
| | | RechargeBlockchainOrder blockchainOrder = rechargeBlockchainOrderService.getOne(new LambdaQueryWrapper<>(RechargeBlockchainOrder.class) |
| | | .eq(RechargeBlockchainOrder::getSucceeded, 0) |
| | | .eq(RechargeBlockchainOrder::getChannelAddress, address).last(" limit 1 ")); |
| | | if(ObjectUtil.isEmpty(blockchainOrder)){ |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(200); |
| | | return resultMsg; |
| | | } |
| | | SysUser user = sysUserService.getSysUserById( Long.getLong(blockchainOrder.getPartyId())); |
| | | rechargeBlockchainOrderService.manualReceipt(1,blockchainOrder.getPartyId(), BigDecimal.valueOf(success_amount),user.getUsername()); |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(200); |
| | | return resultMsg; |
| | | }catch (Exception e){ |
| | | ResultMsg resultMsg = new ResultMsg(); |
| | | resultMsg.setCode(500); |
| | | resultMsg.setMessage("回调处理失败"); |
| | | return resultMsg; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据第三方充值链接 |
| | | */ |
| | |
| | | /** |
| | | * 仓位类型:0:逐仓 1:全仓 |
| | | */ |
| | | private Integer locationType = 0; |
| | | private Integer locationType = 1; |
| | | |
| | | @NotBlank |
| | | private String symbol; |
| | |
| | | spring: |
| | | # 环境 dev|test|prod |
| | | # 环境 local|dev|test|prod |
| | | profiles: |
| | | active: prod |
| | | #文件上传设置 |
| | |
| | | admin_url=https://127.0.0.1:8080/admin |
| | | web_url=http://127.0.0.1:8080/wap/ |
| | | |
| | | http.server.host=D:/jystp/images/ |
| | | images.dir=/mydata/img/ |
| | | loca.images.dir=D:/testimg |
| | | images_http=https://okximg.yanshiz.com/ |
| | | loca.images.dir=/www/wwwroot/img |
| | | email.host=smtp.gmail.com |
| | | email.username= test |
| | | email.password= test |
| | | email.username=coinzne.com@gmail.com |
| | | email.password=pqupwyxoqedhxlfq |
| | | email.from= smtp.gmail.com |
| | | admin_rest_url=https://enjdhdg.site/api |
| | |
| | | * 下单金额 |
| | | */ |
| | | private BigDecimal money; |
| | | |
| | | /** |
| | | * 仓位类型:0:逐仓 1:全仓 |
| | | */ |
| | | private Integer locationType = 1; |
| | | } |
| | |
| | | /** |
| | | * 仓位类型:0:逐仓 1:全仓 |
| | | */ |
| | | private Integer locationType = 0; |
| | | private Integer locationType = 1; |
| | | |
| | | public BigDecimal getAmountClose() { |
| | | if(amountClose == null){ |
| New file |
| | |
| | | package com.yami.trading.bean.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @program: trading-order-master |
| | | * @description: |
| | | * @create: 2025-07-03 16:50 |
| | | **/ |
| | | @Data |
| | | @ApiModel |
| | | public class RechargeAddressVo { |
| | | |
| | | /** |
| | | * 币种名称 BTC ETH USDT |
| | | */ |
| | | private String coin; |
| | | |
| | | /** |
| | | * 链名称 |
| | | */ |
| | | private String blockchainName; |
| | | |
| | | /** |
| | | * 区块链地址 |
| | | */ |
| | | private String address; |
| | | |
| | | } |
| | |
| | | |
| | | public static final String IMAGES_DIR = PropertiesUtil.getProperty("images.dir"); |
| | | |
| | | public static final String IMAGES_HTTP = PropertiesUtil.getProperty("images_http"); |
| | | |
| | | /** |
| | | * c2c卖币 |
| | | */ |
| | |
| | | * 永续合约平仓 |
| | | */ |
| | | public static final String MONEYLOG_CONTENT_CONTRACT_CLOSE = "contract_close"; |
| | | |
| | | /** |
| | | * 永续合约强制平仓 |
| | | */ |
| | | public static final String MANDATORY_LIQUIDATION_CONTRACT_CLOSE = "mandatory_liquidation"; |
| | | /** |
| | | * 永续合约建仓 |
| | | */ |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_15MIN); |
| | | } else { |
| | |
| | | @Autowired |
| | | private CryptosKlineService cryptosKlineService; |
| | | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void taskJob() { |
| | | StopWatch stopWatch = new StopWatch(); |
| | | log.info("Kline1DayJob start ... "); |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_1DAY); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | log.debug("--------------- 5min kline --------- {}", item.getSymbol()); |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_1MIN); |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_1MON); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | continue; |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_1WEEK); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | continue; |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType()) || Item.forex.equalsIgnoreCase(item.getType())) { |
| | | continue; |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_30MIN); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_4HOUR); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (!Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | klineService.saveKline5Day(item.getSymbol(), Kline.PERIOD_5DAY); |
| | | } |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_5MIN); |
| | | } else { |
| | |
| | | List<Item> item_list = itemService.list(); |
| | | for (int i = 0; i < item_list.size(); i++) { |
| | | Item item = item_list.get(i); |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType())) { |
| | | if (MarketOpenChecker.isMarketOpenByItemCloseType(item.getOpenCloseType()) && item.getType().equals("cryptos")) { |
| | | if (Item.cryptos.equalsIgnoreCase(item.getType())) { |
| | | cryptosKlineService.saveOne(item.getSymbol(), Kline.PERIOD_60MIN); |
| | | } else { |
| | |
| | | Result updateWallt(String userId,String deductAccount, String receiveAccount, BigDecimal moneyRevise); |
| | | |
| | | void update(CapitaltWallet capitaltWallet, double amount1); |
| | | |
| | | } |
| | |
| | | Page pageRecord(Page page, String rolename, String orderNo, String userName, Date startTime, Date endTime,String status); |
| | | |
| | | /** |
| | | * 手动到账 |
| | | * 手动到账 auto 1:自动 2:手动 |
| | | * @param id |
| | | */ |
| | | void manualReceipt(String id, BigDecimal amount,String operator_username); |
| | | void manualReceipt(Integer auto, String id, BigDecimal amount,String operator_username); |
| | | |
| | | /** |
| | | * 驳回申请 |
| | |
| | | * @param currentPrice 当前点位 |
| | | */ |
| | | public void settle(ContractOrder order, String profit_loss, BigDecimal currentPrice, List<ContractOrder> partyContractOrders) { |
| | | |
| | | |
| | | |
| | | Item item = itemService.findBySymbol(order.getSymbol()); |
| | | |
| | | /* |
| | | * 根据偏 差点数和手数算出盈亏金额 |
| | | */ |
| | | /** |
| | | * 偏差点位 |
| | | */ |
| | | BigDecimal point = currentPrice.subtract(order.getTradeAvgPrice()); |
| | | /* |
| | | * 根据偏 差点数和手数算出盈亏金额 |
| | | */ |
| | | BigDecimal amount = point.multiply(new BigDecimal("0.01")).multiply(order.getVolumeOpen()).setScale(4, BigDecimal.ROUND_DOWN);; |
| | | if (ContractOrder.DIRECTION_BUY.equals(order.getDirection())) { |
| | | order.setProfit(amount); |
| | | } else{ |
| | | order.setProfit(amount.negate()); |
| | | } |
| | | |
| | | Item item = itemService.findBySymbol(order.getSymbol()); |
| | | |
| | | // if ("profit".equals(profit_loss)) { |
| | | // /** |
| | | // * 盈 正数 |
| | | // */ |
| | | // order.setProfit(amount); |
| | | // } else if ("loss".equals(profit_loss)) { |
| | | // order.setProfit(amount); |
| | | // |
| | | // } |
| | | |
| | | order.setProfit(amount); |
| | | |
| | | double faceValue = 0.01; // 合约面值(固定面值不能调整) |
| | | double maintenanceMarginRate = 0.004; // 维持保证金率(固定不变) |
| | |
| | | // 获取当前账户余额并加到收益中 |
| | | Map<String, Object> moneyAll = walletService.getMoneyAll(order.getPartyId()); |
| | | earnings = earnings.add(new BigDecimal(moneyAll.get("money_all_coin").toString())); |
| | | |
| | | earnings = earnings.add(order.getDepositOpen()); |
| | | } else { |
| | | // 如果不符合条件,直接使用 order.getDepositOpen() 作为收益 |
| | | earnings = order.getDepositOpen(); |
| | |
| | | , maintenanceMarginRate, item.getUnitFee().doubleValue()); |
| | | order.setForceClosePrice(BigDecimal.valueOf(forceClosePrice).toString()); |
| | | }else{ |
| | | double forceClosePrice = strongLevelCalculationService.calculateLiquidationPrice(earnings.doubleValue(), |
| | | double forceClosePrice = strongLevelCalculationService.calculateEmptyLiquidationPrice(earnings.doubleValue(), |
| | | faceValue, order.getVolumeOpen().doubleValue(), order.getTradeAvgPrice().doubleValue() |
| | | , maintenanceMarginRate, item.getUnitFee().doubleValue()); |
| | | order.setForceClosePrice(BigDecimal.valueOf(forceClosePrice).toString()); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | if(order.getDirection().equals("buy")){ |
| | | if (currentPrice.toString().compareTo(order.getForceClosePrice()) <= 0) {//达到强平价 |
| | |
| | | import com.yami.trading.bean.contract.query.ContractOrderQuery; |
| | | import com.yami.trading.bean.data.domain.Realtime; |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.bean.model.MoneyLog; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.model.UserData; |
| | | import com.yami.trading.bean.model.Wallet; |
| | |
| | | import com.yami.trading.common.constants.TipConstants; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.*; |
| | | import com.yami.trading.service.MoneyLogService; |
| | | import com.yami.trading.service.StrongLevelCalculationService; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.system.TipService; |
| | |
| | | |
| | | @Autowired |
| | | private StrongLevelCalculationService strongLevelCalculationService; |
| | | |
| | | @Autowired |
| | | MoneyLogService moneyLogService; |
| | | |
| | | public IPage<ContractOrderDTO> listRecord(Page page, ContractOrderQuery query) { |
| | | return baseMapper.listRecord(page, query); |
| | |
| | | } |
| | | |
| | | } |
| | | walletService.updateMoney(symbol, partyId, finalProfit, BigDecimal.ZERO, |
| | | Constants.MONEYLOG_CATEGORY_CONTRACT, Constants.WALLET_USDT, Constants.MONEYLOG_CONTENT_CONTRACT_CLOSE, "强制平仓,平仓合约数" + list.size() + "[" + volume + "],订单号[" + orderNo + "]"); |
| | | updateMoney(symbol, partyId, finalProfit, BigDecimal.ZERO, |
| | | Constants.MONEYLOG_CATEGORY_CONTRACT, Constants.WALLET_USDT, Constants.MANDATORY_LIQUIDATION_CONTRACT_CLOSE, "强制平仓,平仓合约数" + list.size() + "[" + volume + "],订单号[" + orderNo + "]"); |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | public void updateMoney(String symbol, String userId, BigDecimal money, BigDecimal amountFee, |
| | | String category, String walletType, String contentType, String log) { |
| | | |
| | | Date now = new Date(); |
| | | Wallet wallet = walletService.findByUserId(userId); |
| | | BigDecimal amountBefore = wallet.getMoney(); |
| | | wallet.setMoney(BigDecimal.ZERO); |
| | | if(wallet.getMoney().compareTo(BigDecimal.ZERO) < 0){ |
| | | wallet.setMoney(BigDecimal.ZERO); |
| | | } |
| | | wallet.setUpdateTime(now); |
| | | walletService.updateById(wallet); |
| | | // 账变日志 |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | moneyLog.setCreateTime(now); |
| | | moneyLog.setSymbol(symbol); |
| | | moneyLog.setCategory(category); |
| | | moneyLog.setAmountBefore(amountBefore); |
| | | moneyLog.setAmount(money); |
| | | moneyLog.setAmountAfter(wallet.getMoney()); |
| | | moneyLog.setUserId(userId); |
| | | moneyLog.setWalletType(walletType); |
| | | moneyLog.setContentType(contentType); |
| | | moneyLog.setLog(log); |
| | | moneyLogService.save(moneyLog); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | order.setStopPriceLoss(applyOrder.getStopPriceLoss()); |
| | | order.setPips(item.getPips()); |
| | | order.setPipsAmount(item.getPipsAmount()); |
| | | order.setLocationType(applyOrder.getLocationType()); |
| | | return order; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void getStrongPrice(ContractOrder order, Item item) { |
| | | // 获取当前账户余额并加到收益中 |
| | | Map<String, Object> moneyAll = walletService.getMoneyAll(order.getPartyId()); |
| | | BigDecimal earnings = order.getDepositOpen().add(new BigDecimal(moneyAll.get("money_all_coin").toString())); |
| | | double faceValue = 0.01; // 合约面值(固定面值不能调整) |
| | | double maintenanceMarginRate = 0.004; // 维持保证金率(固定不变) |
| | | //"buy":买(多) "sell":卖(空) |
| | | if(order.getDirection().equals("buy")){ |
| | | double forceClosePrice = strongLevelCalculationService.calculateLiquidationPrice(order.getDepositOpen().doubleValue(), |
| | | double forceClosePrice = strongLevelCalculationService.calculateLiquidationPrice(earnings.doubleValue(), |
| | | faceValue, order.getVolumeOpen().doubleValue(), order.getTradeAvgPrice().doubleValue() |
| | | , maintenanceMarginRate, item.getUnitFee().doubleValue()); |
| | | order.setForceClosePrice(BigDecimal.valueOf(forceClosePrice).toString()); |
| | | }else{ |
| | | double forceClosePrice = strongLevelCalculationService.calculateEmptyLiquidationPrice(order.getDepositOpen().doubleValue(), |
| | | double forceClosePrice = strongLevelCalculationService.calculateEmptyLiquidationPrice(earnings.doubleValue(), |
| | | faceValue, order.getVolumeOpen().doubleValue(), order.getTradeAvgPrice().doubleValue() |
| | | , maintenanceMarginRate, item.getUnitFee().doubleValue()); |
| | | order.setForceClosePrice(BigDecimal.valueOf(forceClosePrice).toString()); |
| | |
| | | map.put("volume", order.getVolume()); |
| | | map.put("volume_open", order.getVolumeOpen()); |
| | | map.put("force_close_rice", order.getForceClosePrice()); |
| | | map.put("locationType", order.getLocationType()); |
| | | |
| | | return map; |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.yami.trading.bean.future.dto.TFuturesOrderDTO; |
| | | import com.yami.trading.bean.future.query.FuturesOrderQuery; |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.bean.model.Log; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.model.UserRecom; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.bean.model.*; |
| | | import com.yami.trading.bean.syspara.domain.Syspara; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.constants.TipConstants; |
| | |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.*; |
| | | import com.yami.trading.dao.future.FuturesOrderMapper; |
| | | import com.yami.trading.service.CapitaltWalletService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.item.ItemService; |
| | |
| | | private TipService tipService; |
| | | @Autowired |
| | | private UserDataService userDataService; |
| | | |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | @Autowired |
| | | private ProfitLossConfigService profitLossConfigService; |
| | |
| | | if (futuresPara.getUnitMaxAmount().doubleValue() > 0 && futuresOrder.getVolume() > futuresPara.getUnitMaxAmount().doubleValue()) { |
| | | throw new BusinessException("金额不在购买区间"); |
| | | } |
| | | |
| | | checkSubmitOrder(futuresOrder.getPartyId().toString(), futuresPara); |
| | | |
| | | futuresOrder.setOrderNo(DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8)); |
| | |
| | | // 钱包扣费 |
| | | walletService.updateMoney(futuresOrder.getSymbol(), futuresOrder.getPartyId(), moneyCost, BigDecimal.ZERO, |
| | | Constants.MONEYLOG_CATEGORY_CONTRACT, Constants.WALLET, Constants.DELIVERY_MONEYLOG_CONTENT_CONTRACT_OPEN, "交割合约,订单号[" + futuresOrder.getOrderNo() + "]"); |
| | | |
| | | checkProfitAndLoss(futuresOrder); |
| | | save(futuresOrder); |
| | | |
| | |
| | | if (Constants.SECURITY_ROLE_MEMBER.equals(party.getRoleName())) { |
| | | tipService.saveTip(futuresOrder.getUuid().toString(), TipConstants.FUTURES_ORDER); |
| | | } |
| | | // saveRecomProfit(futuresOrder.getPartyId().toString(),futuresOrder.getVolume()); |
| | | return futuresOrder; |
| | | } |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | // public static void main(String[] args) { |
| | | // BigDecimal balance = new BigDecimal("9772.9"); // 账户余额 |
| | | // BigDecimal feeRate = new BigDecimal("0.0005"); // 手续费率(基于下单金额) |
| | | // BigDecimal price = new BigDecimal("1"); // 商品价格 |
| | | // int leverage = 150; // 杠杆倍数 |
| | | // |
| | | //// 可购买数量=(余额 ÷ (1÷杠杆 + 费率))/杠杆 |
| | | // |
| | | // |
| | | // // 1. 计算最大可下单金额(x) |
| | | // BigDecimal denominator = BigDecimal.ONE.divide(new BigDecimal(leverage), 10, RoundingMode.HALF_UP).add(feeRate); |
| | | // BigDecimal maxOrderAmount = balance.divide(denominator, 2, RoundingMode.FLOOR); |
| | | // |
| | | // // 2. 计算可购买数量 |
| | | // BigDecimal quantity = maxOrderAmount.divide(price, 0, RoundingMode.FLOOR); |
| | | // BigDecimal actualOrderAmount = quantity.multiply(price); |
| | | // |
| | | // // 3. 计算费用 |
| | | // BigDecimal margin = actualOrderAmount |
| | | // .divide(new BigDecimal(leverage), 2, RoundingMode.HALF_UP); |
| | | // BigDecimal fee = actualOrderAmount.multiply(feeRate).setScale(2, RoundingMode.HALF_UP); |
| | | // BigDecimal totalCost = margin.add(fee); |
| | | // |
| | | // // 输出结果 |
| | | // System.out.println("【输入参数】"); |
| | | // System.out.printf("账户余额: %s 元\n", balance); |
| | | // System.out.printf("手续费率: %s%%\n", feeRate.multiply(new BigDecimal(100))); |
| | | // System.out.printf("商品价格: %s 元\n", price); |
| | | // System.out.printf("杠杆倍数: %d 倍\n\n", leverage); |
| | | // |
| | | // System.out.println("【计算结果】"); |
| | | // System.out.printf("理论最大可下单金额: %s 元\n", maxOrderAmount); |
| | | // System.out.printf("实际可购买数量: %s 份\n", quantity); |
| | | // System.out.printf("实际下单金额: %s 元\n", actualOrderAmount); |
| | | // System.out.println("--------------------------------"); |
| | | // System.out.printf("保证金: %s 元\n", margin); |
| | | // System.out.printf("手续费: %s 元\n", fee); |
| | | // System.out.printf("总支出: %s 元\n", totalCost); |
| | | // System.out.printf("剩余余额: %s 元\n", balance.subtract(totalCost)); |
| | | // } |
| | | |
| | | |
| | | } |
| | |
| | | return baseMapper.listRecord(page, rolename, orderNo, userName, startTime, endTime,status); |
| | | } |
| | | |
| | | //auto 1:自动 2:手动 |
| | | @Override |
| | | @Transactional |
| | | public void manualReceipt(String id, BigDecimal amount,String operator_username) { |
| | | public void manualReceipt(Integer auto ,String id, BigDecimal amount,String operator_username) { |
| | | // Date now = new Date(); |
| | | RechargeBlockchainOrder recharge = getById(id); |
| | | if (recharge == null) { |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | // 给定参数 |
| | | double marginBalance = 10; // 保证金余额 |
| | | double marginBalance = 3857.51; // 保证金余额 |
| | | double faceValue = 0.01; // 合约面值(固定面值不能调整) |
| | | double contractQuantity = 0.5; // 合约张数 张数=可用保证金*杠杆倍数/(面值*最新成交价) |
| | | double contractQuantity = 1.0304; // 合约张数 张数=可用保证金*杠杆倍数/(面值*最新成交价) |
| | | double openingPrice = 97016.4; // 开仓均价 |
| | | double maintenanceMarginRate = 0.004; // 维持保证金率(固定不变) |
| | | double feeRate = 0.0005; // 手续费率 根据实际设置 |
| | |
| | | wallet.setMoney(BigDecimal.ZERO); |
| | | } |
| | | wallet.setUpdateTime(now); |
| | | if (wallet.getMoney().doubleValue() < 0) { |
| | | if (wallet.getMoney().doubleValue() <= 0) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | } |
| | | updateById(wallet); |
| | |
| | | package com.yami.trading.service.impl; |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.extra.qrcode.QrCodeUtil; |
| | | import cn.hutool.extra.qrcode.QrConfig; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | WalletLogService walletLogService; |
| | | @Autowired |
| | | LogService logService; |
| | | @Autowired |
| | | CapitaltWalletService capitaltWalletService; |
| | | |
| | | @Override |
| | | public Page listRecord(Page page, String status, String roleName, |
| | |
| | | |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | |
| | | walletService.update(wallet.getUserId().toString(), |
| | | Arith.add(withdraw.getAmount(), withdraw.getAmountFee())); |
| | | // 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 ")); |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | throw new YamiShopBindException("用户资金账户不存在!"); |
| | | } |
| | | capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>() |
| | | .set(CapitaltWallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney().doubleValue(), amount_before))) |
| | | .eq(CapitaltWallet::getUserId,wallet.getUserId())); |
| | | |
| | | |
| | | /* |
| | | * 保存资金日志 |
| | |
| | | if (party.getStatus() != 1) { |
| | | throw new YamiShopBindException("Your account has been frozen"); |
| | | } |
| | | Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId()); |
| | | if (wallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) { |
| | | |
| | | // Wallet wallet = 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("余额不足"); |
| | | } |
| | | // 手续费(USDT) |
| | |
| | | } |
| | | } |
| | | } |
| | | // String withdraw_fee_type = sysparaService.find("withdraw_fee_type").getValue(); |
| | | // double withdraw_fee = Double.valueOf(((Syspara) sysparaService.find("withdraw_fee")).getValue()); |
| | | // DecimalFormat df = new DecimalFormat("#.##"); |
| | | // if ("fixed".equals(withdraw_fee_type)) { |
| | | // fee = withdraw_fee; |
| | | // } else { |
| | | // fee = Double.valueOf(df.format(Arith.mul(withdraw.getVolume(), withdraw_fee))); |
| | | // |
| | | // } |
| | | withdraw.setAmountFee(new BigDecimal(fee)); |
| | | // ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.OUT, withdraw.getCurrency()); |
| | | // |
| | | // if (exchangeRate == null) { |
| | | // throw new BusinessException("Parameter Error"); |
| | | // } |
| | | // |
| | | // withdraw.setAmount(Double.valueOf(df.format(Arith.mul(withdraw.getVolume(), exchangeRate.getRata())))); |
| | | withdraw.setAmount(new BigDecimal(Arith.sub(withdraw.getVolume().doubleValue(), fee))); |
| | | if (channel.indexOf("USDT") != -1) { |
| | | withdraw.setMethod(channel); |
| | | } |
| | | // if ("USDT".equals(channel)) { |
| | | // withdraw.setMethod("USDT"); |
| | | // } |
| | | else if ("OTC".equals(channel)) { |
| | | throw new YamiShopBindException("渠道未开通"); |
| | | // if (StringUtils.isNullOrEmpty(method_id)) { |
| | | // throw new BusinessException("请选择付款账号"); |
| | | // } |
| | | // PaymentMethod paymentMethod = paymentMethodService.get(method_id); |
| | | // if (paymentMethod == null) { |
| | | // throw new BusinessException("请选择付款账号"); |
| | | // } |
| | | // withdraw.setMethod(paymentMethod.getMethod()); |
| | | // withdraw.setAccount(paymentMethod.getAccount()); |
| | | // withdraw.setBank(paymentMethod.getBank()); |
| | | // withdraw.setDeposit_bank(paymentMethod.getDeposit_bank()); |
| | | // withdraw.setQdcode(paymentMethod.getQdcode()); |
| | | // withdraw.setUsername(withdraw.getUsername()); |
| | | } else { |
| | | throw new YamiShopBindException("渠道未开通"); |
| | | } |
| | |
| | | */ |
| | | String withdraw_qr = qRGenerateService.generateWithdraw(withdraw.getOrderNo(), withdraw.getAddress()); |
| | | withdraw.setQdcode(withdraw_qr); |
| | | double amount_before = wallet.getMoney().doubleValue(); |
| | | walletService.update(wallet.getUserId().toString(), Arith.sub(0, withdraw.getVolume().doubleValue())); |
| | | double amount_before = capitaltWallet.getMoney().doubleValue(); |
| | | |
| | | |
| | | |
| | | // walletService.update(wallet.getUserId().toString(), Arith.sub(0, withdraw.getVolume().doubleValue())); |
| | | |
| | | |
| | | if(ObjectUtil.isEmpty(capitaltWallet)){ |
| | | throw new YamiShopBindException("用户资金账户不存在!"); |
| | | } |
| | | capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>() |
| | | .set(CapitaltWallet::getMoney,new BigDecimal(Arith.sub(capitaltWallet.getMoney().doubleValue(), amount_before))) |
| | | .eq(CapitaltWallet::getUserId,capitaltWallet.getUserId())); |
| | | |
| | | save(withdraw); |
| | | |
| | | /* |
| | |
| | | moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN); |
| | | moneyLog.setAmountBefore(new BigDecimal(amount_before)); |
| | | moneyLog.setAmount(new BigDecimal(Arith.sub(0, withdraw.getVolume().doubleValue()))); |
| | | moneyLog.setAmountAfter(wallet.getMoney()); |
| | | moneyLog.setAmountAfter(capitaltWallet.getMoney()); |
| | | moneyLog.setLog("提现订单[" + withdraw.getOrderNo() + "]"); |
| | | // moneyLog.setExtra(withdraw.getOrder_no()); |
| | | moneyLog.setUserId(withdraw.getUserId()); |
| | |
| | | import com.yami.trading.common.util.StringUtils; |
| | | import com.yami.trading.dao.item.ItemMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private ItemLeverageService itemLeverageService; |
| | | |
| | | private Map<String, Integer> symbolDecimal = Maps.newHashMap(); |
| | | |
| | | |
| | | @Autowired |
| | | private CacheManager cacheManager; |
| | |
| | | @Cached(name = ITEM_CACHE, key = "'all'", expire = 3600) |
| | | @Override |
| | | public List<Item> list() { |
| | | List<Item> list = super.list(); |
| | | List<Item> list = super.list(new LambdaQueryWrapper<>(Item.class).eq(Item::getType,Item.cryptos)); |
| | | symbolDecimal = list.stream() |
| | | .collect(Collectors.toMap(Item::getSymbol, Item::getDecimals, (s1, s2) -> s2)); |
| | | return list; |
| | |
| | | } |
| | | |
| | | public List<Item> cacheGetAll() { |
| | | return ApplicationContextUtils.getApplicationContext().getBean(ItemService.class).list(); |
| | | return ApplicationContextUtils.getApplicationContext().getBean(ItemService.class).list(new LambdaQueryWrapper<>(Item.class).eq(Item::getType,Item.cryptos)); |
| | | } |
| | | |
| | | |