缴费

main
luochuan 11 months ago
parent f1ca9ce975
commit 04fe9043cd

BIN
.DS_Store vendored

Binary file not shown.

BIN
src/.DS_Store vendored

Binary file not shown.

BIN
src/main/.DS_Store vendored

Binary file not shown.

@ -10,6 +10,8 @@ import cn.hutool.http.Method;
import cn.hutool.json.JSON; import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.alis.blackchain.annotation.ExchangeCommand; import org.alis.blackchain.annotation.ExchangeCommand;
import org.alis.blackchain.config.MexcConfiguration; import org.alis.blackchain.config.MexcConfiguration;
@ -17,6 +19,8 @@ import org.alis.blackchain.config.ProxyConfiguration;
import org.alis.blackchain.constanst.ExchangeEnum; import org.alis.blackchain.constanst.ExchangeEnum;
import org.alis.blackchain.domain.order.SymbolDTO; import org.alis.blackchain.domain.order.SymbolDTO;
import org.alis.blackchain.util.OrderUtils; import org.alis.blackchain.util.OrderUtils;
import org.apache.commons.collections4.MapUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -26,11 +30,10 @@ import javax.crypto.spec.SecretKeySpec;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.Proxy; import java.net.Proxy;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Collections; import java.util.*;
import java.util.HashMap; import java.util.concurrent.TimeUnit;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -54,6 +57,10 @@ public class MexcExchangeAdapter implements Exchange, InitializingBean {
private static final String SECURITY_ALGORITHM = "HmacSHA256"; private static final String SECURITY_ALGORITHM = "HmacSHA256";
private final Cache<String, Pair<String, String>> caffeine = Caffeine.newBuilder()
.expireAfterAccess(Duration.ofHours(1L))
.maximumSize(1024L)
.build();
@Override @Override
public List<Pair<String, BigDecimal>> getBalance() { public List<Pair<String, BigDecimal>> getBalance() {
@ -103,7 +110,28 @@ public class MexcExchangeAdapter implements Exchange, InitializingBean {
@Override @Override
public List<SymbolDTO> getAllSymbol() { public List<SymbolDTO> getAllSymbol() {
List<SymbolDTO> list = new ArrayList<>();
if(MapUtils.isEmpty(caffeine.asMap())){
refreshCache();
}
caffeine.asMap().forEach((k, v) -> {
SymbolDTO symbolDTO = new SymbolDTO();
symbolDTO.setInst(k);
symbolDTO.setBaseCcy(v.getKey());
symbolDTO.setBaseCcy(v.getValue());
list.add(symbolDTO);
});
return list;
}
public List<SymbolDTO> symbolList() {
String body = buildBaseRequest(Method.GET, "/api/v3/defaultSymbols", Collections.emptyMap(), "").execute().body(); String body = buildBaseRequest(Method.GET, "/api/v3/defaultSymbols", Collections.emptyMap(), "").execute().body();
if (!StringUtils.hasLength(body)) {
return Collections.emptyList();
}
return JSONUtil.parseObj(body).getJSONArray("data") return JSONUtil.parseObj(body).getJSONArray("data")
.stream().map(ins -> { .stream().map(ins -> {
String symbol = ins.toString(); String symbol = ins.toString();
@ -131,6 +159,12 @@ public class MexcExchangeAdapter implements Exchange, InitializingBean {
// 中断系统 // 中断系统
throw new UnsupportedOperationException("中断启动"); throw new UnsupportedOperationException("中断启动");
} }
refreshCache();
}
private void refreshCache() {
symbolList().forEach(node -> caffeine.put(node.getInst(), Pair.of(node.getBaseCcy(), node.getQuoteCcy())));
} }

Binary file not shown.

Binary file not shown.

@ -1 +1 @@
import{a as y}from"./axios.2d559ee1.js";import{_ as B,d as C,r as v,a as h,b as w,c as t,e as n,f as m,w as i,o as a,g as A,h as D,t as r,i as c,p as N,j as P}from"./index.ebec4008.js";const S=C({name:"Axios",setup(){const e=v(null),o=v(!1);return{userInfo:e,loading:o,getUserInfo:()=>{o.value=!0,y.get("/users/XPoet").then(s=>{console.log("response: ",s.data),e.value=s.data,o.value=!1}).catch(s=>{o.value=!1,console.error(s)})}}}}),g=e=>(N("data-v-3dbd4432"),e=e(),P(),e),V={class:"axios-container page-container"},$=g(()=>n("div",{class:"page-title"},"Axios Test Page",-1)),F={class:"user-info-container"},U={class:"card-header"},X=g(()=>n("span",null,"XPoet",-1)),E={class:"info-list-box"},T={key:0,class:"text item"},j={key:1,class:"text item"},q={key:2,class:"text item"};function z(e,o,b,s,G,H){const I=h("el-button"),x=h("el-card"),k=w("loading");return a(),t("div",V,[$,n("div",F,[m(x,{class:"box-card"},{header:i(()=>[n("div",U,[X,m(I,{class:"button",type:"text",onClick:e.getUserInfo},{default:i(()=>[A("\u70B9\u51FB\u83B7\u53D6XPoet\u4FE1\u606F ")]),_:1},8,["onClick"])])]),default:i(()=>{var d,l,_,u,p,f;return[D((a(),t("div",E,[(d=e.userInfo)!=null&&d.name?(a(),t("div",T,"name: "+r((l=e.userInfo)==null?void 0:l.name),1)):c("",!0),(_=e.userInfo)!=null&&_.bio?(a(),t("div",j,"bio: "+r((u=e.userInfo)==null?void 0:u.bio),1)):c("",!0),(p=e.userInfo)!=null&&p.blog?(a(),t("div",q,"blog: "+r((f=e.userInfo)==null?void 0:f.blog),1)):c("",!0)])),[[k,e.loading]])]}),_:1})])])}var L=B(S,[["render",z],["__scopeId","data-v-3dbd4432"]]);export{L as default}; import{a as y}from"./axios.081d9eba.js";import{_ as B,d as C,r as v,a as h,b as w,c as t,e as n,f as m,w as i,o as a,g as A,h as D,t as r,i as c,p as N,j as P}from"./index.055e2693.js";const S=C({name:"Axios",setup(){const e=v(null),o=v(!1);return{userInfo:e,loading:o,getUserInfo:()=>{o.value=!0,y.get("/users/XPoet").then(s=>{console.log("response: ",s.data),e.value=s.data,o.value=!1}).catch(s=>{o.value=!1,console.error(s)})}}}}),g=e=>(N("data-v-3dbd4432"),e=e(),P(),e),V={class:"axios-container page-container"},$=g(()=>n("div",{class:"page-title"},"Axios Test Page",-1)),F={class:"user-info-container"},U={class:"card-header"},X=g(()=>n("span",null,"XPoet",-1)),E={class:"info-list-box"},T={key:0,class:"text item"},j={key:1,class:"text item"},q={key:2,class:"text item"};function z(e,o,b,s,G,H){const I=h("el-button"),x=h("el-card"),k=w("loading");return a(),t("div",V,[$,n("div",F,[m(x,{class:"box-card"},{header:i(()=>[n("div",U,[X,m(I,{class:"button",type:"text",onClick:e.getUserInfo},{default:i(()=>[A("\u70B9\u51FB\u83B7\u53D6XPoet\u4FE1\u606F ")]),_:1},8,["onClick"])])]),default:i(()=>{var d,l,_,u,p,f;return[D((a(),t("div",E,[(d=e.userInfo)!=null&&d.name?(a(),t("div",T,"name: "+r((l=e.userInfo)==null?void 0:l.name),1)):c("",!0),(_=e.userInfo)!=null&&_.bio?(a(),t("div",j,"bio: "+r((u=e.userInfo)==null?void 0:u.bio),1)):c("",!0),(p=e.userInfo)!=null&&p.blog?(a(),t("div",q,"blog: "+r((f=e.userInfo)==null?void 0:f.blog),1)):c("",!0)])),[[k,e.loading]])]}),_:1})])])}var L=B(S,[["render",z],["__scopeId","data-v-3dbd4432"]]);export{L as default};

@ -1 +1 @@
import{_ as e,c as r,o as c}from"./index.ebec4008.js";const o={};function t(a,n){return c(),r("div")}var s=e(o,[["render",t]]);export{s as default}; import{_ as e,c as r,o as c}from"./index.055e2693.js";const o={};function t(a,n){return c(),r("div")}var s=e(o,[["render",t]]);export{s as default};

@ -1,2 +0,0 @@
import{a as v}from"./axios.2d559ee1.js";import{r as d,k as U,l as $,a as n,c as g,f as e,w as a,E as y,o as _,F as B,m as T,g as m,t as w,e as b,n as S}from"./index.ebec4008.js";const j={class:"container"},q=b("span",null," \u4EA4\u6613\u6240:",-1),A=b("h1",null,null,-1),G=b("span",null,"\u5DF2\u6210\u529F\u7684\u8BA2\u5355\uFF1A",-1),P={__name:"transfer",setup(H){const h=d(0),D=d("USDT"),u=d("OKX"),E=U([{key:"OKX",value:"\u6B27\u6613"},{key:"MEXC",value:"\u62B9\u8336"}]),V=d([{key:"BTC-USDT",value:"BTC-USDT"}]),p=d(""),s=U({sale:!0,transfer:"BTC-USDT",amount:0}),k=()=>{v.get("/api/chain/balance",{params:{exchange:u.value}}).then(o=>{h.value=o.data.data}).catch(o=>{y.error("\u83B7\u53D6\u4F59\u989D\u5931\u8D25"),console.error(o)})},z=()=>{v.post("/api/chain/order",{symbol:s.transfer,exchange:u.value,...s.value}).then(o=>{y({message:`\u4E0B\u5355\u6210\u529F,\u8BA2\u5355id\uFF1A${o.data.data}`,type:"success"}),p.value+=o.data.data+`
`})},L=()=>{v.get("/api/chain/symbol",{params:{exchange:u.value}}).then(o=>{let t=[];o.data.data.forEach(r=>{t.push({key:r.inst,value:r.inst})}),V.value=t}).catch(o=>{y.error("\u4EA4\u6613\u5BF9\u5931\u8D25"),console.error(o)})},M=o=>{k()};return $(()=>{k(),L()}),(o,t)=>{const r=n("el-option"),x=n("el-select"),i=n("el-col"),f=n("el-row"),c=n("el-form-item"),C=n("el-radio"),N=n("el-radio-group"),X=n("el-slider"),F=n("el-button"),K=n("el-form"),O=n("el-input");return _(),g("div",j,[e(f,{gutter:20},{default:a(()=>[e(i,{span:10},{default:a(()=>[q,e(x,{modelValue:u.value,"onUpdate:modelValue":t[0]||(t[0]=l=>u.value=l),class:"m-2",placeholder:"\u9009\u62E9\u4EA4\u6613\u6240",size:"large",onChange:M},{default:a(()=>[(_(!0),g(B,null,T(E,l=>(_(),S(r,{key:l.key,label:l.value,value:l.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(i,{span:6},{default:a(()=>[m(" \u5F53\u524D\u8D26\u53F7\u4F59\u989D: "+w(h.value)+" ("+w(D.value)+")",1)]),_:1})]),_:1}),e(f,null,{default:a(()=>[A]),_:1}),e(K,{model:s,"label-position":"left","label-width":"100px"},{default:a(()=>[e(c,{label:"\u5E01\u79CD:"},{default:a(()=>[e(x,{modelValue:s.transfer,"onUpdate:modelValue":t[1]||(t[1]=l=>s.transfer=l),placeholder:"\u4EA4\u6613\u5BF9",clearable:""},{default:a(()=>[(_(!0),g(B,null,T(V.value,l=>(_(),S(r,{key:l.key,label:l.key,value:l.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(c,{label:"\u4E70\u5165\\\u5356\u51FA:"},{default:a(()=>[e(N,{modelValue:s.sale,"onUpdate:modelValue":t[2]||(t[2]=l=>s.sale=l),flex:""},{default:a(()=>[e(C,{label:!0,size:"large"},{default:a(()=>[m("\u4E70\u5165")]),_:1}),e(C,{label:!1,size:"large"},{default:a(()=>[m("\u5356\u51FA")]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(c,{label:"\u91D1\u989D:"},{default:a(()=>[e(i,{span:10},{default:a(()=>[e(X,{modelValue:s.amount,"onUpdate:modelValue":t[3]||(t[3]=l=>s.amount=l),min:0,step:.01,max:100,"show-input":""},null,8,["modelValue"])]),_:1})]),_:1}),e(c,null,{default:a(()=>[e(F,{type:"primary",onClick:z},{default:a(()=>[m("\u4E0B\u5355")]),_:1})]),_:1})]),_:1},8,["model"]),e(f,null,{default:a(()=>[G,e(O,{modelValue:p.value,"onUpdate:modelValue":t[4]||(t[4]=l=>p.value=l),rows:2,type:"textarea",autosize:"",disable:""},null,8,["modelValue"])]),_:1})])}}};export{P as default};

@ -0,0 +1,2 @@
import{a as v}from"./axios.081d9eba.js";import{r as d,k as B,l as $,a as n,c as g,f as e,w as a,E as b,o as _,F as T,m as w,g as m,t as S,e as y,n as D}from"./index.055e2693.js";const j={class:"container"},q=y("span",null," \u4EA4\u6613\u6240:",-1),A=y("h1",null,null,-1),G=y("span",null,"\u5DF2\u6210\u529F\u7684\u8BA2\u5355\uFF1A",-1),P={__name:"transfer",setup(H){const h=d(0),E=d("USDT"),u=d("OKX"),z=B([{key:"OKX",value:"\u6B27\u6613"},{key:"MEXC",value:"\u62B9\u8336"}]),V=d([{key:"BTC-USDT",value:"BTC-USDT"}]),p=d(""),s=B({sale:!0,transfer:"BTC-USDT",amount:0}),k=()=>{v.get("/api/chain/balance",{params:{exchange:u.value}}).then(o=>{h.value=o.data.data}).catch(o=>{b.error("\u83B7\u53D6\u4F59\u989D\u5931\u8D25"),console.error(o)})},L=()=>{v.post("/api/chain/order",{symbol:s.transfer,exchange:u.value,...s.value}).then(o=>{b({message:`\u4E0B\u5355\u6210\u529F,\u8BA2\u5355id\uFF1A${o.data.data}`,type:"success"}),p.value+=o.data.data+`
`})},x=()=>{v.get("/api/chain/symbol",{params:{exchange:u.value}}).then(o=>{let t=[];o.data.data.forEach(r=>{t.push({key:r.inst,value:r.inst})}),V.value=t}).catch(o=>{b.error("\u4EA4\u6613\u5BF9\u5931\u8D25"),console.error(o)})},M=o=>{k(),x()};return $(()=>{k(),x()}),(o,t)=>{const r=n("el-option"),C=n("el-select"),i=n("el-col"),f=n("el-row"),c=n("el-form-item"),U=n("el-radio"),N=n("el-radio-group"),X=n("el-slider"),F=n("el-button"),K=n("el-form"),O=n("el-input");return _(),g("div",j,[e(f,{gutter:20},{default:a(()=>[e(i,{span:10},{default:a(()=>[q,e(C,{modelValue:u.value,"onUpdate:modelValue":t[0]||(t[0]=l=>u.value=l),class:"m-2",placeholder:"\u9009\u62E9\u4EA4\u6613\u6240",size:"large",onChange:M},{default:a(()=>[(_(!0),g(T,null,w(z,l=>(_(),D(r,{key:l.key,label:l.value,value:l.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(i,{span:6},{default:a(()=>[m(" \u5F53\u524D\u8D26\u53F7\u4F59\u989D: "+S(h.value)+" ("+S(E.value)+")",1)]),_:1})]),_:1}),e(f,null,{default:a(()=>[A]),_:1}),e(K,{model:s,"label-position":"left","label-width":"100px"},{default:a(()=>[e(c,{label:"\u5E01\u79CD:"},{default:a(()=>[e(C,{modelValue:s.transfer,"onUpdate:modelValue":t[1]||(t[1]=l=>s.transfer=l),placeholder:"\u4EA4\u6613\u5BF9",filterable:"",clearable:""},{default:a(()=>[(_(!0),g(T,null,w(V.value,l=>(_(),D(r,{key:l.key,label:l.key,value:l.key},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),e(c,{label:"\u4E70\u5165\\\u5356\u51FA:"},{default:a(()=>[e(N,{modelValue:s.sale,"onUpdate:modelValue":t[2]||(t[2]=l=>s.sale=l),flex:""},{default:a(()=>[e(U,{label:!0,size:"large"},{default:a(()=>[m("\u4E70\u5165")]),_:1}),e(U,{label:!1,size:"large"},{default:a(()=>[m("\u5356\u51FA")]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(c,{label:"\u91D1\u989D:"},{default:a(()=>[e(i,{span:10},{default:a(()=>[e(X,{modelValue:s.amount,"onUpdate:modelValue":t[3]||(t[3]=l=>s.amount=l),min:0,step:.01,max:100,"show-input":""},null,8,["modelValue"])]),_:1})]),_:1}),e(c,null,{default:a(()=>[e(F,{type:"primary",onClick:L},{default:a(()=>[m("\u4E0B\u5355")]),_:1})]),_:1})]),_:1},8,["model"]),e(f,null,{default:a(()=>[G,e(O,{modelValue:p.value,"onUpdate:modelValue":t[4]||(t[4]=l=>p.value=l),rows:2,type:"textarea",autosize:"",disable:""},null,8,["modelValue"])]),_:1})])}}};export{P as default};

@ -5,7 +5,7 @@
<link rel="icon" href="./favicon.ico" /> <link rel="icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title> <title>Vite App</title>
<script type="module" crossorigin src="./assets/index.ebec4008.js"></script> <script type="module" crossorigin src="./assets/index.055e2693.js"></script>
<link rel="stylesheet" href="./assets/index.f1676611.css"> <link rel="stylesheet" href="./assets/index.f1676611.css">
</head> </head>
<body> <body>

Loading…
Cancel
Save