|
|
@@ -0,0 +1,49 @@
|
|
|
+package com.mokamrp.privates.task.pangu;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**检查个微池二维码是否有能用的
|
|
|
+ * @author luqiucheng
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class CheckPoolStatus {
|
|
|
+ @Autowired
|
|
|
+ private FosterwxMobilePoolService fosterwxMobilePoolService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 */1 * * * ?")
|
|
|
+ public void execute() {
|
|
|
+ LambdaQueryWrapper<FosterwxMobilePool> fosterwxMobilePoolLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ // 查询有分组的 类型为游戏导粉的
|
|
|
+ fosterwxMobilePoolLambdaQueryWrapper.ne(FosterwxMobilePool::getFlowPosition, "").eq(FosterwxMobilePool::getIncomeFansType, 2).groupBy(FosterwxMobilePool::getFlowPosition);
|
|
|
+ fosterwxMobilePoolService.list(fosterwxMobilePoolLambdaQueryWrapper).forEach(fosterwxMobilePool -> {
|
|
|
+ // 判断分组下未停用账号是否存在
|
|
|
+ if (fosterwxMobilePoolService.count(new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getFlowPosition, fosterwxMobilePool.getFlowPosition()).ne(FosterwxMobilePool::getStatus, 0)) == 0) {
|
|
|
+ Map<String, Object> jsonObject = new HashMap<>();
|
|
|
+ jsonObject.put("msg_type", "text");
|
|
|
+ Map<String, String> contentObj = new HashMap<>();
|
|
|
+ String info = "流量位置:" + fosterwxMobilePool.getFlowPosition() + "已没有可以使用的二维码了!";
|
|
|
+ contentObj.put("text", info);
|
|
|
+ jsonObject.put("content", contentObj);
|
|
|
+ HttpEntity<Map<String, Object>> entity = new HttpEntity<>(jsonObject, null);
|
|
|
+ ResponseEntity<String> str = restTemplate.exchange("https://open.feishu.cn/open-apis/bot/v2/hook/782210e2-b016-4dd7-885b-e0ea5e58be94", HttpMethod.POST, entity, String.class);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|