zhangjinli 3 years ago
parent d4738af7f4
commit cba1d520db

@ -407,10 +407,10 @@ public class TaskController {
public Result taskUserEffect(@Validated @RequestBody TaskUserParam param) {
QueryWrapper<Task> qw = new QueryWrapper<>();
qw.eq("t1.userId",param.getUserId()).groupBy("t1.userId");
List<Map> maps = taskService.taskEffectData(qw);
JSONObject taskEffect = taskService.taskEffect(qw);
JSONObject obj = new JSONObject();
obj.put("userEffect",maps.get(0));
if(maps!=null) {
obj.put("userEffect",taskEffect);
if(taskEffect!=null) {
QueryWrapper<Video> qw2 = new QueryWrapper<>();
qw2.eq("taskId",param.getId()).eq("userId",param.getUserId());
obj.put("userEffectDetail", videoService.list(qw2));

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zh.project0512.annotation.tokenValid;
import com.zh.project0512.model.UserTask;
import com.zh.project0512.model.Video;
import com.zh.project0512.service.IUserAccountService;
import com.zh.project0512.service.IUserService;
import com.zh.project0512.service.IUserTaskService;
import com.zh.project0512.service.IVideoService;
@ -46,6 +47,8 @@ public class VideoUController {
private IUserService userService;
@Autowired
private IUserTaskService userTaskService;
@Autowired
private IUserAccountService userAccountService;
@Data
static class UserAddParam {
@ -66,15 +69,21 @@ public class VideoUController {
public Result userAdd(@Validated @RequestBody UserAddParam param, @RequestHeader("token") @Parameter(name = "登录token") String token) {
Claims claims = new JwtUtil().parseJWT(token);
Integer useId = userService.selByOpenid(claims.getId()).getId();
// 校验用户和用户账号
if (useId == null) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到该用户");
}
Integer userAccountStatus = userAccountService.userAccountStatus(useId, param.getType());
if (1 != userAccountStatus) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "账号不可用");
}
// 校验任务状态
Integer taskStatus = userTaskService.userTaskStatus(useId, param.getId());
if(taskStatus ==null){
if (taskStatus == null) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "用户未接受任务");
}else if(taskStatus == 0){
} else if (taskStatus == 0) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "任务未开始");
}else if(taskStatus == 2){
} else if (taskStatus == 2) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "任务已结束");
}
videoService.save(new Video().setUserId(useId).setTaskId(param.getId()).setType(param.getType()).setUrl(param.getUrl()).setCreatAt(LocalDateTime.now()));
@ -91,11 +100,11 @@ public class VideoUController {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到该用户");
}
QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("userId",useId);
Integer taskId = obj.getInteger("taskId");
if(taskId != null){
queryWrapper.eq("taskId",taskId);
queryWrapper.eq("userId", useId);
Integer taskId = obj.getInteger("taskId");
if (taskId != null) {
queryWrapper.eq("taskId", taskId);
}
return Result.success(videoService.page(MybatisPlusUtil.SetPage(obj),queryWrapper));
return Result.success(videoService.page(MybatisPlusUtil.SetPage(obj), queryWrapper));
}
}

@ -62,7 +62,7 @@ public interface TaskMapper extends BaseMapper<Task> {
@Select("SELECT SUM(t1.playNum) as playNumSum,SUM(t1.commendNum) as commendNumSum,\n" +
"SUM(t1.collectionNum) as collectionNumSum,SUM(t1.commentNum) as commentNumSum,\n" +
"SUM(t1.reSendNum) as reSendNumSum,SUM(t1.recommendNum) as recommendNumSum,SUM(t1.effectResult) as effectResultSum,t1.userId,\n" +
"t2.title as taskTitle,t3.name as userName,t4.name as departmentName from video as t1 INNER JOIN task as t2 on t2.id = 31 and t2.id = t1.taskId\n" +
"t2.title as taskTitle from video as t1 INNER JOIN task as t2 on t2.id = 31 and t2.id = t1.taskId\n" +
"LEFT JOIN user as t3 on t1.userId = t3.id\n" +
"LEFT JOIN qywxDepartment as t4 on t3.main_department = t4.departmentId " +
"${ew.customSqlSegment}")

@ -32,4 +32,7 @@ public interface UserAccountMapper extends BaseMapper<UserAccount> {
"</if>" +
"</script>")
IPage<Map> listAll(IPage<Map> page, @Param("ew") Wrapper<UserAccount> queryWrapper);
@Select("SELECT t1.status FROM userAccount t1 " +
"INNER JOIN user t2 on t2.id = t1.userId and t2.id = #{userId} and t1.platform = #{platform}")
Integer userAccountStatus(int userId,int platform);
}

@ -1,5 +1,6 @@
package com.zh.project0512.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.model.Reference;
@ -23,5 +24,6 @@ public interface ITaskService extends IService<Task> {
IPage<Integer> idList(IPage iPage,String openid, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper);
List<Map> list(String openid,List<Integer> list, List<Integer> tagIdList, List<Integer> brandIdList, @Param("ew") Wrapper<Reference> queryWrapper);
Task detailById(String openid,int id);
JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper);
List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper);
}

@ -18,4 +18,5 @@ import java.util.Map;
*/
public interface IUserAccountService extends IService<UserAccount> {
IPage<Map> listAll(IPage<Map> page, @Param("ew") Wrapper<UserAccount> queryWrapper);
Integer userAccountStatus(int userId,int platform);
}

@ -1,5 +1,6 @@
package com.zh.project0512.serviceImpl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.model.Reference;
@ -39,6 +40,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
public Task detailById(String openid,int id){
return taskMapper.detailById(openid,id);
}
public JSONObject taskEffect(@Param("ew") Wrapper<Task> queryWrapper){
return taskMapper.taskEffect(queryWrapper);
}
public List<Map> taskEffectData(@Param("ew") Wrapper<Task> queryWrapper){
return taskMapper.taskEffectData(queryWrapper);
}

@ -24,7 +24,12 @@ import java.util.Map;
public class UserAccountServiceImpl extends ServiceImpl<UserAccountMapper, UserAccount> implements IUserAccountService {
@Autowired
private UserAccountMapper userAccountMapper;
public IPage<Map> listAll(IPage<Map> page, @Param("ew") Wrapper<UserAccount> queryWrapper){
return userAccountMapper.listAll(page,queryWrapper);
public IPage<Map> listAll(IPage<Map> page, @Param("ew") Wrapper<UserAccount> queryWrapper) {
return userAccountMapper.listAll(page, queryWrapper);
}
public Integer userAccountStatus(int userId, int platform) {
return userAccountMapper.userAccountStatus(userId, platform);
}
}

Loading…
Cancel
Save