1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.iamberry.wechat.utils;
- import com.iamberry.wechat.core.entity.coupon.ActivityDate;
- import com.iamberry.wechat.face.admin.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- /**
- * 上朵活动类
- */
- @Component
- public class ActivityUtil {
- @Autowired
- private SystemService systemService;
- private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- /**
- * 获取日期
- * @param type
- * @return
- */
- private ActivityDate initDate(Integer type){
- ActivityDate activityDate = new ActivityDate();
- try {
- switch (type){
- case 1:
- String begin = systemService.selectOneShopRuleByIdDynamic(260).getRuleDesc();
- activityDate.setBeginDate(sd.parse(begin)); ;
- String end = systemService.selectOneShopRuleByIdDynamic(261).getRuleDesc();
- activityDate.setEndDate(sd.parse(end));
- break;
- default:
- activityDate = null;
- break;
- }
- }catch (Exception e){
- activityDate = null;
- e.printStackTrace();
- }
- return activityDate;
- }
- /**
- * 判断是否在注销时间内
- * @return 期限内true;
- */
- public ActivityDate doubleTwelve(){
- ActivityDate activityDate = initDate(1);
- activityDate.setRemark("38女神节注销活动时间");
- if(activityDate == null){
- activityDate.setStatus(false);
- }
- Date date = new Date();
- if (activityDate.getBeginDate().before(date) && date.before(activityDate.getEndDate())){ //beginDate 比 date 早? true :false
- activityDate.setStatus(true);
- return activityDate;
- }
- activityDate.setStatus(false);
- return activityDate;
- }
- }
|