Commit ac1e0612 by “Kongxiangkun”

增加积分商城相关代码

parent 593f8d04
...@@ -38,4 +38,9 @@ public interface PointApiFeignClients { ...@@ -38,4 +38,9 @@ public interface PointApiFeignClients {
@GetMapping("/api/point/product/list") @GetMapping("/api/point/product/list")
List<PointProductVo> productList(@RequestParam(name = "pageNo" ,required = false ) Integer pageNo, List<PointProductVo> productList(@RequestParam(name = "pageNo" ,required = false ) Integer pageNo,
@RequestParam(name = "pageSize" ,required = false ) Integer pageSize); @RequestParam(name = "pageSize" ,required = false ) Integer pageSize);
@GetMapping("/read/finished")
boolean readFinished(
@RequestParam(name = "accountId" ,required = false ) Long accountId,
@RequestParam(name = "infoId" ,required = false ) String infoId);
} }
...@@ -73,7 +73,7 @@ public class PointApiController { ...@@ -73,7 +73,7 @@ public class PointApiController {
} }
@GetMapping("/read/finished") @GetMapping("/read/finished")
public boolean finished( public boolean readFinished(
@RequestParam(name = "accountId" ,required = false ) Long accountId, @RequestParam(name = "accountId" ,required = false ) Long accountId,
@RequestParam(name = "infoId" ,required = false ) String infoId){ @RequestParam(name = "infoId" ,required = false ) String infoId){
pointService.addPoint(accountId, "point_read", infoId); pointService.addPoint(accountId, "point_read", infoId);
......
...@@ -104,4 +104,6 @@ public interface PointDetailsMapper extends BaseMapper<PointDetails> { ...@@ -104,4 +104,6 @@ public interface PointDetailsMapper extends BaseMapper<PointDetails> {
Integer getCountToDay(@Param("accountId") Long accountId, @Param("siteId")Long siteId, @Param("type")String type,@Param("toDay")String toDay); Integer getCountToDay(@Param("accountId") Long accountId, @Param("siteId")Long siteId, @Param("type")String type,@Param("toDay")String toDay);
List<PointDetailListVO> getPointDetailsList(@Param("page") Page<PointDetailListVO> page, @Param("accountId") Long accountId); List<PointDetailListVO> getPointDetailsList(@Param("page") Page<PointDetailListVO> page, @Param("accountId") Long accountId);
int getCountTodayByLearnType(@Param("accountId") Long accountId, @Param("learnType")String learnType);
} }
...@@ -9,6 +9,7 @@ import com.yizhi.application.domain.Point; ...@@ -9,6 +9,7 @@ import com.yizhi.application.domain.Point;
import com.yizhi.application.domain.PointDetails; import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.domain.PointTypeStrategy; import com.yizhi.application.domain.PointTypeStrategy;
import com.yizhi.application.domain.PointUser; import com.yizhi.application.domain.PointUser;
import com.yizhi.application.mapper.PointDetailsMapper;
import com.yizhi.application.mapper.PointMapper; import com.yizhi.application.mapper.PointMapper;
import com.yizhi.application.mapper.PointProductMapper; import com.yizhi.application.mapper.PointProductMapper;
import com.yizhi.application.mapper.PointUserMapper; import com.yizhi.application.mapper.PointUserMapper;
...@@ -51,6 +52,8 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -51,6 +52,8 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
private PointUserMapper pointUserMapper; private PointUserMapper pointUserMapper;
@Autowired @Autowired
private PointProductMapper pointProductMapper; private PointProductMapper pointProductMapper;
@Autowired
private PointDetailsMapper pointDetailsMapper;
@Override @Override
public Point pointList(Long companyId, Long siteId) { public Point pointList(Long companyId, Long siteId) {
...@@ -95,7 +98,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -95,7 +98,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
Long siteId = ContextHolder.get().getSiteId(); Long siteId = ContextHolder.get().getSiteId();
String accountName = ContextHolder.get().getAccountName(); String accountName = ContextHolder.get().getAccountName();
//执行积分奖励策略进行相应的业务校验 //执行积分奖励策略进行相应的业务校验
PointTypeStrategy strategy = getPointByType(type, accountId); PointTypeStrategy strategy = getPointByType(type, accountId, sourceId);
log.info("获取赠送积分策略:{}", JSONUtil.toJsonStr(strategy)); log.info("获取赠送积分策略:{}", JSONUtil.toJsonStr(strategy));
if(strategy != null) { if(strategy != null) {
PointUser pu = new PointUser(); PointUser pu = new PointUser();
...@@ -146,7 +149,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -146,7 +149,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
} }
} }
public PointTypeStrategy getPointByType(String type, Long accountId){ public PointTypeStrategy getPointByType(String type, Long accountId, String sourceId){
PointTypeStrategy strategy = null; PointTypeStrategy strategy = null;
if(type.equals(PointTypeEnum.LOGIN.getKey())){ if(type.equals(PointTypeEnum.LOGIN.getKey())){
//查询当天是否首次登录,奖励积分 //查询当天是否首次登录,奖励积分
...@@ -157,13 +160,17 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -157,13 +160,17 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
pd.setLearnSource(date); pd.setLearnSource(date);
EntityWrapper<PointDetails> wrapper = new EntityWrapper<PointDetails>(pd); EntityWrapper<PointDetails> wrapper = new EntityWrapper<PointDetails>(pd);
int cnt = pointDetailsService.selectCount(wrapper); int cnt = pointDetailsService.selectCount(wrapper);
log.info("赠送积分判断是否为首次登录:{}", cnt); log.info("登录 赠送积分判断是否为首次登录:{}", cnt);
if(cnt <= 0) { if(cnt <= 0) {
return new PointTypeStrategy(PointTypeEnum.LOGIN, date); return new PointTypeStrategy(PointTypeEnum.LOGIN, date);
} }
} }
if(type.equals(PointTypeEnum.READ.getKey())){ if(type.equals(PointTypeEnum.READ.getKey())){
return null; int cnt = pointDetailsMapper.getCountTodayByLearnType(accountId, type);
log.info("阅读文章 赠送积分判断当日是否超过次数:{}", cnt);
if(cnt <= 5){
return new PointTypeStrategy(PointTypeEnum.READ, sourceId);
}
} }
if(type.equals(PointTypeEnum.PUBLICATION.getKey())){ if(type.equals(PointTypeEnum.PUBLICATION.getKey())){
return null; return null;
......
...@@ -268,4 +268,12 @@ ...@@ -268,4 +268,12 @@
where account_id = #{accountId} order by time desc where account_id = #{accountId} order by time desc
</select> </select>
<select id="getCountTodayByLearnType" resultType="java.lang.Integer">
select count(*) from point_details where
account_id = #{accountId}
and learn_type =#{learnType}
and DATE_FORMAT(time, '%Y-%m-%d' ) = DATE_FORMAT(now(), '%Y-%m-%d')
</select>
</mapper> </mapper>
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