|
@@ -4,6 +4,8 @@ import java.util.Date;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.TenantEntryActivitiesDao;
|
|
|
import com.ym.mec.biz.dal.entity.TenantEntryActivities;
|
|
@@ -16,11 +18,11 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
public class TenantEntryActivitiesServiceImpl extends BaseServiceImpl<Integer, TenantEntryActivities> implements TenantEntryActivitiesService {
|
|
|
|
|
|
@Autowired
|
|
|
- private TenantEntryActivitiesDao tenantEntryActivitesDao;
|
|
|
+ private TenantEntryActivitiesDao tenantEntryActivitiesDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, TenantEntryActivities> getDAO() {
|
|
|
- return tenantEntryActivitesDao;
|
|
|
+ return tenantEntryActivitiesDao;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -32,25 +34,39 @@ public class TenantEntryActivitiesServiceImpl extends BaseServiceImpl<Integer, T
|
|
|
|
|
|
Date date = new Date();
|
|
|
if (tenantEntryActivites.getId() != null) {
|
|
|
- TenantEntryActivities orginTenantEntryActivites = tenantEntryActivitesDao.get(tenantEntryActivites.getId());
|
|
|
+ TenantEntryActivities orginTenantEntryActivites = tenantEntryActivitiesDao.get(tenantEntryActivites.getId());
|
|
|
|
|
|
if (orginTenantEntryActivites == null) {
|
|
|
throw new BizException("操作失败,请检查输入参数");
|
|
|
}
|
|
|
tenantEntryActivites.setCreateTime(orginTenantEntryActivites.getCreateTime());
|
|
|
tenantEntryActivites.setUpdateTime(date);
|
|
|
- tenantEntryActivitesDao.update(tenantEntryActivites);
|
|
|
+ tenantEntryActivitiesDao.update(tenantEntryActivites);
|
|
|
} else {
|
|
|
tenantEntryActivites.setCreateTime(date);
|
|
|
tenantEntryActivites.setUpdateTime(date);
|
|
|
- tenantEntryActivitesDao.insert(tenantEntryActivites);
|
|
|
+ tenantEntryActivitiesDao.insert(tenantEntryActivites);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public boolean enter(Integer userId, Integer activitiesId) {
|
|
|
- return false;
|
|
|
+ TenantEntryActivities tenantEntryActivities = tenantEntryActivitiesDao.get(activitiesId);
|
|
|
+ if (tenantEntryActivities == null) {
|
|
|
+ throw new BizException("活动不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ // 判断活动是否有效
|
|
|
+ if (tenantEntryActivities.getDelFlag() == true || date.before(tenantEntryActivities.getStartDate()) || date.after(tenantEntryActivities.getEndDate())) {
|
|
|
+ throw new BizException("活动已结束或未开始");
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否满足条件
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
}
|