From 4cdf9b0fdce6d2d7b4ca79055816661b88ac4d5c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 02 六月 2021 18:56:01 +0800
Subject: [PATCH] 订单支付修改

---
 service-lijin/src/test/java/com/ks/LuckyTest.java |   76 ++++++-------------------------------
 1 files changed, 13 insertions(+), 63 deletions(-)

diff --git a/service-lijin/src/test/java/com/ks/LuckyTest.java b/service-lijin/src/test/java/com/ks/LuckyTest.java
index deefdeb..60e03e1 100644
--- a/service-lijin/src/test/java/com/ks/LuckyTest.java
+++ b/service-lijin/src/test/java/com/ks/LuckyTest.java
@@ -1,79 +1,29 @@
 package com.ks;
 
+import com.ks.lijin.LiJinApplication;
 import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.test.context.ContextConfiguration;
 
+import javax.annotation.Resource;
 import java.util.*;
 
+@SpringBootTest(classes = LiJinApplication.class)
 public class LuckyTest {
 
 
+    @Resource
+    private RedisTemplate redisTemplate;
+
     @Test
     public void test() {
-        Map<Long, Integer> map = new HashMap<>();
-        int total = 0;
-        int personCount = 1000000;
-        for (int i = 0; i < personCount; i++) {
-            map.put(10000L + i, i == 0 ? 0 : (int) (1 + 10 * Math.random()));
-            total += map.get(10000L + i);
-        }
-        Set<Long> sets = choujiang(map, 100);
-        int percent = total / personCount;
-        int upCount = 0;
-        for (Long uid : sets) {
-            if (map.get(uid) > percent)
-                upCount += 1;
-            System.out.println(uid + "-" + map.get(uid) + "鏄惁澶т簬鍧囧�硷細" + (map.get(uid) > percent));
-        }
-        System.out.println("澶т簬鍧囧�兼暟閲�:" + upCount);
-        System.out.println("鏁伴噺:" + sets.size());
-    }
+        String key="lijinaccountmoney-20210526-1";
+        redisTemplate.opsForValue().increment(key,123);
 
-    private Set<Long> choujiang(Map<Long, Integer> map, int number) {
+        Object obj = redisTemplate.opsForValue().get("lijinaccountmoney-20210526-1");
+        System.out.println(obj);
 
-        List<Long> mList = new ArrayList<>();
-        for (Iterator<Long> its = map.keySet().iterator(); its.hasNext(); ) {
-            Long uid = its.next();
-            int c = map.get(uid);
-            for (int i = 0; i < c; i++) {
-                mList.add(uid);
-            }
-        }
-
-        Set<Long> luckyUids = new HashSet<>();
-        for (int i = 0; i < number; i++) {
-            if(mList.size()==0)
-                break;
-            long startTime = System.currentTimeMillis();
-            int p = (int) (mList.size() * Math.random());
-            long uid = mList.get(p);
-            luckyUids.add(uid);
-
-            //绉婚櫎鍒楄〃鍙抽潰鐨勭浉鍚寀id
-            while (mList.size() > p && mList.get(p) == uid) {
-                mList.remove(p);
-            }
-
-            //鏌ヨ鐩稿悓uid鐨勫垪琛ㄥ乏渚ц捣鐐�
-            for (int j = p - 1; j >= 0; j--) {
-                if (mList.get(j).longValue() != uid) {
-                    p = j + 1;
-                    break;
-                } else if (j == 0) {
-                    p = 0;
-                }
-            }
-
-            //鍒犻櫎宸︿晶鐩稿悓uid
-            while (mList.size() > p && mList.get(p) == uid) {
-                mList.remove(p);
-            }
-
-            System.out.println("杩愯鏃堕棿锛�" + (System.currentTimeMillis() - startTime));
-        }
-
-
-        System.out.println(luckyUids);
-        return luckyUids;
     }
 
 

--
Gitblit v1.8.0