package com.ks.daylucky.service.impl;
|
|
import com.ks.daylucky.dao.ActivityDrawnRecieveNotifyInfoDao;
|
import com.ks.daylucky.exception.ActivityDrawnRecieveNotifyInfoException;
|
import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo;
|
import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService;
|
import com.ks.lib.common.exception.ParamsException;
|
import com.ks.lucky.pojo.DO.LuckyActivityAwardResult;
|
import org.springframework.stereotype.Service;
|
import org.springframework.validation.annotation.Validated;
|
|
import javax.annotation.Resource;
|
import javax.validation.Valid;
|
import java.util.Date;
|
|
@Service
|
public class ActivityDrawnRecieveNotifyInfoServiceImpl implements ActivityDrawnRecieveNotifyInfoService {
|
|
@Resource
|
private ActivityDrawnRecieveNotifyInfoDao activityDrawnRecieveNotifyInfoDao;
|
|
@Validated
|
@Override
|
public void addNotify(@Valid ActivityDrawnRecieveNotifyInfo notifyInfo) throws ParamsException, ActivityDrawnRecieveNotifyInfoException {
|
if (notifyInfo.getCreateTime() == null) {
|
notifyInfo.setCreateTime(new Date());
|
}
|
|
String id = null;
|
switch (notifyInfo.getAwardResult().getState()) {
|
|
case LuckyActivityAwardResult
|
.STATE_NOT_RECIEVE:
|
id = ActivityDrawnRecieveNotifyInfo.createId(notifyInfo.getAwardResult().getId(), ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE);
|
break;
|
|
case LuckyActivityAwardResult
|
.STATE_OUT_OF_DATE:
|
id = ActivityDrawnRecieveNotifyInfo.createId(notifyInfo.getAwardResult().getId(), ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE);
|
break;
|
|
default:
|
return;
|
}
|
//生成主键
|
ActivityDrawnRecieveNotifyInfo oldInfo = activityDrawnRecieveNotifyInfoDao.get(id);
|
if (oldInfo != null) {
|
throw new ActivityDrawnRecieveNotifyInfoException(ActivityDrawnRecieveNotifyInfoException.CODE_EXIST, "通知已经存在");
|
}
|
notifyInfo.setId(id);
|
activityDrawnRecieveNotifyInfoDao.save(notifyInfo);
|
}
|
|
@Override
|
public ActivityDrawnRecieveNotifyInfo getShowNotifyInfo(Long appId, Long uid, Long activityId) {
|
|
return activityDrawnRecieveNotifyInfoDao.getShowNotifyInfo(appId, uid, activityId);
|
}
|
|
@Override
|
public void setNotifyShown(String id) {
|
ActivityDrawnRecieveNotifyInfo update = new ActivityDrawnRecieveNotifyInfo();
|
update.setId(id);
|
update.setShown(true);
|
update.setShowTime(new Date());
|
activityDrawnRecieveNotifyInfoDao.updateSelective(update);
|
}
|
|
@Override
|
public ActivityDrawnRecieveNotifyInfo selectByPrimaryKey(String id) {
|
return activityDrawnRecieveNotifyInfoDao.get(id);
|
}
|
|
|
}
|