Browse Source

优化一下

flyzto 3 months ago
parent
commit
a7b0ba501b

+ 9 - 6
server/models/GamesPs.js

@@ -516,7 +516,7 @@ const fetchGamesRelation = async (mk='') => {
   });
 }
 
-const getGamesRelation = ({ mk, ids, listEvents } = {}) => {
+const getGamesRelation = ({ mk=-1, ids, listEvents } = {}) => {
   let idsSet = null;
   if (ids?.length) {
     idsSet = new Set(ids);
@@ -525,10 +525,7 @@ const getGamesRelation = ({ mk, ids, listEvents } = {}) => {
     if (idsSet && !idsSet.has(item.id)) {
       return false;
     }
-    if (typeof(mk) === 'undefined' || mk === '') {
-      return true;
-    }
-    return item.mk == mk;
+    return mk == -1 || item.mk == mk;
   }).sort((a, b) => a.timestamp - b.timestamp);
 
   if (listEvents) {
@@ -782,8 +779,9 @@ const updateSolutions = (solutions, eventsLogsMap) => {
 /**
  * 获取中单方案
  */
-const getSolutions = async ({ win_min, no_events }) => {
+const getSolutions = async ({ win_min, no_events, mk=-1 }) => {
   // Logs.out('getSolutions', win_min);
+  const marketType = +mk;
   const { minShowAmount } = getSetting();
   const solutionsList = Object.values(GAMES.Solutions);
   const gamesRelation = getGamesRelation();
@@ -800,7 +798,12 @@ const getSolutions = async ({ win_min, no_events }) => {
       ...item,
       info: { id, mk, ...rel }
     }
+  })
+  .filter(item => {
+    const { info: { mk } } = item;
+    return marketType == -1 || marketType == mk;
   });
+
   const relIds = solutions.map(item => item.info.id);
   let gamesEvents = null;
   if (!no_events) {

+ 11 - 5
server/routes/pstery.js

@@ -61,16 +61,22 @@ router.get('/get_filtered_leagues', (req, res) => {
 // 获取关联列表
 router.get('/get_games_relation', (req, res) => {
   const { mk, id, le } = req.query;
-  const ids = id?.split(',').map(item => +item.trim()).filter(item => !!item) ?? [];
-  const listEvents = le === 'true';
-  const gamesRelation = Games.getGamesRelation({ mk, ids, listEvents });
+  const gamesRelation = Games.getGamesRelation({
+    ids: id?.split(',').map(item => +item.trim()).filter(item => !!item) ?? [],
+    listEvents: le === 'true',
+    mk: mk ? +mk : -1
+  });
   res.sendSuccess(gamesRelation);
 });
 
 // 获取中单方案
 router.get('/get_solutions', (req, res) => {
-  const { win_min, no_events } = req.query;
-  Games.getSolutions({ win_min: win_min ? +win_min : undefined, no_events: no_events === 'true' })
+  const { win_min, no_events, mk } = req.query;
+  Games.getSolutions({
+    win_min: win_min ? +win_min : undefined,
+    no_events: no_events === 'true',
+    mk: mk ? +mk : -1
+  })
   .then(({ solutions, gamesEvents }) => {
     res.sendSuccess({ solutions, gamesEvents });
   })

+ 10 - 6
web/apps/web-antd/src/views/match/datatest/index.vue

@@ -11,7 +11,7 @@ import 'vue-json-pretty/lib/styles.css';
 const currentTime = ref('');
 const gamesRelation = ref([]);
 const gamesSolution = ref({});
-const selectedTestMode = ref('');
+const selectedTestMode = ref(-1);
 const idsText = ref('');
 const idsList = ref([]);
 const buttonDisabled = ref(false);
@@ -35,9 +35,12 @@ const idsInput = (value) => {
 const refreshData = () => {
   buttonDisabled.value = true;
   updateTime();
+  const win_min = -99999;
+  const no_events = true;
+  const mk = selectedTestMode.value;
   Promise.all([
-    requestClient.get('/pstery/get_games_relation', { params: { mk: selectedTestMode.value } }),
-    requestClient.get('/pstery/get_solutions', { params: { win_min: -99999, no_events: true } })
+    requestClient.get('/pstery/get_games_relation', { params: { mk } }),
+    requestClient.get('/pstery/get_solutions', { params: { win_min, no_events, mk } })
   ])
   .then(([relations, solutions]) => {
     gamesRelation.value = relations;
@@ -149,9 +152,10 @@ onMounted(() => {
       </Form.Item>
       <Form.Item label="测试模式:">
         <RadioGroup v-model:value="selectedTestMode">
-          <Radio value="1">今日</Radio>
-          <Radio value="0">早盘</Radio>
-          <Radio value="">全部</Radio>
+          <Radio :value="-1">全部</Radio>
+          <Radio :value="2">滚球</Radio>
+          <Radio :value="1">今日</Radio>
+          <Radio :value="0">早盘</Radio>
         </RadioGroup>
       </Form.Item>
       <Form.Item label="目标赛事ID:">

+ 56 - 11
web/apps/web-antd/src/views/match/solutions/index.vue

@@ -1,7 +1,7 @@
 <script setup>
 import { requestClient } from '#/api/request';
-import { Button, message, Form, InputNumber, Drawer } from 'ant-design-vue';
-import { ref, reactive, computed, onMounted, onUnmounted } from 'vue';
+import { Button, message, Form, InputNumber, RadioGroup, Radio, Drawer } from 'ant-design-vue';
+import { ref, reactive, computed, watch, onMounted, onUnmounted } from 'vue';
 import dayjs from 'dayjs';
 
 import MatchCard from '../components/match_card.vue';
@@ -13,6 +13,10 @@ const solutions = ref([]);
 const selectedSolutions = reactive([]);
 const totalProfit = ref({});
 const loopActive = ref(false);
+const loopTimer = ref(null);
+const updateTimer = ref(null);
+const minProfitRate = ref(2);
+const marketType = ref(-1);
 
 const totalProfitVisible = ref(false);
 
@@ -97,7 +101,9 @@ const solutionsList = computed(() => {
 
 const getSolutions = async () => {
   try {
-    const data = await requestClient.get('/pstery/get_solutions');
+    const win_min = minProfitRate.value * 100;
+    const mk = marketType.value;
+    const data = await requestClient.get('/pstery/get_solutions', { params: { win_min, mk } });
     return data;
   }
   catch (error) {
@@ -317,6 +323,7 @@ const formatSolution = (solution, eventsList) => {
 }
 
 const updateSolutions = async () => {
+  clearTimeout(loopTimer.value);
   getSolutions()
   .then(({ solutions: solutionsList, gamesEvents: eventsList }) => {
     solutions.value = solutionsList?.map(solution => formatSolution(solution, eventsList)) ?? [];
@@ -327,7 +334,7 @@ const updateSolutions = async () => {
   })
   .finally(() => {
     if (loopActive.value) {
-      setTimeout(() => {
+      loopTimer.value = setTimeout(() => {
         updateSolutions();
       }, 1000 * 10);
     }
@@ -363,8 +370,41 @@ const toggleSolution = (sid, timestamp) => {
   }
 }
 
+const setLocalStorage = (key, value) => {
+  localStorage.setItem(key, JSON.stringify(value));
+}
+
+const getLocalStorage = (key) => {
+  const value = localStorage.getItem(key);
+  return value ? JSON.parse(value) : null;
+}
+
+watch(minProfitRate, (newVal) => {
+  clearTimeout(updateTimer.value);
+  updateTimer.value = setTimeout(() => {
+    setLocalStorage('minProfitRate', newVal);
+    updateSolutions();
+  }, 1000);
+});
+
+watch(marketType, (newVal) => {
+  clearTimeout(updateTimer.value);
+  updateTimer.value = setTimeout(() => {
+    setLocalStorage('marketType', newVal);
+    updateSolutions();
+  }, 1000);
+});
+
 onMounted(() => {
   loopActive.value = true;
+  const min_win_rate = getLocalStorage('minProfitRate');
+  const mk = getLocalStorage('marketType');
+  if (min_win_rate !== null) {
+    minProfitRate.value = min_win_rate;
+  }
+  if (mk !== null) {
+    marketType.value = mk;
+  }
   updateSolutions();
 });
 
@@ -379,16 +419,21 @@ onUnmounted(() => {
   <div class="solution-container">
 
     <div class="contents-header transition-all duration-200" :style="headerStyle">
-      <!-- <div class="solution-options">
+      <div class="solution-options">
         <Form layout="inline">
-          <Form.Item label="PS 投注">
-            <InputNumber size="small" placeholder="PS投注" min="1000" v-model:value="psOptions.bet" />
+          <Form.Item label="最小利润率(%)">
+            <InputNumber style="width: 60px" size="small" max="100" min="-100" placeholder="最小利润率(%)" v-model:value="minProfitRate"/>
           </Form.Item>
-          <Form.Item label="PS 返点">
-            <InputNumber size="small" placeholder="PS返点" min="0" v-model:value="psOptions.rebate" />
+          <Form.Item label="盘口类型">
+            <RadioGroup v-model:value="marketType">
+              <Radio :value="-1">全部</Radio>
+              <Radio :value="2">滚球</Radio>
+              <Radio :value="1">今日</Radio>
+              <Radio :value="0">早盘</Radio>
+            </RadioGroup>
           </Form.Item>
         </Form>
-      </div> -->
+      </div>
       <div class="solution-header">
         <span>PS</span>
         <span>OB</span>
@@ -522,7 +567,7 @@ onUnmounted(() => {
 }
 
 .solution-container {
-  padding-top: 31px;
+  padding-top: 74px;
 }
 
 .solution-item {

+ 2 - 2
web/packages/locales/src/langs/en-US/authentication.json

@@ -1,7 +1,7 @@
 {
   "welcomeBack": "Welcome Back",
-  "pageTitle": "Plug-and-play Admin system",
-  "pageDesc": "Efficient, versatile frontend template",
+  "pageTitle": "Q Boss",
+  "pageDesc": "Focus on multi-bet, only for stable red single",
   "loginSuccess": "Login Successful",
   "loginSuccessDesc": "Welcome Back",
   "loginSubtitle": "Enter your account details to manage your projects",

+ 1 - 1
web/packages/locales/src/langs/zh-CN/authentication.json

@@ -1,6 +1,6 @@
 {
   "welcomeBack": "兄弟,欢迎回来",
-  "pageTitle": "串子兄弟",
+  "pageTitle": "Q博士",
   "pageDesc": "专注串关,只为稳稳的红单",
   "loginSuccess": "登录成功",
   "loginSuccessDesc": "兄弟,欢迎回来",