传播效果

master
kanade 3 years ago
parent 1ef28658ac
commit 93d928b207

@ -10,6 +10,7 @@ import com.zh.project0512.controller.manage.ReferenceController;
import com.zh.project0512.model.*;
import com.zh.project0512.model.validatedDemo.TaskValidGroup1;
import com.zh.project0512.model.validatedDemo.TaskValidGroup2;
import com.zh.project0512.model.vo.CommunicationEffectVo;
import com.zh.project0512.service.*;
import com.zh.project0512.utils.CustomUtil;
import com.zh.project0512.utils.JwtUtil;
@ -185,5 +186,18 @@ public class TaskUController {
}
return Result.success(iPage);
}
/**
*
* @param token token
* @return
*/
@Operation(summary = "传播效果")
@PostMapping("/communicationEffect")
@tokenValid
public Result<CommunicationEffectVo> communicationEffect(@RequestHeader(value = "token") String token) {
String openid = new JwtUtil().parseOpenid(token);
return Result.success(customerActionNoteService.communicationEffect(openid),"请求成功");
}
}

@ -120,7 +120,7 @@ public class User extends Model {
/**
*
*/
@TableField("lastLoginAt")
@TableField("historyPoints")
@Schema(title = "历史积分")
private Integer historyPoints;

@ -0,0 +1,114 @@
package com.zh.project0512.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Vo
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommunicationEffectVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Schema(title = "获得积分")
private Integer points;
/**
*
*/
@Schema(title = "抖音播放量")
private Integer dyPlayNum;
/**
*
*/
@Schema(title = "抖音点赞量")
private Integer dyCommendNum;
/**
*
*/
@Schema(title = "抖音收藏量")
private Integer dyCollectionNum;
/**
*
*/
@Schema(title = "抖音评论量")
private Integer dyCommentNum;
/**
*
*/
@Schema(title = "快手播放量")
private Integer ksPlayNum;
/**
*
*/
@Schema(title = "快手点赞量")
private Integer ksCommendNum;
/**
*
*/
@Schema(title = "快手收藏量")
private Integer ksCollectionNum;
/**
*
*/
@Schema(title = "快手评论量")
private Integer ksCommentNum;
/**
*
*/
@Schema(title = "朋友圈点赞量")
private Integer pyqCommendNum;
/**
*
*/
@Schema(title = "朋友圈评论量")
private Integer pyqCommentNum;
/**
*
*/
@Schema(title = "视频号点赞量")
private Integer sphCommendNum;
/**
*
*/
@Schema(title = "视频号转发次数")
private Integer sphReSendNum;
/**
*
*/
@Schema(title = "视频号推荐量")
private Integer sphRecommendNum;
/**
*
*/
@Schema(title = "视频号评论量")
private Integer sphCommentNum;
public Integer getCommunicationNumDy(){
return dyPlayNum + dyCollectionNum + dyCommendNum +dyCommentNum;
}
public Integer getCommunicationNumKs(){
return ksPlayNum +ksCollectionNum + ksCommendNum + ksCommentNum;
}
public Integer getCommunicationNumPyq(){
return pyqCommendNum + pyqCommentNum + sphCommendNum + sphReSendNum;
}
public Integer getCommunicationNumSph(){
return sphRecommendNum + sphCommentNum;
}
public Integer getCommunicationNumAll(){
return getCommunicationNumDy() + getCommunicationNumKs() + getCommunicationNumPyq() + getCommunicationNumSph();
}
}

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.model.CustomerActionNote;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zh.project0512.model.Reference;
import com.zh.project0512.model.vo.CommunicationEffectVo;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@ -19,4 +20,11 @@ import java.util.Map;
*/
public interface ICustomerActionNoteService extends IService<CustomerActionNote> {
IPage<Map> pageList(IPage page,String openid, @Param("ew") Wrapper<CustomerActionNote> queryWrapper);
/**
*
* @param openid openid
* @return
*/
CommunicationEffectVo communicationEffect(String openid);
}

@ -1,16 +1,19 @@
package com.zh.project0512.serviceImpl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.project0512.model.CustomerActionNote;
import com.zh.project0512.mapper.CustomerActionNoteMapper;
import com.zh.project0512.model.Reference;
import com.zh.project0512.mapper.*;
import com.zh.project0512.model.*;
import com.zh.project0512.model.vo.CommunicationEffectVo;
import com.zh.project0512.service.ICustomerActionNoteService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@ -23,9 +26,94 @@ import java.util.Map;
*/
@Service
public class CustomerActionNoteServiceImpl extends ServiceImpl<CustomerActionNoteMapper, CustomerActionNote> implements ICustomerActionNoteService {
@Autowired
private CustomerActionNoteMapper customerActionNoteMapper;
@Resource
CustomerActionNoteMapper customerActionNoteMapper;
@Resource
UserMapper userMapper;
@Resource
VideoMapper videoMapper;
@Resource
RewardRuleTemplateMapper rewardRuleTemplateMapper;
@Resource
RewardRuleMapper rewardRuleMapper;
public IPage<Map> pageList(IPage page,String openid, @Param("ew") Wrapper<CustomerActionNote> queryWrapper){
return customerActionNoteMapper.pageList(page,openid,queryWrapper);
}
@Override
public CommunicationEffectVo communicationEffect(String openid) {
CommunicationEffectVo communicationEffectVo = new CommunicationEffectVo();
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("openid",openid);
User user = userMapper.selectOne(queryWrapper);
//平台1抖音2快手3朋友圈4视频号
Video dyVideo = findVideoByUserId(user.getId(),1);
communicationEffectVo.setDyPlayNum(dyVideo.getPlayNum());
communicationEffectVo.setDyCommendNum(dyVideo.getCommendNum());
communicationEffectVo.setDyCollectionNum(dyVideo.getCollectionNum());
communicationEffectVo.setDyCommentNum(dyVideo.getCommentNum());
Video ksVideo = findVideoByUserId(user.getId(),2);
communicationEffectVo.setKsPlayNum(ksVideo.getPlayNum());
communicationEffectVo.setKsCommendNum(ksVideo.getCommendNum());
communicationEffectVo.setKsCollectionNum(ksVideo.getCollectionNum());
communicationEffectVo.setKsCommentNum(ksVideo.getCommentNum());
Video pyqVideo = findVideoByUserId(user.getId(),3);
communicationEffectVo.setPyqCommendNum(pyqVideo.getCommendNum());
communicationEffectVo.setPyqCommentNum(pyqVideo.getCommentNum());
Video sphVideo = findVideoByUserId(user.getId(),4);
communicationEffectVo.setSphCommendNum(sphVideo.getCommendNum());
communicationEffectVo.setSphReSendNum(sphVideo.getReSendNum());
communicationEffectVo.setSphRecommendNum(sphVideo.getRecommendNum());
communicationEffectVo.setSphCommentNum(sphVideo.getCommentNum());
//查询默认模版
QueryWrapper<RewardRuleTemplate> queryWrapper3 = new QueryWrapper<>();
queryWrapper3.eq("isDefault",1);
RewardRuleTemplate rewardRuleTemplate = rewardRuleTemplateMapper.selectOne(queryWrapper3);
if (rewardRuleTemplate == null){
// Integer communicationNumAll = communicationEffectVo.getCommunicationNumAll();
communicationEffectVo.setPoints(0);
return communicationEffectVo;
}
Integer points = findPointByCommunicationNum(rewardRuleTemplate.getId(),communicationEffectVo.getCommunicationNumAll());
communicationEffectVo.setPoints(points);
return communicationEffectVo;
}
/**
*
* @param templateId Id
* @param communicationNum
* @return
*/
private Integer findPointByCommunicationNum(Integer templateId, Integer communicationNum) {
QueryWrapper<RewardRule> queryWrapper4 = new QueryWrapper<>();
queryWrapper4.eq("templateId",templateId);
queryWrapper4.le("limitNum",communicationNum);
queryWrapper4.orderByDesc("limitNum");
queryWrapper4.last("limit 1");
RewardRule rewardRule = rewardRuleMapper.selectOne(queryWrapper4);
if (rewardRule == null){
return 0;
}
return rewardRule.getReward();
}
/**
*
* @param userId id
* @param type 1234
* @return
*/
private Video findVideoByUserId(Integer userId, int type) {
QueryWrapper<Video> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.eq("type",1);
queryWrapper2.eq("userId",userId);
queryWrapper2.select("IFNULL(SUM(playNum),0) as playNum,IFNULL(SUM(commendNum),0) as commendNum,IFNULL(SUM(collectionNum),0) as collectionNum,IFNULL(SUM(commentNum),0) as commentNum,IFNULL(SUM(reSendNum),0) as reSendNum,IFNULL(SUM(recommendNum),0) as recommendNum");
return videoMapper.selectOne(queryWrapper2);
}
}

Loading…
Cancel
Save