Просмотр исходного кода

Merge branch 'test' into dev-lqc

lqc 4 лет назад
Родитель
Сommit
8fa97db2f5

+ 2 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxCashOasBoxService.java

@@ -17,6 +17,8 @@ import java.util.Map;
 public interface FosterwxCashOasBoxService extends IService<FosterwxCashOasBox> {
     //.@leon 获取数据列表
     public ResHandle<List<FosterwxCashOasBox>> getList(PostBasePageHandle handle);
+    //.@leon 增加发文数量记录
+    public Boolean addSendTextCnt(String ghId);
     //.@leon 获取一个正常状态的小程序
     public FosterwxCashOasBox getRandBox(Integer groupId);
     //.@leon 获取一个正常状态的公众号

+ 25 - 8
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashOasBoxServiceImpl.java

@@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import com.mokamrp.privates.entity.ResHandle;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -46,20 +48,34 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
         return res;
     }
 
+    @Transactional(isolation = Isolation.READ_COMMITTED)
+    public Boolean addSendTextCnt(String ghId) {
+        FosterwxCashOasBox fosterwxCashOasBox = this.getOne(new QueryWrapper<FosterwxCashOasBox>()
+                .eq("gh_id", ghId)
+                .last("for update"));
+        if (fosterwxCashOasBox == null){
+            return false;
+        }
+        FosterwxCashOasBox save = new FosterwxCashOasBox();
+        save.setSendTextCnt(fosterwxCashOasBox.getSendTextCnt()+1);
+        return true;
+    }
+
     /**
      * 获取一个有效的小程序
+     *
      * @return
      */
     public FosterwxCashOasBox getRandBox(Integer groupId) {
         List<FosterwxCashOasBox> list = this.list(new QueryWrapper<FosterwxCashOasBox>()
                 .eq("type", 1)
-                .eq("group_id",groupId)
-                .lt("send_text_cnt",90)
-                .eq("fobidden_status",1));
+                .eq("group_id", groupId)
+                .lt("send_text_cnt", 90)
+                .eq("fobidden_status", 1));
         if (list == null || list.size() <= 0) {
             return null;
         }
-        int max = list.size()-1;
+        int max = list.size() - 1;
         int min = 0;
         Random random = new Random();
         int i = random.nextInt(max) % (max - min + 1) + min;
@@ -68,18 +84,19 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
 
     /**
      * 获取一个有效的公众号
+     *
      * @return
      */
     public FosterwxCashOasBox getRandOas(Integer groupId) {
         List<FosterwxCashOasBox> list = this.list(new QueryWrapper<FosterwxCashOasBox>()
                 .eq("type", 2)
-                .eq("group_id",groupId)
-                .lt("send_text_cnt",90)
-                .eq("fobidden_status",1));
+                .eq("group_id", groupId)
+                .lt("send_text_cnt", 90)
+                .eq("fobidden_status", 1));
         if (list == null || list.size() <= 0) {
             return null;
         }
-        int max = list.size()-1;
+        int max = list.size() - 1;
         int min = 0;
         Random random = new Random();
         int i = random.nextInt(max) % (max - min + 1) + min;