|
|
|
@@ -7,15 +7,14 @@ import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
import com.iformall.domain.po.WxCouponOrder; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.domain.po.WxMerchantBUser; |
|
|
|
import com.iformall.domain.vo.WxCouponCVo; |
|
|
|
import com.iformall.domain.vo.WxCouponOrderCVo; |
|
|
|
import com.iformall.enums.EnumCouponValidType; |
|
|
|
import com.iformall.enums.EnumCreditLockedStatus; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.WxCUserBasicInfoService; |
|
|
|
import com.iformall.service.WxCUserService; |
|
|
|
import com.iformall.service.WxCouponOrderService; |
|
|
|
import com.iformall.service.WxMerchantBUserService; |
|
|
|
import com.iformall.service.*; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
@@ -24,6 +23,9 @@ 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.ValueOperations; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
@@ -35,9 +37,15 @@ import java.util.Map; |
|
|
|
public class WxCouponOrderController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponOrderService wxCouponOrderService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponService wxCouponService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxMerchantBUserService wxMerchantBUserService; |
|
|
|
|
|
|
|
@@ -47,6 +55,10 @@ public class WxCouponOrderController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private WxCUserService wxCUserService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Qualifier("couponDetailRedisTemplate") |
|
|
|
RedisTemplate<String, WxCouponCVo> cdRedisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@GetMapping("list") |
|
|
|
@@ -115,7 +127,59 @@ public class WxCouponOrderController extends BaseController { |
|
|
|
if(couponOrderId == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); |
|
|
|
} |
|
|
|
return wxCouponOrderService.detailBUserVo(getUser().getId(), couponOrderId); |
|
|
|
Long bUserId = getUser().getId(); |
|
|
|
WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(getUser().getId()); |
|
|
|
if (wxMerchantBUser == null) { |
|
|
|
logger.error("用户不存在:" + bUserId); |
|
|
|
throw new MallinkException(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
WxMerchant wxMerchant = wxMerchantService.getById(wxMerchantBUser.getMerchantId()); |
|
|
|
if (wxMerchant == null) { |
|
|
|
logger.error("商户不存在:" + bUserId); |
|
|
|
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
WxCouponOrderCVo wxCouponOrderCVo = null; |
|
|
|
try { |
|
|
|
wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); |
|
|
|
} catch (Exception e) { |
|
|
|
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); |
|
|
|
} |
|
|
|
if (wxCouponOrderCVo == null) |
|
|
|
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()); |
|
|
|
return new ResultData(wxCouponOrderCVo); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") |
|
|
|
|