|
@@ -1,5 +1,7 @@
|
|
|
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.CollectionUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
@@ -20,12 +22,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.zxing.WriterException;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.UserDTO;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDictItem;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysRole;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmAdRecord;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskSubmissionRule;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.enums.SignatureStatusEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.vo.UserVO;
|
|
|
import com.qunzhixinxi.hnqz.admin.config.UpmsConfig;
|
|
@@ -86,7 +90,9 @@ import com.qunzhixinxi.hnqz.admin.service.WmTaskContentConfigService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskContentService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskRuleService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
|
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.WmUserSignService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmWkAlbumService;
|
|
@@ -213,6 +219,8 @@ public class ApiController {
|
|
|
private final WmAdRecordService adRecordService;
|
|
|
private final SysUserSignCertService sysUserSignCertService;
|
|
|
private final SysUserExtRecordService sysUserExtRecordService;
|
|
|
+ private final WmTaskSubmissionRuleService taskSubmissionRuleService;
|
|
|
+ private final WmTaskTypeSubCategoryService taskTypeSubCategoryService;
|
|
|
|
|
|
@SysLog("通过任务类型获取表单配置")
|
|
|
@ApiOperation(value = "任务类型表单配置-通过任务类型获取表单配置", notes = "根据任务类型获取表单配置")
|
|
@@ -987,7 +995,7 @@ public class ApiController {
|
|
|
@ApiOperation(value = "任务-新增任务内容表", notes = "新增任务内容表")
|
|
|
@SysLog("新增任务内容表")
|
|
|
@PostMapping("/saveTaskContent")
|
|
|
- public R saveTaskContent(@RequestBody WmTaskContent wmTaskContent) {
|
|
|
+ public R<?> saveTaskContent(@RequestBody WmTaskContent wmTaskContent) {
|
|
|
Set<String> errorHash = new HashSet<>();
|
|
|
List<String> ducImgUrl = new ArrayList<>();
|
|
|
List<String> all = new ArrayList<>();
|
|
@@ -1023,24 +1031,36 @@ public class ApiController {
|
|
|
return R.failed(ducImgUrl, "提交重复的图片");
|
|
|
}
|
|
|
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(wmTaskContent.getTemp30())) {
|
|
|
+ return R.failed("任务类型不能为空");
|
|
|
+ }
|
|
|
|
|
|
- R r = wmTaskContentService.saveTaskContent(wmTaskContent);
|
|
|
-
|
|
|
- log.info("结果:{}, 草稿key:{}", r, draftKey);
|
|
|
- if (r.getCode() == CommonConstants.SUCCESS && StrUtil.isNotEmpty(draftKey)) {
|
|
|
- String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, taskTypeId, id);
|
|
|
- log.info("删除草稿:{}", key);
|
|
|
- redisTemplate.delete(key);
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(wmTaskContent.getTemp32())) {
|
|
|
+ return R.failed("关联积分包不能为空");
|
|
|
}
|
|
|
|
|
|
- if (r.getCode() == CommonConstants.FAIL && CollUtil.isNotEmpty(all)) {
|
|
|
- // 保存图片
|
|
|
- log.info("all size:{}", all.size());
|
|
|
- all.forEach(hash -> {
|
|
|
- String key = String.format("%s:%s", id, hash);
|
|
|
- log.info("key: {}", key);
|
|
|
+ R<?> r = null;
|
|
|
+ try {
|
|
|
+ r = wmTaskContentService.saveTaskContent(wmTaskContent);
|
|
|
+ } catch (Exception e){
|
|
|
+ return R.failed(e.getMessage());
|
|
|
+ } finally {
|
|
|
+ log.info("结果:{}, 草稿key:{}", r, draftKey);
|
|
|
+ if (r != null && r.getCode() == CommonConstants.SUCCESS && StrUtil.isNotEmpty(draftKey)) {
|
|
|
+ String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, taskTypeId, id);
|
|
|
+ log.info("删除草稿:{}", key);
|
|
|
redisTemplate.delete(key);
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (r == null || (r.getCode() == CommonConstants.FAIL && CollUtil.isNotEmpty(all))) {
|
|
|
+ // 保存图片
|
|
|
+ log.info("all size:{}", all.size());
|
|
|
+ all.forEach(hash -> {
|
|
|
+ String key = String.format("%s:%s", id, hash);
|
|
|
+ log.info("key: {}", key);
|
|
|
+ redisTemplate.delete(key);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return r;
|
|
@@ -3326,6 +3346,8 @@ public class ApiController {
|
|
|
map.put("value", wmScorePackage.getId());
|
|
|
String drugProducer = ArrayUtils.isEmpty(wmScorePackage.getDrugProducerList()) ? "" : String.join(StrUtil.COMMA, wmScorePackage.getDrugProducerList());
|
|
|
map.put("drugProducer", drugProducer);
|
|
|
+ map.put("deptId", wmScorePackage.getDeptId());
|
|
|
+ map.put("relDeptId", wmScorePackage.getRelatedService());
|
|
|
listMap.add(map);
|
|
|
}
|
|
|
|
|
@@ -3491,6 +3513,8 @@ public class ApiController {
|
|
|
wmWkAlbum = wmWkAlbumService.getById(id);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 获取分享人
|
|
|
SysUser sysUser = sysUserService.getById(shareUserId);
|
|
|
|
|
@@ -3506,9 +3530,9 @@ public class ApiController {
|
|
|
if ("share".equals(type)) {
|
|
|
String info = null;
|
|
|
if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
|
- info = checkAlbumLimit(wmWkAlbum, sysUser);
|
|
|
+ info = checkAlbumLimit(wmWkAlbum, sysUser, "8", tWmScorePackage.getRelatedService());
|
|
|
} else if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
|
- info = checkArticleLimit(wmWkArticle, sysUser);
|
|
|
+ info = checkArticleLimit(wmWkArticle, sysUser,"9", tWmScorePackage.getRelatedService());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(info)) {
|
|
|
return R.failed(info);
|
|
@@ -3641,9 +3665,9 @@ public class ApiController {
|
|
|
// 校验打开结果
|
|
|
if (needToCheckLimit) {
|
|
|
if ("article".equalsIgnoreCase(taskCategoryName)) {
|
|
|
- needToCheckLimit = checkArticleOpenLimit(wmWkArticle, sysUser, wmTask);
|
|
|
+ needToCheckLimit = checkArticleOpenLimit(wmWkArticle, sysUser, wmTask, "10", tWmScorePackage.getRelatedService());
|
|
|
} else if ("album".equalsIgnoreCase(taskCategoryName)) {
|
|
|
- needToCheckLimit = checkAlbumOpenLimit(wmWkAlbum, sysUser, wmTask);
|
|
|
+ needToCheckLimit = checkAlbumOpenLimit(wmWkAlbum, sysUser, wmTask, "11", tWmScorePackage.getRelatedService());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3796,14 +3820,40 @@ public class ApiController {
|
|
|
* @param article 文章
|
|
|
* @param user 分享用户
|
|
|
* @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);
|
|
|
+
|
|
|
+ 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();
|
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
|
+ user.getUserId() + ":" + article.getId();
|
|
|
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);
|
|
|
task.setScore(0);
|
|
|
return false;
|
|
@@ -3817,9 +3867,35 @@ public class ApiController {
|
|
|
* @param album 相册
|
|
|
* @param user 分享用户
|
|
|
* @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);
|
|
|
+
|
|
|
+ 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())) {
|
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(album.getGlyp().split(",")));
|
|
@@ -3834,7 +3910,7 @@ public class ApiController {
|
|
|
+ drug.getDrugEntId() + CacheConstants.DRUG_ENT_PERSONAL_SHARE_KEY2 + user.getUserId();
|
|
|
log.info("key:{}", key);
|
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(key);
|
|
|
- if (times != null && times >= upmsConfig.getMaxShareTimes()) {
|
|
|
+ if (times != null && times >= maxShareTimes) {
|
|
|
task.setScore(0);
|
|
|
return false;
|
|
|
}
|
|
@@ -3849,18 +3925,44 @@ public class ApiController {
|
|
|
*
|
|
|
* @param wmWkArticle 文章
|
|
|
* @param sysUser 转发人
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
+ * @param pkgId 积分包id
|
|
|
* @return 校验信息
|
|
|
*/
|
|
|
- private String checkArticleLimit(WmWkArticle wmWkArticle, SysUser sysUser) {
|
|
|
+ private String checkArticleLimit(WmWkArticle wmWkArticle, SysUser sysUser, String taskTypeId, String pkgId) {
|
|
|
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();
|
|
|
final String cacheKey = CacheConstants.ARTICLE_PERSONAL_SHARE_KEY + DateUtil.format(now, "yyyyMMdd:")
|
|
|
+ sysUser.getUserId() + ":" + wmWkArticle.getId();
|
|
|
Integer times = (Integer) redisTemplate.opsForValue().get(cacheKey);
|
|
|
if (null != 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 {
|
|
|
log.info("{}:{}已经首次转发文章:{}", sysUser.getUserId(), sysUser.getRealname(), wmWkArticle.getId(), times);
|
|
@@ -3876,11 +3978,36 @@ public class ApiController {
|
|
|
*
|
|
|
* @param wmWkAlbum 相册
|
|
|
* @param sysUser 分享人
|
|
|
+ * @param taskTypeId 任务类型id
|
|
|
+ * @param pkgId 积分包id
|
|
|
* @return 校验结果信息
|
|
|
*/
|
|
|
- private String checkAlbumLimit(WmWkAlbum wmWkAlbum, SysUser sysUser) {
|
|
|
+ private String checkAlbumLimit(WmWkAlbum wmWkAlbum, SysUser sysUser, String taskTypeId, String pkgId) {
|
|
|
|
|
|
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())) {
|
|
|
List<WmDaDrugEntDrugtable> drugTableList =
|
|
|
wmDaDrugEntDrugtableService.listByIds(Arrays.asList(wmWkAlbum.getGlyp().split(",")));
|
|
@@ -3901,8 +4028,8 @@ public class ApiController {
|
|
|
System.err.println("key" + key);
|
|
|
if (redisTemplate.hasKey(key)) {
|
|
|
int times = Integer.parseInt(redisTemplate.opsForValue().get(key).toString());
|
|
|
- if (times >= upmsConfig.getMaxShareTimes()) {
|
|
|
- return "您当日转发的该药企产品相册次数已超过20次,转发将不再获得积分";
|
|
|
+ if (times >= maxShareTimes) {
|
|
|
+ return String.format("您当日转发的该药企产品相册次数已超过%s次,转发将不再获得积分", maxShareTimes);
|
|
|
}
|
|
|
times++;
|
|
|
redisTemplate.opsForValue().set(key, times, CacheConstants.SHARE_TIME, TimeUnit.DAYS);
|
|
@@ -4045,6 +4172,22 @@ public class ApiController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取任务类型的小程序端限制规则
|
|
|
+ *
|
|
|
+ * @param deptId 企业id
|
|
|
+ * @param subCategory 二级分类
|
|
|
+ * @return 限制规则
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/task-sub-rule")
|
|
|
+ public R<?> listTaskSubmissionRule(@RequestParam(value = "deptId") Integer deptId, @RequestParam(value = "subCategory") UpmsType.TaskSubCategory subCategory) {
|
|
|
+ WmTaskSubmissionRule rule = taskSubmissionRuleService.getOne(Wrappers.<WmTaskSubmissionRule>lambdaQuery()
|
|
|
+ .eq(WmTaskSubmissionRule::getDeptId, deptId)
|
|
|
+ .eq(WmTaskSubmissionRule::getSubCategory, subCategory)
|
|
|
+ );
|
|
|
+ return R.ok(rule.getRule());
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|