Commit fc2e4671 by “Kongxiangkun”

增加积分商城相关代码

parent 36229ad8
...@@ -97,7 +97,7 @@ public interface PointDetailsMapper extends BaseMapper<PointDetails> { ...@@ -97,7 +97,7 @@ public interface PointDetailsMapper extends BaseMapper<PointDetails> {
@Param("companyId") Long companyId, @Param("companyId") Long companyId,
@Param("siteId") Long siteId); @Param("siteId") Long siteId);
Integer selectPointVo(@Param("accountId") Long accountId, @Param("siteId")Long siteId, @Param("type")String type,@Param("toDay")String toDay); Integer selectPointVo(@Param("accountId") Long accountId, @Param("toDay")String toDay);
Integer getAmount(@Param("accountId") Long accountId, @Param("siteId")Long siteId); Integer getAmount(@Param("accountId") Long accountId, @Param("siteId")Long siteId);
......
...@@ -2,10 +2,12 @@ package com.yizhi.application.service.impl; ...@@ -2,10 +2,12 @@ package com.yizhi.application.service.impl;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yizhi.application.constant.PointChangeReasonConstant; import com.yizhi.application.constant.PointChangeReasonConstant;
import com.yizhi.application.constant.PointTypeEnum;
import com.yizhi.application.domain.PointDetails; import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.domain.PointUser; import com.yizhi.application.domain.PointUser;
import com.yizhi.application.mapper.PointDetailsMapper; import com.yizhi.application.mapper.PointDetailsMapper;
...@@ -18,6 +20,7 @@ import com.yizhi.application.service.PointDetailsService; ...@@ -18,6 +20,7 @@ import com.yizhi.application.service.PointDetailsService;
import com.yizhi.application.service.PointUserService; import com.yizhi.application.service.PointUserService;
import com.yizhi.point.application.vo.*; import com.yizhi.point.application.vo.*;
import com.yizhi.point.application.vo.domain.PointDetailsVo; import com.yizhi.point.application.vo.domain.PointDetailsVo;
import com.yizhi.util.application.json.JsonUtil;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -445,41 +448,36 @@ public class PointDetailsServiceImpl extends ServiceImpl<PointDetailsMapper, com ...@@ -445,41 +448,36 @@ public class PointDetailsServiceImpl extends ServiceImpl<PointDetailsMapper, com
@Override @Override
public PointDetailVO getPointDetail(Long accountId,Long siteId){ public PointDetailVO getPointDetail(Long accountId,Long siteId){
PointDetailVO pointDetailVO = new PointDetailVO(); PointDetailVO pointDetailVO = new PointDetailVO();
List<String> pointTypeList = Lists.newArrayList(); //今日获得积分
pointTypeList.add("登录");
pointTypeList.add("阅读文章");
pointTypeList.add("我要投稿");
pointTypeList.add("发表评论");
pointTypeList.add("参加活动");
pointTypeList.add("培训测试");
pointDetailVO.setPoint(0);
String toDay = DateUtil.formatDate(new Date()); String toDay = DateUtil.formatDate(new Date());
Arrays.stream(PointChangeReasonConstant.values()).forEach(e->{ pointDetailVO.setPoint(pointDetailsMapper.selectPointVo(accountId, toDay));
if(pointTypeList.contains(e.getValue())){ //总积分
Integer point = pointDetailsMapper.selectPointVo(accountId,siteId,e.getKey(),toDay); pointDetailVO.setAmount(pointDetailsMapper.getAmount(accountId,siteId).toString());
Integer count = pointDetailsMapper.getCountToDay(accountId,siteId,e.getKey(),toDay); //每日首登
if(Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITCOURSEDONE1.getKey()) Integer loginCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.LOGIN.getKey());
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITEXAMPASSED.getKey()) pointDetailVO.addPoint(PointChangeReasonConstant.POINT_LOGIN.getKey(), PointChangeReasonConstant.POINT_LOGIN.getValue(),
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITCALENDARDONE.getKey())){ loginCount, (loginCount != null && loginCount > 0) ? 1 : 0);
//每日阅读
}else if(Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITEXAMDONE.getKey()) Integer readCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.READ.getKey());
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITSIGNDONE.getKey())) { pointDetailVO.addPoint(PointChangeReasonConstant.POINT_READ.getKey(), PointChangeReasonConstant.POINT_READ.getValue(),
pointDetailVO.addPoint(e.getKey(), e.getValue(),count, 0); readCount, (readCount != null && readCount >= 5) ? 1 : 0);
}else{ //投稿
pointDetailVO.addPoint(e.getKey(), e.getValue(),count, (point != null && point > 0) ? 1 : 0); Integer pubCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.PUBLICATION.getKey());
} pointDetailVO.addPoint(PointChangeReasonConstant.POINT_DRAFT.getKey(),
if(point!=null&&point>0){ PointChangeReasonConstant.POINT_DRAFT.getValue(), pubCount, 0);
pointDetailVO.setPoint(point+pointDetailVO.getPoint()); //评论
} Integer commentCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.COMMENT.getKey());
} pointDetailVO.addPoint(PointChangeReasonConstant.POINT_COMMENT.getKey(),
}); PointChangeReasonConstant.POINT_COMMENT.getValue(), commentCount, 0);
Integer point = pointDetailsMapper.getAmount(accountId,siteId); //活动
if(point!=null){ Integer activityCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.ACITVITY.getKey());
pointDetailVO.setAmount(point.toString()); pointDetailVO.addPoint(PointChangeReasonConstant.CREDITSIGNDONE.getKey(),
}else{ PointChangeReasonConstant.CREDITSIGNDONE.getValue(), activityCount, 0);
pointDetailVO.setAmount("0"); //培训考试
} Integer examCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.EXAM.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.CREDITEXAMDONE.getKey(),
PointChangeReasonConstant.CREDITEXAMDONE.getValue(), examCount, 0);
log.info("我的积分主页返回对象pointDetailVO:{}", JSONUtil.toJsonStr(pointDetailVO));
return pointDetailVO; return pointDetailVO;
} }
......
...@@ -22,6 +22,7 @@ import com.yizhi.point.application.vo.PointDetailListVO; ...@@ -22,6 +22,7 @@ import com.yizhi.point.application.vo.PointDetailListVO;
import com.yizhi.point.application.vo.PointUserExchangeVO; import com.yizhi.point.application.vo.PointUserExchangeVO;
import com.yizhi.util.application.date.DateUtil; import com.yizhi.util.application.date.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -96,6 +97,10 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -96,6 +97,10 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addPoint(Long accountId, String type, String sourceId){ public void addPoint(Long accountId, String type, String sourceId){
if(accountId == null || StringUtils.isBlank(type) || StringUtils.isBlank(sourceId)){
log.error("增加积分入参异常 accountId:{}, type:{}, sourceId:{}", accountId, type, sourceId);
return;
}
log.info("增加积分入参: accountId:{}, type:{}, sourceId:{}", accountId, type, sourceId); log.info("增加积分入参: accountId:{}, type:{}, sourceId:{}", accountId, type, sourceId);
Long companyId = ContextHolder.get().getCompanyId(); Long companyId = ContextHolder.get().getCompanyId();
Long orgId = ContextHolder.get().getOrgId(); Long orgId = ContextHolder.get().getOrgId();
...@@ -190,10 +195,16 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -190,10 +195,16 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
return null; return null;
} }
if(type.equals(PointTypeEnum.COMMENT.getKey())){ if(type.equals(PointTypeEnum.COMMENT.getKey())){
PointDetails pd = new PointDetails();
pd.setAccountId(accountId);
pd.setLearnType(PointTypeEnum.COMMENT.getKey());
pd.setLearnSource(sourceId);
EntityWrapper<PointDetails> wrapper = new EntityWrapper<PointDetails>(pd);
int cnt = pointDetailsService.selectCount(wrapper);
log.info("评论上架 赠送积分判断此活动是不是首次评论上架:{}", cnt);
if(cnt <= 0) {
return new PointTypeStrategy(PointTypeEnum.COMMENT, sourceId, PointTypeEnum.COMMENT.getPoint());
}
return null; return null;
} }
if(type.equals(PointTypeEnum.ACITVITY.getKey())){ if(type.equals(PointTypeEnum.ACITVITY.getKey())){
......
...@@ -238,18 +238,12 @@ ...@@ -238,18 +238,12 @@
</if> </if>
</select> </select>
<select id="selectPointVo" resultType="java.lang.Integer"> <select id="selectPointVo" resultType="java.lang.Integer">
select select ifnull(sum(point), 0) from point_details where account_id = #{accountId}
sum(pd.`point`) and DATE_FORMAT(create_time, '%Y-%m-%d' ) = #{toDay} and point > 0
from
point_details pd
inner join mq_point_param mpp on
pd.learn_source_id = mpp.source_id
where mpp.account_id =#{accountId} and mpp.site_id =#{siteId} and mpp.event_name =#{type}
and DATE_FORMAT(mpp.create_point_time, '%Y-%m-%d' ) = #{toDay}
</select> </select>
<select id="getAmount" resultType="java.lang.Integer"> <select id="getAmount" resultType="java.lang.Integer">
select select
sum(`point`) ifnull(sum(`point`), 0)
from from
point_details point_details
where account_id =#{accountId} and site_id =#{siteId} where account_id =#{accountId} and site_id =#{siteId}
...@@ -260,7 +254,7 @@ ...@@ -260,7 +254,7 @@
from from
mq_point_param mpp mq_point_param mpp
where mpp.account_id =#{accountId} and mpp.site_id =#{siteId} and mpp.event_name =#{type} where mpp.account_id =#{accountId} and mpp.site_id =#{siteId} and mpp.event_name =#{type}
and DATE_FORMAT(mpp.create_point_time, '%Y-%m-%d' ) = #{toDay} and DATE_FORMAT(mpp.create_point_time, '%Y-%m-%d' ) = #{toDay}
</select> </select>
<select id="getPointDetailsList" resultType="com.yizhi.point.application.vo.PointDetailListVO"> <select id="getPointDetailsList" resultType="com.yizhi.point.application.vo.PointDetailListVO">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment