| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void updateCounponInvalid(List<UserSystemCoupon> list) {
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | for (UserSystemCoupon userSystemCoupon : list) {
|
| | | UserSystemCoupon userCoupon = new UserSystemCoupon();
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_OVERDUE);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | |
|
| | | SystemCoupon baseCoupon = userSystemCoupon.getSystemCoupon();
|
| | | if (baseCoupon == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | baseCoupon = systemCouponService.selectByPrimaryKey(baseCoupon.getId());
|
| | | if (baseCoupon == null || baseCoupon.getId() == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
|
| | | userOtherMsgNotificationService.welfareCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
|
| | | userOtherMsgNotificationService.freeSheetCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
|
| | | userOtherMsgNotificationService.rewardCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | }else if (baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
|
| | | userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponBuy);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.freeCouponGive) {
|
| | | userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponGive);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void sendBackTimeOutCoupon(Long uid) {
|
| | | // 超过10分钟 未被匹配的券
|
| | | List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (UserSystemCouponRecord couponRecord : list) {
|
| | | // 更新状态:匹配超时
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
|
| | | couponRecord.setUpdateTime(new Date());
|
| | | userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
|
| | |
|
| | | UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
|
| | | // 状态初始化
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userSystemCoupon.setUseTime(null);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | |
| | | return isfree;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 退回券 初始数据
|
| | | * |
| | | * @param userSystemCoupon
|
| | | */
|
| | | public void sendBackCoupon(UserSystemCoupon userCoupon, UserSystemCouponRecord record) throws Exception {
|
| | | if (userCoupon == null)
|
| | | return;
|
| | | |
| | | Integer state = userCoupon.getState();
|
| | | if (state != UserSystemCoupon.STATE_IN_USE) |
| | | return;
|
| | | |
| | | Date now = new Date();
|
| | | Date endTime = userCoupon.getEndTime();
|
| | | if (endTime != null && endTime.getTime() < now.getTime()) {
|
| | | // 过期
|
| | | List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
|
| | | list.add(userCoupon);
|
| | | updateCounponInvalid(list);
|
| | | return;
|
| | | }
|
| | | |
| | | // 退回券
|
| | | UserSystemCoupon userSystemCoupon = new UserSystemCoupon();
|
| | | userSystemCoupon.setId(userCoupon.getId());
|
| | | userSystemCoupon.setGive(false);
|
| | | userSystemCoupon.setUseTime(null);
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
|
| | | |
| | | // 使用记录
|
| | | if (record != null) {
|
| | | UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
|
| | | useRecordUpdate.setId(record.getId());
|
| | | useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
|
| | | useRecordUpdate.setUpdateTime(new Date());
|
| | | userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
|
| | | |
| | | if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
|
| | | } else if (CouponTypeEnum.freeCouponBuy.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.couponDrawBack(userSystemCoupon, record.getOrderNo(), MsgTypeOtherTypeEnum.freeCouponBuy);
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void updateCounponInvalid(List<UserSystemCoupon> list) {
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (UserSystemCoupon userSystemCoupon : list) {
|
| | | UserSystemCoupon userCoupon = new UserSystemCoupon();
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_OVERDUE);
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | |
|
| | | SystemCoupon baseCoupon = userSystemCoupon.getSystemCoupon();
|
| | | if (baseCoupon == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | baseCoupon = systemCouponService.selectByPrimaryKey(baseCoupon.getId());
|
| | | if (baseCoupon == null || baseCoupon.getId() == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
|
| | | userOtherMsgNotificationService.welfareCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
|
| | | userOtherMsgNotificationService.freeSheetCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
|
| | | userOtherMsgNotificationService.rewardCouponAlreadyOutOfDate(userSystemCoupon);
|
| | | }else if (baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
|
| | | userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponBuy);
|
| | | } else if (baseCoupon.getType() == CouponTypeEnum.freeCouponGive) {
|
| | | userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponGive);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 退回券 初始数据
|
| | | * |
| | | * @param userSystemCoupon
|
| | | */
|
| | | public void sendBackCoupon(UserSystemCoupon userCoupon, UserSystemCouponRecord record) throws Exception {
|
| | | if (userCoupon == null)
|
| | | return;
|
| | | |
| | | Integer state = userCoupon.getState();
|
| | | if (state != UserSystemCoupon.STATE_IN_USE) |
| | | return;
|
| | | |
| | | Date now = new Date();
|
| | | Date endTime = userCoupon.getEndTime();
|
| | | if (endTime != null && endTime.getTime() < now.getTime()) {
|
| | | // 过期
|
| | | List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
|
| | | list.add(userCoupon);
|
| | | updateCounponInvalid(list);
|
| | | return;
|
| | | }
|
| | | |
| | | // 退回券
|
| | | UserSystemCoupon userSystemCoupon = new UserSystemCoupon();
|
| | | userSystemCoupon.setId(userCoupon.getId());
|
| | | userSystemCoupon.setGive(false);
|
| | | userSystemCoupon.setUseTime(null);
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
|
| | | |
| | | // 使用记录
|
| | | if (record != null) {
|
| | | UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
|
| | | useRecordUpdate.setId(record.getId());
|
| | | useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
|
| | | useRecordUpdate.setUpdateTime(new Date());
|
| | | userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
|
| | | |
| | | if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
|
| | | } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
|
| | | } else if (CouponTypeEnum.freeCouponBuy.name().equals(record.getCouponType())) {
|
| | | userOtherMsgNotificationService.couponDrawBack(userSystemCoupon, record.getOrderNo(), MsgTypeOtherTypeEnum.freeCouponBuy);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Transactional
|
| | | @Override
|
| | | public void sendBackTimeOutCoupon(Long uid) {
|
| | | // 超过10分钟 未被匹配的券
|
| | | List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (UserSystemCouponRecord couponRecord : list) {
|
| | | // 更新状态:匹配超时
|
| | | couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
|
| | | couponRecord.setUpdateTime(new Date());
|
| | | userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
|
| | |
|
| | | UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
|
| | | // 状态初始化
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userSystemCoupon.setUseTime(null);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void sendBackGiveCoupon(List<UserSystemCouponGiveRecord> overdueList) {
|
| | | for (UserSystemCouponGiveRecord record: overdueList) {
|
| | | // 更新赠送记录
|