|
@@ -1,28 +1,25 @@
|
|
|
package com.caimei365.commodity.service.impl;
|
|
|
|
|
|
import com.caimei365.commodity.components.PriceUtilService;
|
|
|
-import com.caimei365.commodity.mapper.CouponMapper;
|
|
|
-import com.caimei365.commodity.mapper.PageMapper;
|
|
|
-import com.caimei365.commodity.mapper.PriceMapper;
|
|
|
-import com.caimei365.commodity.mapper.ShopMapper;
|
|
|
+import com.caimei365.commodity.mapper.*;
|
|
|
import com.caimei365.commodity.model.ResponseJson;
|
|
|
import com.caimei365.commodity.model.dto.CollarCouponsDto;
|
|
|
import com.caimei365.commodity.model.dto.RedeemCouponsDto;
|
|
|
import com.caimei365.commodity.model.po.CouponClubPo;
|
|
|
import com.caimei365.commodity.model.po.CouponRedemptionCodePo;
|
|
|
-import com.caimei365.commodity.model.vo.ActivityCouponVo;
|
|
|
-import com.caimei365.commodity.model.vo.CouponVo;
|
|
|
-import com.caimei365.commodity.model.vo.ProductItemVo;
|
|
|
-import com.caimei365.commodity.model.vo.ShopVo;
|
|
|
+import com.caimei365.commodity.model.vo.*;
|
|
|
import com.caimei365.commodity.service.CouponService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -43,6 +40,8 @@ public class CouponServiceImpl implements CouponService {
|
|
|
private PriceMapper priceMapper;
|
|
|
@Resource
|
|
|
private PriceUtilService priceUtilService;
|
|
|
+ @Resource
|
|
|
+ private MessageCenterMapper messageCenterMapper;
|
|
|
|
|
|
/**
|
|
|
* 已领取优惠券中心
|
|
@@ -131,7 +130,7 @@ public class CouponServiceImpl implements CouponService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) {
|
|
|
+ public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) throws ParseException {
|
|
|
Integer id = couponMapper.findCouponClubByUserId(couponsDto.getUserId(), couponsDto.getCouponId());
|
|
|
if (id != null && id > 0) {
|
|
|
return ResponseJson.error("已经领取过了", null);
|
|
@@ -144,6 +143,9 @@ public class CouponServiceImpl implements CouponService {
|
|
|
return ResponseJson.error("未成为超级会员无法领取超级会员券!");
|
|
|
}
|
|
|
}
|
|
|
+ Timerw(couponsDto.getUserId());
|
|
|
+ Timeto(couponsDto.getUserId());
|
|
|
+ Timeth(couponsDto.getUserId());
|
|
|
CouponClubPo couponClub = new CouponClubPo();
|
|
|
BeanUtils.copyProperties(couponsDto, couponClub);
|
|
|
couponClub.setStatus("1");
|
|
@@ -153,6 +155,119 @@ public class CouponServiceImpl implements CouponService {
|
|
|
return ResponseJson.success("领取成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 每天12点判断
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 12 * * ?")
|
|
|
+ private Void Timerw(Integer userId) throws ParseException {
|
|
|
+ if(userId!=null){
|
|
|
+ UserVo user= messageCenterMapper.clubList(userId);
|
|
|
+ CouponVo coupon= messageCenterMapper.CouponList(userId);
|
|
|
+ Date date=new Date();
|
|
|
+ Date d=coupon.getStartDate();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1=sdf.parse(endTime);
|
|
|
+ Long s=(da1.getTime()-d.getTime())/24/60/60/1000;
|
|
|
+ Long t=(date.getTime()-da1.getTime())/24/60/60/1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenter messageCenter=new MessageCenter();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ if(s>15){
|
|
|
+ if(t==7){
|
|
|
+ messageCenter.setShopID(null);
|
|
|
+ messageCenter.setClubID(user.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setContent(t+"天后过期");
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天下午3点判断
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 10 * * ?")
|
|
|
+ private Void Timeto(Integer userId) throws ParseException {
|
|
|
+ if(userId!=null){
|
|
|
+ UserVo user= messageCenterMapper.clubList(userId);
|
|
|
+ CouponVo coupon= messageCenterMapper.CouponList(userId);
|
|
|
+ Date d=new Date();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1=sdf.parse(endTime);
|
|
|
+ Long s=(da1.getTime()-d.getTime())/24/60/60/1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenter messageCenter=new MessageCenter();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+ if(s==1){
|
|
|
+
|
|
|
+ messageCenter.setShopID(null);
|
|
|
+ messageCenter.setClubID(user.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setContent(null);
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 15 * * ?")
|
|
|
+ private Void Timeth(Integer userId) throws ParseException {
|
|
|
+ if(userId!=null){
|
|
|
+ UserVo user= messageCenterMapper.clubList(userId);
|
|
|
+ CouponVo coupon= messageCenterMapper.CouponList(userId);
|
|
|
+ Date date=new Date();
|
|
|
+ Date d=coupon.getStartDate();
|
|
|
+ //1.日期格式
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String endTime = sdf.format(coupon.getEndDate());
|
|
|
+ //2.某天的日期
|
|
|
+ Date da1=sdf.parse(endTime);
|
|
|
+ Long s=(da1.getTime()-d.getTime())/24/60/60/1000;
|
|
|
+ Long t=(date.getTime()-da1.getTime())/24/60/60/1000;
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String current = dateFormat.format(new Date());
|
|
|
+ MessageCenter messageCenter=new MessageCenter();
|
|
|
+ //推送信息中心-账户通知
|
|
|
+
|
|
|
+ if(t==3){
|
|
|
+ messageCenter.setShopID(null);
|
|
|
+ messageCenter.setClubID(user.getClubId());
|
|
|
+ messageCenter.setUserType(1);
|
|
|
+ messageCenter.setMessageType(4);
|
|
|
+ messageCenter.setCouponType(2);
|
|
|
+ messageCenter.setContent(t+"天后下架");
|
|
|
+ messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
|
|
|
+ messageCenter.setTime(current);
|
|
|
+ messageCenterMapper.addMessageCenter(messageCenter);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public ResponseJson<CouponVo> redeemCoupons(RedeemCouponsDto redeemCouponsDto) {
|