zhangjinli 3 years ago
parent 2cc628c7ba
commit 50b8ff4783

@ -1,21 +1,21 @@
package com.zh.project0512.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zh.project0512.mapper.QywxDepartmentUserLinkMapper;
import com.zh.project0512.mapper.RankMapper;
import com.zh.project0512.mapper.UserMapper;
import com.zh.project0512.model.Rank;
import com.zh.project0512.model.Task;
import com.zh.project0512.model.UserPointsRecords;
import com.zh.project0512.model.Video;
import com.zh.project0512.model.*;
import com.zh.project0512.model.dto.RankListDTO;
import com.zh.project0512.model.vo.RankListVo;
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.AppMessageUtil;
import com.zh.project0512.utils.HttpUtil;
import com.zh.project0512.utils.PropertyUtils;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +47,8 @@ public class ScheduleController {
private IRewardRuleService rewardRuleService;
@Autowired
private IUserPointsRecordsService userPointsRecordsService;
@Autowired
private HttpUtil httpUtil;
@Scheduled(cron = "0 0 0 * * ?")
public void taskBegin() {
UpdateWrapper<Task> ew = new UpdateWrapper<>();
@ -76,9 +78,11 @@ public class ScheduleController {
QueryWrapper<Task> qw = new QueryWrapper<>();
LocalDateTime now = LocalDateTime.now();
LocalDateTime weekAgo = now.minusWeeks(1);
AppMessage appMessage = new AppMessage().setTitle("任务积分结算");
String format = weekAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
qw.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();
@ -93,15 +97,28 @@ public class ScheduleController {
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);
recordsList.add(new UserPointsRecords().setSettlementMethod(1).setPoints(point).setType(1).setCreateDate(now).setUserId(userId));
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));
}
}
// 按任务生成积分流水记录

@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.sql.Ref;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -175,17 +176,17 @@ public class ReferenceController {
@Data
static class DelRParam {
@NotNull(message = "id不能为空")
@Min(value = 1, message = "id最小值为1")
@Schema(title = "素材id")
private Integer id;
@NotNull(message = "id数组不能为空")
@Schema(title = "素材Id数组")
private List<Integer> idList;
}
@Operation(summary = "删除素材")
@Operation(summary = "删除素材(软删除)")
@PostMapping("/del")
@AdminTokenValid
public Result del(@Validated @RequestBody DelRParam param) {
return MybatisPlusUtil.sqlResult(referenceService.removeById(param.getId()), "删除");
return MybatisPlusUtil.sqlResult(referenceService.update(new UpdateWrapper<Reference>().in("id", param.getIdList()).set("isDeleted", 1)), "删除");
}
@Data

@ -1,6 +1,7 @@
package com.zh.project0512.controller.manage;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -12,6 +13,7 @@ import com.zh.project0512.service.IUserAccountService;
import com.zh.project0512.service.IUserService;
import com.zh.project0512.utils.AppMessageUtil;
import com.zh.project0512.utils.ExcelUtil;
import com.zh.project0512.utils.HttpUtil;
import com.zh.project0512.utils.MybatisPlusUtil;
import com.zh.project0512.utils.result.HttpStatusEnum;
import com.zh.project0512.utils.result.Result;
@ -35,6 +37,8 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -58,6 +62,8 @@ public class UserAccountController {
@Autowired
private IUserService userService;
@Autowired
private HttpUtil httpUtil;
@Data
static class ListUAParam {
private int pageNum;
@ -150,21 +156,46 @@ public class UserAccountController {
if (ua.getStatus() != 0) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "账号状态不在审核中");
}
String platForm = "未知平台";
switch (ua.getPlatform()) {
case 1:
platForm = "抖音";
break;
case 2:
platForm = "快手";
break;
case 3:
platForm = "朋友圈";
break;
case 4:
platForm = "视频号";
break;
default:
}
UpdateWrapper<UserAccount> updateWrapper = new UpdateWrapper<>();
Integer status = param.getStatus();
updateWrapper.eq("id", param.getId()).set("status", status).set("updateAt", LocalDateTime.now());
String description = "恭喜您,抖音关联账号审核通过。";
AppMessage appMessage = new AppMessage().setTitle("关联账号审核结果").setDescription("恭喜您,"+platForm+"关联账号审核通过。")
.setUrl("pages/user/subpage/relation/relation").setCreateDate(LocalDateTime.now()).setReceiverId(ua.getUserId());
if (status == 2) {
String reason = param.getReason();
if (null == reason) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "请说明拒绝理由");
}
updateWrapper.set("reason", reason);
description = "您的抖音关联账号审核未通过,未通过原因:"+ reason+"。";
appMessage.setDescription("您的"+platForm+"关联账号审核未通过,未通过原因:" + reason + "。");
}
userAccountService.update(updateWrapper);
AppMessageUtil.sendMessage(new AppMessage().setTitle("关联账号审核结果").setDescription(description)
.setUrl("pages/user/subpage/relation/relation").setCreateDate(LocalDateTime.now()).setReceiverId(ua.getUserId()));
String touser = userService.getById(ua.getUserId()).getUserid();
// 企业微信消息通知
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(httpUtil.qywxGetToken(), touser, "关联账号审核", null, appMessage.getUrl(), content_item);
}
AppMessageUtil.sendMessage(appMessage);
return Result.success("修改完成");
}
}

@ -137,6 +137,34 @@ public class UserController {
private String remarks;
}
@Data
static class DetUParam {
private Integer pageNum;
private Integer pageSize;
@NotNull(message = "userId不能为空")
@Min(value = 1, message = "userId最小值为1")
@Schema(title = "用户id")
private Integer userId;
@Schema(title = "类型",description = "1.任务奖励2.素材分享奖励3.线下结算扣除 4.后台更改")
private Integer type;
@Schema(title = "结算方式",description = "1.增加2.扣除")
private Integer settlementMethod;
}
@Operation(summary = "用户积分记录")
@PostMapping("/pointsRecords")
@Transactional
@AdminTokenValid
public Result pointsRecords(@Validated @RequestBody DetUParam param) {
QueryWrapper<UserPointsRecords> qw = new QueryWrapper<>();
qw.eq("userId",param.getUserId());
qw.eq(param.getType()!=null,"type",param.getType());
qw.eq(param.getSettlementMethod()!=null,"type",param.getSettlementMethod());
qw.select("*,(case when type = 0 then '无' when type = 1 then '任务奖励'" +
" when type =2 then '素材分享奖励' when type = 3 then '线下结算扣除' when type = 4 then '后台更改' else '其他' end) as typeDSC," +
"(case when settlementMethod = 1 then '增加' when settlementMethod = 2 then '扣除' else '无' end) as settlementMethodDSC ");
return Result.success(userPointsRecordsService.page(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()),qw));
}
@Operation(summary = "修改积分")
@PostMapping("/pointsTran")
@Transactional

@ -4,6 +4,8 @@ package com.zh.project0512.controller.manage;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zh.project0512.annotation.AdminCheckAuthorityAnnotation;
import com.zh.project0512.annotation.AdminTokenValid;
import com.zh.project0512.mapper.UserEffectRecordsMapper;
@ -13,6 +15,7 @@ import com.zh.project0512.service.IUserService;
import com.zh.project0512.service.IVideoEffectSettingService;
import com.zh.project0512.service.IVideoService;
import com.zh.project0512.utils.AppMessageUtil;
import com.zh.project0512.utils.ExcelUtil;
import com.zh.project0512.utils.HttpUtil;
import com.zh.project0512.utils.MybatisPlusUtil;
import com.zh.project0512.utils.result.HttpStatusEnum;
@ -21,19 +24,24 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.*;
/**
* <p>
@ -73,6 +81,12 @@ public class VideoController {
private Integer departmentId;
@Schema(title = "任务标题")
private String taskTitle;
@Schema(title = "开始时间(yyyy-MM-dd HH:mm:ss)")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime beginTime;
@Schema(title = "结束时间(yyyy-MM-dd HH:mm:ss)")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
}
@Operation(summary = "审核视频列表")
@ -84,9 +98,51 @@ public class VideoController {
qw.like(param.providerName != null, "t2.name", param.getProviderName());
qw.eq(param.getDepartmentId() != null, "t3.departmentId", param.getDepartmentId());
qw.like(param.getTaskTitle() != null, "t4.title", param.getTaskTitle());
qw.ge(param.getBeginTime() != null, "t1.creatAt", param.getBeginTime());
qw.le(param.getEndTime() != null, "t1.creatAt", param.getEndTime());
return Result.success(videoService.pageList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
}
@Operation(summary = "导出excel", description = "审核视频列表导出")
@PostMapping("/excel")
@AdminTokenValid
public void excel(HttpServletResponse response, @Validated @RequestBody VParam param) throws IOException {
//这是表头及格式
String[][] array ={
{"申请人", "任务标题","平台","传播链接","播放数","点赞数","收藏数","评论数","转发数","推荐数","提交时间"},
{"providerName", "taskTitle","type","url","playNum","commendNum","collectionNum","commentNum","reSendNum","recommendNum","creatAt"},
{"String", "String","String","String","int","int","int","int","int","int","LocalDateTime"}
};
QueryWrapper<Video> qw = new QueryWrapper<>();
qw.eq("t1.status", param.getStatus());
qw.like(param.providerName != null, "t2.name", param.getProviderName());
qw.eq(param.getDepartmentId() != null, "t3.departmentId", param.getDepartmentId());
qw.like(param.getTaskTitle() != null, "t4.title", param.getTaskTitle());
qw.ge(param.getBeginTime() != null, "t1.creatAt", param.getBeginTime());
qw.le(param.getEndTime() != null, "t1.creatAt", param.getEndTime());
IPage<Map> iPage = videoService.pageList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw);
List<Map> records = iPage.getRecords();
for (Map m : records) {
//平台1抖音2快手3朋友圈4视频号
Integer platform = (Integer) m.get("type");
if (platform != null) {
m.replace("type", platform == 1 ? "抖音" : (platform == 2 ? "快手" : (platform == 3 ? "朋友圈" : platform == 4 ? "朋友圈" : null)));
}
}
Workbook wb = ExcelUtil.writeToExcelByList(array, records);
OutputStream output = response.getOutputStream();
String fileName = "审核视频数据.xlsx";
try {
fileName = URLEncoder.encode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ";" + "filename*=utf-8''" + fileName);
wb.write(output);
output.close();
}
@Data
static class VVParam {
@NotNull(message = "id不能为空")
@ -136,6 +192,22 @@ public class VideoController {
public Result valid(@Validated @RequestBody VVParam param) {
int id = param.getId();
Video video = videoService.getById(id);
String platForm = "未知平台";
switch (video.getType()) {
case 1:
platForm = "抖音";
break;
case 2:
platForm = "快手";
break;
case 3:
platForm = "朋友圈";
break;
case 4:
platForm = "视频号";
break;
default:
}
if (null == video) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到该视频");
}
@ -155,7 +227,7 @@ public class VideoController {
if (!op) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "无效操作");
}
appMessage.setDescription("您的抖音传播效果审核未通过,未通过原因:" + param.getReason() + "。");
appMessage.setDescription("您的" + platForm +"传播效果审核未通过,未通过原因:" + param.getReason() + "。");
// 企业微信消息通知
if (touser != null) {
appMessage.setTouser(touser);
@ -184,29 +256,14 @@ public class VideoController {
up.set("updateAt", LocalDateTime.now());
videoService.update(up);
userEffectRecordsMapper.saveEffectResult(new UserEffectRecords().setUserId(video.getUserId()).setEffectResultTran(effectResult - originEffectResult).setCreateAt(LocalDateTime.now()));
String platForm = "未知平台";
switch (video.getType()) {
case 1:
platForm = "抖音";
break;
case 2:
platForm = "快手";
break;
case 3:
platForm = "朋友圈";
break;
case 4:
platForm = "视频号";
break;
default:
}
appMessage.setDescription("恭喜您," + platForm + "传播效果审核通过,平台评定传播值为" + effectResult + "。");
// 企业微信消息通知
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"))));
String format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.of("GMT+08:00")));
content_item.add(new JSONObject().fluentPut("key", "审核时间").fluentPut("value", format));
httpUtil.qywxMessage(httpUtil.qywxGetToken(), touser, "传播效果审核", null, appMessage.getUrl(), content_item);
}
AppMessageUtil.sendMessage(appMessage);

@ -25,7 +25,7 @@ public interface ReferenceMapper extends BaseMapper<Reference> {
@Select("<script>" +
"SELECT t1.id " +
"from reference t1 " +
"WHERE t1.id "+
"WHERE t1.id and t1.isDeleted = 0 "+
"<if test='tagIdList !=null and tagIdList.size()!=0'> " +
"and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in " +
@ -53,7 +53,7 @@ public interface ReferenceMapper extends BaseMapper<Reference> {
@Select("<script>" +
"SELECT date_format(t1.creatAt, '%Y-%m-%d') dat " +
"from reference t1 " +
"WHERE t1.id "+
"WHERE t1.id and t1.isDeleted = 0 "+
"<if test='tagIdList !=null and tagIdList.size()!=0'> " +
"and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in " +

@ -30,7 +30,7 @@ public interface UserEffectRecordsMapper extends BaseMapper<UserEffectRecords> {
"GROUP BY departmentId\n" +
"ORDER BY effectValue DESC")
List<Map> rankByDepartment(@Param("ew") Wrapper<UserEffectRecords> queryWrapper);
@Select("SELECT t1.userId,t2.name as title,t2.departmentId,t2.departmentName as subtitle,sum(t1.effectResultTran) as effectValue from userEffectRecords as t1\n" +
@Select("SELECT t1.userId,t2.name as title,t2.departmentId,t2.departmentName as subtitle,IFNULL(sum(t1.effectResultTran),0) as effectValue from userEffectRecords as t1\n" +
"INNER JOIN (SELECT t1.id,t1.name,t2.departmentId,t2.name as departmentName FROM user as t1 left join qywxDepartment as t2 on t1.main_department = t2.departmentId) as t2 on t1.userId = t2.id\n" +
"${ew.customSqlSegment} " +
"GROUP BY userId\n" +

@ -67,7 +67,7 @@ public interface VideoMapper extends BaseMapper<Video> {
"${ew.customSqlSegment}")
List<Map> videoDataByUserTask(@Param("ew") Wrapper<Video> queryWrapper);
// 任务下视频影响值统计
@Select("SELECT t1.id,t1.taskId,t2.title as taskTitle,t1.userId,t3.name as userName,SUM(IFNULL(t1.effectResult,0)) as effectResultSum \n" +
@Select("SELECT t1.id,t1.taskId,t2.title as taskTitle,t1.userId,t3.name as userName,t3.userId as touser,SUM(IFNULL(t1.effectResult,0)) as effectResultSum \n" +
"from video as t1\n" +
"INNER JOIN task as t2 on t1.taskId = t2.id\n" +
"INNER JOIN user as t3 on t1.userId = t3.id\n" +

@ -95,4 +95,11 @@ public class Reference extends Model {
@TableField(exist = false)
private Integer isCollected;
/**
* :01
*/
@Schema(title = "是否删除:0否1是")
@TableField("isDeleted")
private Integer isDeleted;
}

@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -39,16 +42,21 @@ public class UserPointsRecords extends Model {
private Integer userId;
/**
* 1.2.3.线
* 1.2.3.线 4.
*/
private Integer type;
@Schema(title="类型说明")
@TableField(exist = false)
private String typeDSC;
/**
* 1.2.
*/
@TableField("settlementMethod")
private Integer settlementMethod;
@Schema(title="结算方式说明")
@TableField(exist = false)
private String settlementMethodDSC;
/**
*
*/

@ -23,7 +23,7 @@
from reference as t1
LEFT JOIN referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId
LEFT JOIN referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId
WHERE t1.id
WHERE t1.id and t1.isDeleted = 0
<if test="tagIdList !=null and tagIdList.size()!=0 ">
and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in
<foreach collection="tagIdList" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
@ -79,7 +79,7 @@
from reference as t1
LEFT JOIN referenceTag as t2 on t1.id = t2.referenceId LEFT JOIN tag as t3 on t3.id = t2.tagId
LEFT JOIN referenceBrand as t4 on t1.id = t4.referenceId LEFT JOIN brand as t5 on t5.id = t4.brandId
WHERE t1.id
WHERE t1.id and t1.isDeleted = 0
<if test="tagIdList !=null and tagIdList.size()!=0 ">
and t1.id in (SELECT referenceId from referenceTag WHERE referenceTag.tagId in
<foreach collection="tagIdList" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>

Loading…
Cancel
Save