@ -407,8 +407,8 @@ public class TaskController {
@AdminCheckAuthorityAnnotation ( jurisdictionId = "135" )
@AdminCheckAuthorityAnnotation ( jurisdictionId = "135" )
public Result dele ( @Validated @RequestBody DelTaskParam param ) {
public Result dele ( @Validated @RequestBody DelTaskParam param ) {
Task task = taskService . getById ( param . getId ( ) ) ;
Task task = taskService . getById ( param . getId ( ) ) ;
if ( task . getStatus ( ) ! = 0 ) {
if ( task . getStatus ( ) ! = 0 ) {
return Result . fail ( HttpStatusEnum . CUSTOM_EXCEPTION , "只支持未上线的任务删除" ) ;
return Result . fail ( HttpStatusEnum . CUSTOM_EXCEPTION , "只支持未上线的任务删除" ) ;
}
}
return MybatisPlusUtil . sqlResult ( taskService . removeById ( param . getId ( ) ) , "删除" ) ;
return MybatisPlusUtil . sqlResult ( taskService . removeById ( param . getId ( ) ) , "删除" ) ;
}
}
@ -421,7 +421,7 @@ public class TaskController {
public Result del ( @Validated @RequestBody DetTaskParam param ) {
public Result del ( @Validated @RequestBody DetTaskParam param ) {
UpdateWrapper < Task > ew = new UpdateWrapper < > ( ) ;
UpdateWrapper < Task > ew = new UpdateWrapper < > ( ) ;
ew . eq ( "status" , 1 ) . eq ( "id" , param . getId ( ) )
ew . eq ( "status" , 1 ) . eq ( "id" , param . getId ( ) )
. set ( "status" , 2 ) . set ( "end" , LocalDateTime . now ( ) ) . set ( "updateAt" , LocalDateTime . now ( ) ) ;
. set ( "status" , 2 ) . set ( "end" , LocalDateTime . now ( ) ) . set ( "updateAt" , LocalDateTime . now ( ) ) ;
taskService . update ( ew ) ;
taskService . update ( ew ) ;
videoService . updStatusByTaskId ( param . getId ( ) , LocalDateTime . now ( ) ) ;
videoService . updStatusByTaskId ( param . getId ( ) , LocalDateTime . now ( ) ) ;
return Result . success ( "" , "终止任务完成" ) ;
return Result . success ( "" , "终止任务完成" ) ;
@ -433,16 +433,17 @@ public class TaskController {
private IUserPointsRecordsService userPointsRecordsService ;
private IUserPointsRecordsService userPointsRecordsService ;
@Autowired
@Autowired
private HttpUtil httpUtil ;
private HttpUtil httpUtil ;
@PostMapping ( "/finish" )
@PostMapping ( "/finish" )
@ResponseBody
@ResponseBody
public Result test ( @Validated @RequestBody DelTaskParam param ) {
public Result finish ( @Validated @RequestBody DelTaskParam param ) {
// 任务结束7天时, 自动结算积分
// 任务结束7天时, 自动结算积分
QueryWrapper < Task > qw = new QueryWrapper < > ( ) ;
QueryWrapper < Task > qw = new QueryWrapper < > ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime weekAgo = now . minusWeeks ( 0 ) ;
LocalDateTime weekAgo = now . minusWeeks ( 0 ) ;
AppMessage appMessage = new AppMessage ( ) . setTitle ( "任务积分结算" ) ;
AppMessage appMessage = new AppMessage ( ) . setTitle ( "任务积分结算" ) ;
String format = weekAgo . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) ;
String format = weekAgo . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) ;
qw . eq ( "status" , 2 ) . eq ( "id" , param . getId ( ) ) ;
qw . eq ( "status" , 2 ) . eq ( "id" , param . getId ( ) ) ;
List < Task > taskList = taskService . list ( qw ) ;
List < Task > taskList = taskService . list ( qw ) ;
String qywxAccessToken = httpUtil . qywxGetToken ( ) ;
String qywxAccessToken = httpUtil . qywxGetToken ( ) ;
// 处理每个任务的传播值
// 处理每个任务的传播值
@ -479,12 +480,12 @@ public class TaskController {
httpUtil . qywxMessage ( qywxAccessToken , touser , "任务积分结算" , null , appMessage . getUrl ( ) , content_item ) ;
httpUtil . qywxMessage ( qywxAccessToken , touser , "任务积分结算" , null , appMessage . getUrl ( ) , content_item ) ;
}
}
AppMessageUtil . sendMessage ( appMessage ) ;
AppMessageUtil . sendMessage ( appMessage ) ;
recordsList . add ( new UserPointsRecords ( ) . setSettlementMethod ( 1 ) . setPoints ( point ) . setType ( 1 ) . setRemarks ( "任务完成结算:" + t . getTitle ( ) ) . setCreateDate ( now ) . setUserId ( userId ) ) ;
recordsList . add ( new UserPointsRecords ( ) . setSettlementMethod ( 1 ) . setPoints ( point ) . setType ( 1 ) . setRemarks ( "任务完成结算:" + t . getTitle ( ) ) . setCreateDate ( now ) . setUserId ( userId ) ) ;
}
}
}
}
// 按任务生成积分流水记录
// 按任务生成积分流水记录
userPointsRecordsService . saveBatch ( recordsList ) ;
userPointsRecordsService . saveBatch ( recordsList ) ;
taskService . update ( new UpdateWrapper < Task > ( ) . eq ( "id" , taskId ) . set ( "status" , 3 ) ) ;
taskService . update ( new UpdateWrapper < Task > ( ) . eq ( "id" , taskId ) . set ( "status" , 3 ) ) ;
}
}
return Result . success ( ) ;
return Result . success ( ) ;
}
}
@ -559,19 +560,50 @@ public class TaskController {
return Result . success ( res ) ;
return Result . success ( res ) ;
}
}
@Data
static class TaskDataParam {
@NotNull ( message = "id不能为空" )
@Min ( value = 1 , message = "id最小值为1" )
@Schema ( title = "任务id" )
private Integer id ;
@Schema ( title = "用户名称" )
private String userName ;
@Schema ( title = "部门名称" )
private String departmentName ;
}
@Operation ( summary = "任务传播数据" )
@Operation ( summary = "任务传播数据" )
@PostMapping ( "taskEffect" )
@PostMapping ( "taskEffect" )
@AdminTokenValid
@AdminTokenValid
public Result taskEffect ( @Validated @RequestBody DetTaskParam param ) {
public Result taskEffect ( @Validated @RequestBody DetTaskParam param ) {
List < Map > maps = taskService . taskEffectData ( new QueryWrapper < Task > ( ) . eq ( "t2.id" , param . getId ( ) ) ) ;
Integer taskId = param . getId ( ) ;
JSONObject obj = new JSONObject ( ) ;
List < Map > maps = taskService . taskEffectData ( new QueryWrapper < Task > ( ) . eq ( "t2.id" , taskId ) ) ;
obj . put ( "taskEffect" , maps . get ( 0 ) ) ;
Map map = maps . get ( 0 ) ;
if ( maps ! = null ) {
if ( map ! = null ) {
QueryWrapper < Task > qw = new QueryWrapper < > ( ) ;
map . remove ( "userId" ) ;
qw . eq ( "t2.id" , param . getId ( ) ) . groupBy ( "t1.userId" ) ;
map . remove ( "userName" ) ;
obj . put ( "userEffectList" , taskService . taskEffectData ( qw ) ) ;
Integer taskUserSum = 0 ;
if ( taskDepartmentService . count ( new QueryWrapper < TaskDepartment > ( ) . eq ( "taskId" , taskId ) ) = = 0 ) {
taskUserSum = userService . count ( ) ;
} else {
taskUserSum = taskService . taskUserSum ( taskId ) ;
}
map . put ( "taskUserSum" , taskUserSum ) ;
map . put ( "taskUserNum" , taskService . taskUserNum ( taskId ) ) ;
}
}
return Result . success ( obj ) ;
return Result . success ( map ) ;
}
@Operation ( summary = "任务传播数据" )
@PostMapping ( "taskEffectData" )
@AdminTokenValid
public Result taskEffectData ( @Validated @RequestBody TaskDataParam param ) {
QueryWrapper < Task > qw = new QueryWrapper < > ( ) ;
qw . eq ( "t2.id" , param . getId ( ) ) . groupBy ( "t1.userId" ) ;
qw . like ( param . getUserName ( ) ! = null , "t3.name" , param . getUserName ( ) ) ;
qw . like ( param . getDepartmentName ( ) ! = null , "t4.name" , param . getDepartmentName ( ) ) ;
return Result . success ( taskService . taskEffectData ( qw ) ) ;
}
}
@Data
@Data