|
|
@@ -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;
|