|
|
|
@ -3,13 +3,18 @@ package com.zh.project0512.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
//import com.zh.project0512.service.IUserService;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.zh.project0512.mapper.QywxDepartmentUserLinkMapper;
|
|
|
|
|
import com.zh.project0512.mapper.RankMapper;
|
|
|
|
|
import com.zh.project0512.mapper.UserMapper;
|
|
|
|
|
import com.zh.project0512.model.AppMessage;
|
|
|
|
|
import com.zh.project0512.model.Task;
|
|
|
|
|
import com.zh.project0512.model.UserPointsRecords;
|
|
|
|
|
import com.zh.project0512.service.IRewardRuleService;
|
|
|
|
|
import com.zh.project0512.service.ITaskService;
|
|
|
|
|
import com.zh.project0512.service.IUserPointsRecordsService;
|
|
|
|
|
import com.zh.project0512.service.IVideoService;
|
|
|
|
|
import com.zh.project0512.utils.FileTypeUtil;
|
|
|
|
|
import com.zh.project0512.utils.RegexUtil;
|
|
|
|
|
import com.zh.project0512.utils.RegexUtils;
|
|
|
|
|
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;
|
|
|
|
@ -31,6 +36,7 @@ import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.ZoneOffset;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
@ -186,16 +192,75 @@ 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) {
|
|
|
|
|
File file = new File("/Users/apple/Pictures/ss/tt/default (10).xlsx");
|
|
|
|
|
file.delete();
|
|
|
|
|
|
|
|
|
|
String url ="测试https://v.kuaishou.com/lnmWDU 测试 复制此消息,打开【快手】直接观看!";
|
|
|
|
|
String s = RegexUtils.get("(https://)(.*?)(/)(.*?)(/)",url,0);
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
// String url = "4.38 wfb:/ 复制打开抖音身 https://v.douyin.com/YT98hjf/,看看【酸味真火的作品】坚持总会有收获的# 意想不到的情侣健身 https://v.douyin.com/YT982Sf/";
|
|
|
|
|
// System.out.println( RegexUtils.get("(https://)(.*?)(/)(.*?)(/)",url,0));
|
|
|
|
|
// String a = m.find() ? m.group(1) : url;
|
|
|
|
|