Authored by Lixiaodi

提交未抽奖service

/**
*
*/
package com.yoho.activity.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.common.vo.ActVoteResultVO;
import com.yoho.activity.dal.ActVoteResultMapper;
import com.yoho.activity.dal.model.ActVoteResult;
import com.yoho.activity.service.IActVoteResultService;
import com.yoho.core.common.utils.DateUtil;
/**
* 描述:
*/
@Service
public class LotteryServiceImpl implements IActVoteResultService {
static Logger log = LoggerFactory.getLogger(LotteryServiceImpl.class);
@Resource
private ActVoteResultMapper actVoteResultMapper;
@Override
public ApiResponse selectVoteNumByUid(int uid) throws Exception {
log.info("selectVoteNumByUid with uid={}", uid);
List<ActVoteResult> votedList = actVoteResultMapper.selectActVoteResultByUid(uid);
log.info("selectVoteNumByUid success. uid={}", uid);
return new ApiResponse(votedList);
}
@Override
public ApiResponse insertVoteResultInfo(ActVoteResultVO voteResult) throws Exception {
log.info("insertVoteResultInfo with voteResult={}", voteResult);
List<ActVoteResult> votedList = actVoteResultMapper.selectActVoteResultByUid(voteResult.getUid());
if (CollectionUtils.isNotEmpty(votedList) && votedList.size() > 0) {
log.warn("insertVoteResultInfo error voteResult={}", voteResult);
return new ApiResponse(201, "您已经投过票了");
}
List<ActVoteResult> actVoteResult = JSON.parseArray(voteResult.getItemIds(), ActVoteResult.class);
if (actVoteResult.size() == 0) {
log.warn("insertVoteResultInfo with actVoteResult empty. ");
return new ApiResponse(201, "您还没有投票");
}
for (ActVoteResult act : actVoteResult) {
act.setCreateTime(DateUtil.getCurrentTimeSecond());
}
actVoteResultMapper.insertBatch(actVoteResult);
log.info("insertVoteResultInfo success. voteResult={}", voteResult);
return new ApiResponse();
}
}
... ...