| | |
| | | }, null);
|
| | | System.out.println(result);
|
| | | } catch (Exception e) {
|
| | | throw new Exception();
|
| | | e.printStackTrace();
|
| | | throw e;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | sendBackGiveCoupon(list);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#giveid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void sendBackByGiveId(Long giveid) {
|
| | | if (giveid == null)
|
| | | return;
|
| | | |
| | | UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.selectByPrimaryKey(giveid);
|
| | | if (giveRecord == null)
|
| | | return;
|
| | | |
| | | if (giveRecord.getState() != null && giveRecord.getState() != UserSystemCouponGiveRecord.STATE_INIT) |
| | | return;
|
| | | |
| | | // 更新赠送记录
|
| | | UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord();
|
| | | updateRecord.setId(giveid);
|
| | | updateRecord.setState(UserSystemCouponGiveRecord.STATE_OVERDUE);
|
| | | userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateRecord);
|
| | | |
| | | // 口令失效
|
| | | tokenRecordService.invalidByCoupon(giveid);
|
| | |
|
| | | Long couponId = giveRecord.getCouponId();
|
| | | if (couponId == null) |
| | | return;
|
| | | |
| | | UserSystemCoupon userCoupon = userSystemCouponMapper.selectByPrimaryKey(couponId);
|
| | | 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.updateByPrimaryKeySelective(userSystemCoupon);
|
| | |
|
| | | // 使用记录
|
| | | UserSystemCouponRecord useRecord = userSystemCouponRecordService.getNearByUserCouponId(couponId);
|
| | | if (useRecord != null) {
|
| | | UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
|
| | | useRecordUpdate.setId(useRecord.getId());
|
| | | useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
|
| | | useRecordUpdate.setUpdateTime(new Date());
|
| | | userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
|
| | | }
|
| | |
|
| | | SystemCoupon systemCoupon = userCoupon.getSystemCoupon();
|
| | | if (systemCoupon != null)
|
| | | systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
|
| | |
|
| | | if (systemCoupon == null)
|
| | | return;
|
| | |
|
| | | // 退回消息
|
| | | String couponName = systemCoupon.getName();
|
| | | if (CouponTypeEnum.freeCouponGive == systemCoupon.getType()) {
|
| | | couponName = "免单券";
|
| | | } else if (CouponTypeEnum.rebatePercentCoupon == systemCoupon.getType()) {
|
| | | couponName = "奖励券";
|
| | | }
|
| | |
|
| | | String beiZhu = "请到我的-福利中心查看";
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
|
| | | msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
|
| | | msgOther.setTitle(couponName + "退回");
|
| | | msgOther.setGiveType("你赠送的" + couponName + "未被成功领取");
|
| | | msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
|
| | | msgOther.setReturnTime(sd.format(new Date()));
|
| | | userOtherMsgNotificationService.tokenGiveMsg(giveRecord.getGiveUid(), beiZhu, msgOther);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void sendBackGiveCoupon(List<UserSystemCouponGiveRecord> overdueList) {
|
| | | for (UserSystemCouponGiveRecord record : overdueList) {
|
| | | if (record.getState() != null && record.getState() != UserSystemCouponGiveRecord.STATE_INIT) |
| | | continue;
|
| | | |
| | | // 更新赠送记录
|
| | | UserSystemCouponGiveRecord updateRecord = new UserSystemCouponGiveRecord();
|
| | | updateRecord.setId(record.getId());
|