|
@@ -5,6 +5,7 @@ import java.util.List;
|
|
|
|
|
|
import com.caimei.modules.hehe.entity.CmHeheReduction;
|
|
|
import com.caimei.modules.hehe.entity.CmHeheReductionUser;
|
|
|
+import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -45,7 +46,26 @@ public class CmHeheReductionService extends CrudService<CmHeheReductionDao, CmHe
|
|
|
public void save(CmHeheReduction cmHeheReduction) {
|
|
|
super.save(cmHeheReduction);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保证一个时间只存在唯一的活动
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean checkTime(String reductionId, Date startTime1, Date endTime1) {
|
|
|
+ List<CmHeheReduction> allTimeList = cmHeheReductionDao.getAllTime();
|
|
|
+ for (int i = 0; i < allTimeList.size(); i++) {
|
|
|
+ CmHeheReduction time = allTimeList.get(i);
|
|
|
+ Date startTime2 = time.getStartTime();
|
|
|
+ Date endTime2 = time.getEndTime();
|
|
|
+ boolean sameTimeFlag = (startTime1.compareTo(startTime2) <= 0 && endTime1.compareTo(startTime2) >= 0)
|
|
|
+ || (startTime2.compareTo(startTime1) <= 0 && endTime2.compareTo(startTime1) >= 0);
|
|
|
+ if (sameTimeFlag && !(StringUtils.isNotEmpty(reductionId) && reductionId.equals(time.getId()))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(readOnly = false)
|
|
|
public void delete(CmHeheReduction cmHeheReduction) {
|
|
|
super.delete(cmHeheReduction);
|