@ -68,11 +68,12 @@ public class TaskUController {
private ICustomerActionNoteService customerActionNoteService ;
private ICustomerActionNoteService customerActionNoteService ;
@Autowired
@Autowired
private IVideoEffectSettingService videoEffectSettingService ;
private IVideoEffectSettingService videoEffectSettingService ;
@Data
@Data
static class ListTParam {
static class ListTParam {
private int pageNum ;
private int pageNum ;
private int pageSize ;
private int pageSize ;
@Schema ( title = "用户的任务状态" , description = "0待领取; 1进行中; 2已完成 ")
@Schema ( title = "用户的任务状态" , description = "0待领取; 1进行中; 2已完成 ; 3已结束; 4我的任务 ")
@Min ( value = 0 )
@Min ( value = 0 )
@Max ( value = 2 )
@Max ( value = 2 )
private Integer status ;
private Integer status ;
@ -97,17 +98,42 @@ public class TaskUController {
@TokenValid
@TokenValid
public Result list ( @Validated @RequestBody ListTParam param , @RequestHeader String token ) {
public Result list ( @Validated @RequestBody ListTParam param , @RequestHeader String token ) {
QueryWrapper < Reference > qw = new QueryWrapper < > ( ) ;
QueryWrapper < Reference > qw = new QueryWrapper < > ( ) ;
Integer status = param . getStatus ( ) ;
String openid = new JwtUtil ( ) . parseOpenid ( token ) ;
String openid = new JwtUtil ( ) . parseOpenid ( token ) ;
// 提供给前端三个状态: 0待领取; 1进行中; 2已完成; 3已结束; 4我的任务
// 与sql表中task的status意义不同, 这里status--
// 0:0待领取(未接受任务且任务status为1);
// 1:进行中(已接受任务且任务status为1);
// 2:已完成(已接受任务且任务status2);
// 3:已结束(未接受任务且任务status为2);
// 4:我的任务(已接受任务且任务status2);
Integer status = param . getStatus ( ) ;
qw . ne ( "t1.status" , 0 ) ;
qw . ne ( "t1.status" , 0 ) ;
if ( null ! = status ) {
switch ( status ) {
qw . eq ( "t1.status" , status = = 2 ? 2 : 1 ) ;
case 0 :
if ( status = = 0 ) {
qw . eq ( "t1.status" , 1 ) . ne ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
qw . ne ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
break ;
} else if ( status = = 1 ) {
case 1 :
qw . eq ( "t1.status" , 1 ) . eq ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
break ;
case 2 :
qw . eq ( "t1.status" , 2 ) . eq ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
break ;
case 3 :
qw . eq ( "t1.status" , 2 ) . ne ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
break ;
case 4 :
qw . eq ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
qw . eq ( "(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )" , 1 ) ;
}
break ;
default :
}
}
// if (null != status) {
// qw.eq("t1.status", status == 2 ? 2 : 1);
// if (status == 0) {
// qw.ne("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1);
// } else if (status == 1) {
// qw.eq("(SELECT count(*)!=0 from userTask as t4,user as t5 WHERE t1.id = t4.taskId and t4.userId = t5.id and t5.openid = +'" + openid + "' )", 1);
// }
// }
if ( null ! = param . getMonth ( ) ) {
if ( null ! = param . getMonth ( ) ) {
qw . between ( "t1.creatAt" , LocalDateTime . now ( ) . minusMonths ( param . getMonth ( ) ) , LocalDateTime . now ( ) ) ;
qw . between ( "t1.creatAt" , LocalDateTime . now ( ) . minusMonths ( param . getMonth ( ) ) , LocalDateTime . now ( ) ) ;
} else {
} else {
@ -226,21 +252,21 @@ public class TaskUController {
public Result communicationEffect ( @Validated @RequestBody DetTaskParam param , @RequestHeader ( value = "token" ) String token ) {
public Result communicationEffect ( @Validated @RequestBody DetTaskParam param , @RequestHeader ( value = "token" ) String token ) {
String openid = new JwtUtil ( ) . parseOpenid ( token ) ;
String openid = new JwtUtil ( ) . parseOpenid ( token ) ;
QueryWrapper < Video > qw = new QueryWrapper < > ( ) ;
QueryWrapper < Video > qw = new QueryWrapper < > ( ) ;
qw . eq ( "taskId" , param . getId ( ) ) ;
qw . eq ( "taskId" , param . getId ( ) ) ;
qw . eq ( "t2.openid" , openid ) ;
qw . eq ( "t2.openid" , openid ) ;
List < Map > videoDataSum = videoService . videoDataByUserTask ( qw ) ;
List < Map > videoDataSum = videoService . videoDataByUserTask ( qw ) ;
Map map = videoDataSum . get ( 0 ) ;
Map map = videoDataSum . get ( 0 ) ;
if ( map = = null | | map . size ( ) = = 0 ) {
if ( map = = null | | map . size ( ) = = 0 ) {
return Result . fail ( HttpStatusEnum . CUSTOM_EXCEPTION , "数据异常" ) ;
return Result . fail ( HttpStatusEnum . CUSTOM_EXCEPTION , "数据异常" ) ;
}
}
List < VideoEffectSetting > list = videoEffectSettingService . list ( ) ;
List < VideoEffectSetting > list = videoEffectSettingService . list ( ) ;
Integer effectResult =
Integer effectResult =
cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "playNumSum" ) ) . toString ( ) ) , list . get ( 0 ) . getEffectTimes ( ) )
cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "playNumSum" ) ) . toString ( ) ) , list . get ( 0 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "commendNumSum" ) ) . toString ( ) ) , list . get ( 1 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "commendNumSum" ) ) . toString ( ) ) , list . get ( 1 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "collectionNumSum" ) ) . toString ( ) ) , list . get ( 2 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "collectionNumSum" ) ) . toString ( ) ) , list . get ( 2 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "commentNumSum" ) ) . toString ( ) ) , list . get ( 3 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "commentNumSum" ) ) . toString ( ) ) , list . get ( 3 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "reSendNumSum" ) ) . toString ( ) ) , list . get ( 4 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "reSendNumSum" ) ) . toString ( ) ) , list . get ( 4 ) . getEffectTimes ( ) )
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "recommendNumSum" ) ) . toString ( ) ) , list . get ( 5 ) . getEffectTimes ( ) ) ;
+ cal ( Integer . parseInt ( ( ( BigDecimal ) map . get ( "recommendNumSum" ) ) . toString ( ) ) , list . get ( 5 ) . getEffectTimes ( ) ) ;
List < Map > rewardRule = rewardRuleService . listByTaskId ( param . getId ( ) ) ;
List < Map > rewardRule = rewardRuleService . listByTaskId ( param . getId ( ) ) ;
// 根据传播值计算规则算出奖励
// 根据传播值计算规则算出奖励
int point = 0 ;
int point = 0 ;
@ -252,7 +278,7 @@ public class TaskUController {
qw . groupBy ( "type" ) ;
qw . groupBy ( "type" ) ;
List < Map > videoData = videoService . videoDataByUserTask ( qw ) ;
List < Map > videoData = videoService . videoDataByUserTask ( qw ) ;
JSONObject obj = new JSONObject ( ) ;
JSONObject obj = new JSONObject ( ) ;
obj . fluentPut ( "point" , point ) . fluentPut ( "effectResult" , effectResult ) . fluentPut ( "videoData" , videoData ) ;
obj . fluentPut ( "point" , point ) . fluentPut ( "effectResult" , effectResult ) . fluentPut ( "videoData" , videoData ) ;
return Result . success ( obj , "请求成功" ) ;
return Result . success ( obj , "请求成功" ) ;
}
}