|
@@ -1,5 +1,7 @@
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
@@ -90,6 +92,7 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeSubCategoryService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmUserSignDetailService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmUserSignDetailService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmUserSignService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmUserSignService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmWkAlbumService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmWkAlbumService;
|
|
@@ -217,6 +220,7 @@ public class ApiController {
|
|
private final SysUserSignCertService sysUserSignCertService;
|
|
private final SysUserSignCertService sysUserSignCertService;
|
|
private final SysUserExtRecordService sysUserExtRecordService;
|
|
private final SysUserExtRecordService sysUserExtRecordService;
|
|
private final WmTaskSubmissionRuleService taskSubmissionRuleService;
|
|
private final WmTaskSubmissionRuleService taskSubmissionRuleService;
|
|
|
|
+ private final WmTaskTypeSubCategoryService taskTypeSubCategoryService;
|
|
|
|
|
|
@SysLog("通过任务类型获取表单配置")
|
|
@SysLog("通过任务类型获取表单配置")
|
|
@ApiOperation(value = "任务类型表单配置-通过任务类型获取表单配置", notes = "根据任务类型获取表单配置")
|
|
@ApiOperation(value = "任务类型表单配置-通过任务类型获取表单配置", notes = "根据任务类型获取表单配置")
|
|
@@ -1014,18 +1018,18 @@ public class ApiController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if (CollUtil.isNotEmpty(ducImgUrl)) {
|
|
|
|
- // 保存图片
|
|
|
|
- log.info("all size:{}", all.size());
|
|
|
|
- if (CollUtil.isNotEmpty(all)) {
|
|
|
|
- all.forEach(hash -> {
|
|
|
|
- String key = String.format("%s:%s", id, hash);
|
|
|
|
- log.info("key: {}", key);
|
|
|
|
- redisTemplate.delete(key);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- return R.failed(ducImgUrl, "提交重复的图片");
|
|
|
|
- }
|
|
|
|
|
|
+ // if (CollUtil.isNotEmpty(ducImgUrl)) {
|
|
|
|
+ // // 保存图片
|
|
|
|
+ // log.info("all size:{}", all.size());
|
|
|
|
+ // if (CollUtil.isNotEmpty(all)) {
|
|
|
|
+ // all.forEach(hash -> {
|
|
|
|
+ // String key = String.format("%s:%s", id, hash);
|
|
|
|
+ // log.info("key: {}", key);
|
|
|
|
+ // redisTemplate.delete(key);
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // return R.failed(ducImgUrl, "提交重复的图片");
|
|
|
|
+ // }
|
|
|
|
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(wmTaskContent.getTemp30())) {
|
|
if (org.apache.commons.lang.StringUtils.isEmpty(wmTaskContent.getTemp30())) {
|
|
return R.failed("任务类型不能为空");
|
|
return R.failed("任务类型不能为空");
|
|
@@ -3503,6 +3507,8 @@ public class ApiController {
|
|
wmWkAlbum = wmWkAlbumService.getById(id);
|
|
wmWkAlbum = wmWkAlbumService.getById(id);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// 获取分享人
|
|
// 获取分享人
|
|
SysUser sysUser = sysUserService.getById(shareUserId);
|
|
SysUser sysUser = sysUserService.getById(shareUserId);
|
|
|
|
|
|
@@ -3518,9 +3524,9 @@ public class ApiController {
|
|
if ("share".equals(type)) {
|
|
if ("share".equals(type)) {
|
|
String info = null;
|
|
String info = null;
|
|
if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
- info = checkAlbumLimit(wmWkAlbum, sysUser);
|
|
|
|
|
|
+ info = checkAlbumLimit(wmWkAlbum, sysUser, "8", tWmScorePackage.getRelatedService());
|
|
} else if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
} else if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
- info = checkArticleLimit(wmWkArticle, sysUser);
|
|
|
|
|
|
+ info = checkArticleLimit(wmWkArticle, sysUser,"9", tWmScorePackage.getRelatedService());
|
|
}
|
|
}
|
|
if (StringUtils.isNotEmpty(info)) {
|
|
if (StringUtils.isNotEmpty(info)) {
|
|
return R.failed(info);
|
|
return R.failed(info);
|
|
@@ -3653,9 +3659,9 @@ public class ApiController {
|
|
// 校验打开结果
|
|
// 校验打开结果
|
|
if (needToCheckLimit) {
|
|
if (needToCheckLimit) {
|
|
if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
- needToCheckLimit = checkArticleOpenLimit(wmWkArticle, sysUser, wmTask);
|
|
|
|
|
|
+ needToCheckLimit = checkArticleOpenLimit(wmWkArticle, sysUser, wmTask, "10", tWmScorePackage.getRelatedService());
|
|
} else if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
} else if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
- needToCheckLimit = checkAlbumOpenLimit(wmWkAlbum, sysUser, wmTask);
|
|
|
|
|
|
+ needToCheckLimit = checkAlbumOpenLimit(wmWkAlbum, sysUser, wmTask, "11", tWmScorePackage.getRelatedService());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3808,14 +3814,40 @@ public class ApiController {
|
|
* @param article 文章
|
|
* @param article 文章
|
|
* @param user 分享用户
|
|
* @param user 分享用户
|
|
* @param task 任务
|
|
* @param task 任务
|
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
|
+ * @param pkgId 积分包id
|
|
|
|
+ * @return 校验信息
|
|
*/
|
|
*/
|
|
- private Boolean checkArticleOpenLimit(WmWkArticle article, SysUser user, WmTask task) {
|
|
|
|
|
|
+ private Boolean checkArticleOpenLimit(WmWkArticle article, SysUser user, WmTask task, String taskTypeId, String pkgId) {
|
|
Assert.notNull(article);
|
|
Assert.notNull(article);
|
|
|
|
+
|
|
|
|
+ List<WmTaskSubmissionRule.SubmissionRule> rules = wmTaskContentService.getTaskSubmissionRule(taskTypeId, pkgId);
|
|
|
|
+
|
|
|
|
+ int maxShareTimes = upmsConfig.getMaxShareTimes();
|
|
|
|
+ if (CollUtil.isNotEmpty(rules)){
|
|
|
|
+ // 获取限制
|
|
|
|
+ for (int i = 0, size = rules.size(); i < size; i++) {
|
|
|
|
+ Map<String, Object> map = (Map<String, Object>) rules.get(i);
|
|
|
|
+ WmTaskSubmissionRule.SubmissionRule r = BeanUtil.mapToBean(map, WmTaskSubmissionRule.SubmissionRule.class, true, new CopyOptions());
|
|
|
|
+
|
|
|
|
+ if ("同一个人对同一篇文章的转发上限".equals(r.getManual())) {
|
|
|
|
+
|
|
|
|
+ List<Integer> quantity = r.getFrequency().stream().map(f -> {
|
|
|
|
+ Object o = f.get("quantity");
|
|
|
|
+ return o instanceof String ? Integer.parseInt((String) o) : (int) o;
|
|
|
|
+ }).sorted().collect(Collectors.toList());
|
|
|
|
+ maxShareTimes = quantity.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
+ user.getUserId() + ":" + article.getId();
|
|
+ user.getUserId() + ":" + article.getId();
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(cacheKey);
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(cacheKey);
|
|
- if (null != times && times >= upmsConfig.getMaxShareTimes()) {
|
|
|
|
|
|
+ if (null != times && times >= maxShareTimes) {
|
|
log.info("{}:{}已经转发文章{}次数:{}", user.getUserId(), user.getRealname(), article.getId(), times);
|
|
log.info("{}:{}已经转发文章{}次数:{}", user.getUserId(), user.getRealname(), article.getId(), times);
|
|
task.setScore(0);
|
|
task.setScore(0);
|
|
return false;
|
|
return false;
|
|
@@ -3829,9 +3861,35 @@ public class ApiController {
|
|
* @param album 相册
|
|
* @param album 相册
|
|
* @param user 分享用户
|
|
* @param user 分享用户
|
|
* @param task 任务
|
|
* @param task 任务
|
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
|
+ * @param pkgId 积分包id
|
|
|
|
+ * @return 校验信息
|
|
*/
|
|
*/
|
|
- private Boolean checkAlbumOpenLimit(WmWkAlbum album, SysUser user, WmTask task) {
|
|
|
|
|
|
+ private Boolean checkAlbumOpenLimit(WmWkAlbum album, SysUser user, WmTask task, String taskTypeId, String pkgId) {
|
|
Assert.notNull(album);
|
|
Assert.notNull(album);
|
|
|
|
+
|
|
|
|
+ List<WmTaskSubmissionRule.SubmissionRule> rules = wmTaskContentService.getTaskSubmissionRule(taskTypeId, pkgId);
|
|
|
|
+
|
|
|
|
+ int maxShareTimes = upmsConfig.getMaxShareTimes();
|
|
|
|
+ if (CollUtil.isNotEmpty(rules)){
|
|
|
|
+ // 获取限制
|
|
|
|
+ for (int i = 0, size = rules.size(); i < size; i++) {
|
|
|
|
+ Map<String, Object> map = (Map<String, Object>) rules.get(i);
|
|
|
|
+ WmTaskSubmissionRule.SubmissionRule r = BeanUtil.mapToBean(map, WmTaskSubmissionRule.SubmissionRule.class, true, new CopyOptions());
|
|
|
|
+
|
|
|
|
+ if ("同一个人对同一个相册的转发上限".equals(r.getManual())) {
|
|
|
|
+
|
|
|
|
+ List<Integer> quantity = r.getFrequency().stream().map(f -> {
|
|
|
|
+ Object o = f.get("quantity");
|
|
|
|
+ return o instanceof String ? Integer.parseInt((String) o) : (int) o;
|
|
|
|
+ }).sorted().collect(Collectors.toList());
|
|
|
|
+ maxShareTimes = quantity.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
if (StringUtils.isNotEmpty(album.getGlyp())) {
|
|
if (StringUtils.isNotEmpty(album.getGlyp())) {
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(album.getGlyp().split(",")));
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(album.getGlyp().split(",")));
|
|
@@ -3846,7 +3904,7 @@ public class ApiController {
|
|
+ drug.getDrugEntId() + CacheConstants.DRUG_ENT_PERSONAL_SHARE_KEY2 + user.getUserId();
|
|
+ drug.getDrugEntId() + CacheConstants.DRUG_ENT_PERSONAL_SHARE_KEY2 + user.getUserId();
|
|
log.info("key:{}", key);
|
|
log.info("key:{}", key);
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(key);
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(key);
|
|
- if (times != null && times >= upmsConfig.getMaxShareTimes()) {
|
|
|
|
|
|
+ if (times != null && times >= maxShareTimes) {
|
|
task.setScore(0);
|
|
task.setScore(0);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -3861,18 +3919,44 @@ public class ApiController {
|
|
*
|
|
*
|
|
* @param wmWkArticle 文章
|
|
* @param wmWkArticle 文章
|
|
* @param sysUser 转发人
|
|
* @param sysUser 转发人
|
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
|
+ * @param pkgId 积分包id
|
|
* @return 校验信息
|
|
* @return 校验信息
|
|
*/
|
|
*/
|
|
- private String checkArticleLimit(WmWkArticle wmWkArticle, SysUser sysUser) {
|
|
|
|
|
|
+ private String checkArticleLimit(WmWkArticle wmWkArticle, SysUser sysUser, String taskTypeId, String pkgId) {
|
|
Assert.notNull(wmWkArticle);
|
|
Assert.notNull(wmWkArticle);
|
|
|
|
+
|
|
|
|
+ List<WmTaskSubmissionRule.SubmissionRule> rules = wmTaskContentService.getTaskSubmissionRule(taskTypeId, pkgId);
|
|
|
|
+
|
|
|
|
+ int maxShareTimes = upmsConfig.getMaxShareTimes();
|
|
|
|
+ if (CollUtil.isNotEmpty(rules)){
|
|
|
|
+ // 获取限制
|
|
|
|
+ for (int i = 0, size = rules.size(); i < size; i++) {
|
|
|
|
+ Map<String, Object> map = (Map<String, Object>) rules.get(i);
|
|
|
|
+ WmTaskSubmissionRule.SubmissionRule r = BeanUtil.mapToBean(map, WmTaskSubmissionRule.SubmissionRule.class, true, new CopyOptions());
|
|
|
|
+
|
|
|
|
+ if ("同一个人对同一篇文章的转发上限".equals(r.getManual())) {
|
|
|
|
+
|
|
|
|
+ List<Integer> quantity = r.getFrequency().stream().map(f -> {
|
|
|
|
+ Object o = f.get("quantity");
|
|
|
|
+ return o instanceof String ? Integer.parseInt((String) o) : (int) o;
|
|
|
|
+ }).sorted().collect(Collectors.toList());
|
|
|
|
+ maxShareTimes = quantity.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
+ sysUser.getUserId() + ":" + wmWkArticle.getId();
|
|
+ sysUser.getUserId() + ":" + wmWkArticle.getId();
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(cacheKey);
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(cacheKey);
|
|
if (null != times) {
|
|
if (null != times) {
|
|
log.info("{}:{}已经转发文章{}次数:{}", sysUser.getUserId(), sysUser.getRealname(), wmWkArticle.getId(), times);
|
|
log.info("{}:{}已经转发文章{}次数:{}", sysUser.getUserId(), sysUser.getRealname(), wmWkArticle.getId(), times);
|
|
- if (times++ >= upmsConfig.getMaxShareTimes()) {
|
|
|
|
- return "您当日转发的该文章次数已超过20次,转发将不再获得积分";
|
|
|
|
|
|
+ if (times++ >= maxShareTimes) {
|
|
|
|
+ return String.format("您当日转发的该药企产品相册次数已超过%s次,转发将不再获得积分", maxShareTimes);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.info("{}:{}已经首次转发文章:{}", sysUser.getUserId(), sysUser.getRealname(), wmWkArticle.getId(), times);
|
|
log.info("{}:{}已经首次转发文章:{}", sysUser.getUserId(), sysUser.getRealname(), wmWkArticle.getId(), times);
|
|
@@ -3888,11 +3972,36 @@ public class ApiController {
|
|
*
|
|
*
|
|
* @param wmWkAlbum 相册
|
|
* @param wmWkAlbum 相册
|
|
* @param sysUser 分享人
|
|
* @param sysUser 分享人
|
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
|
+ * @param pkgId 积分包id
|
|
* @return 校验结果信息
|
|
* @return 校验结果信息
|
|
*/
|
|
*/
|
|
- private String checkAlbumLimit(WmWkAlbum wmWkAlbum, SysUser sysUser) {
|
|
|
|
|
|
+ private String checkAlbumLimit(WmWkAlbum wmWkAlbum, SysUser sysUser, String taskTypeId, String pkgId) {
|
|
|
|
|
|
Assert.notNull(wmWkAlbum);
|
|
Assert.notNull(wmWkAlbum);
|
|
|
|
+
|
|
|
|
+ List<WmTaskSubmissionRule.SubmissionRule> rules = wmTaskContentService.getTaskSubmissionRule(taskTypeId, pkgId);
|
|
|
|
+
|
|
|
|
+ int maxShareTimes = upmsConfig.getMaxShareTimes();
|
|
|
|
+ if (CollUtil.isNotEmpty(rules)){
|
|
|
|
+ // 获取限制
|
|
|
|
+ for (int i = 0, size = rules.size(); i < size; i++) {
|
|
|
|
+ Map<String, Object> map = (Map<String, Object>) rules.get(i);
|
|
|
|
+ WmTaskSubmissionRule.SubmissionRule r = BeanUtil.mapToBean(map, WmTaskSubmissionRule.SubmissionRule.class, true, new CopyOptions());
|
|
|
|
+
|
|
|
|
+ if ("同一个人对同一个相册的转发上限".equals(r.getManual())) {
|
|
|
|
+
|
|
|
|
+ List<Integer> quantity = r.getFrequency().stream().map(f -> {
|
|
|
|
+ Object o = f.get("quantity");
|
|
|
|
+ return o instanceof String ? Integer.parseInt((String) o) : (int) o;
|
|
|
|
+ }).sorted().collect(Collectors.toList());
|
|
|
|
+ maxShareTimes = quantity.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
if (StringUtils.isNotEmpty(wmWkAlbum.getGlyp())) {
|
|
if (StringUtils.isNotEmpty(wmWkAlbum.getGlyp())) {
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(wmWkAlbum.getGlyp().split(",")));
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(wmWkAlbum.getGlyp().split(",")));
|
|
@@ -3913,8 +4022,8 @@ public class ApiController {
|
|
System.err.println("key" + key);
|
|
System.err.println("key" + key);
|
|
if (redisTemplate.hasKey(key)) {
|
|
if (redisTemplate.hasKey(key)) {
|
|
int times = Integer.parseInt(redisTemplate.opsForValue().get(key).toString());
|
|
int times = Integer.parseInt(redisTemplate.opsForValue().get(key).toString());
|
|
- if (times >= upmsConfig.getMaxShareTimes()) {
|
|
|
|
- return "您当日转发的该药企产品相册次数已超过20次,转发将不再获得积分";
|
|
|
|
|
|
+ if (times >= maxShareTimes) {
|
|
|
|
+ return String.format("您当日转发的该药企产品相册次数已超过%s次,转发将不再获得积分", maxShareTimes);
|
|
}
|
|
}
|
|
times++;
|
|
times++;
|
|
redisTemplate.opsForValue().set(key, times, CacheConstants.SHARE_TIME, TimeUnit.DAYS);
|
|
redisTemplate.opsForValue().set(key, times, CacheConstants.SHARE_TIME, TimeUnit.DAYS);
|