|
|
@@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.mokamrp.privates.constant.RedisKey;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.Playbill;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.PromoteCode;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.PromoteQrcodePool;
|
|
|
import com.mokamrp.privates.service.pangu.PlaybillService;
|
|
|
import com.mokamrp.privates.service.pangu.PromoteCodeService;
|
|
|
+import com.mokamrp.privates.service.pangu.PromoteQrcodePoolService;
|
|
|
import com.mokamrp.privates.utils.http.HttpUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
@@ -29,6 +31,9 @@ public class ResetCustserviceDayViewTask {
|
|
|
public PromoteCodeService promoteCodeService;
|
|
|
|
|
|
@Autowired
|
|
|
+ public PromoteQrcodePoolService promoteQrcodePoolService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
public StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
@Scheduled(cron = "0 0 0 * * ?") //.每天0点重置每日个微客服访问量
|
|
|
@@ -36,10 +41,21 @@ public class ResetCustserviceDayViewTask {
|
|
|
System.out.println("[cronjob]:盘古活码个微每日访问量清空");
|
|
|
List<PromoteCode> promoteCodeList = promoteCodeService.list();
|
|
|
for (PromoteCode promoteCode : promoteCodeList) {
|
|
|
- Set<String> members = stringRedisTemplate.opsForZSet().range(RedisKey.PanCustServiceIdDayView+Integer.toString(promoteCode.getId()),0,-1);
|
|
|
- for (String member : members){
|
|
|
- stringRedisTemplate.opsForZSet().add(RedisKey.PanCustServiceIdDayView+Integer.toString(promoteCode.getId()), member, 0);
|
|
|
+ List<PromoteQrcodePool> promoteQrcodePoolList = promoteQrcodePoolService.list(new QueryWrapper<PromoteQrcodePool>().eq("promote_id", promoteCode.getId()));
|
|
|
+ for (PromoteQrcodePool promoteQrcodePool : promoteQrcodePoolList){
|
|
|
+ this.addRedis(promoteCode.getId(),promoteQrcodePool.getCustserviceId(),promoteQrcodePool.getWeight());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private Boolean addRedis(Integer promoteId, Integer custserviceId, Integer weight) {
|
|
|
+ Float score = weight.floatValue() / 10000;
|
|
|
+ Long index = stringRedisTemplate.opsForZSet().rank(RedisKey.PanCustServiceIdDayView + promoteId, Integer.toString(custserviceId));
|
|
|
+ //.redis存在记录时才做更新
|
|
|
+ if (index != null) {
|
|
|
+ stringRedisTemplate.opsForZSet().add(RedisKey.PanCustServiceIdDayView + promoteId, Integer.toString(custserviceId), score);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|