| @@ -13,6 +13,8 @@ import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -270,6 +272,19 @@ public class WxCouponOrderController extends BaseController { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| String _decodeCouponOrderId = WxCouponOrderCVo.getDecodeExpiredCouponOrderId(couponOrderIdStr); | |||
| if (_decodeCouponOrderId.contains(":")) { | |||
| String[] decodeids = _decodeCouponOrderId.split(":"); | |||
| couponOrderIdStr = decodeids[0]; | |||
| String expiredtimeStr = decodeids[0]; | |||
| Date expiredtime = DateUtils.string2Date(expiredtimeStr).getTime(); | |||
| if (expiredtime.before(new Date())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"码已失效,请重新刷新"); | |||
| } | |||
| } | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| @@ -196,6 +196,22 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(wxCouponOrderCVo); | |||
| } | |||
| @ApiOperation(value = "获取动态id") | |||
| @GetMapping("dynamicId") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "string", paramType = "query", required = true) | |||
| }) | |||
| public ResultData dynamicId(String couponOrderId) { | |||
| if (StringUtils.isBlank(couponOrderId) || couponOrderId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Map retmap = new HashMap(); | |||
| retmap.put("dynamicId", WxCouponOrderCVo.calcuteExpiredCouponOrderId(couponOrderId)); | |||
| retmap.put("expiredSeconds", WxCouponOrderCVo.expiredSeconds); | |||
| return new ResultData(retmap); | |||
| } | |||
| @ApiOperation(value = "卡券富文本接口") | |||
| @GetMapping("html") | |||
| @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import com.iformall.common.SortColumn; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.utils.Base64Util; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -12,6 +15,8 @@ import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @JsonIgnoreProperties(value = {"handler"}) | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @@ -154,4 +159,21 @@ public class WxCouponOrderCVo extends WxCouponOrder { | |||
| } | |||
| return priceStr; | |||
| } | |||
| public static final int expiredSeconds = 30; | |||
| public static String calcuteExpiredCouponOrderId(String couponOrderId) { | |||
| if (StringUtils.isBlank(couponOrderId)) { | |||
| return null; | |||
| } | |||
| StringBuffer sb = new StringBuffer().append(couponOrderId).append(":").append(DateUtils.date2String(DateUtils.getSecondsTimeAfter(expiredSeconds, new Date()))); | |||
| return Base64Util.encode(sb.toString().getBytes()); | |||
| } | |||
| public static String getDecodeExpiredCouponOrderId(String couponOrderId) { | |||
| if (StringUtils.isBlank(couponOrderId)) { | |||
| return null; | |||
| } | |||
| return new String(Base64Util.decode(couponOrderId)); | |||
| } | |||
| } | |||
| @@ -382,7 +382,34 @@ public class DateUtils { | |||
| Date date = new Date(myTime * 1000); | |||
| return formatter.format(date); | |||
| } | |||
| /** | |||
| * 获得当前时间前几秒的时间 | |||
| * | |||
| * @param hour | |||
| * 前几小时 | |||
| * @return | |||
| */ | |||
| public static String getSecondsTimeBefore(int seconds, Date myDate) { | |||
| SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| long myTime = (myDate.getTime() / 1000) - seconds; | |||
| Date date = new Date(myTime * 1000); | |||
| return formatter.format(date); | |||
| } | |||
| /** | |||
| * 获得当前时间后几秒的时间 | |||
| * | |||
| * @param hour | |||
| * 后几小时 | |||
| * @return | |||
| */ | |||
| public static Date getSecondsTimeAfter(int seconds, Date myDate) { | |||
| long myTime = (myDate.getTime() / 1000) + seconds; | |||
| Date testDate = new Date(myTime * 1000); | |||
| return testDate; | |||
| } | |||
| /** | |||
| * 获得当前时间后几小时的时间 | |||
| * | |||
| @@ -395,7 +422,7 @@ public class DateUtils { | |||
| Date testDate = new Date(myTime * 1000); | |||
| return testDate; | |||
| } | |||
| /** | |||
| * 获得当前时间后几天的时间 | |||
| * | |||