|
@@ -37,7 +37,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @Author: Silent
|
|
* @Author: Silent
|
|
@@ -104,7 +106,7 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//判断所使用的道具是否是该活动的
|
|
//判断所使用的道具是否是该活动的
|
|
|
- if(!activeRecord.getId().equals(helpGoods.getActiveId())){
|
|
|
|
|
|
|
+ if (!activeRecord.getId().equals(helpGoods.getActiveId())) {
|
|
|
throw new AppActiveProductException("所使用的道具非该活动下的");
|
|
throw new AppActiveProductException("所使用的道具非该活动下的");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -133,6 +135,7 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新活动作品的票数和热力值
|
|
* 更新活动作品的票数和热力值
|
|
|
|
|
+ *
|
|
|
* @param activeHelpRecord
|
|
* @param activeHelpRecord
|
|
|
* @param activeProductRecord
|
|
* @param activeProductRecord
|
|
|
* @param activeSetting
|
|
* @param activeSetting
|
|
@@ -146,7 +149,7 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
if (ObjectUtils.isNotEmpty(activeSetting.getVoteAndHeatRate()) && !activeSetting.getVoteAndHeatRate().equals(BigDecimal.ZERO)) {
|
|
if (ObjectUtils.isNotEmpty(activeSetting.getVoteAndHeatRate()) && !activeSetting.getVoteAndHeatRate().equals(BigDecimal.ZERO)) {
|
|
|
//查询参赛用户
|
|
//查询参赛用户
|
|
|
UserHeat userHeat = userHeatService.getOne(Wrappers.<UserHeat>lambdaQuery().eq(UserHeat::getPhone, activeProductRecord.getPhone()));
|
|
UserHeat userHeat = userHeatService.getOne(Wrappers.<UserHeat>lambdaQuery().eq(UserHeat::getPhone, activeProductRecord.getPhone()));
|
|
|
- if(ObjectUtils.isEmpty(userHeat)){
|
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(userHeat)) {
|
|
|
userHeat = new UserHeat();
|
|
userHeat = new UserHeat();
|
|
|
userHeat.setPhone(activeProductRecord.getPhone());
|
|
userHeat.setPhone(activeProductRecord.getPhone());
|
|
|
userHeat.setHeatValue(BigDecimal.ZERO);
|
|
userHeat.setHeatValue(BigDecimal.ZERO);
|
|
@@ -181,11 +184,12 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新用户普法积分
|
|
* 更新用户普法积分
|
|
|
|
|
+ *
|
|
|
* @param activeHelpRecord
|
|
* @param activeHelpRecord
|
|
|
* @param activeSetting
|
|
* @param activeSetting
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void userPuFaPointUpdate(ActiveHelpRecord activeHelpRecord,ActiveSettingDto activeSetting) {
|
|
|
|
|
|
|
+ public void userPuFaPointUpdate(ActiveHelpRecord activeHelpRecord, ActiveSettingDto activeSetting) {
|
|
|
//判断是否普法积分
|
|
//判断是否普法积分
|
|
|
if (ObjectUtils.isNotEmpty(activeSetting.getVoteAndPointRate()) && !activeSetting.getVoteAndPointRate().equals(BigDecimal.ZERO)) {
|
|
if (ObjectUtils.isNotEmpty(activeSetting.getVoteAndPointRate()) && !activeSetting.getVoteAndPointRate().equals(BigDecimal.ZERO)) {
|
|
|
//修改普法积分(票数*积分比例+原有积分)
|
|
//修改普法积分(票数*积分比例+原有积分)
|
|
@@ -203,7 +207,7 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
|
|
|
|
|
//修改积分
|
|
//修改积分
|
|
|
UserPufaPoint userPufaPoint = userPufaPointService.getOne(Wrappers.<UserPufaPoint>lambdaQuery().eq(UserPufaPoint::getPhone, activeHelpRecord.getPhone()));
|
|
UserPufaPoint userPufaPoint = userPufaPointService.getOne(Wrappers.<UserPufaPoint>lambdaQuery().eq(UserPufaPoint::getPhone, activeHelpRecord.getPhone()));
|
|
|
- if(ObjectUtils.isEmpty(userPufaPoint)){
|
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(userPufaPoint)) {
|
|
|
userPufaPoint = new UserPufaPoint();
|
|
userPufaPoint = new UserPufaPoint();
|
|
|
userPufaPoint.setPhone(activeHelpRecord.getPhone());
|
|
userPufaPoint.setPhone(activeHelpRecord.getPhone());
|
|
|
userPufaPoint.setUserId(activeHelpRecord.getUserId());
|
|
userPufaPoint.setUserId(activeHelpRecord.getUserId());
|
|
@@ -218,6 +222,7 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 判断用户使用该道具对该活动助力次数是否到达上限
|
|
* 判断用户使用该道具对该活动助力次数是否到达上限
|
|
|
|
|
+ *
|
|
|
* @param activeHelpRecord
|
|
* @param activeHelpRecord
|
|
|
* @param activeProductRecord
|
|
* @param activeProductRecord
|
|
|
* @param loginUser
|
|
* @param loginUser
|
|
@@ -244,4 +249,24 @@ public class AppActiveProductServiceImpl implements AppActiveProductService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 刷新活动作品缓存
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 活动ID
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void refreshActiveProductCache(Long id) {
|
|
|
|
|
+ //查询该活动的所有作品
|
|
|
|
|
+ List<ActiveProductRecord> activeProductRecordList = activeProductRecordService
|
|
|
|
|
+ .list(Wrappers.<ActiveProductRecord>lambdaQuery()
|
|
|
|
|
+ .select(ActiveProductRecord::getId, ActiveProductRecord::getVoteCount)
|
|
|
|
|
+ .eq(ActiveProductRecord::getActiveId, id)
|
|
|
|
|
+ .eq(ActiveProductRecord::getStatus, 1));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(activeProductRecordList) && activeProductRecordList.size() != 0) {
|
|
|
|
|
+ Map<Object, Double> map = activeProductRecordList.stream().collect(Collectors.toMap(ele -> ele.getId(), ele -> Double.valueOf(ele.getVoteCount())));
|
|
|
|
|
+ ActiveProductUtil.addActiveCache(id.toString(), map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|