zhangjinli 3 years ago
parent 2c85fef5a3
commit 10dc72b2a4

@ -123,6 +123,7 @@ public class ScheduleController {
}
// 按任务生成积分流水记录
userPointsRecordsService.saveBatch(recordsList);
taskService.update(new UpdateWrapper<Task>().eq("id",taskId).set("status",3));
}
}
// @Scheduled(cron = "0 0/1 * * * ? ")

@ -192,69 +192,7 @@ public class UtilsController {
private IVideoService videoService;
@Autowired
private UserMapper userMapper;
@Autowired
private IRewardRuleService rewardRuleService;
@Autowired
private IUserPointsRecordsService userPointsRecordsService;
@Autowired
private HttpUtil httpUtil;
@PostMapping("/test")
@ResponseBody
public Result test() {
// 任务结束7天时自动结算积分
QueryWrapper<Task> qw = new QueryWrapper<>();
LocalDateTime now = LocalDateTime.now();
LocalDateTime weekAgo = now.minusWeeks(0);
AppMessage appMessage = new AppMessage().setTitle("任务积分结算");
String format = weekAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
qw.eq("status",2).eq("date_format(end, '%Y-%m-%d')", format);
List<Task> taskList = taskService.list(qw);
String qywxAccessToken = httpUtil.qywxGetToken();
// 处理每个任务的传播值
for (Task t : taskList) {
Integer taskId = t.getId();
List<Map> videoEffectResult = videoService.videoEffectResult(taskId);
List<Map> rewardRule = rewardRuleService.listByTemplateId(t.getRewardRuleTemplateId());
List<UserPointsRecords> recordsList = new ArrayList<>();
System.out.println("videoEffectResult" + videoEffectResult);
// 处理任务中每个用户的传播值
for (Map m : videoEffectResult) {
BigDecimal bigDecimal = (BigDecimal) m.get("effectResultSum");
Integer effectResultSum = Integer.parseInt(bigDecimal.toString());
if (effectResultSum != null && effectResultSum != 0) {
int point = 0;
int userId = (Integer) m.get("userId");
String touser = (String) m.get("touser");
// 根据传播值计算规则算出奖励
for (Map r : rewardRule) {
if (effectResultSum > (Integer) r.get("limitNum")) {
point = (Integer) r.get("reward");
}
}
// (视频结算标识)并更新用户积分,发送企业消息和小程序内消息
userMapper.updPoints(userId, point);
appMessage.setDescription("恭喜您获得星途积分" + point + "。")
.setUrl("pages/quest/subpage/detail/detail?id=" + taskId)
.setReceiverId(userId);
// 企业微信消息通知
if (touser != null) {
appMessage.setTouser(touser);
List<JSONObject> content_item = new ArrayList<>();
content_item.add(new JSONObject().fluentPut("key", "到账结果").fluentPut("value", appMessage.getDescription()));
content_item.add(new JSONObject().fluentPut("key", "到账时间").fluentPut("value", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
httpUtil.qywxMessage(qywxAccessToken, touser, "任务积分结算", null, appMessage.getUrl(), content_item);
}
AppMessageUtil.sendMessage(appMessage);
recordsList.add(new UserPointsRecords().setSettlementMethod(1).setPoints(point).setType(1).setRemarks("任务完成结算:"+t.getTitle()).setCreateDate(now).setUserId(userId));
}
}
// 按任务生成积分流水记录
userPointsRecordsService.saveBatch(recordsList);
}
return Result.success();
}
public static void main(String[] args) {
System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM")));

@ -196,23 +196,17 @@ public class ReferenceController {
@AdminTokenValid
@AdminCheckAuthorityAnnotation(jurisdictionId = "109")
public Result del(@Validated @RequestBody DelRParam param) {
// List<Reference> rList = referenceService.list(new QueryWrapper<Reference>().in("id", param.getIdList()));
// // 删除素材字段
// referenceService.update(new UpdateWrapper<Reference>().in("id", param.getIdList()).set("isDeleted", 1));
// //删除素材文件
// for (Reference r : rList) {
// if (path != null) {
// if (r.getFileUrl() != null) {
// new File(path + "/upload" + r.getFileUrl()).delete();
// }
// if (r.getCoverUrl() != null) {
// new File(path + "/upload" + r.getCoverUrl()).delete();
// }
// }
// }
List<Reference> rList = referenceService.list(new QueryWrapper<Reference>().in("id", param.getIdList()));
// 删除素材字段
referenceService.update(new UpdateWrapper<Reference>().in("id", param.getIdList()).set("isDeleted", 1));
//删除素材文件
for (Reference r : rList) {
deleteFile(r.getFileUrl());
deleteFile(r.getCoverUrl());
}
// //删除素材任务关联
// taskReferenceService.remove(new UpdateWrapper<TaskReference>().in("referenceId", param.getIdList()));
return MybatisPlusUtil.sqlResult( referenceService.update(new UpdateWrapper<Reference>().in("id", param.getIdList()).set("isDeleted", 1)),"删除");
return MybatisPlusUtil.sqlResult(referenceService.update(new UpdateWrapper<Reference>().in("id", param.getIdList()).set("isDeleted", 1)), "删除");
}
@ -413,5 +407,11 @@ public class ReferenceController {
return reference != null ? Result.success(reference.setBrandList(referenceBrandService.selByReferenceId(id)).setTagList(referenceTagService.selByReferenceId(id))) : Result.fail(HttpStatusEnum.NOT_FOUND);
}
void deleteFile(String fileUrl) {
File file = new File(path + "/upload" + fileUrl);
if (fileUrl != null) {
System.out.println("fileDelete================"+file);
file.delete();
}
}
}

@ -9,15 +9,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zh.project0512.annotation.AdminCheckAuthorityAnnotation;
import com.zh.project0512.annotation.AdminTokenValid;
import com.zh.project0512.mapper.UserMapper;
import com.zh.project0512.model.*;
import com.zh.project0512.model.validatedDemo.TaskValidGroup1;
import com.zh.project0512.model.validatedDemo.TaskValidGroup2;
import com.zh.project0512.model.vo.FileUploadParamVo;
import com.zh.project0512.service.*;
import com.zh.project0512.utils.CustomUtil;
import com.zh.project0512.utils.ExcelUtil;
import com.zh.project0512.utils.FileTypeUtil;
import com.zh.project0512.utils.MybatisPlusUtil;
import com.zh.project0512.utils.*;
import com.zh.project0512.utils.result.HttpStatusEnum;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
@ -36,8 +34,10 @@ import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -427,6 +427,68 @@ public class TaskController {
return Result.success("", "终止任务完成");
}
@Autowired
private UserMapper userMapper;
@Autowired
private IUserPointsRecordsService userPointsRecordsService;
@Autowired
private HttpUtil httpUtil;
@PostMapping("/finish")
@ResponseBody
public Result test(@Validated @RequestBody DelTaskParam param) {
// 任务结束7天时自动结算积分
QueryWrapper<Task> qw = new QueryWrapper<>();
LocalDateTime now = LocalDateTime.now();
LocalDateTime weekAgo = now.minusWeeks(0);
AppMessage appMessage = new AppMessage().setTitle("任务积分结算");
String format = weekAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
qw.eq("status",2).eq("id", param.getId());
List<Task> taskList = taskService.list(qw);
String qywxAccessToken = httpUtil.qywxGetToken();
// 处理每个任务的传播值
for (Task t : taskList) {
Integer taskId = t.getId();
List<Map> videoEffectResult = videoService.videoEffectResult(taskId);
List<Map> rewardRule = rewardRuleService.listByTemplateId(t.getRewardRuleTemplateId());
List<UserPointsRecords> recordsList = new ArrayList<>();
// 处理任务中每个用户的传播值
for (Map m : videoEffectResult) {
BigDecimal bigDecimal = (BigDecimal) m.get("effectResultSum");
Integer effectResultSum = Integer.parseInt(bigDecimal.toString());
if (effectResultSum != null && effectResultSum != 0) {
int point = 0;
int userId = (Integer) m.get("userId");
String touser = (String) m.get("touser");
// 根据传播值计算规则算出奖励
for (Map r : rewardRule) {
if (effectResultSum > (Integer) r.get("limitNum")) {
point = (Integer) r.get("reward");
}
}
// (视频结算标识)并更新用户积分,发送企业消息和小程序内消息
userMapper.updPoints(userId, point);
appMessage.setDescription("恭喜您获得星途积分" + point + "。")
.setUrl("pages/quest/subpage/detail/detail?id=" + taskId)
.setReceiverId(userId);
// 企业微信消息通知
if (touser != null) {
appMessage.setTouser(touser);
List<JSONObject> content_item = new ArrayList<>();
content_item.add(new JSONObject().fluentPut("key", "到账结果").fluentPut("value", appMessage.getDescription()));
content_item.add(new JSONObject().fluentPut("key", "到账时间").fluentPut("value", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
httpUtil.qywxMessage(qywxAccessToken, touser, "任务积分结算", null, appMessage.getUrl(), content_item);
}
AppMessageUtil.sendMessage(appMessage);
recordsList.add(new UserPointsRecords().setSettlementMethod(1).setPoints(point).setType(1).setRemarks("任务完成结算:"+t.getTitle()).setCreateDate(now).setUserId(userId));
}
}
// 按任务生成积分流水记录
userPointsRecordsService.saveBatch(recordsList);
taskService.update(new UpdateWrapper<Task>().eq("id",taskId).set("status",3));
}
return Result.success();
}
@Data
static class ListTParam {
private int pageNum;

@ -94,9 +94,9 @@ public class Task extends Model {
private LocalDateTime end;
/**
* 0线1线2
* 0线1线23
*/
@Schema(title="状态",description = "0未上线1已上线2已结束")
@Schema(title="状态",description = "0未上线1已上线2已结束3已结算")
private Integer status;
/**

@ -57,8 +57,8 @@ web:
# uploadPath: /Users/apple/Pictures
# 线上图片上传位置
uploadPath: /static/sws/upload/
# 图片压缩尺寸界限(1024*1024)
picSizeLimit: 1048576
# 图片压缩尺寸界限(200*1024)
picSizeLimit: 204800
cdn: http://cdn.sws010.com
#springdoc:

@ -29,7 +29,7 @@
</collection>
</resultMap>
<select id="rrList" resultMap="selectTemplateDetail">
SELECT t1.id,t1.title,t2.id as ruleId,t2.reward,t2.limitNum,t2.templateId
SELECT t1.*,t2.id as ruleId,t2.reward,t2.limitNum,t2.templateId
from rewardRuleTemplate as t1
left JOIN rewardRule AS t2
on t1.id =t2.templateId

Loading…
Cancel
Save