| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
|
| | |
|
| | | int expiryDay = 15;
|
| | |
|
| | | SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
|
| | | SystemCoupon coupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
|
| | | if (coupon != null) {
|
| | | expiryDay = coupon.getExpiryDay();
|
| | | }
|
| | |
|
| | | // 结束日期
|
| | | Date endTime = null;
|
| | | try {
|
| | | // 今天在内 减去一天
|
| | | String endDay = DateUtil.plusDay(expiryDay - 1, new Date());
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | endTime = format.parse(endDay);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // 状态初始化
|
| | | userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userSystemCoupon.setUseTime(null);
|
| | |
|
| | | // 有效期时间重新定义
|
| | | userSystemCoupon.setStartTime(new Date());
|
| | | userSystemCoupon.setEndTime(endTime);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
|
| | | }
|