|
|
@@ -3,22 +3,26 @@ package com.tuoheng.api.service.impl; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.tuoheng.api.entity.domain.WestreamScenery; |
|
|
|
import com.tuoheng.api.entity.domain.WestreamVideo; |
|
|
|
import com.tuoheng.api.entity.domain.WestreamVideoUser; |
|
|
|
import com.tuoheng.api.constants.DictConstants; |
|
|
|
import com.tuoheng.api.entity.domain.*; |
|
|
|
import com.tuoheng.api.entity.request.WestreamVideoQuery; |
|
|
|
import com.tuoheng.api.mapper.WestreamVideoMapper; |
|
|
|
import com.tuoheng.api.mapper.WestreamVideoUserMapper; |
|
|
|
import com.tuoheng.api.mapper.*; |
|
|
|
import com.tuoheng.api.service.IWestreamVideoService; |
|
|
|
import com.tuoheng.api.utils.SmsUtil; |
|
|
|
import com.tuoheng.common.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.config.CommonConfig; |
|
|
|
import com.tuoheng.common.utils.CommonUtils; |
|
|
|
import com.tuoheng.common.utils.JsonResult; |
|
|
|
import com.tuoheng.common.utils.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 全民护河学习视频表 服务实现类 |
|
|
|
* |
|
|
@@ -34,6 +38,18 @@ public class WestreamVideoServiceImpl extends BaseServiceImpl<WestreamVideoMappe |
|
|
|
@Autowired |
|
|
|
private WestreamVideoUserMapper westreamVideoUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WestreamUserMapper westreamUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ThDictMapper thDictMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ThDictDataMapper thDictDataMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserPointsDetailMapper userPointsDetailMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult queryPage(WestreamVideoQuery query) { |
|
|
|
if(null == query.getTenantId() || StringUtils.isEmpty(query.getOpenid())){ |
|
|
@@ -66,4 +82,76 @@ public class WestreamVideoServiceImpl extends BaseServiceImpl<WestreamVideoMappe |
|
|
|
|
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JsonResult updateProgress(WestreamVideoQuery query) { |
|
|
|
if(null == query.getTenantId() || StringUtils.isEmpty(query.getOpenid())){ |
|
|
|
return JsonResult.error("参数为空!"); |
|
|
|
} |
|
|
|
|
|
|
|
if(null == query.getVideoId()){ |
|
|
|
return JsonResult.error("视频ID为空!"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WestreamVideoUser westreamVideoUser = westreamVideoUserMapper.selectOne(new LambdaQueryWrapper<WestreamVideoUser>() |
|
|
|
.eq(WestreamVideoUser::getTenantId, query.getTenantId()) |
|
|
|
.eq(WestreamVideoUser::getOpenid, query.getOpenid()) |
|
|
|
.eq(WestreamVideoUser::getVideoId, query.getVideoId()) |
|
|
|
.eq(WestreamVideoUser::getMark, 1)); |
|
|
|
|
|
|
|
if(ObjectUtil.isNull(westreamVideoUser)){ |
|
|
|
WestreamVideoUser westreamVideoUserAdd = new WestreamVideoUser(); |
|
|
|
BeanUtils.copyProperties(query, westreamVideoUserAdd); |
|
|
|
westreamVideoUserAdd.setCreateTime(new Date()); |
|
|
|
westreamVideoUserMapper.insert(westreamVideoUserAdd); |
|
|
|
}else { |
|
|
|
westreamVideoUser.setVideoProgress(query.getVideoProgress()); |
|
|
|
westreamVideoUser.setStatus(query.getStatus()); |
|
|
|
westreamVideoUserMapper.updateById(westreamVideoUser); |
|
|
|
//视频学习完成,开始计算积分 |
|
|
|
if(2 == query.getStatus()){ |
|
|
|
|
|
|
|
//查询学习视频 积分设置 |
|
|
|
//发送短信 |
|
|
|
ThDict thDict = thDictMapper.selectOne(new LambdaQueryWrapper<ThDict>() |
|
|
|
.eq(ThDict::getTenantId, query.getTenantId()) |
|
|
|
.eq(ThDict::getCode, DictConstants.POINTS_RULE_CODE) |
|
|
|
.eq(ThDict::getMark, 1)); |
|
|
|
if(ObjectUtils.isNotNull(thDict)){ |
|
|
|
ThDictData thDictData = thDictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>() |
|
|
|
.eq(ThDictData::getDictId, thDict.getId()) |
|
|
|
.eq(ThDictData::getName, DictConstants.VIDEO)); |
|
|
|
if(ObjectUtils.isNotNull(thDictData)){ |
|
|
|
if(StringUtils.isNotEmpty(thDictData.getValue())){ |
|
|
|
//查询用户昵称 |
|
|
|
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() |
|
|
|
.eq(WestreamUser::getTenantId, query.getTenantId()) |
|
|
|
.eq(WestreamUser::getOpenid, query.getOpenid()) |
|
|
|
.eq(WestreamUser::getMark, 1)); |
|
|
|
|
|
|
|
|
|
|
|
//积分明细表入库 |
|
|
|
UserPointsDetail userPointsDetail = new UserPointsDetail(); |
|
|
|
BeanUtils.copyProperties(query,userPointsDetail); |
|
|
|
userPointsDetail.setNickname(westreamUser.getNickname()); |
|
|
|
userPointsDetail.setPointsChange(Integer.parseInt(thDictData.getValue())); |
|
|
|
userPointsDetail.setPointsTime(new Date()); |
|
|
|
userPointsDetail.setChangeName("观看学习视频"+query.getVideoId()); |
|
|
|
userPointsDetail.setType(1); |
|
|
|
userPointsDetailMapper.insert(userPointsDetail); |
|
|
|
|
|
|
|
//TODO 对接商城 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
} |