Commit fc2e4671 by “Kongxiangkun”

增加积分商城相关代码

parent 36229ad8
......@@ -97,7 +97,7 @@ public interface PointDetailsMapper extends BaseMapper<PointDetails> {
@Param("companyId") Long companyId,
@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);
......
......@@ -2,10 +2,12 @@ package com.yizhi.application.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.yizhi.application.constant.PointChangeReasonConstant;
import com.yizhi.application.constant.PointTypeEnum;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.domain.PointUser;
import com.yizhi.application.mapper.PointDetailsMapper;
......@@ -18,6 +20,7 @@ import com.yizhi.application.service.PointDetailsService;
import com.yizhi.application.service.PointUserService;
import com.yizhi.point.application.vo.*;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import com.yizhi.util.application.json.JsonUtil;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;
......@@ -445,41 +448,36 @@ public class PointDetailsServiceImpl extends ServiceImpl<PointDetailsMapper, com
@Override
public PointDetailVO getPointDetail(Long accountId,Long siteId){
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());
Arrays.stream(PointChangeReasonConstant.values()).forEach(e->{
if(pointTypeList.contains(e.getValue())){
Integer point = pointDetailsMapper.selectPointVo(accountId,siteId,e.getKey(),toDay);
Integer count = pointDetailsMapper.getCountToDay(accountId,siteId,e.getKey(),toDay);
if(Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITCOURSEDONE1.getKey())
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITEXAMPASSED.getKey())
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITCALENDARDONE.getKey())){
}else if(Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITEXAMDONE.getKey())
||Objects.equals(e.getKey(),PointChangeReasonConstant.CREDITSIGNDONE.getKey())) {
pointDetailVO.addPoint(e.getKey(), e.getValue(),count, 0);
}else{
pointDetailVO.addPoint(e.getKey(), e.getValue(),count, (point != null && point > 0) ? 1 : 0);
}
if(point!=null&&point>0){
pointDetailVO.setPoint(point+pointDetailVO.getPoint());
}
}
});
Integer point = pointDetailsMapper.getAmount(accountId,siteId);
if(point!=null){
pointDetailVO.setAmount(point.toString());
}else{
pointDetailVO.setAmount("0");
}
pointDetailVO.setPoint(pointDetailsMapper.selectPointVo(accountId, toDay));
//总积分
pointDetailVO.setAmount(pointDetailsMapper.getAmount(accountId,siteId).toString());
//每日首登
Integer loginCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.LOGIN.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.POINT_LOGIN.getKey(), PointChangeReasonConstant.POINT_LOGIN.getValue(),
loginCount, (loginCount != null && loginCount > 0) ? 1 : 0);
//每日阅读
Integer readCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.READ.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.POINT_READ.getKey(), PointChangeReasonConstant.POINT_READ.getValue(),
readCount, (readCount != null && readCount >= 5) ? 1 : 0);
//投稿
Integer pubCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.PUBLICATION.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.POINT_DRAFT.getKey(),
PointChangeReasonConstant.POINT_DRAFT.getValue(), pubCount, 0);
//评论
Integer commentCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.COMMENT.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.POINT_COMMENT.getKey(),
PointChangeReasonConstant.POINT_COMMENT.getValue(), commentCount, 0);
//活动
Integer activityCount = pointDetailsMapper.getCountTodayByLearnType(accountId, PointTypeEnum.ACITVITY.getKey());
pointDetailVO.addPoint(PointChangeReasonConstant.CREDITSIGNDONE.getKey(),
PointChangeReasonConstant.CREDITSIGNDONE.getValue(), activityCount, 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;
}
......
......@@ -22,6 +22,7 @@ import com.yizhi.point.application.vo.PointDetailListVO;
import com.yizhi.point.application.vo.PointUserExchangeVO;
import com.yizhi.util.application.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -96,6 +97,10 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
@Transactional(rollbackFor = Exception.class)
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);
Long companyId = ContextHolder.get().getCompanyId();
Long orgId = ContextHolder.get().getOrgId();
......@@ -190,10 +195,16 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
return null;
}
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;
}
if(type.equals(PointTypeEnum.ACITVITY.getKey())){
......
......@@ -238,18 +238,12 @@
</if>
</select>
<select id="selectPointVo" resultType="java.lang.Integer">
select
sum(pd.`point`)
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 ifnull(sum(point), 0) from point_details where account_id = #{accountId}
and DATE_FORMAT(create_time, '%Y-%m-%d' ) = #{toDay} and point > 0
</select>
<select id="getAmount" resultType="java.lang.Integer">
select
sum(`point`)
ifnull(sum(`point`), 0)
from
point_details
where account_id =#{accountId} and site_id =#{siteId}
......
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