Commit 842aac7e by “Kongxiangkun”

增加积分商城相关代码

parent 34a806ff
...@@ -7,11 +7,12 @@ import com.yizhi.application.redis.RedisUtils; ...@@ -7,11 +7,12 @@ import com.yizhi.application.redis.RedisUtils;
import com.yizhi.application.service.MqPointParamService; import com.yizhi.application.service.MqPointParamService;
import com.yizhi.application.service.PointService; import com.yizhi.application.service.PointService;
import com.yizhi.point.application.vo.PointParamVO; import com.yizhi.point.application.vo.PointParamVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController @RestController
public class PointRedisController { public class PointRedisController {
...@@ -46,7 +47,13 @@ public class PointRedisController { ...@@ -46,7 +47,13 @@ public class PointRedisController {
@RequestParam(name = "type",required = false)String type, @RequestParam(name = "type",required = false)String type,
@RequestParam(name = "accountId",required = false)Long accountId, @RequestParam(name = "accountId",required = false)Long accountId,
@RequestParam(name = "sourceId",required = false)String sourceId) { @RequestParam(name = "sourceId",required = false)String sourceId) {
try {
log.info("增加积分新接口入参 type:{}, accountId:{}, sourceId:{}", type, accountId, sourceId);
pointService.addPoint(accountId, type, sourceId); pointService.addPoint(accountId, type, sourceId);
} catch (Exception e) {
e.printStackTrace();
log.error("增加积分新接口发生异常:{}",e.getMessage());
}
} }
} }
package com.yizhi.application.service.impl; package com.yizhi.application.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.constant.PointTypeEnum; import com.yizhi.application.constant.PointTypeEnum;
...@@ -14,6 +15,7 @@ import com.yizhi.application.service.PointService; ...@@ -14,6 +15,7 @@ import com.yizhi.application.service.PointService;
import com.yizhi.application.service.PointUserService; import com.yizhi.application.service.PointUserService;
import com.yizhi.core.application.context.ContextHolder; import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.util.application.date.DateUtil; import com.yizhi.util.application.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -27,6 +29,7 @@ import java.util.Date; ...@@ -27,6 +29,7 @@ import java.util.Date;
* @author bob123 * @author bob123
* @since 2018-04-20 * @since 2018-04-20
*/ */
@Slf4j
@Service @Service
public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements PointService { public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements PointService {
...@@ -83,6 +86,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -83,6 +86,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements
String accountName = ContextHolder.get().getAccountName(); String accountName = ContextHolder.get().getAccountName();
//执行积分奖励策略进行相应的业务校验 //执行积分奖励策略进行相应的业务校验
PointTypeStrategy strategy = getPointByType(type, accountId); PointTypeStrategy strategy = getPointByType(type, accountId);
log.info("获取赠送积分策略:{}", JSONUtil.toJsonStr(strategy));
if(strategy != null) { if(strategy != null) {
PointUser pu = new PointUser(); PointUser pu = new PointUser();
pu.setUserId(accountId); pu.setUserId(accountId);
...@@ -143,6 +147,7 @@ public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements ...@@ -143,6 +147,7 @@ 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);
if(cnt <= 0) { if(cnt <= 0) {
return new PointTypeStrategy(PointTypeEnum.LOGIN, date); return new PointTypeStrategy(PointTypeEnum.LOGIN, date);
} }
......
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