yujian
2019-03-06 fec4f669c779151ba6d1699c053bad4575f4060f
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -15,7 +15,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper;
import com.yeshi.fanli.entity.bus.user.DeviceLotteryRecord;
@@ -28,6 +27,8 @@
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.entity.push.PushCoupon;
import com.yeshi.fanli.entity.push.PushCouponRecord;
import com.yeshi.fanli.entity.system.SystemCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -46,6 +47,8 @@
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.push.PushCouponRecordService;
import com.yeshi.fanli.service.inter.push.PushCouponService;
import com.yeshi.fanli.service.inter.user.DeviceLotteryRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
@@ -126,7 +129,14 @@
   
   @Resource
   private CommonOrderCountService commonOrderCountService;
   @Resource
   private PushCouponService pushCouponService;
   @Resource
   private PushCouponRecordService pushCouponRecordService;
   @Override
   public int insertSelective(UserSystemCoupon record) {
      return userSystemCouponMapper.insertSelective(record);
@@ -186,7 +196,8 @@
      }
      
      // 结束日期
      String endDay = DateUtil.plusDay(coupon.getExpiryDay(), new Date());
      // 今天在内  减去一天
      String endDay = DateUtil.plusDay(coupon.getExpiryDay() - 1, new Date());
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
      Date endTime = format.parse(endDay);
      
@@ -596,6 +607,13 @@
      if (userSystemCoupon == null) {
         throw new UserSystemCouponException(1, "券数据不正确");
      }
      Integer state = userSystemCoupon.getState();
      Integer stateActivated = userSystemCoupon.getStateActivated();
      if (UserSystemCoupon.STATE_CAN_USE != state || 1 != stateActivated) {
         throw new UserSystemCouponException(1, "该券不能被使用");
      }
      Long couponUid = userSystemCoupon.getUid();
      if (!uid.equals(couponUid)) {
@@ -658,6 +676,12 @@
      UserSystemCoupon userSystemCoupon = selectByPrimaryKey(id);
      if (userSystemCoupon == null) {
         throw new UserSystemCouponException(1, "券信息不存在");
      }
      Integer state = userSystemCoupon.getState();
      Integer stateActivated = userSystemCoupon.getStateActivated();
      if (UserSystemCoupon.STATE_CAN_USE != state || 1 != stateActivated) {
         throw new UserSystemCouponException(1, "该券不能被使用");
      }
      // 系统券信息
@@ -1040,9 +1064,10 @@
      return userRecordVO;
   }
   
   @Transactional
   @Override
   public void activatedWelfareFreeCoupon(Long uid) {
   public void activatedWelfareFreeCoupon(Long uid, String fromNickName) {
      
      LogHelper.test("券激活:"+uid);
      if (uid == null) {
@@ -1080,7 +1105,9 @@
         
         // 消息推送
         try {
            UserInfo userInfo = userInfoService.selectByPKey(uid);
            UserInfo userInfo = new UserInfo();
            userInfo.setId(uid);
            userInfo.setNickName(fromNickName);
            
            userOtherMsgNotificationService.welfareCouponActive(userSystemCoupon, userInfo);
         } catch(Exception e) {
@@ -1212,7 +1239,8 @@
         // 结束日期
         Date endTime = null;
         try {
            String endDay = DateUtil.plusDay(expiryDay, new Date());
            // 今天在内  减去一天
            String endDay = DateUtil.plusDay(expiryDay - 1, new Date());
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            endTime = format.parse(endDay);
         } catch (ParseException e) {
@@ -1323,7 +1351,8 @@
      // 结束日期
      Date endTime = null;
      try {
         String endDay = DateUtil.plusDay(expiryDay, new Date());
         // 今天在内  减去一天
         String endDay = DateUtil.plusDay(expiryDay - 1, new Date());
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         endTime = format.parse(endDay);
      } catch (ParseException e) {
@@ -1365,6 +1394,8 @@
      
      // 获取额外信息
      UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
      // 已经抽过奖的或者已经进入过抽奖页面的
      if (userInfoExtra != null && userInfoExtra.getLotteryNewbies() != null) {
         return;
      }
@@ -1401,8 +1432,8 @@
            }
         }
         
         // 结束日期
         String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay(), new Date());
         // 今天在内  减去一天
         String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay() - 1, new Date());
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         Date endTime = format.parse(endDay);
         
@@ -1456,5 +1487,8 @@
      userInfoExtraService.saveUserInfoExtra(userInfoExtra);
   
   }
}