|
|
package com.yohoufo.promotion.controller;
|
|
|
|
|
|
import com.yoho.core.rest.annotation.ServiceDesc;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.promotion.request.CouponCancelUseReq;
|
|
|
import com.yohobuy.ufo.model.promotion.request.CouponUseReq;
|
|
|
import com.yohobuy.ufo.model.promotion.request.UserCouponListReq;
|
|
|
import com.yohobuy.ufo.model.promotion.UserCouponsListBo;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by jiexiang.wu on 2018/11/19.
|
|
|
* 内部接口
|
...
|
...
|
@@ -28,88 +18,79 @@ public class UserCouponController { |
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(UserCouponController.class);
|
|
|
|
|
|
/**
|
|
|
* 新获取可用的优惠券接口,包括基本信息,以及优惠规则。(供购物车使用)
|
|
|
*
|
|
|
* @param req 包含用户id的请求
|
|
|
* @return
|
|
|
* @see [类、类#方法、类#成员]
|
|
|
*/
|
|
|
@RequestMapping(value = "/getUserAvailableCoupons")
|
|
|
@ResponseBody
|
|
|
public UserCouponsListBo getUserAvailableCoupons(@RequestBody UserCouponListReq req) {
|
|
|
logger.info("queryUserNoUsedCoupons request is {}", req);
|
|
|
|
|
|
if (req == null || (req.getUid() <= 0)) {
|
|
|
logger.warn("queryUserNoUsedCoupons RequestBody is wrong , the request is {} ", req);
|
|
|
throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
}
|
|
|
|
|
|
//todo
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询并校验优惠券是否能用
|
|
|
* 提供给order模块调用判断优惠券是否可以使用
|
|
|
* 订单使用前调用校验优惠券是否可用
|
|
|
*
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/checkUseCouponsAndGet")
|
|
|
@ResponseBody
|
|
|
public UserCouponsListBo checkUseCouponsAndGet(@RequestBody UserCouponListReq req) {
|
|
|
logger.info("checkUseCouponsAndGet req is:{}", req);
|
|
|
if (req == null || req.getUid() <= 0 || CollectionUtils.isEmpty(req.getCouponCodes())) {
|
|
|
throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
}
|
|
|
//todo
|
|
|
return null;
|
|
|
}
|
|
|
// /**
|
|
|
// * 新获取可用的优惠券接口,包括基本信息,以及优惠规则。(供购物车使用)
|
|
|
// *
|
|
|
// * @param req 包含用户id的请求
|
|
|
// * @return
|
|
|
// * @see [类、类#方法、类#成员]
|
|
|
// */
|
|
|
// @RequestMapping(value = "/getUserAvailableCoupons")
|
|
|
// @ResponseBody
|
|
|
// public UserCouponsListBo getUserAvailableCoupons(@RequestBody UserCouponListReq req) {
|
|
|
// logger.info("queryUserNoUsedCoupons request is {}", req);
|
|
|
//
|
|
|
// if (req == null || (req.getUid() <= 0)) {
|
|
|
// logger.warn("queryUserNoUsedCoupons RequestBody is wrong , the request is {} ", req);
|
|
|
// throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
// }
|
|
|
//
|
|
|
// //todo
|
|
|
// return null;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 查询并校验优惠券是否能用
|
|
|
// * 提供给order模块调用判断优惠券是否可以使用
|
|
|
// * 订单使用前调用校验优惠券是否可用
|
|
|
// *
|
|
|
// * @param req
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "/checkUseCouponsAndGet")
|
|
|
// @ResponseBody
|
|
|
// public UserCouponsListBo checkUseCouponsAndGet(@RequestBody UserCouponListReq req) {
|
|
|
// logger.info("checkUseCouponsAndGet req is:{}", req);
|
|
|
// if (req == null || req.getUid() <= 0 || CollectionUtils.isEmpty(req.getCouponCodes())) {
|
|
|
// throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
// }
|
|
|
// //todo
|
|
|
// return null;
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 订单使用优惠券(订单中心调用)
|
|
|
*
|
|
|
* @param useReq
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/orderUseCoupon")
|
|
|
@ResponseBody
|
|
|
public Boolean orderUseCoupon(@RequestBody CouponUseReq useReq) {
|
|
|
logger.info("use coupon request is {}", useReq);
|
|
|
if (useReq.getUid() <= 0 || CollectionUtils.isEmpty(useReq.getCouponCodes()) || useReq.getOrderCode() <= 0) {
|
|
|
logger.info("use coupon request params error {}", useReq);
|
|
|
throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
}
|
|
|
// UseCouponBo useCouponBo = new UseCouponBo(useReq.getUid(), useReq.getOrderCode(), useReq.getCouponCodes());
|
|
|
// return iCouponService.useCoupons(useCouponBo);
|
|
|
//todo
|
|
|
public Boolean orderUseCoupon() {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消订单优惠券的使用
|
|
|
*
|
|
|
* @param couponOrderCancelUseReq
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/cancelCouponUse")
|
|
|
@ResponseBody
|
|
|
public boolean cancelOrderUseCoupon(@RequestBody CouponCancelUseReq couponOrderCancelUseReq) {
|
|
|
|
|
|
int uid = couponOrderCancelUseReq.getUid();
|
|
|
long orderCode = couponOrderCancelUseReq.getOrderCode();
|
|
|
List<String> couponCodes = couponOrderCancelUseReq.getCouponCodes();
|
|
|
if (uid <= 0 || orderCode <= 0 || CollectionUtils.isEmpty(couponCodes)) {
|
|
|
logger.warn("cancel order use coupons req param err:{}", couponOrderCancelUseReq);
|
|
|
throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
}
|
|
|
|
|
|
// CancelUseCouponBo cancelUseCouponBo = new CancelUseCouponBo(uid, orderCode, couponCodes);
|
|
|
// return iCouponService.cancelOrderUseCoupon(cancelUseCouponBo);
|
|
|
//todo
|
|
|
return false;
|
|
|
}
|
|
|
// /**
|
|
|
// * 取消订单优惠券的使用
|
|
|
// *
|
|
|
// * @param couponOrderCancelUseReq
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "/cancelCouponUse")
|
|
|
// @ResponseBody
|
|
|
// public boolean cancelOrderUseCoupon(@RequestBody CouponCancelUseReq couponOrderCancelUseReq) {
|
|
|
//
|
|
|
// int uid = couponOrderCancelUseReq.getUid();
|
|
|
// long orderCode = couponOrderCancelUseReq.getOrderCode();
|
|
|
// List<String> couponCodes = couponOrderCancelUseReq.getCouponCodes();
|
|
|
// if (uid <= 0 || orderCode <= 0 || CollectionUtils.isEmpty(couponCodes)) {
|
|
|
// logger.warn("cancel order use coupons req param err:{}", couponOrderCancelUseReq);
|
|
|
// throw new ServiceException(ServiceError.PROMOTION_REQUEST_PAREMENT_ERROR);
|
|
|
// }
|
|
|
//
|
|
|
//// CancelUseCouponBo cancelUseCouponBo = new CancelUseCouponBo(uid, orderCode, couponCodes);
|
|
|
//// return iCouponService.cancelOrderUseCoupon(cancelUseCouponBo);
|
|
|
// //todo
|
|
|
// return false;
|
|
|
// }
|
|
|
} |
...
|
...
|
|