|
|
|
@@ -9,12 +9,14 @@ import com.iformall.domain.po.base.BaseEntity; |
|
|
|
import com.iformall.domain.po.WxCouponOrder; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.WxCardCVo; |
|
|
|
import com.iformall.domain.vo.WxCouponCVo; |
|
|
|
import com.iformall.domain.vo.WxCouponOrderCVo; |
|
|
|
import com.iformall.enums.EnumCouponChannelActivityStatus; |
|
|
|
import com.iformall.enums.EnumCouponOrderStatus; |
|
|
|
import com.iformall.enums.EnumCouponOrderValidStatus; |
|
|
|
import com.iformall.service.MemCouponFromDspService; |
|
|
|
import com.iformall.service.WxCouponOrderService; |
|
|
|
import com.iformall.service.WxCouponService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
@@ -24,7 +26,10 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
import org.springframework.data.redis.core.ValueOperations; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
@@ -35,12 +40,18 @@ import java.util.*; |
|
|
|
public class WxCouponOrderController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponService wxCouponService; |
|
|
|
@Autowired |
|
|
|
private WxCouponOrderService wxCouponOrderService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MemCouponFromDspService memCouponFromDspService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Qualifier("couponDetailRedisTemplate") |
|
|
|
RedisTemplate<String, WxCouponCVo> cdRedisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
StringRedisTemplate stringRedisTemplate; |
|
|
|
|
|
|
|
@@ -82,7 +93,7 @@ public class WxCouponOrderController extends BaseController { |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
@RedisCache(expireTime = 300) |
|
|
|
@RedisCache(expireTime = 100) |
|
|
|
@ApiOperation(value = "券详情接口") |
|
|
|
@GetMapping("detail") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@@ -94,15 +105,46 @@ public class WxCouponOrderController extends BaseController { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderId); |
|
|
|
|
|
|
|
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); |
|
|
|
if (wxCouponOrderCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
if (!wxCouponOrderCVo.getCUserId().equals(getUserId())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); |
|
|
|
} |
|
|
|
WxCouponCVo wxCouponCVo = null; |
|
|
|
String key = "cd:" + wxCouponOrderCVo.getCouponId(); |
|
|
|
ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); |
|
|
|
// 缓存 |
|
|
|
boolean hasKey = cdRedisTemplate.hasKey(key); |
|
|
|
if (hasKey) { |
|
|
|
// 从缓存获取用户信息 |
|
|
|
wxCouponCVo = operations.get(key); |
|
|
|
if (wxCouponCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
} else { |
|
|
|
wxCouponCVo = wxCouponService.getVoById(wxCouponOrderCVo.getCouponId()); |
|
|
|
if (wxCouponCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wxCouponOrderCVo.setType(wxCouponCVo.getType()); |
|
|
|
wxCouponOrderCVo.setCoverImg(wxCouponCVo.getCoverImg()); |
|
|
|
wxCouponOrderCVo.setTitle(wxCouponCVo.getTitle()); |
|
|
|
wxCouponOrderCVo.setSubTitle(wxCouponCVo.getSubTitle()); |
|
|
|
wxCouponOrderCVo.setSalePrice(wxCouponCVo.getSalePrice()); |
|
|
|
wxCouponOrderCVo.setUsePrice(wxCouponCVo.getUsePrice()); |
|
|
|
wxCouponOrderCVo.setPrice(wxCouponCVo.getPrice()); |
|
|
|
wxCouponOrderCVo.setUnit(wxCouponCVo.getUnit()); |
|
|
|
wxCouponOrderCVo.setDetail(wxCouponCVo.getDetail()); |
|
|
|
wxCouponOrderCVo.setRemark(wxCouponCVo.getRemark()); |
|
|
|
wxCouponOrderCVo.setValidType(wxCouponCVo.getValidType()); |
|
|
|
wxCouponOrderCVo.setValidStartDate(wxCouponCVo.getValidStartDate()); |
|
|
|
wxCouponOrderCVo.setValidEndDate(wxCouponCVo.getValidEndDate()); |
|
|
|
wxCouponOrderCVo.setAutoRefund(wxCouponCVo.getAutoRefund()); |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
if (wxCouponOrderCVo.getValidStartDate() != null && wxCouponOrderCVo.getValidEndDate() != null ) { |
|
|
|
if (wxCouponOrderCVo.getValidStartDate().getTime() > now.getTime()) { |
|
|
|
|