Commit 842aac7e by “Kongxiangkun”

增加积分商城相关代码

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