43 files modified
5 files added
| New file |
| | |
| | | const fs = require('fs'); |
| | | const path = require('path'); |
| | | |
| | | const apiRoot = path.join(__dirname, '../trading-order-admin/src/main/java/com/yami/trading/api'); |
| | | |
| | | const pairs = [ |
| | | ['校验IP不合法', 'Invalid IP address'], |
| | | ['资金密码不能为空', 'Fund password is required'], |
| | | ['资金密码不符合设定', 'Fund password does not meet requirements'], |
| | | ['请先登录', 'Please log in first'], |
| | | ['用户名不能为空', 'Username is required'], |
| | | ['密码不能为空', 'Password is required'], |
| | | ['密码必须6-12位', 'Password must be 6-12 characters'], |
| | | ['验证类型不能为空', 'Verification type is required'], |
| | | ['验证码不能为空', 'Verification code is required'], |
| | | ['用户名不存在', 'Username does not exist'], |
| | | ['验证码不正确', 'Incorrect verification code'], |
| | | ['用户名参数为空', 'Username is required'], |
| | | ['请填写正确的电话号码', 'Please enter a valid phone number'], |
| | | ['电话号码已绑定', 'Phone number is already bound'], |
| | | ['电话号码已绑定其他用户', 'Phone number is bound to another user'], |
| | | ['请填写正确的验证码', 'Please enter a valid verification code'], |
| | | ['请输入推荐码', 'Please enter referral code'], |
| | | ['推荐人无权限推荐', 'Referrer is not authorized to refer'], |
| | | ['请填写正确的邮箱地址', 'Please enter a valid email address'], |
| | | ['邮箱已绑定', 'Email is already bound'], |
| | | ['邮箱已绑定其他用户', 'Email is bound to another user'], |
| | | ['旧密码不能为空', 'Old password is required'], |
| | | ['新密码不能为空', 'New password is required'], |
| | | ['新密码确认不能为空', 'Password confirmation is required'], |
| | | ['旧密码不正确!', 'Incorrect old password'], |
| | | ['新密码不一致', 'New passwords do not match'], |
| | | ['旧资金密码不能为空', 'Old fund password is required'], |
| | | ['新资金密码不能为空', 'New fund password is required'], |
| | | ['新资金密码确认不能为空', 'Fund password confirmation is required'], |
| | | ['操作类型为空', 'Operation type is required'], |
| | | ['操作类型不是整数', 'Operation type must be an integer'], |
| | | ['操作类型不能小于0', 'Operation type cannot be negative'], |
| | | ['备注长度超过250', 'Remark exceeds 250 characters'], |
| | | ['请求第三方失败', 'Third-party request failed'], |
| | | ['资金密码必须6-12位', 'Fund password must be 6-12 characters'], |
| | | ['资金密码错误', 'Incorrect fund password'], |
| | | ['订单不存在!', 'Order does not exist'], |
| | | ['页码不是整数', 'Page number must be an integer'], |
| | | ['页码不能小于等于0', 'Page number must be greater than 0'], |
| | | ['k线图获取失败', 'Failed to load chart data'], |
| | | ['请输入正确的货币数量', 'Please enter a valid amount'], |
| | | ['请选择正确的币种', 'Please select a valid currency'], |
| | | ['请稍后再试', 'Please try again later'], |
| | | ['用户已禁用!', 'User account is disabled'], |
| | | ['用户已禁用', 'User account is disabled'], |
| | | ['系统错误,请稍后重试', 'System error, please try again later'], |
| | | ['参数错误', 'Invalid parameters'], |
| | | ['请输入正确的兑换数量', 'Please enter a valid exchange amount'], |
| | | ['生成实时数据失败', 'Failed to generate market data'], |
| | | ['状态不是整数', 'Status must be an integer'], |
| | | ['状态不能小于0', 'Status cannot be negative'], |
| | | ['证件号码长度超过50', 'ID number exceeds 50 characters'], |
| | | ['实名姓名长度超过50', 'Real name exceeds 50 characters'], |
| | | ['账号或密码不正确', 'Incorrect username or password'], |
| | | ['请重新登录', 'Please log in again'], |
| | | ['操作失败,请稍后再试', 'Operation failed, please try again later'], |
| | | ['当前币对不存在', 'Trading pair does not exist'], |
| | | ['未开放合约交易', 'Contract trading is not available'], |
| | | ['停牌禁止交易', 'Trading suspended for this symbol'], |
| | | ['当前已经休市', 'Market is closed'], |
| | | ['订单不存在', 'Order does not exist'], |
| | | ['追加保证金异常', 'Failed to add margin'], |
| | | ['委托单不存在', 'Order does not exist'], |
| | | ['执行撤单异常', 'Failed to cancel order'], |
| | | ['无网络', 'Network unavailable'], |
| | | ['无权限', 'Permission denied'], |
| | | ['请登录!', 'Please log in'], |
| | | ['支付币种不正确', 'Invalid payment currency'], |
| | | ['提交失败,当前有未处理订单', 'Submission failed, pending order exists'], |
| | | ['用户未结束订单数量已达上限', 'Too many open orders'], |
| | | ['今日取消订单次数太多了,请明日再试', 'Too many cancellations today, try again tomorrow'], |
| | | ['广告不存在', 'Advertisement does not exist'], |
| | | ['支付方式不存在', 'Payment method does not exist'], |
| | | ['订单类型不正确', 'Invalid order type'], |
| | | ['支付金额不正确', 'Invalid payment amount'], |
| | | ['币种数量不正确', 'Invalid currency amount'], |
| | | ['承兑商的用户信息不存在', 'Merchant user info does not exist'], |
| | | ['请先通过高级认证', 'Advanced verification required'], |
| | | ['流水小于限额', 'Transaction volume below minimum limit'], |
| | | ['用户不能取消提现', 'Withdrawal cannot be cancelled'], |
| | | ['充值或提现不正确', 'Invalid deposit or withdrawal type'], |
| | | ['订单状态不正确', 'Invalid order status'], |
| | | ['承兑商不存在', 'Merchant does not exist'], |
| | | ['C2C广告id不正确', 'Invalid C2C advertisement ID'], |
| | | ['请上传图片', 'Please upload an image'], |
| | | ['提交失败,当前有未处理银行卡订单', 'Submission failed, pending bank order exists'], |
| | | ['申诉订单号不正确', 'Invalid appeal order number'], |
| | | ['请输入申诉原因', 'Please enter appeal reason'], |
| | | ['请上传申诉凭证', 'Please upload appeal evidence'], |
| | | ['该订单已提交申诉', 'Appeal already submitted for this order'], |
| | | ['申诉不存在', 'Appeal does not exist'], |
| | | ['订单号不能未空', 'Order number is required'], |
| | | ['当前支付方式有未处理完成的订单!', 'Pending orders exist for this payment method'], |
| | | ['广告id不正确', 'Invalid advertisement ID'], |
| | | ['承兑商支付方式未配置', 'Merchant payment method not configured'], |
| | | ['承兑商广告支付方式未配置', 'Merchant ad payment method not configured'], |
| | | ['图片大小不能超过4M', 'Image size cannot exceed 4MB'], |
| | | ['文件上传失败', 'File upload failed'], |
| | | ['实名认证未通过,无法进行高级认证', 'Real-name verification required before advanced verification'], |
| | | ['工作地址长度超过245', 'Work address exceeds 245 characters'], |
| | | ['家庭地址长度超过245', 'Home address exceeds 245 characters'], |
| | | ['该自选组名称已经使用', 'Watchlist name already in use'], |
| | | ['已经添加过该分组了', 'Group already added'], |
| | | ['自选组不存在', 'Watchlist group does not exist'], |
| | | ['谷歌验证码未绑定', 'Google Authenticator is not bound'], |
| | | ['谷歌验证码错误', 'Incorrect Google Authenticator code'], |
| | | ['用户不存在', 'User does not exist'], |
| | | ['推广码不存在', 'Promotion code does not exist'], |
| | | ['推广码已失效', 'Promotion code has expired'], |
| | | ['参数错误!', 'Invalid parameters'], |
| | | ]; |
| | | |
| | | function walk(dir, files = []) { |
| | | for (const name of fs.readdirSync(dir)) { |
| | | const p = path.join(dir, name); |
| | | if (fs.statSync(p).isDirectory()) walk(p, files); |
| | | else if (name.endsWith('.java')) files.push(p); |
| | | } |
| | | return files; |
| | | } |
| | | |
| | | let count = 0; |
| | | for (const file of walk(apiRoot)) { |
| | | let text = fs.readFileSync(file, 'utf8'); |
| | | const orig = text; |
| | | text = text.replace(/最低下单金额:/g, 'Minimum order amount: '); |
| | | text = text.replace(/最低下单金额:/g, 'Minimum order amount: '); |
| | | const sorted = [...pairs].sort((a, b) => b[0].length - a[0].length); |
| | | for (const [zh, en] of sorted) { |
| | | text = text.split(`YamiShopBindException("${zh}")`).join(`YamiShopBindException("${en}")`); |
| | | text = text.split(`new YamiShopBindException("${zh}")`).join(`new YamiShopBindException("${en}")`); |
| | | } |
| | | if (text !== orig) { |
| | | fs.writeFileSync(file, text, 'utf8'); |
| | | count++; |
| | | console.log(file); |
| | | } |
| | | } |
| | | console.log('Updated', count, 'files'); |
| New file |
| | |
| | | $apiRoot = "d:\新版交易所\trading-order-master\trading-order-admin\src\main\java\com\yami\trading\api" |
| | | $pairs = @( |
| | | @("校验IP不合法","Invalid IP address"), |
| | | @("资金密码不能为空","Fund password is required"), |
| | | @("资金密码不符合设定","Fund password does not meet requirements"), |
| | | @("请先登录","Please log in first"), |
| | | @("用户名不能为空","Username is required"), |
| | | @("密码不能为空","Password is required"), |
| | | @("密码必须6-12位","Password must be 6-12 characters"), |
| | | @("验证类型不能为空","Verification type is required"), |
| | | @("验证码不能为空","Verification code is required"), |
| | | @("用户名不存在","Username does not exist"), |
| | | @("验证码不正确","Incorrect verification code"), |
| | | @("用户名参数为空","Username is required"), |
| | | @("请填写正确的电话号码","Please enter a valid phone number"), |
| | | @("电话号码已绑定","Phone number is already bound"), |
| | | @("电话号码已绑定其他用户","Phone number is bound to another user"), |
| | | @("请填写正确的验证码","Please enter a valid verification code"), |
| | | @("请输入推荐码","Please enter referral code"), |
| | | @("推荐人无权限推荐","Referrer is not authorized to refer"), |
| | | @("请填写正确的邮箱地址","Please enter a valid email address"), |
| | | @("邮箱已绑定","Email is already bound"), |
| | | @("邮箱已绑定其他用户","Email is bound to another user"), |
| | | @("旧密码不能为空","Old password is required"), |
| | | @("新密码不能为空","New password is required"), |
| | | @("新密码确认不能为空","Password confirmation is required"), |
| | | @("旧密码不正确!","Incorrect old password"), |
| | | @("新密码不一致","New passwords do not match"), |
| | | @("旧资金密码不能为空","Old fund password is required"), |
| | | @("新资金密码不能为空","New fund password is required"), |
| | | @("新资金密码确认不能为空","Fund password confirmation is required"), |
| | | @("操作类型为空","Operation type is required"), |
| | | @("操作类型不是整数","Operation type must be an integer"), |
| | | @("操作类型不能小于0","Operation type cannot be negative"), |
| | | @("备注长度超过250","Remark exceeds 250 characters"), |
| | | @("请求第三方失败","Third-party request failed"), |
| | | @("资金密码必须6-12位","Fund password must be 6-12 characters"), |
| | | @("资金密码错误","Incorrect fund password"), |
| | | @("订单不存在!","Order does not exist"), |
| | | @("页码不是整数","Page number must be an integer"), |
| | | @("页码不能小于等于0","Page number must be greater than 0"), |
| | | @("k线图获取失败","Failed to load chart data"), |
| | | @("请输入正确的货币数量","Please enter a valid amount"), |
| | | @("请选择正确的币种","Please select a valid currency"), |
| | | @("请稍后再试","Please try again later"), |
| | | @("用户已禁用!","User account is disabled"), |
| | | @("用户已禁用","User account is disabled"), |
| | | @("系统错误,请稍后重试","System error, please try again later"), |
| | | @("参数错误","Invalid parameters"), |
| | | @("请输入正确的兑换数量","Please enter a valid exchange amount"), |
| | | @("生成实时数据失败","Failed to generate market data"), |
| | | @("状态不是整数","Status must be an integer"), |
| | | @("状态不能小于0","Status cannot be negative"), |
| | | @("证件号码长度超过50","ID number exceeds 50 characters"), |
| | | @("实名姓名长度超过50","Real name exceeds 50 characters"), |
| | | @("账号或密码不正确","Incorrect username or password"), |
| | | @("请重新登录","Please log in again"), |
| | | @("操作失败,请稍后再试","Operation failed, please try again later"), |
| | | @("当前币对不存在","Trading pair does not exist"), |
| | | @("未开放合约交易","Contract trading is not available"), |
| | | @("停牌禁止交易","Trading suspended for this symbol"), |
| | | @("当前已经休市","Market is closed"), |
| | | @("订单不存在","Order does not exist"), |
| | | @("追加保证金异常","Failed to add margin"), |
| | | @("委托单不存在","Order does not exist"), |
| | | @("执行撤单异常","Failed to cancel order"), |
| | | @("无网络","Network unavailable"), |
| | | @("无权限","Permission denied"), |
| | | @("请登录!","Please log in"), |
| | | @("支付币种不正确","Invalid payment currency"), |
| | | @("提交失败,当前有未处理订单","Submission failed, pending order exists"), |
| | | @("用户未结束订单数量已达上限","Too many open orders"), |
| | | @("今日取消订单次数太多了,请明日再试","Too many cancellations today, try again tomorrow"), |
| | | @("广告不存在","Advertisement does not exist"), |
| | | @("支付方式不存在","Payment method does not exist"), |
| | | @("订单类型不正确","Invalid order type"), |
| | | @("支付金额不正确","Invalid payment amount"), |
| | | @("币种数量不正确","Invalid currency amount"), |
| | | @("承兑商的用户信息不存在","Merchant user info does not exist"), |
| | | @("请先通过高级认证","Advanced verification required"), |
| | | @("流水小于限额","Transaction volume below minimum limit"), |
| | | @("用户不能取消提现","Withdrawal cannot be cancelled"), |
| | | @("充值或提现不正确","Invalid deposit or withdrawal type"), |
| | | @("订单状态不正确","Invalid order status"), |
| | | @("承兑商不存在","Merchant does not exist"), |
| | | @("C2C广告id不正确","Invalid C2C advertisement ID"), |
| | | @("请上传图片","Please upload an image"), |
| | | @("提交失败,当前有未处理银行卡订单","Submission failed, pending bank order exists"), |
| | | @("申诉订单号不正确","Invalid appeal order number"), |
| | | @("请输入申诉原因","Please enter appeal reason"), |
| | | @("请上传申诉凭证","Please upload appeal evidence"), |
| | | @("该订单已提交申诉","Appeal already submitted for this order"), |
| | | @("申诉不存在","Appeal does not exist"), |
| | | @("订单号不能未空","Order number is required"), |
| | | @("当前支付方式有未处理完成的订单!","Pending orders exist for this payment method"), |
| | | @("广告id不正确","Invalid advertisement ID"), |
| | | @("承兑商支付方式未配置","Merchant payment method not configured"), |
| | | @("承兑商广告支付方式未配置","Merchant ad payment method not configured"), |
| | | @("图片大小不能超过4M","Image size cannot exceed 4MB"), |
| | | @("文件上传失败","File upload failed"), |
| | | @("实名认证未通过,无法进行高级认证","Real-name verification required before advanced verification"), |
| | | @("工作地址长度超过245","Work address exceeds 245 characters"), |
| | | @("家庭地址长度超过245","Home address exceeds 245 characters"), |
| | | @("该自选组名称已经使用","Watchlist name already in use"), |
| | | @("已经添加过该分组了","Group already added"), |
| | | @("自选组不存在","Watchlist group does not exist"), |
| | | @("谷歌验证码未绑定","Google Authenticator is not bound"), |
| | | @("谷歌验证码错误","Incorrect Google Authenticator code"), |
| | | @("用户不存在","User does not exist") |
| | | ) |
| | | $files = Get-ChildItem -Path $apiRoot -Filter "*.java" -Recurse |
| | | $count = 0 |
| | | foreach ($file in $files) { |
| | | $text = [System.IO.File]::ReadAllText($file.FullName, [System.Text.Encoding]::UTF8) |
| | | $orig = $text |
| | | $text = $text.Replace("最低下单金额:", "Minimum order amount: ") |
| | | $text = $text.Replace("最低下单金额:", "Minimum order amount: ") |
| | | foreach ($p in $pairs) { |
| | | $text = $text.Replace("YamiShopBindException(`"$($p[0])`")", "YamiShopBindException(`"$($p[1])`")") |
| | | $text = $text.Replace("new YamiShopBindException(`"$($p[0])`")", "new YamiShopBindException(`"$($p[1])`")") |
| | | } |
| | | if ($text -ne $orig) { |
| | | [System.IO.File]::WriteAllText($file.FullName, $text, [System.Text.UTF8Encoding]::new($false)) |
| | | $count++ |
| | | Write-Host $file.FullName |
| | | } |
| | | } |
| | | Write-Host "Updated $count files" |
| New file |
| | |
| | | # -*- coding: utf-8 -*- |
| | | import os |
| | | import re |
| | | |
| | | API_ROOT = os.path.join( |
| | | os.path.dirname(os.path.dirname(__file__)), |
| | | "trading-order-admin", "src", "main", "java", "com", "yami", "trading", "api", |
| | | ) |
| | | |
| | | ZH_TO_EN = { |
| | | "参数错误": "Invalid parameters", |
| | | "参数错误!": "Invalid parameters", |
| | | "系统错误,请稍后重试": "System error, please try again later", |
| | | "请稍后再试": "Please try again later", |
| | | "操作失败,请稍后再试": "Operation failed, please try again later", |
| | | "无权限": "Permission denied", |
| | | "无网络": "Network unavailable", |
| | | "请先登录": "Please log in first", |
| | | "请登录!": "Please log in", |
| | | "请重新登录": "Please log in again", |
| | | "用户已禁用": "User account is disabled", |
| | | "用户已禁用!": "User account is disabled", |
| | | "校验IP不合法": "Invalid IP address", |
| | | "账号或密码不正确": "Incorrect username or password", |
| | | "用户名不能为空": "Username is required", |
| | | "用户名不存在": "Username does not exist", |
| | | "用户名参数为空": "Username is required", |
| | | "密码不能为空": "Password is required", |
| | | "密码必须6-12位": "Password must be 6-12 characters", |
| | | "验证类型不能为空": "Verification type is required", |
| | | "验证码不能为空": "Verification code is required", |
| | | "验证码不正确": "Incorrect verification code", |
| | | "请填写正确的电话号码": "Please enter a valid phone number", |
| | | "电话号码已绑定": "Phone number is already bound", |
| | | "电话号码已绑定其他用户": "Phone number is bound to another user", |
| | | "请填写正确的验证码": "Please enter a valid verification code", |
| | | "请输入推荐码": "Please enter referral code", |
| | | "推荐人无权限推荐": "Referrer is not authorized to refer", |
| | | "请填写正确的邮箱地址": "Please enter a valid email address", |
| | | "邮箱已绑定": "Email is already bound", |
| | | "邮箱已绑定其他用户": "Email is bound to another user", |
| | | "旧密码不能为空": "Old password is required", |
| | | "新密码不能为空": "New password is required", |
| | | "新密码确认不能为空": "Password confirmation is required", |
| | | "旧密码不正确!": "Incorrect old password", |
| | | "新密码不一致": "New passwords do not match", |
| | | "资金密码不能为空": "Fund password is required", |
| | | "资金密码不符合设定": "Fund password does not meet requirements", |
| | | "资金密码必须6-12位": "Fund password must be 6-12 characters", |
| | | "资金密码错误": "Incorrect fund password", |
| | | "旧资金密码不能为空": "Old fund password is required", |
| | | "新资金密码不能为空": "New fund password is required", |
| | | "新资金密码确认不能为空": "Fund password confirmation is required", |
| | | "操作类型为空": "Operation type is required", |
| | | "操作类型不是整数": "Operation type must be an integer", |
| | | "操作类型不能小于0": "Operation type cannot be negative", |
| | | "备注长度超过250": "Remark exceeds 250 characters", |
| | | "请求第三方失败": "Third-party request failed", |
| | | "订单不存在!": "Order does not exist", |
| | | "页码不是整数": "Page number must be an integer", |
| | | "页码不能小于等于0": "Page number must be greater than 0", |
| | | "k线图获取失败": "Failed to load chart data", |
| | | "请输入正确的货币数量": "Please enter a valid amount", |
| | | "请选择正确的币种": "Please select a valid currency", |
| | | "请输入正确的兑换数量": "Please enter a valid exchange amount", |
| | | "生成实时数据失败": "Failed to generate market data", |
| | | "状态不是整数": "Status must be an integer", |
| | | "状态不能小于0": "Status cannot be negative", |
| | | "证件号码长度超过50": "ID number exceeds 50 characters", |
| | | "实名姓名长度超过50": "Real name exceeds 50 characters", |
| | | "当前币对不存在": "Trading pair does not exist", |
| | | "未开放合约交易": "Contract trading is not available", |
| | | "停牌禁止交易": "Trading suspended for this symbol", |
| | | "当前已经休市": "Market is closed", |
| | | "订单不存在": "Order does not exist", |
| | | "追加保证金异常": "Failed to add margin", |
| | | "委托单不存在": "Order does not exist", |
| | | "执行撤单异常": "Failed to cancel order", |
| | | "支付币种不正确": "Invalid payment currency", |
| | | "提交失败,当前有未处理订单": "Submission failed, pending order exists", |
| | | "用户未结束订单数量已达上限": "Too many open orders", |
| | | "今日取消订单次数太多了,请明日再试": "Too many cancellations today, try again tomorrow", |
| | | "广告不存在": "Advertisement does not exist", |
| | | "支付方式不存在": "Payment method does not exist", |
| | | "订单类型不正确": "Invalid order type", |
| | | "支付金额不正确": "Invalid payment amount", |
| | | "币种数量不正确": "Invalid currency amount", |
| | | "承兑商的用户信息不存在": "Merchant user info does not exist", |
| | | "请先通过高级认证": "Advanced verification required", |
| | | "流水小于限额": "Transaction volume below minimum limit", |
| | | "用户不能取消提现": "Withdrawal cannot be cancelled", |
| | | "充值或提现不正确": "Invalid deposit or withdrawal type", |
| | | "订单状态不正确": "Invalid order status", |
| | | "承兑商不存在": "Merchant does not exist", |
| | | "C2C广告id不正确": "Invalid C2C advertisement ID", |
| | | "请上传图片": "Please upload an image", |
| | | "提交失败,当前有未处理银行卡订单": "Submission failed, pending bank order exists", |
| | | "申诉订单号不正确": "Invalid appeal order number", |
| | | "请输入申诉原因": "Please enter appeal reason", |
| | | "请上传申诉凭证": "Please upload appeal evidence", |
| | | "该订单已提交申诉": "Appeal already submitted for this order", |
| | | "申诉不存在": "Appeal does not exist", |
| | | "订单号不能未空": "Order number is required", |
| | | "当前支付方式有未处理完成的订单!": "Pending orders exist for this payment method", |
| | | "广告id不正确": "Invalid advertisement ID", |
| | | "承兑商支付方式未配置": "Merchant payment method not configured", |
| | | "承兑商广告支付方式未配置": "Merchant ad payment method not configured", |
| | | "图片大小不能超过4M": "Image size cannot exceed 4MB", |
| | | "文件上传失败": "File upload failed", |
| | | "实名认证未通过,无法进行高级认证": "Real-name verification required before advanced verification", |
| | | "工作地址长度超过245": "Work address exceeds 245 characters", |
| | | "家庭地址长度超过245": "Home address exceeds 245 characters", |
| | | "该自选组名称已经使用": "Watchlist name already in use", |
| | | "已经添加过该分组了": "Group already added", |
| | | "自选组不存在": "Watchlist group does not exist", |
| | | "谷歌验证码未绑定": "Google Authenticator is not bound", |
| | | "谷歌验证码错误": "Incorrect Google Authenticator code", |
| | | "用户不存在": "User does not exist", |
| | | "用户已禁用!": "User account is disabled", |
| | | "推广码不存在": "Promotion code does not exist", |
| | | "推广码已失效": "Promotion code has expired", |
| | | } |
| | | |
| | | |
| | | def main(): |
| | | items = sorted(ZH_TO_EN.items(), key=lambda x: -len(x[0])) |
| | | changed = 0 |
| | | for dirpath, _, files in os.walk(API_ROOT): |
| | | for fn in files: |
| | | if not fn.endswith(".java"): |
| | | continue |
| | | path = os.path.join(dirpath, fn) |
| | | with open(path, "r", encoding="utf-8") as f: |
| | | text = f.read() |
| | | orig = text |
| | | text = text.replace("最低下单金额:", "Minimum order amount: ") |
| | | text = text.replace("最低下单金额:", "Minimum order amount: ") |
| | | for zh, en in items: |
| | | text = text.replace(f'YamiShopBindException("{zh}")', f'YamiShopBindException("{en}")') |
| | | text = text.replace(f"new YamiShopBindException(\"{zh}\")", f'new YamiShopBindException("{en}")') |
| | | if text != orig: |
| | | with open(path, "w", encoding="utf-8", newline="\n") as f: |
| | | f.write(text) |
| | | changed += 1 |
| | | print(path) |
| | | print("updated files:", changed) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | main() |
| | |
| | | market = new StockMarket(); |
| | | market.setTime_zone( "America/New_York"); |
| | | if(MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType())){ |
| | | market.setStatus("交易中"); |
| | | market.setStatus("Trading"); |
| | | }else{ |
| | | market.setStatus("未开盘"); |
| | | market.setStatus("Not open"); |
| | | } |
| | | market.calculate(); |
| | | map.put("market", market); |
| | |
| | | if (flag) { |
| | | User user = userService.getById(userId); |
| | | if (user.isGoogleAuthBind()) { |
| | | throw new YamiShopBindException("谷歌验证码已绑定"); |
| | | throw new YamiShopBindException("Google Authenticator is already bound"); |
| | | } |
| | | user.setGoogleAuthBind(true); |
| | | user.setGoogleAuthSecret(model.getSecret()); |
| | |
| | | map.put("google_auth_bind",true); |
| | | return Result.succeed(map); |
| | | } else { |
| | | throw new YamiShopBindException("谷歌验证码错误"); |
| | | throw new YamiShopBindException("Incorrect Google Authenticator code"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (null == cpmMap || 0 == cpmMap.size()) { |
| | | // TODO: 2023/4/16 |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | throw new YamiShopBindException("Payment method does not exist"); |
| | | } |
| | | List<String> cpmList = new ArrayList<String>(); |
| | | for (String key : cpmMap.keySet()) { |
| | |
| | | |
| | | private String verif(String direction, String nationality, String currency, String payment_method_id, String coin_amount, String img) { |
| | | if (StringUtils.isEmptyString(direction) || !Arrays.asList("recharge", "withdraw").contains(direction)) { |
| | | return "充值或提现不正确"; |
| | | return "Invalid recharge or withdrawal type"; |
| | | } |
| | | Map<String, String> currencyMap = this.c2cPaymentMethodService.getCurrencyMap(); |
| | | if (StringUtils.isEmptyString(currency) || null == currencyMap || (null != currencyMap && !currencyMap.containsKey(currency))) { |
| | | return "支付币种不正确"; |
| | | return "Invalid payment currency"; |
| | | } |
| | | if (StringUtils.isEmptyString(payment_method_id)) { |
| | | return "支付方式不正确"; |
| | | return "Invalid payment method"; |
| | | } |
| | | if (StringUtils.isEmptyString(coin_amount) || !StringUtils.isDouble(coin_amount) || Double.valueOf(coin_amount).doubleValue() <= 0) { |
| | | return "交易数量不正确"; |
| | | return "Invalid transaction amount"; |
| | | } |
| | | if ("recharge".equals(direction)) { |
| | | if (StringUtils.isEmptyString(nationality)) { |
| | | return "国家/地区不正确"; |
| | | return "Invalid country or region"; |
| | | } |
| | | // 银行卡充值是否强制需要上传图片,需要true,不需要false |
| | | boolean bank_card_recharge_must_need_img = this.sysparaService.find("bank_card_recharge_must_need_img").getBoolean(); |
| | | if (bank_card_recharge_must_need_img) { |
| | | if (StringUtils.isEmptyString(img)) { |
| | | return "请上传图片"; |
| | | return "Please upload an image"; |
| | | } |
| | | } |
| | | } |
| | |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if (null == object || !userId.equals((String) object)) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (null == partyId) { |
| | | throw new YamiShopBindException("请重新登录"); |
| | | throw new YamiShopBindException("Please log in again"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("User is locked"); |
| | |
| | | party_kyc=new RealNameAuthRecord(); |
| | | } |
| | | if (!(party_kyc.getStatus() == 2) && "true".equals(this.sysparaService.find("withdraw_by_kyc").getSvalue())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | HighLevelAuthRecord party_kycHighLevel = highLevelAuthRecordService.findByUserId(partyId); |
| | | if (party_kycHighLevel==null){ |
| | |
| | | } |
| | | double withdraw_by_high_kyc = Double.valueOf(this.sysparaService.find("withdraw_by_high_kyc").getSvalue()); |
| | | if (withdraw_by_high_kyc > 0 && coin_amount_double > withdraw_by_high_kyc && !(party_kycHighLevel.getStatus() == 2)) { |
| | | throw new YamiShopBindException("请先通过高级认证"); |
| | | throw new YamiShopBindException("Advanced verification required"); |
| | | } |
| | | // if (!party.getWithdraw_authority()) { |
| | | // throw new BusinessException(1, "无权限"); |
| | |
| | | // 流水小于限额 |
| | | if (userdata_turnover < party_withdraw) { |
| | | fact_withdraw_amount = Arith.sub(party_withdraw, userdata_turnover); |
| | | throw new YamiShopBindException("流水小于限额"); |
| | | throw new YamiShopBindException("Transaction volume below minimum limit"); |
| | | } |
| | | } |
| | | if ("2".equals(withdraw_limit_open_use_type)) { |
| | |
| | | Object obj1 = this.sysparaService.find("bank_card_order_cancel_day_times"); |
| | | if (null != obj1) { |
| | | if (orderCancelDayTimes >= Integer.valueOf(this.sysparaService.find("bank_card_order_cancel_day_times").getSvalue()).intValue()) { |
| | | throw new YamiShopBindException("今日取消订单次数太多了,请明日再试"); |
| | | throw new YamiShopBindException("Too many cancellations today, try again tomorrow"); |
| | | } |
| | | } |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | | ExchangeRate ex = this.exchangeRateService.findBy(Constants.OUT_OR_IN_DEFAULT, currency.toUpperCase()); |
| | | if (null == ex) { |
| | | throw new YamiShopBindException("支付币种不正确"); |
| | | throw new YamiShopBindException("Invalid payment currency"); |
| | | } |
| | | C2cOrder c2cOrder = new C2cOrder(); |
| | | c2cOrder.setPartyId(party.getUserId()); |
| | |
| | | public Result orderCancel(String order_no, String remark) { |
| | | User party = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("User is locked"); |
| | | } |
| | | C2cOrder order = this.c2cOrderService.get(order_no); |
| | | if (null == order || !order.getPartyId().equals(SecurityUtils.getUser().getUserId())) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | order.setRemark(remark); |
| | | // 用户不能取消提现 |
| | | if (SecurityUtils.getUser().getUserId().equals(order.getPartyId())) { |
| | | if ("withdraw".equals(order.getDirection())) { |
| | | throw new YamiShopBindException("用户不能取消提现"); |
| | | throw new YamiShopBindException("Withdrawal cannot be cancelled"); |
| | | } |
| | | this.c2cOrderService.saveOrderCancel(order, "user"); |
| | | } |
| | |
| | | public Result get(@RequestParam String order_no, @RequestParam String language) { |
| | | C2cOrder c2cOrder = this.c2cOrderService.get(order_no); |
| | | if (null == c2cOrder) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | List<String> nos = new ArrayList<String>(); |
| | | nos.add(c2cOrder.getOrderNo()); |
| | |
| | | public Result list(String page_no, String direction, String state) { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (null == partyId) { |
| | | throw new YamiShopBindException("请重新登录"); |
| | | throw new YamiShopBindException("Please log in again"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(page_no)) { |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | if (StringUtils.isNotEmpty(direction) && !Arrays.asList("recharge", "withdraw").contains(direction)) { |
| | | throw new YamiShopBindException("充值或提现不正确"); |
| | | throw new YamiShopBindException("Invalid deposit or withdrawal type"); |
| | | } |
| | | if (StringUtils.isNotEmpty(state) && !Arrays.asList("0", "3", "4").contains(state)) { |
| | | throw new YamiShopBindException("订单状态不正确"); |
| | | throw new YamiShopBindException("Invalid order status"); |
| | | } |
| | | Page page = this.c2cOrderService.pagedQuery(page_no_int, 20, direction, state, partyId); |
| | | if (null == page) { |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | String c2cUserId = ""; |
| | | User party = userService.getById(partyId); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户不存在"); |
| | | throw new YamiShopBindException("User does not exist"); |
| | | } |
| | | if (Arrays.asList(1, 2).contains(party.getC2cUserType())) { |
| | | C2cUser c2cUser = c2cUserService.getByPartyId(partyId); |
| | |
| | | String id = request.getParameter("id"); |
| | | String language = request.getParameter("language"); |
| | | if (StringUtils.isEmptyString(id)) { |
| | | throw new YamiShopBindException("C2C广告id不正确"); |
| | | throw new YamiShopBindException("Invalid C2C advertisement ID"); |
| | | } |
| | | C2cAdvert c2cAdvert = c2cAdvertService.getById(id); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | C2cUser c2cUser = this.c2cUserService.getById(c2cAdvert.getC2cUserId()); |
| | | if (null == c2cUser) { |
| | | throw new YamiShopBindException("承兑商不存在"); |
| | | throw new YamiShopBindException("Merchant does not exist"); |
| | | } |
| | | User c2cParty = userService.getById(c2cUser.getC2cUserPartyId()); |
| | | if (null == c2cParty) { |
| | | throw new YamiShopBindException("承兑商的用户信息不存在"); |
| | | throw new YamiShopBindException("Merchant user info does not exist"); |
| | | } |
| | | Map<String, String> data = new HashMap<String, String>(); |
| | | data.put("id", c2cAdvert.getUuid().toString()); |
| | |
| | | // |
| | | private String verif(String direction, String currency, String symbol, String method_type, String amount) { |
| | | if (!StringUtils.isEmptyString(direction) && !Arrays.asList("buy", "sell").contains(direction)) { |
| | | return "买卖方式不正确"; |
| | | return "Invalid trade direction"; |
| | | } |
| | | Map<String, String> currencyMap = this.c2cAdvertService.getCurrencyMap(); |
| | | Map<String, String> symbolMap = this.c2cAdvertService.getSymbolMap(); |
| | | if (!StringUtils.isEmptyString(currency) && null != currencyMap && !currencyMap.containsKey(currency)) { |
| | | return "支付币种不正确"; |
| | | return "Invalid payment currency"; |
| | | } |
| | | if (!StringUtils.isEmptyString(symbol) && null != symbolMap && !symbolMap.containsKey(symbol)) { |
| | | return "上架币种不正确"; |
| | | return "Invalid listed currency"; |
| | | } |
| | | Map<String, String> pmtMap = this.c2cAdvertService.getC2cSyspara("c2c_payment_method_type"); |
| | | if (!StringUtils.isEmptyString(method_type) && !pmtMap.keySet().contains(method_type)) { |
| | | return "支付方式类型不正确"; |
| | | return "Invalid payment method type"; |
| | | } |
| | | if (!StringUtils.isEmptyString(amount) && (!StringUtils.isDouble(amount) || Double.valueOf(amount).doubleValue() < 0)) { |
| | | return "支付金额不正确"; |
| | | return "Invalid payment amount"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | String name = request.getParameter("name"); |
| | | String phone = request.getParameter("phone"); |
| | | if (StringUtils.isEmptyString(order_no)) { |
| | | throw new YamiShopBindException("申诉订单号不正确"); |
| | | throw new YamiShopBindException("Invalid appeal order number"); |
| | | } |
| | | if (StringUtils.isEmptyString(reason)) { |
| | | throw new YamiShopBindException("请输入申诉原因"); |
| | | throw new YamiShopBindException("Please enter appeal reason"); |
| | | } |
| | | if (StringUtils.isEmptyString(img)) { |
| | | throw new YamiShopBindException("请上传申诉凭证"); |
| | | throw new YamiShopBindException("Please upload appeal evidence"); |
| | | } |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | C2cOrder order = this.c2cOrderService.get(order_no); |
| | | if (null == order || !partyId.equals(order.getPartyId())) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | C2cAppeal appeal = this.c2cAppealService.findByOrderNo(order_no); |
| | | if (null != appeal) { |
| | | throw new YamiShopBindException("该订单已提交申诉"); |
| | | throw new YamiShopBindException("Appeal already submitted for this order"); |
| | | } |
| | | C2cAppeal entity = new C2cAppeal(); |
| | | entity.setOrderNo(order_no); |
| | |
| | | public Result get(HttpServletRequest request) throws IOException { |
| | | String order_no = request.getParameter("order_no"); |
| | | if (StringUtils.isEmptyString(order_no)) { |
| | | throw new YamiShopBindException("申诉订单号不正确"); |
| | | throw new YamiShopBindException("Invalid appeal order number"); |
| | | } |
| | | C2cAppeal c2cAppeal = this.c2cAppealService.findByOrderNo(order_no); |
| | | if (null == c2cAppeal) { |
| | | throw new YamiShopBindException("申诉不存在"); |
| | | throw new YamiShopBindException("Appeal does not exist"); |
| | | } |
| | | if (StringUtils.isNotEmpty(c2cAppeal.getImg())) { |
| | | String path = Constants.IMAGES_HTTP+c2cAppeal.getImg(); |
| | |
| | | public Object order_open(HttpServletRequest request) throws IOException { |
| | | String currency = request.getParameter("currency"); |
| | | if (StringUtils.isEmptyString(currency)) { |
| | | throw new YamiShopBindException("支付币种不正确"); |
| | | throw new YamiShopBindException("Invalid payment currency"); |
| | | } |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | String session_token = sessionTokenService.savePut(partyId); |
| | |
| | | party = userService.getById(partyId); |
| | | log.error("用户"+direction+"开始当前用户uid:"+party.getUserCode()+"当前用户名:"+party.getUserName()+"生成的订单号:"+orderNo); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | |
| | | if (!C2cLock.add(partyId)) { |
| | |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if (null == object || !partyId.equals((String) object)) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | |
| | | if (!party.isEnabled()) { |
| | |
| | | String c2c_sell_only_one = sysparaService.find("c2c_sell_only_one").getSvalue(); |
| | | if(StringUtils.isNotEmpty(c2c_sell_only_one)&&"1".equals(c2c_sell_only_one)) { |
| | | if(nofinishOrderCount >= 1) { |
| | | throw new YamiShopBindException("提交失败,当前有未处理订单"); |
| | | throw new YamiShopBindException("Submission failed, pending order exists"); |
| | | } |
| | | Long.valueOf(c2c_sell_only_one).longValue(); |
| | | } |
| | | Object obj2 = this.sysparaService.find("c2c_nofinish_order_count_max"); |
| | | if (null != obj2) { |
| | | if (nofinishOrderCount >= Long.valueOf(this.sysparaService.find("c2c_nofinish_order_count_max").getSvalue()).longValue()) { |
| | | throw new YamiShopBindException("用户未结束订单数量已达上限"); |
| | | throw new YamiShopBindException("Too many open orders"); |
| | | } |
| | | } |
| | | |
| | |
| | | Object obj1 = this.sysparaService.find("c2c_order_cancel_day_times"); |
| | | if (null != obj1) { |
| | | if (orderCancelDayTimes >= Integer.valueOf(this.sysparaService.find("c2c_order_cancel_day_times").getSvalue()).intValue()) { |
| | | throw new YamiShopBindException("今日取消订单次数太多了,请明日再试"); |
| | | throw new YamiShopBindException("Too many cancellations today, try again tomorrow"); |
| | | } |
| | | } |
| | | |
| | | C2cAdvert c2cAdvert = this.c2cAdvertService.getById(c2c_advert_id); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | |
| | | C2cPaymentMethod method =c2cPaymentMethodService.get(payment_method_id); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | throw new YamiShopBindException("Payment method does not exist"); |
| | | } |
| | | |
| | | if (StringUtils.isEmptyString(order_type) || !Arrays.asList("by_amount", "by_num").contains(order_type)) { |
| | | throw new YamiShopBindException("订单类型不正确"); |
| | | throw new YamiShopBindException("Invalid order type"); |
| | | } |
| | | |
| | | if (C2cOrder.ORDER_TYPE_BY_AMOUNT.equals(order_type)) { |
| | | // 按支付金额支付 |
| | | if (StringUtils.isEmptyString(amount) || !StringUtils.isDouble(amount) || Double.valueOf(amount).doubleValue() <= 0) { |
| | | throw new YamiShopBindException("支付金额不正确"); |
| | | throw new YamiShopBindException("Invalid payment amount"); |
| | | } |
| | | coin_amount = "0"; |
| | | } else { |
| | | // 按币种数量支付 |
| | | if (StringUtils.isEmptyString(coin_amount) || !StringUtils.isDouble(coin_amount) || Double.valueOf(coin_amount).doubleValue() <= 0) { |
| | | throw new YamiShopBindException("币种数量不正确"); |
| | | throw new YamiShopBindException("Invalid currency amount"); |
| | | } |
| | | amount = "0"; |
| | | } |
| | |
| | | |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if (null == partyId) { |
| | | throw new BusinessException("请重新登录"); |
| | | throw new BusinessException("Please log in again"); |
| | | } |
| | | |
| | | User party = userService.getById(partyId); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new BusinessException("无权限"); |
| | | throw new BusinessException("Permission denied"); |
| | | } |
| | | |
| | | if (!userService.checkLoginSafeword(partyId, safe_password)) { |
| | | throw new BusinessException("资金密码错误"); |
| | | throw new BusinessException("Incorrect fund password"); |
| | | } |
| | | |
| | | if (!party.isEnabled()) { |
| | |
| | | |
| | | C2cOrder order = this.c2cOrderService.get(order_no); |
| | | if (null == order) { |
| | | throw new BusinessException("订单不存在"); |
| | | throw new BusinessException("Order does not exist"); |
| | | } |
| | | |
| | | if (partyId.equals(order.getPartyId())) { |
| | | // 用户操作 |
| | | if (!"buy".equals(order.getDirection())) { |
| | | throw new BusinessException("用户不能支付卖单"); |
| | | throw new BusinessException("User cannot pay for a sell order"); |
| | | } |
| | | } else if (partyId.equals(order.getC2cUserPartyId())) { |
| | | // 承兑商操作 |
| | | if (!"sell".equals(order.getDirection())) { |
| | | throw new BusinessException("承兑商不能支付买单"); |
| | | throw new BusinessException("Merchant cannot pay for a buy order"); |
| | | } |
| | | } else { |
| | | throw new BusinessException("无权限"); |
| | | throw new BusinessException("Permission denied"); |
| | | } |
| | | |
| | | if (!"0".equals(order.getState())) { |
| | | throw new BusinessException("订单不是未付款状态"); |
| | | throw new BusinessException("Order is not in unpaid status"); |
| | | } |
| | | |
| | | if (!C2cOrderLock.add(order_no)) { |
| | | throw new BusinessException(1, "请稍后再试"); |
| | | throw new BusinessException(1, "Please try again later"); |
| | | } |
| | | |
| | | lock = true; |
| | |
| | | |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if (null == partyId) { |
| | | throw new BusinessException("请重新登录"); |
| | | throw new BusinessException("Please log in again"); |
| | | } |
| | | |
| | | User party = userService.getById(partyId); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new BusinessException("无权限"); |
| | | throw new BusinessException("Permission denied"); |
| | | } |
| | | |
| | | if (!C2cOrderLock.add(order_no)) { |
| | | throw new BusinessException(1, "请稍后再试"); |
| | | throw new BusinessException(1, "Please try again later"); |
| | | } |
| | | |
| | | lock = true; |
| | | |
| | | if (!userService.checkLoginSafeword(partyId, safe_password)) { |
| | | throw new BusinessException("资金密码错误"); |
| | | throw new BusinessException("Incorrect fund password"); |
| | | } |
| | | if (!party.isEnabled()) { |
| | | return Result.succeed("User is locked"); |
| | |
| | | |
| | | C2cOrder order = this.c2cOrderService.get(order_no); |
| | | if (null == order || !order.getPartyId().equals(partyId)) { |
| | | throw new BusinessException("订单不存在"); |
| | | throw new BusinessException("Order does not exist"); |
| | | } |
| | | if ("0".equals(order.getState())) { |
| | | throw new BusinessException("待付款的订单无法放行"); |
| | | throw new BusinessException("Unpaid order cannot be released"); |
| | | } |
| | | if ("3".equals(order.getState())) { |
| | | resultObject.setCode(0); |
| | |
| | | //throw new BusinessException("订单已完成,无法放行"); |
| | | } |
| | | if ("4".equals(order.getState())) { |
| | | throw new BusinessException("订单已取消,无法放行"); |
| | | throw new BusinessException("Cancelled order cannot be released"); |
| | | } |
| | | |
| | | this.c2cOrderService.saveOrderPass(order); |
| | |
| | | String language = request.getParameter("language"); |
| | | C2cPaymentMethodConfig config = this.c2cPaymentMethodConfigService.getById(id); |
| | | if (null == config) { |
| | | throw new BusinessException("支付方式模板不存在"); |
| | | throw new BusinessException("Payment method template does not exist"); |
| | | } |
| | | if (StringUtils.isNotEmpty(config.getMethodImg())) { |
| | | String path = Constants.IMAGES_HTTP+config.getMethodImg(); |
| | |
| | | |
| | | C2cUser c2cUser = this.c2cUserService.getById(c2c_user_id); |
| | | if (null == c2cUser) { |
| | | throw new BusinessException("承兑商不存在"); |
| | | throw new BusinessException("Merchant does not exist"); |
| | | } |
| | | |
| | | C2cUserParamBaseSet paramBaseSet = this.c2cUserParamBaseSetService.getByPartyId(c2cUser.getC2cUserPartyId()); |
| | | if (null == paramBaseSet) { |
| | | throw new BusinessException("承兑商参数基础设置不存在"); |
| | | throw new BusinessException("Merchant base settings do not exist"); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(c2cUser.getHeadImg())) { |
| | |
| | | |
| | | User party = userService.getById(c2cUser.getC2cUserPartyId()); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("承兑商的用户信息不存在"); |
| | | throw new YamiShopBindException("Merchant user info does not exist"); |
| | | } |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.########"); |
| | |
| | | public Result updateWallt(@Valid TransferModel model) { |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if(!StringUtils.isNotEmpty(partyId)){ |
| | | throw new YamiShopBindException("请登录!"); |
| | | throw new YamiShopBindException("Please log in"); |
| | | } |
| | | return capitaltWalletService.updateWallt(partyId,model.getDeductAccount(),model.getReceiveAccount(),model.getMoneyRevise()); |
| | | } |
| | |
| | | public Result updateWallt() { |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if(!StringUtils.isNotEmpty(partyId)){ |
| | | throw new YamiShopBindException("请登录!"); |
| | | throw new YamiShopBindException("Please log in"); |
| | | } |
| | | // 获取合约账户(contract) |
| | | Wallet wallet = walletService.saveWalletByPartyId(partyId); |
| | |
| | | lockAcquired = rLock.tryLock(5, TimeUnit.SECONDS); |
| | | if (!lockAcquired) { |
| | | log.warn("无法获取锁: contract_open_{}", partyId); |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | //判断下单金额是否符合最低金额 最低下单张数:0.01 |
| | | //合约张数 张数=保证金*杠杆倍数/(面值*最新成交价) |
| | |
| | | if (amount.compareTo(new BigDecimal(faceValue)) < 0) { |
| | | double minimumAmount = minAmount * faceValue * openAction.getPrice().doubleValue() / openAction.getLever_rate().doubleValue(); |
| | | double roundedAmount = Math.ceil(minimumAmount * 10000) / 10000; |
| | | throw new YamiShopBindException("最低下单金额:"+roundedAmount); |
| | | throw new YamiShopBindException("Minimum order amount: "+roundedAmount); |
| | | } |
| | | |
| | | // 校验当前用户订单状态 |
| | |
| | | throw e; // 重新抛出自定义异常 |
| | | } catch (Exception e) { |
| | | log.error("系统异常: {}", e.getMessage(), e); |
| | | throw new YamiShopBindException("操作失败,请稍后再试"); |
| | | throw new YamiShopBindException("Operation failed, please try again later"); |
| | | } finally { |
| | | // 确保释放锁 |
| | | if (lockAcquired && rLock.isHeldByCurrentThread()) { |
| | |
| | | String[] stopUsers = stopUserInternet.split(","); |
| | | User user = userService.getById(partyId); |
| | | if (Arrays.asList(stopUsers).contains(user.getUserName())) { |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("Network unavailable"); |
| | | } |
| | | } |
| | | } |
| | |
| | | RLock rLock = redissonClient.getLock("contract_close_" + partyId); |
| | | boolean lockResult = rLock.tryLock(5, TimeUnit.SECONDS); |
| | | if (!lockResult) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | try { |
| | | User user = userService.getById(partyId); |
| | |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(user.getUserName())){ |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("Network unavailable"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | ContractApplyOrder order = this.contractApplyOrderService.findByOrderNo(order_no); |
| | | if (order == null) { |
| | | throw new YamiShopBindException("委托单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("order_no", order.getOrderNo()); |
| | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("执行撤单异常", e); |
| | | throw new YamiShopBindException("执行撤单异常"); |
| | | throw new YamiShopBindException("Failed to cancel order"); |
| | | } |
| | | |
| | | return Result.succeed(null,"success"); |
| | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("执行撤单异常", e); |
| | | throw new YamiShopBindException("执行撤单异常"); |
| | | throw new YamiShopBindException("Failed to cancel order"); |
| | | } |
| | | |
| | | return Result.succeed(null,"success"); |
| | |
| | | Page<ContractApplyOrder> result = contractApplyOrderService.findList(page, SecurityUtils.getUser().getUserId(), type, symbolType); |
| | | List<ContractApplyOrder> datas = result.getRecords(); |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | Long count = 0L; |
| | | |
| | |
| | | t.start(); |
| | | } catch (Exception e) { |
| | | log.error("平仓失败", e); |
| | | return Result.failed("平仓失败"); |
| | | return Result.failed("Failed to close position"); |
| | | } |
| | | |
| | | return Result.succeed("平仓成功"); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("追加保证金异常", e); |
| | | throw new YamiShopBindException("追加保证金异常"); |
| | | throw new YamiShopBindException("Failed to add margin"); |
| | | } |
| | | return Result.succeed("success"); |
| | | } |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("追加保证金异常", e); |
| | | throw new YamiShopBindException("追加保证金异常"); |
| | | throw new YamiShopBindException("Failed to add margin"); |
| | | } |
| | | return Result.succeed("success"); |
| | | } |
| | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("一键平仓失败", e); |
| | | return Result.failed("一键平仓失败"); |
| | | return Result.failed("Failed to close all positions"); |
| | | } |
| | | |
| | | return Result.succeed("一键平仓成功"); |
| | |
| | | |
| | | if (null == order) { |
| | | log.info("contractOrder!get order_no:" + order_no + ", order null"); |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | |
| | | return Result.ok(this.contractOrderService.bulidOne(order)); |
| | |
| | | } |
| | | |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | |
| | |
| | | Map<String, Object> data = new HashMap<>(); |
| | | Item bySymbol = itemService.findBySymbol(symbol); |
| | | if(bySymbol == null){ |
| | | throw new YamiShopBindException("当前币对不存在"); |
| | | throw new YamiShopBindException("Trading pair does not exist"); |
| | | } |
| | | List<Map<String,Object>> futuresParas = new ArrayList<>(); |
| | | for (FuturesPara para : this.futuresParaService.getBySymbolSort(symbol)) { |
| | |
| | | public Result<Map<String, String>> open(FutureOpenAction futureOpenAction) { |
| | | Item bySymbol = itemService.findBySymbol(futureOpenAction.getSymbol()); |
| | | if(bySymbol == null){ |
| | | throw new YamiShopBindException("当前币对不存在"); |
| | | throw new YamiShopBindException("Trading pair does not exist"); |
| | | } |
| | | if (!itemService.isContractTrading(bySymbol)) { |
| | | throw new YamiShopBindException("未开放合约交易"); |
| | | throw new YamiShopBindException("Contract trading is not available"); |
| | | } |
| | | /*if (itemService.isSuspended(bySymbol.getSymbol())) { |
| | | throw new YamiShopBindException("停牌禁止交易"); |
| | | throw new YamiShopBindException("Trading suspended for this symbol"); |
| | | }*/ |
| | | |
| | | |
| | | boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType()); |
| | | if(!isOpen){ |
| | | throw new YamiShopBindException("当前已经休市"); |
| | | throw new YamiShopBindException("Market is closed"); |
| | | } |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | boolean lock = false; |
| | |
| | | Map<String, String> data = new HashMap<String, String>(); |
| | | |
| | | if (!FuturesLock.add(partyId)) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | |
| | | lock = true; |
| | |
| | | throw new YamiShopBindException("User is locked"); |
| | | } |
| | | if (null == object || !party.getUserId().equals((String) object)) { |
| | | throw new BusinessException("请稍后再试"); |
| | | throw new BusinessException("Please try again later"); |
| | | } |
| | | |
| | | FuturesOrder order = new FuturesOrder(); |
| | |
| | | FuturesOrder order = this.futuresOrderService.cacheByOrderNo(order_no); |
| | | if (null == order) { |
| | | log.info("futuresOrder!get order_no:" + order_no + ", order null"); |
| | | throw new YamiShopBindException("订单不存在"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | return Result.succeed(this.futuresOrderService.bulidOne(order)); |
| | | } |
| | |
| | | public Result applyHighLevelAuth(@Valid ApplyHighLevelAuthModel model) { |
| | | User user = userCacheService.currentUser(); |
| | | if (!realNameAuthRecordService.isPass(user.getUserId())) { |
| | | throw new YamiShopBindException("实名认证未通过,无法进行高级认证"); |
| | | throw new YamiShopBindException("Real-name verification required before advanced verification"); |
| | | } |
| | | HighLevelAuthRecord highLevelAuthRecord = highLevelAuthRecordService.findByUserId(user.getUserId()); |
| | | if (highLevelAuthRecord != null) { |
| | | String msg = ""; |
| | | switch (highLevelAuthRecord.getStatus()) { |
| | | case 0: |
| | | msg = "已经提交申请,请等待审核"; |
| | | msg = "Application submitted, please wait for review"; |
| | | break; |
| | | case 1: |
| | | msg = "审核中"; |
| | | msg = "Under review"; |
| | | break; |
| | | case 2: |
| | | msg = "审核已通过"; |
| | | msg = "Already approved"; |
| | | break; |
| | | case 3: |
| | | highLevelAuthRecord.setStatus(1); |
| | |
| | | // msg = MessageFormat.format("审核未通过,原因:{0}", record.getMsg()); |
| | | break; |
| | | default: |
| | | msg = "审核状态异常请联系客服"; |
| | | msg = "Abnormal review status, please contact support"; |
| | | break; |
| | | } |
| | | if (StrUtil.isNotBlank(msg)) { |
| | |
| | | |
| | | if (StrUtil.isNotBlank(model.getWork_place())){ |
| | | if ( model.getWork_place().length()>245){ |
| | | throw new YamiShopBindException("工作地址长度超过245"); |
| | | throw new YamiShopBindException("Work address exceeds 245 characters"); |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(model.getHome_place())){ |
| | | if ( model.getHome_place().length()>245){ |
| | | throw new YamiShopBindException("家庭地址长度超过245"); |
| | | throw new YamiShopBindException("Home address exceeds 245 characters"); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(model.getRelatives_relation())){ |
| | | if ( model.getRelatives_relation().length()>32){ |
| | | throw new YamiShopBindException("亲属电话长度超过32"); |
| | | throw new YamiShopBindException("Relative phone exceeds 32 characters"); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(model.getRelatives_name())){ |
| | | if ( model.getRelatives_name().length()>32){ |
| | | throw new YamiShopBindException("亲属名称长度超过32"); |
| | | throw new YamiShopBindException("Relative name exceeds 32 characters"); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(model.getRelatives_place())){ |
| | | if ( model.getRelatives_place().length()>245){ |
| | | throw new YamiShopBindException("亲属地址长度超过245"); |
| | | throw new YamiShopBindException("Relative address exceeds 245 characters"); |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(model.getRelatives_phone())){ |
| | | if ( model.getRelatives_phone().length()>32){ |
| | | throw new YamiShopBindException("亲属电话长度超过32"); |
| | | throw new YamiShopBindException("Relative phone exceeds 32 characters"); |
| | | } |
| | | } |
| | | |
| | |
| | | public Result<String> subscribe(@Valid UserSubscription model) { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (StringUtils.isEmpty(partyId)) { |
| | | throw new YamiShopBindException("请重新登录"); |
| | | throw new YamiShopBindException("Please log in again"); |
| | | } |
| | | RLock rLock = redissonClient.getLock("subscribe" + partyId); |
| | | boolean lockAcquired = false; |
| | |
| | | lockAcquired = rLock.tryLock(5, TimeUnit.SECONDS); |
| | | if (!lockAcquired) { |
| | | log.warn("无法获取锁: subscribe{}", partyId); |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | model.setUserId(partyId); |
| | | return icoService.subscribe(model); |
| | |
| | | throw e; // 重新抛出自定义异常 |
| | | } catch (Exception e) { |
| | | log.error("系统异常: {}", e.getMessage(), e); |
| | | throw new YamiShopBindException("操作失败,请稍后再试"); |
| | | throw new YamiShopBindException("Operation failed, please try again later"); |
| | | } finally { |
| | | // 确保释放锁 |
| | | if (lockAcquired && rLock.isHeldByCurrentThread()) { |
| | |
| | | QueryWrapper queryWrapper = QueryWrapperGenerator.buildQueryCondition (icoQuery, IcoQuery.class); |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (StringUtils.isEmpty(partyId)) { |
| | | throw new YamiShopBindException("请重新登录"); |
| | | throw new YamiShopBindException("Please log in again"); |
| | | } |
| | | queryWrapper.eq("u.user_id", partyId); |
| | | queryWrapper.orderByDesc("created_at"); |
| | |
| | | user= userService.findByUserName(mobileOrUserName); |
| | | } |
| | | if (user==null){ |
| | | throw new YamiShopBindException("账号或密码不正确"); |
| | | throw new YamiShopBindException("Incorrect username or password"); |
| | | } |
| | | |
| | | // 半小时内密码输入错误十次,已限制登录30分钟 |
| | |
| | | bySymbol.transName(); |
| | | } |
| | | if (bySymbol == null) { |
| | | throw new YamiShopBindException(symbol + " 不存在"); |
| | | throw new YamiShopBindException(symbol + " does not exist"); |
| | | } |
| | | List<StocksDto> stocks = findRealTimeByBoard(symbol); |
| | | RelatedStocksDto relatedStocksDto = new RelatedStocksDto(symbol, stocks); |
| | |
| | | queryWrapper.eq("symbol", symbol); |
| | | long count = itemUserOptionalService.count(queryWrapper); |
| | | if(count > 0 ){ |
| | | throw new YamiShopBindException("当前已经加入过自选"); |
| | | throw new YamiShopBindException("Already added to favorites"); |
| | | |
| | | } |
| | | |
| | |
| | | entity.setSymbol(symbol); |
| | | itemUserOptionalService.save(entity); |
| | | }else { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("保存自选失败", e); |
| | | throw new YamiShopBindException("保存自选失败:"+ e.getMessage()); |
| | | throw new YamiShopBindException("Failed to save favorites: " + e.getMessage()); |
| | | }finally { |
| | | if (lock) { |
| | | ThreadUtils.sleep(50); |
| | |
| | | queryWrapper.eq("symbol", symbol); |
| | | itemUserOptionalService.remove(queryWrapper); |
| | | }else { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("删除失败", e); |
| | | throw new YamiShopBindException("删除失败"); |
| | | throw new YamiShopBindException("Delete failed"); |
| | | |
| | | } finally { |
| | | if (lock) { |
| | |
| | | public Result<String> save(@Valid ItemUserOptionalListDTO itemUserOptionalListDTO) { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (itemUserOptionalListService.findOne(partyId, itemUserOptionalListDTO.getName()) != null) { |
| | | return Result.failed("该自选组名称已经使用"); |
| | | return Result.failed("Watchlist name already in use"); |
| | | } |
| | | //新增或编辑表单保存 |
| | | ItemUserOptionalList entity = itemUserOptionalListWrapper.toEntity(itemUserOptionalListDTO); |
| | |
| | | public Result<String> saveItem(String listId, String symbol) { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (itemUserOptionalItemService.findOne(partyId, listId, symbol) != null) { |
| | | return Result.failed("已经添加过该分组了"); |
| | | return Result.failed("Group already added"); |
| | | } |
| | | ItemUserOptionalItem itemUserOptionalItem = new ItemUserOptionalItem(); |
| | | itemUserOptionalItem.setListId(listId); |
| | |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | ItemUserOptionalList one = itemUserOptionalListService.findOne(partyId, updateDTO.getName()); |
| | | if (one != null && !one.getUuid().equalsIgnoreCase(updateDTO.getUuid())) { |
| | | return Result.failed("该自选组名称已经使用"); |
| | | return Result.failed("Watchlist name already in use"); |
| | | } |
| | | //新增或编辑表单保存 |
| | | ItemUserOptionalList entity = BeanUtil.copyProperties(updateDTO, ItemUserOptionalList.class); |
| | |
| | | // } |
| | | // |
| | | // if (model.getIdNumber().length()>50){ |
| | | // throw new YamiShopBindException("证件号码长度超过50"); |
| | | // throw new YamiShopBindException("ID number exceeds 50 characters"); |
| | | // } |
| | | // if (model.getName().length()>50){ |
| | | // throw new YamiShopBindException("实名姓名长度超过50"); |
| | | // throw new YamiShopBindException("Real name exceeds 50 characters"); |
| | | // } |
| | | // BeanUtils.copyProperties(model, realNameAuthRecord); |
| | | // realNameAuthRecord.setUserId(user.getUserId()); |
| | |
| | | String content = request.getParameter("content"); |
| | | String type = request.getParameter("type"); |
| | | if (StringUtils.isNullOrEmpty(content.trim()) || StringUtils.isNullOrEmpty(type)) { |
| | | return Result.failed("发送消息为空"); |
| | | return Result.failed("Message cannot be empty"); |
| | | } |
| | | log.info("==========sendsendsendsend======="); |
| | | if(-1>=content.indexOf("%")) content = URLDecoder.decode(content, "utf-8"); |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | Page<News> page = new Page<>(1, 1000000); |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | List<News> list = new ArrayList<News>(); |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | List<News> list = new ArrayList<News>(); |
| | |
| | | } |
| | | |
| | | if(StringUtils.isEmptyString(orderNo)) { |
| | | throw new YamiShopBindException("订单号不能未空"); |
| | | throw new YamiShopBindException("Order number is required"); |
| | | } |
| | | |
| | | otcOnlineChatMessageService.saveSend(SecurityUtils.getCurrentUserId(), type, content, null, orderNo); |
| | |
| | | int unreadMsg = 0; |
| | | String orderNo = request.getParameter("orderNo"); |
| | | if(StringUtils.isEmptyString(orderNo)) { |
| | | throw new YamiShopBindException("订单号不能未空"); |
| | | throw new YamiShopBindException("Order number is required"); |
| | | } |
| | | unreadMsg = otcOnlineChatMessageService.unreadMsg(orderNo, SecurityUtils.getCurrentUserId()); |
| | | resultObject.setData(unreadMsg); |
| | |
| | | String id = request.getParameter("id"); |
| | | List<C2cOrder> order = c2cOrderService.getByPayId(id); |
| | | if (ObjectUtils.isNotEmpty(order)) { |
| | | throw new YamiShopBindException("当前支付方式有未处理完成的订单!"); |
| | | throw new YamiShopBindException("Pending orders exist for this payment method"); |
| | | } |
| | | this.c2cPaymentMethodService.removeById(id); |
| | | return Result.succeed(); |
| | |
| | | String language = request.getParameter("language"); |
| | | C2cPaymentMethod method = this.c2cPaymentMethodService.getById(id); |
| | | if (null == method) { |
| | | throw new BusinessException("支付方式不存在"); |
| | | throw new BusinessException("Payment method does not exist"); |
| | | } |
| | | if (StringUtils.isNotEmpty(method.getMethodImg())) { |
| | | method.setMethodImg(Constants.IMAGES_HTTP+method.getMethodImg()); |
| | |
| | | String qrcode = request.getParameter("qrcode"); |
| | | String remark = request.getParameter("remark"); |
| | | if (StringUtils.isNullOrEmpty(method_config_id)) { |
| | | throw new BusinessException("支付方式模板不正确"); |
| | | throw new BusinessException("Invalid payment method template"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(real_name)) { |
| | | throw new BusinessException("真实姓名必填"); |
| | | throw new BusinessException("Real name is required"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(param_value1)) { |
| | | throw new BusinessException("参数值1必填"); |
| | | throw new BusinessException("Parameter value 1 is required"); |
| | | } |
| | | C2cPaymentMethodConfig methodConfig = this.c2cPaymentMethodConfigService.getById(method_config_id); |
| | | if (null == methodConfig) { |
| | | throw new BusinessException("支付方式模板不存在"); |
| | | throw new BusinessException("Payment method template does not exist"); |
| | | } |
| | | // C2C用户和承兑商添加支付方式最大数量 |
| | | Map<String, C2cPaymentMethod> methodMap = this.c2cPaymentMethodService.getByPartyId(SecurityUtils.getCurrentUserId()); |
| | | Object obj = this.sysparaService.find("c2c_payment_method_count_max"); |
| | | if (null != obj) { |
| | | if (methodMap.size() >= Integer.valueOf(this.sysparaService.find("c2c_payment_method_count_max").getSvalue()).intValue()) { |
| | | throw new BusinessException("支付方式数量已达上限"); |
| | | throw new BusinessException("Payment method limit reached"); |
| | | } |
| | | } |
| | | C2cPaymentMethod method = new C2cPaymentMethod(); |
| | |
| | | String qrcode = request.getParameter("qrcode"); |
| | | String remark = request.getParameter("remark"); |
| | | if (StringUtils.isNullOrEmpty(real_name)) { |
| | | throw new BusinessException("真实姓名必填"); |
| | | throw new BusinessException("Real name is required"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(param_value1)) { |
| | | throw new BusinessException("参数值1必填"); |
| | | throw new BusinessException("Parameter value 1 is required"); |
| | | } |
| | | C2cPaymentMethod method = this.c2cPaymentMethodService.getById(id); |
| | | if (null == method) { |
| | | throw new BusinessException("支付方式不存在"); |
| | | throw new BusinessException("Payment method does not exist"); |
| | | } |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | if (!method.getPartyId().equals(partyId)) { |
| | | throw new BusinessException("支付方式不匹配该用户"); |
| | | throw new BusinessException("Payment method does not match this user"); |
| | | } |
| | | String log = MessageFormat.format("ip:" + IPHelper.getIpAddr() |
| | | + ",用户修改支付方式,id:{0},原用户PARTY_ID:{1},原支付方式模板:{2},原支付方式类型:{3},原支付方式名称:{4},原支付方式图片:{5},原真实姓名:{6}," |
| | |
| | | String id = request.getParameter("id"); |
| | | String language = request.getParameter("language"); |
| | | if (StringUtils.isEmptyString(id)) { |
| | | throw new YamiShopBindException("广告id不正确"); |
| | | throw new YamiShopBindException("Invalid advertisement ID"); |
| | | } |
| | | C2cAdvert c2cAdvert = c2cAdvertService.getById(id); |
| | | if (null == c2cAdvert) { |
| | | throw new YamiShopBindException("广告不存在"); |
| | | throw new YamiShopBindException("Advertisement does not exist"); |
| | | } |
| | | C2cUser c2cUser = this.c2cUserService.getById(c2cAdvert.getC2cUserId()); |
| | | if (null == c2cUser) { |
| | | throw new YamiShopBindException("承兑商不存在"); |
| | | throw new YamiShopBindException("Merchant does not exist"); |
| | | } |
| | | List<C2cPaymentMethod> list = new ArrayList<C2cPaymentMethod>(); |
| | | Map<String, C2cPaymentMethod> map = this.c2cPaymentMethodService.getByPartyId(c2cUser.getC2cUserPartyId()); |
| | |
| | | } |
| | | } |
| | | if (null == list || 0 == list.size()) { |
| | | throw new YamiShopBindException("承兑商支付方式未配置"); |
| | | throw new YamiShopBindException("Merchant payment method not configured"); |
| | | } |
| | | String[] payTypes = c2cAdvert.getPayType().split(","); |
| | | List<C2cPaymentMethod> resList = new ArrayList<C2cPaymentMethod>(); |
| | |
| | | } |
| | | } |
| | | if (null == resList || 0 == resList.size()) { |
| | | throw new YamiShopBindException("承兑商广告支付方式未配置"); |
| | | throw new YamiShopBindException("Merchant ad payment method not configured"); |
| | | } |
| | | for (int i = 0; i < resList.size(); i++) { |
| | | C2cPaymentMethod method = resList.get(i); |
| | |
| | | public Result<?> add(@Valid AddPaymentMethodModel model) { |
| | | String language = ServletUtil.getRequest().getParameter("language"); |
| | | if (StringUtils.isNullOrEmpty(model.getMethod_config_id())) { |
| | | throw new YamiShopBindException("支付方式模板不正确"); |
| | | throw new YamiShopBindException("Invalid payment method template"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(model.getReal_name())) { |
| | | throw new YamiShopBindException("真实姓名必填"); |
| | | throw new YamiShopBindException("Real name is required"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(model.getParam_value1())) { |
| | | throw new YamiShopBindException("参数值1必填"); |
| | | throw new YamiShopBindException("Parameter value 1 is required"); |
| | | } |
| | | if (model.getReal_name().length() > 20) { |
| | | if (language.equals("zh-CN")) { |
| | | throw new YamiShopBindException("真实姓名长度大于20"); |
| | | throw new YamiShopBindException("Real name exceeds 20 characters"); |
| | | } else { |
| | | throw new YamiShopBindException("Real name length greater than 20"); |
| | | } |
| | | } |
| | | if (model.getRemark().length() > 100) { |
| | | if (language.equals("zh-CN")) { |
| | | throw new YamiShopBindException("备注长度大于100"); |
| | | throw new YamiShopBindException("Remark exceeds 100 characters"); |
| | | } else { |
| | | throw new YamiShopBindException("Note length greater than 100"); |
| | | } |
| | | } |
| | | C2cPaymentMethodConfig methodConfig = c2cPaymentMethodConfigService.getById(model.getMethod_config_id()); |
| | | if (null == methodConfig) { |
| | | throw new YamiShopBindException("支付方式模板不存在"); |
| | | throw new YamiShopBindException("Payment method template does not exist"); |
| | | } |
| | | if (!StrUtil.isEmpty(model.getParam_value1())) { |
| | | if (model.getParam_value1().length() > 25) { |
| | | throw new YamiShopBindException(methodConfig.getParamName1() + "长度大于25"); |
| | | throw new YamiShopBindException(methodConfig.getParamName1() + " exceeds 25 characters"); |
| | | } |
| | | } |
| | | if (!StrUtil.isEmpty(model.getParam_value2())) { |
| | | if (model.getParam_value2().length() > 25) { |
| | | throw new YamiShopBindException(methodConfig.getParamName2() + "长度大于25"); |
| | | throw new YamiShopBindException(methodConfig.getParamName2() + " exceeds 25 characters"); |
| | | } |
| | | } |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (null == partyId) { |
| | | throw new YamiShopBindException("请重新登录"); |
| | | throw new YamiShopBindException("Please log in again"); |
| | | } |
| | | // C2C用户和承兑商添加支付方式最大数量 |
| | | Map<String, C2cPaymentMethod> methodMap = c2cPaymentMethodService.getByPartyId(partyId); |
| | | Object obj = this.sysparaService.find("c2c_payment_method_count_max"); |
| | | if (null != obj) { |
| | | if (methodMap.size() >= Integer.valueOf(this.sysparaService.find("c2c_payment_method_count_max").getSvalue()).intValue()) { |
| | | throw new YamiShopBindException("支付方式数量已达上限"); |
| | | throw new YamiShopBindException("Payment method limit reached"); |
| | | } |
| | | } |
| | | C2cPaymentMethod method = new C2cPaymentMethod(); |
| | |
| | | public Result<?> update(@Valid AddPaymentMethodModel model) { |
| | | String language = ServletUtil.getRequest().getParameter("language"); |
| | | if (StringUtils.isNullOrEmpty(model.getReal_name())) { |
| | | throw new YamiShopBindException("真实姓名必填"); |
| | | throw new YamiShopBindException("Real name is required"); |
| | | } |
| | | if (StringUtils.isNullOrEmpty(model.getParam_value1())) { |
| | | throw new YamiShopBindException("参数值1必填"); |
| | | throw new YamiShopBindException("Parameter value 1 is required"); |
| | | } |
| | | if (model.getReal_name().length() > 20) { |
| | | if (language.equals("zh-CN")) { |
| | | throw new YamiShopBindException("真实姓名长度大于20"); |
| | | throw new YamiShopBindException("Real name exceeds 20 characters"); |
| | | } else { |
| | | throw new YamiShopBindException("Real name length greater than 20"); |
| | | } |
| | | } |
| | | if (model.getRemark().length() > 100) { |
| | | if (language.equals("zh-CN")) { |
| | | throw new YamiShopBindException("备注长度大于100"); |
| | | throw new YamiShopBindException("Remark exceeds 100 characters"); |
| | | } else { |
| | | throw new YamiShopBindException("Note length greater than 100"); |
| | | } |
| | | } |
| | | C2cPaymentMethod method = this.c2cPaymentMethodService.getById(model.getId()); |
| | | if (null == method) { |
| | | throw new YamiShopBindException("支付方式不存在"); |
| | | throw new YamiShopBindException("Payment method does not exist"); |
| | | } |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | if (!method.getPartyId().equals(partyId)) { |
| | | throw new YamiShopBindException("支付方式不匹配该用户"); |
| | | throw new YamiShopBindException("Payment method does not match this user"); |
| | | } |
| | | String log = MessageFormat.format("ip:" + IPHelper.getIpAddr() |
| | | + ",用户修改支付方式,id:{0},原用户PARTY_ID:{1},原支付方式模板:{2},原支付方式类型:{3},原支付方式名称:{4},原支付方式图片:{5},原真实姓名:{6}," |
| | |
| | | if (realNameAuthRecord != null) { |
| | | switch (realNameAuthRecord.getStatus()) { |
| | | case 0: |
| | | msg = "已经提交申请,请等待审核"; |
| | | msg = "Application submitted, please wait for review"; |
| | | break; |
| | | case 1: |
| | | msg = "审核中"; |
| | | msg = "Under review"; |
| | | break; |
| | | case 2: |
| | | msg = "审核已通过"; |
| | | msg = "Already approved"; |
| | | break; |
| | | case 3: |
| | | realNameAuthRecord.setStatus(1); |
| | |
| | | } |
| | | |
| | | if (model.getIdNumber().length()>50){ |
| | | throw new YamiShopBindException("证件号码长度超过50"); |
| | | throw new YamiShopBindException("ID number exceeds 50 characters"); |
| | | } |
| | | if (model.getName().length()>50){ |
| | | throw new YamiShopBindException("实名姓名长度超过50"); |
| | | throw new YamiShopBindException("Real name exceeds 50 characters"); |
| | | } |
| | | BeanUtils.copyProperties(model, realNameAuthRecord); |
| | | realNameAuthRecord.setUserId(user.getUserId()); |
| | |
| | | boolean recharge_must_need_qr = this.sysparaService.find("recharge_must_need_qr").getBoolean(); |
| | | if (recharge_must_need_qr) { |
| | | if (StringUtils.isEmptyString(img)) { |
| | | throw new YamiShopBindException("请上传图片"); |
| | | throw new YamiShopBindException("Please upload an image"); |
| | | } |
| | | } |
| | | } |
| | |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if (null == object || !SecurityUtils.getUser().getUserId().equals((String) object)) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | // 充值申请中的订单是否只能唯一:1唯一,2不限制 |
| | | double recharge_only_one = Double.valueOf(sysparaService.find("recharge_only_one").getSvalue()); |
| | | // 用户未结束银行卡订单数量 |
| | | Long nofinishOrderCount = this.c2cOrderService.getNofinishOrderCount(SecurityUtils.getUser().getUserId().toString()); |
| | | if (null != nofinishOrderCount && 0 != nofinishOrderCount.longValue() && 1 == recharge_only_one) { |
| | | throw new YamiShopBindException("提交失败,当前有未处理银行卡订单"); |
| | | throw new YamiShopBindException("Submission failed, pending bank order exists"); |
| | | } |
| | | if(!coin.equals("usdt")){ |
| | | coin += "usdt"; |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | Page<Map> page = new Page<>(page_no_int, 10); |
| | |
| | | |
| | | private String verif(String amount, String coin, String blockchain_name, String channel_address) { |
| | | if (StringUtils.isNullOrEmpty(amount)) { |
| | | return "充值数量必填"; |
| | | return "Recharge amount is required"; |
| | | } |
| | | if (!StringUtils.isDouble(amount)) { |
| | | return "充值数量输入错误,请输入浮点数"; |
| | | return "Invalid recharge amount, please enter a number"; |
| | | } |
| | | if (Double.valueOf(amount).doubleValue() <= 0) { |
| | | return "充值数量不能小于等于0"; |
| | | return "Recharge amount must be greater than 0"; |
| | | } |
| | | if (StringUtils.isEmptyString(coin)) { |
| | | return "请输入充值币种"; |
| | | return "Please select recharge currency"; |
| | | } |
| | | if (StringUtils.isEmptyString(blockchain_name)) { |
| | | return "Parameter Error"; |
| | | } |
| | | if (StringUtils.isEmptyString(channel_address)) { |
| | | return "请输入地址"; |
| | | return "Address is required"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | public Result uploadFile(FileUploadParamsModel model) { |
| | | try { |
| | | if (model.getFile().getSize() / 1000L > 4500) { |
| | | throw new YamiShopBindException("图片大小不能超过4M"); |
| | | throw new YamiShopBindException("Image size cannot exceed 4MB"); |
| | | } |
| | | String path= awsS3OSSFileService.uploadFile(model.getModuleName(), model.getFile()); |
| | | FileInfoVo fileInfoVo=new FileInfoVo(); |
| | |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new YamiShopBindException("文件上传失败"); |
| | | throw new YamiShopBindException("File upload failed"); |
| | | } |
| | | } |
| | | } |
| | |
| | | @RequestMapping(value = basePath + "!execute.action") |
| | | public Result<String> execute(MultipartFile file) { |
| | | if (file.getSize() / 1024L > 30720L) { |
| | | return Result.failed("图片大小不能超过30M"); |
| | | return Result.failed("Image size cannot exceed 30MB"); |
| | | } |
| | | String path = awsS3OSSFileService.uploadFile("chat", file); |
| | | return Result.succeed(Constants.IMAGES_HTTP+path); |
| | |
| | | public Result login(String username, String password) { |
| | | |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名不能为空"); |
| | | throw new YamiShopBindException("Username cannot be empty"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("登录密码不能为空"); |
| | | throw new YamiShopBindException("The login password cannot be empty"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("登录密码必须6-12位"); |
| | | throw new YamiShopBindException("The login password must be 6 to 12 characters long."); |
| | | } |
| | | String ip = IPHelper.getIpAddr(); |
| | | if (!IpUtil.isCorrectIpRegular(ip)) { |
| | | log.error("校验IP不合法,参数{}", ip); |
| | | throw new YamiShopBindException("校验IP不合法"); |
| | | throw new YamiShopBindException("Invalid IP address"); |
| | | } |
| | | |
| | | // 黑名单限制 |
| | |
| | | String[] ips = blackUsers.split(","); |
| | | |
| | | if(Arrays.asList(ips).contains(ip.trim())){ |
| | | throw new YamiShopBindException("当前用户在黑名单中"); |
| | | throw new YamiShopBindException("The current user is on the blacklist."); |
| | | } |
| | | } |
| | | |
| | |
| | | private String validateParam(String username, String verifcode, String password, String type) { |
| | | |
| | | if (StringUtils.isEmptyString(username)) { |
| | | return "用户名不能为空"; |
| | | return "Username cannot be empty"; |
| | | } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // return "验证码不能为空"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // return "Verification code cannot be empty"; |
| | | // } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | return "登录密码不能为空"; |
| | | return "Login password cannot be empty"; |
| | | } |
| | | int min = 6; |
| | | int max = 12; |
| | | if (!RegexUtil.length(password, min, max)) { |
| | | return "登陆密码长度不符合设定"; |
| | | return "Login password length does not meet the requirements"; |
| | | } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // 只能输入数字 |
| | | // return "登陆密码不符合设定"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(this.usercode)) { |
| | | // return "推荐码不能为空"; |
| | | // } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // Only digits allowed |
| | | // return "Login password does not meet the requirements"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(this.usercode)) { |
| | | // return "Referral code cannot be empty"; |
| | | // } |
| | | if (StringUtils.isEmptyString(type) || !Arrays.asList("1", "2").contains(type)) { |
| | | return "类型不能为空"; |
| | | return "Type cannot be empty"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | throw new YamiShopBindException(error); |
| | | } |
| | | /*if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | }*/ |
| | | //默认123456 |
| | | safeword = "123456"; |
| | |
| | | public Object resetUserName(String username, String password, String safeword, String verifcode, String type) { |
| | | String userId = SecurityUtils.getUser().getUserId(); |
| | | if (StringUtils.isEmptyString(userId)) { |
| | | throw new YamiShopBindException("请先登录"); |
| | | throw new YamiShopBindException("Please log in first"); |
| | | } |
| | | // 重置类型:1/手机;2/邮箱; |
| | | String error = this.validateParam(username, verifcode, password, type); |
| | |
| | | throw new YamiShopBindException(error); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | userService.resetUserName(userId ,username, password, safeword, verifcode, type); |
| | | |
| | |
| | | throw new YamiShopBindException("The fund password cannot be blank"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("The fund password does not match the settings."); |
| | | } |
| | | userService.setSafeword(SecurityUtils.getUser().getUserId(), passwordEncoder.encode(model.getSafeword())); |
| | | return Result.succeed(null); |
| | |
| | | String verifcode_type = request.getParameter("verifcode_type"); |
| | | String verifcode = request.getParameter("verifcode"); |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名不能为空"); |
| | | throw new YamiShopBindException("Username is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("密码不能为空"); |
| | | throw new YamiShopBindException("Password is required"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("密码必须6-12位"); |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new YamiShopBindException("验证类型不能为空"); |
| | | throw new YamiShopBindException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("验证码不能为空"); |
| | | throw new YamiShopBindException("Verification code is required"); |
| | | } |
| | | User party = userService.findByUserName(username); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户名不存在"); |
| | | throw new YamiShopBindException("Username does not exist"); |
| | | } |
| | | // 根据验证类型获取验证key verifcode_type: 1/手机;2/邮箱;3/谷歌验证器; |
| | | String key = ""; |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new YamiShopBindException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setLoginPassword(passwordEncoder.encode(password)); |
| | |
| | | |
| | | Map<String, Object> data = new HashMap<>(); |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名参数为空"); |
| | | throw new YamiShopBindException("Username is required"); |
| | | } |
| | | User party = userService.findByUserName(username); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户名不存在"); |
| | | throw new YamiShopBindException("Username does not exist"); |
| | | } |
| | | // verifcode_type未明确指定,返回所有的方式 |
| | | if (StringUtils.isEmptyString(verifcode_type) || !Arrays.asList("1", "2", "3").contains(verifcode_type)) { |
| | |
| | | map.put("user_level_custom", (int) Math.floor(party.getUserLevel() / 10)); |
| | | String projectType = this.sysparaService.find("project_type").getSvalue(); |
| | | if (StringUtils.isEmptyString(projectType)) { |
| | | throw new BusinessException("系统参数错误"); |
| | | throw new BusinessException("System parameter error"); |
| | | } |
| | | if (projectType.equals("DAPP_EXCHANGE_BINANCE") |
| | | || projectType.equals("EXCHANGE_EASYCRYPTO") |
| | |
| | | String usercode) { |
| | | // if (StringUtils.isEmptyString(phone) || !Strings.isNumber(phone) || phone.length() > 15) { |
| | | if (StringUtils.isEmptyString(phone) || phone.length() > 20) { |
| | | throw new YamiShopBindException("请填写正确的电话号码"); |
| | | throw new YamiShopBindException("Please enter a valid phone number"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | | if (null != party.getUserMobile() && party.getUserMobile().equals(phone) && true == party.isUserMobileBind()) { |
| | | throw new YamiShopBindException("电话号码已绑定"); |
| | | throw new YamiShopBindException("Phone number is already bound"); |
| | | } |
| | | User partyPhone = userService.findPartyByVerifiedPhone(phone); |
| | | if (null != partyPhone && !partyPhone.getUserId().toString().equals(loginPartyId)) { |
| | | throw new YamiShopBindException("电话号码已绑定其他用户"); |
| | | throw new YamiShopBindException("Phone number is bound to another user"); |
| | | } |
| | | String authcode = identifyingCodeTimeWindowService.getAuthCode(phone); |
| | | String bind_phone_email_ver = this.sysparaService.find("bind_phone_email_ver").getSvalue(); |
| | |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if ("1".contentEquals(bind_phone_email_ver)) { |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("请填写正确的验证码"); |
| | | throw new YamiShopBindException("Please enter a valid verification code"); |
| | | } |
| | | if ((null == authcode) || (!authcode.equals(verifcode))) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | if ("1".contentEquals(bind_usercode)) { |
| | | if (StringUtils.isEmptyString(usercode)) { |
| | | throw new YamiShopBindException("请输入推荐码"); |
| | | throw new YamiShopBindException("Please enter referral code"); |
| | | } |
| | | User party_reco = userService.findUserByUserCode(usercode); |
| | | if (null == party_reco || party_reco.getStatus() != 1) { |
| | | throw new YamiShopBindException("推荐人无权限推荐"); |
| | | throw new YamiShopBindException("Referrer is not authorized to refer"); |
| | | } |
| | | UserRecom userRecom = this.userRecomService.findByPartyId(party.getUserId()); |
| | | if (null == userRecom) { |
| | |
| | | public Result<?> save_email(String email, String verifcode) { |
| | | |
| | | if (StringUtils.isEmptyString(email) || !Strings.isEmail(email)) { |
| | | throw new YamiShopBindException("请填写正确的邮箱地址"); |
| | | throw new YamiShopBindException("Please enter a valid email address"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | | if (null != party.getUserMail() && party.getUserMail().equals(email) && true == party.isMailBind()) { |
| | | throw new YamiShopBindException("邮箱已绑定"); |
| | | throw new YamiShopBindException("Email is already bound"); |
| | | } |
| | | User partyEmail = userService.findPartyByVerifiedEmail(email); |
| | | if (null != partyEmail && !partyEmail.getUserId().toString().equals(loginPartyId)) { |
| | | throw new YamiShopBindException("邮箱已绑定其他用户"); |
| | | throw new YamiShopBindException("Email is bound to another user"); |
| | | } |
| | | String authcode = this.identifyingCodeTimeWindowService.getAuthCode(email); |
| | | String bind_phone_email_ver = sysparaService.find("bind_phone_email_ver").getSvalue(); |
| | |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if ("1".contentEquals(bind_phone_email_ver)) { |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("请填写正确的验证码"); |
| | | throw new YamiShopBindException("Please enter a valid verification code"); |
| | | } |
| | | if ((null == authcode) || (!authcode.equals(verifcode))) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | } |
| | |
| | | String verifcode_type = request.getParameter("verifcode_type"); |
| | | String verifcode = request.getParameter("verifcode"); |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new BusinessException("密码不能为空"); |
| | | throw new BusinessException("Password is required"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new BusinessException("密码必须6-12位"); |
| | | throw new BusinessException("Password must be 6-12 characters"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new BusinessException("验证类型不能为空"); |
| | | throw new BusinessException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new BusinessException("验证码不能为空"); |
| | | throw new BusinessException("Verification code is required"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getCurrentUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new BusinessException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new BusinessException("验证码不正确"); |
| | | throw new BusinessException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setLoginPassword(passwordEncoder.encode(password)); |
| | |
| | | public Result updateOldAndNewPsw(String old_password, String password, String re_password) { |
| | | |
| | | if (StringUtils.isEmptyString(old_password)) { |
| | | throw new YamiShopBindException("旧密码不能为空"); |
| | | throw new YamiShopBindException("Old password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("新密码不能为空"); |
| | | throw new YamiShopBindException("New password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(re_password)) { |
| | | throw new YamiShopBindException("新密码确认不能为空"); |
| | | throw new YamiShopBindException("Password confirmation is required"); |
| | | } |
| | | if (old_password.length() < 6 || old_password.length() > 12 || password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("密码必须6-12位"); |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | User secUser = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (!passwordEncoder.matches(old_password, secUser.getLoginPassword())) { |
| | | throw new YamiShopBindException("旧密码不正确!"); |
| | | throw new YamiShopBindException("Incorrect old password"); |
| | | } |
| | | if (!password.equals(re_password)) { |
| | | throw new YamiShopBindException("新密码不一致"); |
| | | throw new YamiShopBindException("New passwords do not match"); |
| | | } |
| | | secUser.setLoginPassword(passwordEncoder.encode(re_password)); |
| | | userService.updateById(secUser); |
| | |
| | | public Result setSafeword(String safeword, String verifcode_type, String verifcode) { |
| | | |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new YamiShopBindException("验证类型不能为空"); |
| | | throw new YamiShopBindException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("验证码不能为空"); |
| | | throw new YamiShopBindException("Verification code is required"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new YamiShopBindException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setSafePassword(passwordEncoder.encode(safeword)); |
| | |
| | | public Result updateOldAndNewSafePsw(String old_safeword, String safeword, String safeword_confirm) { |
| | | |
| | | if (StringUtils.isEmptyString(old_safeword)) { |
| | | throw new YamiShopBindException("旧资金密码不能为空"); |
| | | throw new YamiShopBindException("Old fund password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("新资金密码不能为空"); |
| | | throw new YamiShopBindException("New fund password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword_confirm)) { |
| | | throw new YamiShopBindException("新资金密码确认不能为空"); |
| | | throw new YamiShopBindException("Fund password confirmation is required"); |
| | | } |
| | | if (old_safeword.length() < 6 || old_safeword.length() > 12 || safeword.length() < 6 || safeword.length() > 12) { |
| | | throw new YamiShopBindException("密码必须6-12位"); |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | User secUser = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (!passwordEncoder.matches(old_safeword, secUser.getSafePassword())) { |
| | | throw new YamiShopBindException("旧密码不正确!"); |
| | | throw new YamiShopBindException("Incorrect old password"); |
| | | } |
| | | if (!safeword.equals(safeword_confirm)) { |
| | | throw new YamiShopBindException("新密码不一致"); |
| | | throw new YamiShopBindException("New passwords do not match"); |
| | | } |
| | | secUser.setSafePassword(passwordEncoder.encode(safeword_confirm)); |
| | | userService.updateById(secUser); |
| | |
| | | String remark) { |
| | | |
| | | if (StringUtils.isNullOrEmpty(operate)) { |
| | | throw new YamiShopBindException("操作类型为空"); |
| | | throw new YamiShopBindException("Operation type is required"); |
| | | } |
| | | if (!StringUtils.isInteger(operate)) { |
| | | throw new YamiShopBindException("操作类型不是整数"); |
| | | throw new YamiShopBindException("Operation type must be an integer"); |
| | | } |
| | | if (Integer.valueOf(operate).intValue() < 0) { |
| | | throw new YamiShopBindException("操作类型不能小于0"); |
| | | throw new YamiShopBindException("Operation type cannot be negative"); |
| | | } |
| | | |
| | | if(!StrUtil.isEmpty(remark)){ |
| | | if (remark.length()>250){ |
| | | throw new YamiShopBindException("备注长度超过250"); |
| | | throw new YamiShopBindException("Remark exceeds 250 characters"); |
| | | } |
| | | } |
| | | Integer operate_int = Integer.valueOf(operate); |
| | |
| | | String code = request.getParameter("code"); |
| | | String key = request.getParameter("key"); |
| | | if (!LockFilter.add(username)) { |
| | | return Result.failed("重复提交"); |
| | | return Result.failed("Duplicate submission"); |
| | | } |
| | | String error = validateParamUsername(username, password); |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | return Result.failed(error); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | } |
| | | boolean register_image_code_button = sysparaService.find("register_image_code_button").getBoolean(); |
| | | if (register_image_code_button) { |
| | | if (StringUtils.isEmptyString(code) || StringUtils.isEmptyString(key)) { |
| | | throw new BusinessException("验证码不能为空"); |
| | | throw new BusinessException("Verification code is required"); |
| | | } else { |
| | | String codeText = redisTemplate.opsForValue().get(key).toString(); |
| | | String decryptCode = ImageVerificationEndecrypt.decryptDES(code, key + "key"); |
| | | if (!decryptCode.equalsIgnoreCase(codeText)) { |
| | | log.info("ip:{" + IPHelper.getIpAddr() + "},图片验证码不正确,paramcode:{" + decryptCode + "},truecode:{" |
| | | + codeText + "}"); |
| | | throw new BusinessException("验证码错误"); |
| | | throw new BusinessException("Incorrect verification code"); |
| | | } |
| | | } |
| | | } |
| | |
| | | private String validateParamUsername(String username, String password) { |
| | | |
| | | if (StringUtils.isNullOrEmpty(username)) { |
| | | return "用户名不能为空"; |
| | | return "Username is required"; |
| | | } |
| | | if (StringUtils.isNullOrEmpty(password)) { |
| | | return "登录密码不能为空"; |
| | | return "Login password is required"; |
| | | } |
| | | if (!RegexUtil.isUSername(username)) { |
| | | return "用户名必须由数字和英文字母组成"; |
| | | return "Username must contain letters and numbers"; |
| | | } |
| | | int min = 6; |
| | | int max = 12; |
| | | int max_name = 24; |
| | | if (!RegexUtil.length(username, min, max_name)) { |
| | | return "用户名不符合设定"; |
| | | return "Username does not meet requirements"; |
| | | } |
| | | if (!RegexUtil.length(password, min, max)) { |
| | | return "登陆密码长度不符合设定"; |
| | | return "Login password length does not meet requirements"; |
| | | } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // 只能输入数字 |
| | |
| | | public Result getPairs(@RequestParam String pairs, String symbolType) throws IOException { |
| | | HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
| | | if (StringUtils.isEmptyString(pairs) || !pairs.contains("/")) { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | List<String> symbolList = Arrays.asList(pairs.split("/")); |
| | | if (null == symbolList || 2 != symbolList.size()) { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | String symbol1 = symbolList.get(0).toLowerCase(); |
| | | String symbol2 = symbolList.get(1).toLowerCase(); |
| | |
| | | status_int = null; |
| | | } else { |
| | | if (!StringUtils.isInteger(status)) { |
| | | throw new YamiShopBindException("状态不是整数"); |
| | | throw new YamiShopBindException("Status must be an integer"); |
| | | } |
| | | if (Integer.valueOf(status).intValue() < 0) { |
| | | throw new YamiShopBindException("状态不能小于0"); |
| | | throw new YamiShopBindException("Status cannot be negative"); |
| | | } |
| | | status_int = Integer.valueOf(status); |
| | | } |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | List<Map<String, Object>> data = this.walletLogService.pagedQueryRecords(page_no_int, 10, SecurityUtils.getUser().getUserId(), category, start_time, end_time, wallet_type, status_int).getRecords(); |
| | |
| | | if ("true".equals(exchange_withdraw_need_safeword)) { |
| | | // 资金密码验证 |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() < 6 || safeword.length() > 12) { |
| | | throw new YamiShopBindException("资金密码必须6-12位"); |
| | | throw new YamiShopBindException("Fund password must be 6-12 characters"); |
| | | } |
| | | if (!userService.checkLoginSafeword(SecurityUtils.getUser().getUserId(), safeword)) { |
| | | throw new YamiShopBindException("资金密码错误"); |
| | | throw new YamiShopBindException("Incorrect fund password"); |
| | | } |
| | | } |
| | | this.sessionTokenService.del(session_token); |
| | |
| | | public Result get(@RequestParam String order_no) throws IOException { |
| | | Withdraw withdraw = this.withdrawService.findByOrderNo(order_no); |
| | | if (withdraw==null){ |
| | | throw new YamiShopBindException("订单不存在!"); |
| | | throw new YamiShopBindException("Order does not exist"); |
| | | } |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("order_no", withdraw.getOrderNo()); |
| | |
| | | page_no = "1"; |
| | | } |
| | | if (!StringUtils.isInteger(page_no)) { |
| | | throw new YamiShopBindException("页码不是整数"); |
| | | throw new YamiShopBindException("Page number must be an integer"); |
| | | } |
| | | if (Integer.valueOf(page_no).intValue() <= 0) { |
| | | throw new YamiShopBindException("页码不能小于等于0"); |
| | | throw new YamiShopBindException("Page number must be greater than 0"); |
| | | } |
| | | int page_no_int = Integer.valueOf(page_no).intValue(); |
| | | List<Map<String, Object>> data = this.walletLogService.pagedQueryWithdraw(page_no_int, 10, SecurityUtils.getUser().getUserId(), "1").getRecords(); |
| | |
| | | |
| | | private String verif(String amount) { |
| | | if (StringUtils.isNullOrEmpty(amount)) { |
| | | return "提币数量必填"; |
| | | return "Withdrawal amount is required"; |
| | | } |
| | | if (!StringUtils.isDouble(amount)) { |
| | | return "提币数量输入错误,请输入浮点数"; |
| | | return "Invalid withdrawal amount, please enter a number"; |
| | | } |
| | | if (Double.valueOf(amount).doubleValue() <= 0) { |
| | | return "提币数量不能小于等于0"; |
| | | return "Withdrawal amount must be greater than 0"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | return Result.succeed(this.build(data, line, symbol)); |
| | | } catch (Exception e) { |
| | | logger.error("getKline error", e); |
| | | throw new YamiShopBindException("k线图获取失败"); |
| | | throw new YamiShopBindException("Failed to load chart data"); |
| | | } |
| | | } |
| | | |
| | |
| | | String level_temp = request.getParameter("level"); |
| | | if (StringUtils.isNullOrEmpty(level_temp) |
| | | || !StringUtils.isInteger(level_temp) || Integer.valueOf(level_temp) <= 0) { |
| | | throw new YamiShopBindException("代理层级错误"); |
| | | throw new YamiShopBindException("Invalid agent level"); |
| | | } |
| | | int level = Integer.valueOf(level_temp); |
| | | String page_no = request.getParameter("page_no"); |
| | |
| | | return Result.ok(data); |
| | | } catch (Exception e) { |
| | | log.error("c", e); |
| | | throw new YamiShopBindException("生成实时数据失败"); |
| | | throw new YamiShopBindException("Failed to generate market data"); |
| | | } |
| | | } |
| | | |
| | |
| | | return Result.ok(stockTradeList); |
| | | } catch (Exception e) { |
| | | log.error("生成实时数据失败", e); |
| | | throw new YamiShopBindException("生成实时数据失败"); |
| | | throw new YamiShopBindException("Failed to generate market data"); |
| | | } |
| | | } |
| | | |
| | |
| | | //} |
| | | }catch (Exception e){ |
| | | log.error("获取充值地址错误:",e); |
| | | return Result.failed("失败"); |
| | | return Result.failed("Failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | Response response = okHttpClient.newCall(requestParm).execute(); |
| | | result = response.body().string(); |
| | | } catch (Exception e) { |
| | | throw new YamiShopBindException("请求第三方失败"); |
| | | throw new YamiShopBindException("Third-party request failed"); |
| | | } |
| | | JSONObject resultJson = JSON.parseObject(result); |
| | | Integer code = resultJson.getInteger("code"); |
| | |
| | | String volume_temp = request.getParameter("volume"); |
| | | if (StringUtils.isNullOrEmpty(volume_temp) |
| | | || !StringUtils.isDouble(volume_temp) || Double.valueOf(volume_temp) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid amount"); |
| | | } |
| | | double volume = Double.valueOf(volume_temp); |
| | | String symbol = request.getParameter("symbol"); |
| | | String symbol_to = request.getParameter("symbol_to"); |
| | | if (symbol.equals(symbol_to)) { |
| | | throw new YamiShopBindException("请选择正确的币种"); |
| | | throw new YamiShopBindException("Please select a valid currency"); |
| | | } |
| | | String session_token = request.getParameter("session_token"); |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | log.info("sessionToken{}", object); |
| | | System.out.println("sessionToken " + object); |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用!"); |
| | | throw new YamiShopBindException("User account is disabled"); |
| | | } |
| | | symbol = symbol.toLowerCase(); |
| | | symbol_to = symbol_to.toLowerCase(); |
| | |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | double symbol_to_price = realtime.getClose().doubleValue(); |
| | | // usdt除以的数量 |
| | |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | double symbol_price = realtime.getClose().doubleValue(); |
| | | // 对应usdt数量 |
| | |
| | | realtime = realtime_list.get(0); |
| | | symbol_price = realtime.getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | // 获取币种最新价格 |
| | | List<Realtime> realtime_list_to = this.dataService.realtime(symbol_to); |
| | |
| | | realtime_to = realtime_list_to.get(0); |
| | | symbol_to_price = realtime_to.getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | if (symbol_to_price == 0) { |
| | | symbol_to_price = 1; |
| | |
| | | if (realtimes != null && realtimes.size() > 0) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | return close; |
| | | } |
| | |
| | | // 兑换后的币种 |
| | | String symbol_to = request.getParameter("symbol_to"); |
| | | if (symbol.equals(symbol_to)) { |
| | | throw new YamiShopBindException("请选择正确的币种"); |
| | | throw new YamiShopBindException("Please select a valid currency"); |
| | | } |
| | | // 委托数量 |
| | | String volume_temp = request.getParameter("volume"); |
| | | if (StringUtils.isNullOrEmpty(volume_temp) |
| | | || !StringUtils.isDouble(volume_temp) || Double.valueOf(volume_temp) < 0) { |
| | | throw new YamiShopBindException("请输入正确的兑换数量"); |
| | | throw new YamiShopBindException("Please enter a valid exchange amount"); |
| | | } |
| | | Map<String, Object> parities = parities(symbol, symbol_to, volume_temp); |
| | | return Result.succeed(parities); |
| | |
| | | if (StringUtils.isNullOrEmpty(volume) |
| | | || !StringUtils.isDouble(volume) |
| | | || Double.valueOf(volume) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid amount"); |
| | | } |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用"); |
| | | throw new YamiShopBindException("User account is disabled"); |
| | | } |
| | | |
| | | String userName = party.getUserName(); |
| | |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(userName.trim())){ |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("Network unavailable"); |
| | | } |
| | | } |
| | | |
| | |
| | | RealNameAuthRecord party_kyc = realNameAuthRecordService.getByUserId(partyId); |
| | | if (party_kyc != null) { |
| | | if (!(party_kyc.getStatus() == 2) && "true".equals(sysparaService.find("exchange_by_kyc").getSvalue())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | } |
| | | List<Realtime> realtimes = this.dataService.realtime(symbol); |
| | |
| | | if (realtimes != null) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | ExchangeApplyOrder order = new ExchangeApplyOrder(); |
| | | order.setPartyId(partyId); |
| | |
| | | if (StringUtils.isNullOrEmpty(volume) |
| | | || !StringUtils.isDouble(volume) |
| | | || Double.valueOf(volume) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid amount"); |
| | | } |
| | | lock = true; |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用"); |
| | | throw new YamiShopBindException("User account is disabled"); |
| | | } |
| | | |
| | | Syspara syspara = sysparaService.find("stop_user_internet"); |
| | |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(party.getUserName())){ |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("Network unavailable"); |
| | | } |
| | | } |
| | | |
| | |
| | | if (realtimes != null) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | ExchangeApplyOrder order = new ExchangeApplyOrder(); |
| | | order.setPartyId(partyId); |
| | |
| | | /** |
| | | * direction "buy":多 "sell":空 |
| | | */ |
| | | @Pattern(regexp="^(buy|sell)$",message = "请输入正确的方向") |
| | | @Pattern(regexp="^(buy|sell)$",message = "Please enter a valid direction") |
| | | private String direction; |
| | | /** |
| | | * amount 委托数量(张) |
| | | */ |
| | | @NotNull(message = "委托数量(张)必填") |
| | | @DecimalMin(value = "0.00000001", message = "委托数量(张)不能小于0") |
| | | @NotNull(message = "Order quantity (lots) is required") |
| | | @DecimalMin(value = "0.00000001", message = "Order quantity cannot be less than 0") |
| | | private BigDecimal amount; |
| | | |
| | | |
| | | /** |
| | | * price 交易价格 |
| | | */ |
| | | @NotNull(message = "交易价格必填") |
| | | @DecimalMin(value = "0.00000001", message = "交易价格不能小于0") |
| | | @NotNull(message = "Price is required") |
| | | @DecimalMin(value = "0.00000001", message = "Price cannot be less than 0") |
| | | private BigDecimal price; |
| | | |
| | | |
| | |
| | | *price_type 订单报价类型:"limit":限价 "opponent":对手价(市价) |
| | | */ |
| | | @NotNull |
| | | @Pattern(regexp="^(limit|opponent)$",message = "请输入订单报价类型") |
| | | @Pattern(regexp="^(limit|opponent)$",message = "Please enter a valid order price type") |
| | | private String price_type; |
| | | } |
| | |
| | | /** |
| | | * direction "buy":多 "sell":空 |
| | | */ |
| | | @Pattern(regexp="^(buy|sell)$",message = "请输入正确的方向") |
| | | @Pattern(regexp="^(buy|sell)$",message = "Please enter a valid direction") |
| | | @ApiModelProperty("方向") |
| | | private String direction; |
| | | /** |
| | | * amount 委托数量(张) |
| | | */ |
| | | @NotNull(message = "金额") |
| | | @DecimalMin(value = "0.00000001", message = "金额小于0") |
| | | @NotNull(message = "Amount is required") |
| | | @DecimalMin(value = "0.00000001", message = "Amount cannot be less than 0") |
| | | @ApiModelProperty("金额") |
| | | private BigDecimal amount; |
| | | |
| | | @NotNull(message = "交割参数不能为空") |
| | | @NotNull(message = "Delivery parameter is required") |
| | | @ApiModelProperty("交割参数") |
| | | private String para_id; |
| | | |
| | |
| | | /** |
| | | * direction "buy":多 "sell":空 |
| | | */ |
| | | @Pattern(regexp="^(buy|sell)$",message = "请输入正确的方向") |
| | | @Pattern(regexp="^(buy|sell)$",message = "Please enter a valid direction") |
| | | private String direction; |
| | | /** |
| | | * amount 委托数量(张) |
| | | */ |
| | | @NotNull(message = "委托数量(张)必填") |
| | | @DecimalMin(value = "0.00000001", message = "委托数量(张)不能小于0") |
| | | @NotNull(message = "Order quantity (lots) is required") |
| | | @DecimalMin(value = "0.00000001", message = "Order quantity cannot be less than 0") |
| | | private BigDecimal amount; |
| | | /** |
| | | * lever_rate 杠杆倍数 |
| | |
| | | /** |
| | | * price 交易价格 |
| | | */ |
| | | @NotNull(message = "交易价格必填") |
| | | @DecimalMin(value = "0.00000001", message = "交易价格不能小于0") |
| | | @NotNull(message = "Price is required") |
| | | @DecimalMin(value = "0.00000001", message = "Price cannot be less than 0") |
| | | private BigDecimal price; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @NotNull |
| | | @JsonProperty("price_type") |
| | | @Pattern(regexp="^(limit|opponent)$",message = "请输入订单报价类型") |
| | | @Pattern(regexp="^(limit|opponent)$",message = "Please enter a valid order price type") |
| | | private String price_type; |
| | | |
| | | |
| | |
| | | userService.logout(SecurityUtils.getUser().getUserId()); |
| | | // 删除该用户在该系统当前的token |
| | | tokenStore.deleteCurrentToken(token); |
| | | throw new YamiShopBindException(403,"accessToken 已过期"); |
| | | throw new YamiShopBindException(403,"Access token has expired"); |
| | | } |
| | | } |
| | | } |
| | |
| | | public class SetSafewordModel { |
| | | |
| | | |
| | | @Length(min = 1,message = "资金密码最小6位") |
| | | @NotBlank(message = "资金密码不能为空") |
| | | @Length(min = 6, message = "Fund password must be at least 6 characters") |
| | | @NotBlank(message = "Fund password is required") |
| | | @ApiModelProperty("资金密码") |
| | | private String safeword; |
| | | } |
| | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @NotBlank(message = "passWord不能为空") |
| | | @NotBlank(message = "Password is required") |
| | | @ApiModelProperty(value = "一般用作密码", required = true) |
| | | protected String passWord; |
| | | |
| New file |
| | |
| | | package com.yami.trading.common.config; |
| | | |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.util.ApiMessageTranslator; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.http.server.ServerHttpRequest; |
| | | import org.springframework.http.server.ServerHttpResponse; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; |
| | | |
| | | /** |
| | | * Translates Chinese messages in API responses to English for the user client. |
| | | */ |
| | | @RestControllerAdvice |
| | | public class ApiResponseBodyAdvice implements ResponseBodyAdvice<Object> { |
| | | |
| | | @Override |
| | | public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, |
| | | Class<? extends HttpMessageConverter<?>> selectedConverterType, |
| | | ServerHttpRequest request, ServerHttpResponse response) { |
| | | if (!ApiMessageTranslator.isUserApiRequest(request.getURI().getPath())) { |
| | | return body; |
| | | } |
| | | if (body instanceof Result) { |
| | | Result<?> result = (Result<?>) body; |
| | | if (result.getMsg() != null && ApiMessageTranslator.containsChinese(result.getMsg())) { |
| | | result.setMsg(ApiMessageTranslator.toEnglish(result.getMsg())); |
| | | } |
| | | } |
| | | return body; |
| | | } |
| | | } |
| | |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.BusinessException; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.ApiMessageTranslator; |
| | | import com.yami.trading.common.util.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | |
| | | |
| | | @ExceptionHandler(MethodArgumentNotValidException.class) |
| | | public Result <String> exception(MethodArgumentNotValidException e) { |
| | | public Result <String> exception(MethodArgumentNotValidException e, HttpServletRequest req) { |
| | | BindingResult bindingResult = e.getBindingResult(); |
| | | List<ObjectError> allErrors = bindingResult.getAllErrors(); |
| | | List<ErrorMsg> errorMsgs = new ArrayList<>(); |
| | |
| | | errorMsg.setMessage(fieldError.getDefaultMessage()); |
| | | errorMsgs.add(errorMsg); |
| | | }); |
| | | return Result.failed(errorMsgs.toString()); } |
| | | return Result.failed(translateForUserClient(req, errorMsgs.toString())); } |
| | | |
| | | |
| | | @ExceptionHandler(value = ConstraintViolationException.class) |
| | |
| | | log.error("{}", ex); |
| | | String message = ex.getMessage(); |
| | | if(StringUtils.isNotEmpty(message)){ |
| | | return Result.failed(message); |
| | | return Result.failed(translateForUserClient(req, message)); |
| | | }else{ |
| | | return Result.failed(ex.toString()); |
| | | } |
| | |
| | | |
| | | |
| | | @ExceptionHandler(YamiShopBindException.class) |
| | | public Result unauthorizedExceptionHandler(YamiShopBindException e){ |
| | | public Result unauthorizedExceptionHandler(YamiShopBindException e, HttpServletRequest req){ |
| | | log.error("YamiException Message :{}",e.getMessage()); |
| | | return Result.of(null,e.getCode(),e.getMessage()); |
| | | return Result.of(null,e.getCode(),translateForUserClient(req, e.getMessage())); |
| | | } |
| | | @ExceptionHandler(BusinessException.class) |
| | | public Result businessExceptionHandler(BusinessException e){ |
| | | public Result businessExceptionHandler(BusinessException e, HttpServletRequest req){ |
| | | log.error("YamiException Message :{}",e.getMessage()); |
| | | return Result.failed(e.getMessage()); |
| | | return Result.failed(translateForUserClient(req, e.getMessage())); |
| | | } |
| | | |
| | | private static String translateForUserClient(HttpServletRequest req, String message) { |
| | | if (req == null || message == null) { |
| | | return message; |
| | | } |
| | | if (ApiMessageTranslator.isUserApiRequest(req.getRequestURI())) { |
| | | return ApiMessageTranslator.toEnglish(message); |
| | | } |
| | | return message; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.yami.trading.common.util; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * Translates API error/success messages to English for the user client (H5). |
| | | * <p>User API controllers ({@code com.yami.trading.api}) should throw English messages directly. |
| | | * This translator only applies to {@code /api/} and {@code *.action} requests, mainly for |
| | | * shared service-layer exceptions; admin endpoints are not translated. |
| | | */ |
| | | public final class ApiMessageTranslator { |
| | | |
| | | private static final Pattern CHINESE = Pattern.compile("[\u4e00-\u9fff]"); |
| | | |
| | | private static final Map<String, String> ZH_TO_EN = new HashMap<>(); |
| | | |
| | | static { |
| | | // Common |
| | | ZH_TO_EN.put("参数错误", "Invalid parameters"); |
| | | ZH_TO_EN.put("参数错误!", "Invalid parameters"); |
| | | ZH_TO_EN.put("系统错误,请稍后重试", "System error, please try again later"); |
| | | ZH_TO_EN.put("请稍后再试", "Please try again later"); |
| | | ZH_TO_EN.put("操作失败,请稍后再试", "Operation failed, please try again later"); |
| | | ZH_TO_EN.put("无权限", "Permission denied"); |
| | | ZH_TO_EN.put("无网络", "Network unavailable"); |
| | | ZH_TO_EN.put("请先登录", "Please log in first"); |
| | | ZH_TO_EN.put("请登录!", "Please log in"); |
| | | ZH_TO_EN.put("请重新登录", "Please log in again"); |
| | | ZH_TO_EN.put("用户已禁用", "User account is disabled"); |
| | | ZH_TO_EN.put("用户已禁用!", "User account is disabled"); |
| | | |
| | | // Auth / user |
| | | ZH_TO_EN.put("校验IP不合法", "Invalid IP address"); |
| | | ZH_TO_EN.put("账号或密码不正确", "Incorrect username or password"); |
| | | ZH_TO_EN.put("用户名不能为空", "Username is required"); |
| | | ZH_TO_EN.put("用户名不存在", "Username does not exist"); |
| | | ZH_TO_EN.put("用户名参数为空", "Username is required"); |
| | | ZH_TO_EN.put("用户名重复", "Username already exists"); |
| | | ZH_TO_EN.put("用户名不合法!", "Invalid username"); |
| | | ZH_TO_EN.put("密码不能为空", "Password is required"); |
| | | ZH_TO_EN.put("密码必须6-12位", "Password must be 6-12 characters"); |
| | | ZH_TO_EN.put("密码不正确", "Incorrect password"); |
| | | ZH_TO_EN.put("密码不正确!", "Incorrect password"); |
| | | ZH_TO_EN.put("旧密码不能为空", "Old password is required"); |
| | | ZH_TO_EN.put("新密码不能为空", "New password is required"); |
| | | ZH_TO_EN.put("新密码确认不能为空", "Password confirmation is required"); |
| | | ZH_TO_EN.put("旧密码不正确!", "Incorrect old password"); |
| | | ZH_TO_EN.put("新密码不一致", "New passwords do not match"); |
| | | ZH_TO_EN.put("登录失败", "Login failed"); |
| | | ZH_TO_EN.put("注册失败!", "Registration failed"); |
| | | ZH_TO_EN.put("用户不存在", "User does not exist"); |
| | | ZH_TO_EN.put("用户不存在!", "User does not exist"); |
| | | ZH_TO_EN.put("账号不存在", "Account does not exist"); |
| | | ZH_TO_EN.put("当前登录账号不存在!", "Current account does not exist"); |
| | | ZH_TO_EN.put("账号已存在!", "Account already exists"); |
| | | |
| | | // Fund password / verification |
| | | ZH_TO_EN.put("资金密码不能为空", "Fund password is required"); |
| | | ZH_TO_EN.put("资金密码不符合设定", "Fund password does not meet requirements"); |
| | | ZH_TO_EN.put("资金密码必须6-12位", "Fund password must be 6-12 characters"); |
| | | ZH_TO_EN.put("资金密码错误", "Incorrect fund password"); |
| | | ZH_TO_EN.put("资金密码不正确!", "Incorrect fund password"); |
| | | ZH_TO_EN.put("旧资金密码不能为空", "Old fund password is required"); |
| | | ZH_TO_EN.put("新资金密码不能为空", "New fund password is required"); |
| | | ZH_TO_EN.put("新资金密码确认不能为空", "Fund password confirmation is required"); |
| | | ZH_TO_EN.put("验证类型不能为空", "Verification type is required"); |
| | | ZH_TO_EN.put("验证码不能为空", "Verification code is required"); |
| | | ZH_TO_EN.put("验证码不正确", "Incorrect verification code"); |
| | | ZH_TO_EN.put("请填写正确的验证码", "Please enter a valid verification code"); |
| | | ZH_TO_EN.put("谷歌验证码错误!", "Incorrect Google Authenticator code"); |
| | | ZH_TO_EN.put("用户谷歌验证码未绑定!", "Google Authenticator is not bound"); |
| | | |
| | | // Phone / email |
| | | ZH_TO_EN.put("请填写正确的电话号码", "Please enter a valid phone number"); |
| | | ZH_TO_EN.put("电话号码已绑定", "Phone number is already bound"); |
| | | ZH_TO_EN.put("电话号码已绑定其他用户", "Phone number is bound to another user"); |
| | | ZH_TO_EN.put("请输入正确的手机号码", "Please enter a valid phone number"); |
| | | ZH_TO_EN.put("手机号格式不正常!", "Invalid phone number format"); |
| | | ZH_TO_EN.put("手机号已存在!", "Phone number already exists"); |
| | | ZH_TO_EN.put("请填写正确的邮箱地址", "Please enter a valid email address"); |
| | | ZH_TO_EN.put("邮箱已绑定", "Email is already bound"); |
| | | ZH_TO_EN.put("邮箱已绑定其他用户", "Email is bound to another user"); |
| | | ZH_TO_EN.put("邮箱已存在!", "Email already exists"); |
| | | ZH_TO_EN.put("邮箱已重复", "Email already exists"); |
| | | ZH_TO_EN.put("请输入正确的邮箱地址", "Please enter a valid email address"); |
| | | |
| | | // Referral |
| | | ZH_TO_EN.put("请输入推荐码", "Please enter referral code"); |
| | | ZH_TO_EN.put("请输入正确的推荐码", "Please enter a valid referral code"); |
| | | ZH_TO_EN.put("推荐码不正确", "Incorrect referral code"); |
| | | ZH_TO_EN.put("推荐人无权限推荐", "Referrer is not authorized to refer"); |
| | | |
| | | // Trading |
| | | ZH_TO_EN.put("不在交易时段", "Outside trading hours"); |
| | | ZH_TO_EN.put("当前已经休市", "Market is closed"); |
| | | ZH_TO_EN.put("未开放合约交易", "Contract trading is not available"); |
| | | ZH_TO_EN.put("停牌禁止交易", "Trading suspended for this symbol"); |
| | | ZH_TO_EN.put("余额不足", "Insufficient balance"); |
| | | ZH_TO_EN.put("仓位不足", "Insufficient position"); |
| | | ZH_TO_EN.put("可平仓合约数量不足", "Insufficient closable contract quantity"); |
| | | ZH_TO_EN.put("杠杠倍数不存在", "Leverage multiplier does not exist"); |
| | | ZH_TO_EN.put("当前币对不存在", "Trading pair does not exist"); |
| | | ZH_TO_EN.put("您已存在订单", "You already have an open order"); |
| | | ZH_TO_EN.put("订单不存在", "Order does not exist"); |
| | | ZH_TO_EN.put("订单不存在!", "Order does not exist"); |
| | | ZH_TO_EN.put("委托单不存在", "Order does not exist"); |
| | | ZH_TO_EN.put("平仓失败", "Failed to close position"); |
| | | ZH_TO_EN.put("一键平仓失败", "Failed to close all positions"); |
| | | ZH_TO_EN.put("追加保证金异常", "Failed to add margin"); |
| | | ZH_TO_EN.put("执行撤单异常", "Failed to cancel order"); |
| | | |
| | | // Futures / delivery |
| | | ZH_TO_EN.put("k线图获取失败", "Failed to load chart data"); |
| | | ZH_TO_EN.put("生成实时数据失败", "Failed to generate market data"); |
| | | |
| | | // Exchange / wallet |
| | | ZH_TO_EN.put("请输入正确的货币数量", "Please enter a valid amount"); |
| | | ZH_TO_EN.put("请输入正确的兑换数量", "Please enter a valid exchange amount"); |
| | | ZH_TO_EN.put("请选择正确的币种", "Please select a valid currency"); |
| | | ZH_TO_EN.put("操作钱包失败!", "Wallet operation failed"); |
| | | ZH_TO_EN.put("操作钱包失败!", "Wallet operation failed"); |
| | | |
| | | // Withdraw / recharge |
| | | ZH_TO_EN.put("未基础认证", "Basic verification required"); |
| | | ZH_TO_EN.put("未安全认证,无提现权限", "Security verification required for withdrawal"); |
| | | ZH_TO_EN.put("请先通过高级认证", "Advanced verification required"); |
| | | ZH_TO_EN.put("无提现权限", "Withdrawal not permitted"); |
| | | ZH_TO_EN.put("提现不得大于限额", "Withdrawal amount exceeds limit"); |
| | | ZH_TO_EN.put("用户资金账户不存在!", "User fund account does not exist"); |
| | | ZH_TO_EN.put("订单已操作,请不要重复操作!", "Order already processed"); |
| | | ZH_TO_EN.put("请上传图片", "Please upload an image"); |
| | | ZH_TO_EN.put("提交失败,当前有未处理银行卡订单", "Submission failed, pending bank order exists"); |
| | | ZH_TO_EN.put("请求第三方失败", "Third-party request failed"); |
| | | |
| | | // C2C |
| | | ZH_TO_EN.put("支付币种不正确", "Invalid payment currency"); |
| | | ZH_TO_EN.put("提交失败,当前有未处理订单", "Submission failed, pending order exists"); |
| | | ZH_TO_EN.put("用户未结束订单数量已达上限", "Too many open orders"); |
| | | ZH_TO_EN.put("今日取消订单次数太多了,请明日再试", "Too many cancellations today, try again tomorrow"); |
| | | ZH_TO_EN.put("广告不存在", "Advertisement does not exist"); |
| | | ZH_TO_EN.put("支付方式不存在", "Payment method does not exist"); |
| | | ZH_TO_EN.put("订单类型不正确", "Invalid order type"); |
| | | ZH_TO_EN.put("支付金额不正确", "Invalid payment amount"); |
| | | ZH_TO_EN.put("币种数量不正确", "Invalid currency amount"); |
| | | ZH_TO_EN.put("承兑商不存在", "Merchant does not exist"); |
| | | ZH_TO_EN.put("承兑商的用户信息不存在", "Merchant user info does not exist"); |
| | | ZH_TO_EN.put("流水小于限额", "Transaction volume below minimum limit"); |
| | | ZH_TO_EN.put("用户不能取消提现", "Withdrawal cannot be cancelled"); |
| | | ZH_TO_EN.put("充值或提现不正确", "Invalid deposit or withdrawal type"); |
| | | ZH_TO_EN.put("订单状态不正确", "Invalid order status"); |
| | | |
| | | // Appeal / chat |
| | | ZH_TO_EN.put("申诉订单号不正确", "Invalid appeal order number"); |
| | | ZH_TO_EN.put("请输入申诉原因", "Please enter appeal reason"); |
| | | ZH_TO_EN.put("请上传申诉凭证", "Please upload appeal evidence"); |
| | | ZH_TO_EN.put("该订单已提交申诉", "Appeal already submitted for this order"); |
| | | ZH_TO_EN.put("申诉不存在", "Appeal does not exist"); |
| | | ZH_TO_EN.put("订单号不能未空", "Order number is required"); |
| | | ZH_TO_EN.put("发送消息为空", "Message cannot be empty"); |
| | | |
| | | // KYC |
| | | ZH_TO_EN.put("实名认证未通过,无法进行高级认证", "Real-name verification required before advanced verification"); |
| | | ZH_TO_EN.put("证件号码长度超过50", "ID number exceeds 50 characters"); |
| | | ZH_TO_EN.put("实名姓名长度超过50", "Real name exceeds 50 characters"); |
| | | ZH_TO_EN.put("工作地址长度超过245", "Work address exceeds 245 characters"); |
| | | ZH_TO_EN.put("家庭地址长度超过245", "Home address exceeds 245 characters"); |
| | | |
| | | // Upload / pagination |
| | | ZH_TO_EN.put("图片大小不能超过4M", "Image size cannot exceed 4MB"); |
| | | ZH_TO_EN.put("图片大小不能超过30M", "Image size cannot exceed 30MB"); |
| | | ZH_TO_EN.put("文件上传失败", "File upload failed"); |
| | | ZH_TO_EN.put("页码不是整数", "Page number must be an integer"); |
| | | ZH_TO_EN.put("页码不能小于等于0", "Page number must be greater than 0"); |
| | | ZH_TO_EN.put("状态不是整数", "Status must be an integer"); |
| | | ZH_TO_EN.put("状态不能小于0", "Status cannot be negative"); |
| | | |
| | | // Misc API responses |
| | | ZH_TO_EN.put("重复提交", "Duplicate submission"); |
| | | ZH_TO_EN.put("失败", "Failed"); |
| | | ZH_TO_EN.put("删除自选币种成功", "Removed from favorites"); |
| | | ZH_TO_EN.put("该自选组名称已经使用", "Watchlist name already in use"); |
| | | ZH_TO_EN.put("已经添加过该分组了", "Group already added"); |
| | | ZH_TO_EN.put("当前支付方式有未处理完成的订单!", "Pending orders exist for this payment method"); |
| | | ZH_TO_EN.put("广告id不正确", "Invalid advertisement ID"); |
| | | ZH_TO_EN.put("承兑商支付方式未配置", "Merchant payment method not configured"); |
| | | ZH_TO_EN.put("承兑商广告支付方式未配置", "Merchant ad payment method not configured"); |
| | | |
| | | // Operation type / remark |
| | | ZH_TO_EN.put("操作类型为空", "Operation type is required"); |
| | | ZH_TO_EN.put("操作类型不是整数", "Operation type must be an integer"); |
| | | ZH_TO_EN.put("操作类型不能小于0", "Operation type cannot be negative"); |
| | | ZH_TO_EN.put("备注长度超过250", "Remark exceeds 250 characters"); |
| | | ZH_TO_EN.put("请填入有效数字", "Please enter a valid number"); |
| | | ZH_TO_EN.put("修改后金额不能小于0", "Amount cannot be negative after adjustment"); |
| | | ZH_TO_EN.put("请选择转移类型", "Please select transfer type"); |
| | | |
| | | // Bean validation (API DTOs) |
| | | ZH_TO_EN.put("请输入正确的方向", "Please enter a valid direction"); |
| | | ZH_TO_EN.put("委托数量(张)必填", "Order quantity (lots) is required"); |
| | | ZH_TO_EN.put("委托数量(张)不能小于0", "Order quantity cannot be less than 0"); |
| | | ZH_TO_EN.put("交易价格必填", "Price is required"); |
| | | ZH_TO_EN.put("交易价格不能小于0", "Price cannot be less than 0"); |
| | | ZH_TO_EN.put("请输入订单报价类型", "Please enter a valid order price type"); |
| | | ZH_TO_EN.put("金额", "Amount is required"); |
| | | ZH_TO_EN.put("金额小于0", "Amount cannot be less than 0"); |
| | | ZH_TO_EN.put("交割参数不能为空", "Delivery parameter is required"); |
| | | ZH_TO_EN.put("资金密码最小6位", "Fund password must be at least 6 characters"); |
| | | } |
| | | |
| | | private ApiMessageTranslator() { |
| | | } |
| | | |
| | | public static boolean isUserApiRequest(String requestUri) { |
| | | if (requestUri == null) { |
| | | return false; |
| | | } |
| | | return requestUri.contains("/api/") || requestUri.endsWith(".action"); |
| | | } |
| | | |
| | | public static boolean containsChinese(String text) { |
| | | return text != null && CHINESE.matcher(text).find(); |
| | | } |
| | | |
| | | public static String toEnglish(String message) { |
| | | if (message == null || message.isEmpty()) { |
| | | return message; |
| | | } |
| | | String trimmed = message.trim(); |
| | | String mapped = ZH_TO_EN.get(trimmed); |
| | | if (mapped != null) { |
| | | return mapped; |
| | | } |
| | | if (trimmed.startsWith("最低下单金额:")) { |
| | | return "Minimum order amount: " + trimmed.substring("最低下单金额:".length()); |
| | | } |
| | | if (trimmed.startsWith("最低下单金额:")) { |
| | | return "Minimum order amount: " + trimmed.substring("最低下单金额:".length()); |
| | | } |
| | | if (containsChinese(trimmed)) { |
| | | return "Operation failed, please try again later"; |
| | | } |
| | | return message; |
| | | } |
| | | } |