|
|
package com.yohoufo.promotion.convert;
|
|
|
|
|
|
import com.yohobuy.ufo.model.promotion.UserCouponsBo;
|
|
|
import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum;
|
|
|
import com.yohobuy.ufo.model.promotion.constant.CouponUseLimitTypeEnum;
|
|
|
import com.yohobuy.ufo.model.promotion.constant.UserCouponsStatusEnum;
|
|
|
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.promotion.model.*;
|
|
|
import com.yohoufo.promotion.common.ProductLimitType;
|
|
|
import com.yohoufo.promotion.common.UseLimitType;
|
|
|
import com.yohoufo.promotion.common.UserCouponsStatusEnum;
|
|
|
import com.yohoufo.promotion.model.response.CouponInfo;
|
|
|
import com.yohoufo.promotion.model.response.CouponBo;
|
|
|
|
|
|
import java.text.MessageFormat;
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
public class CouponConvert {
|
|
|
|
|
|
|
|
|
public static CouponBo covertCouponBo(UserCoupon userCoupon, Coupon coupon){
|
|
|
public static UserCouponsBo covertCouponBo(UserCoupon userCoupon, Coupon coupon){
|
|
|
|
|
|
CouponBo couponBo = new CouponBo();
|
|
|
UserCouponsBo couponBo = new UserCouponsBo();
|
|
|
|
|
|
couponBo.setUid(userCoupon.getUid());
|
|
|
couponBo.setCouponId(userCoupon.getCouponId());
|
|
|
couponBo.setCouponCode(userCoupon.getCouponCode());
|
|
|
couponBo.setCouponToken(userCoupon.getCouponToken());
|
|
|
couponBo.setCouponType(userCoupon.getCouponType());
|
|
|
|
|
|
couponBo.setCouponAmount(coupon.getCouponAmount());
|
|
|
couponBo.setCouponName(coupon.getCouponName());
|
|
|
couponBo.setProductLimitType(coupon.getProductLimitType());
|
|
|
couponBo.setProductLimitValue(coupon.getProductLimitValue());
|
|
|
couponBo.setUseLimitType(coupon.getUseLimitType());
|
|
|
couponBo.setUseLimitValue(coupon.getUseLimitValue());
|
|
|
couponBo.setProductLimitType(coupon.getProductLimitType()!=null ? String.valueOf(coupon.getProductLimitType()):"");
|
|
|
couponBo.setUseLimitType(coupon.getUseLimitType()!=null ? String.valueOf(coupon.getUseLimitType()) : "");
|
|
|
couponBo.setUseLimitValue(coupon.getUseLimitValue()!=null ? String.valueOf(coupon.getUseLimitValue()) : "");
|
|
|
|
|
|
couponBo.setStartTime(userCoupon.getStartTime());
|
|
|
couponBo.setEndTime(userCoupon.getEndTime());
|
|
|
couponBo.setStatus(userCoupon.getStatus());
|
|
|
|
|
|
// use_limit_type use_limit_value 满多少元可用
|
|
|
if (coupon.getUseLimitType()!=null){
|
|
|
couponBo.setUseRule(MessageFormat.format(CouponUseLimitTypeEnum.of(String.valueOf(coupon.getUseLimitType())).get().getText(),coupon.getUseLimitValue().intValue()));
|
|
|
}
|
|
|
|
|
|
return couponBo;
|
|
|
}
|
...
|
...
|
@@ -62,13 +65,13 @@ public class CouponConvert { |
|
|
couponInfo.setCoupon_value(coupon.getCouponAmount());
|
|
|
|
|
|
// use_limit_type use_limit_value 满多少元可用
|
|
|
if (coupon.getUseLimitType()!=null && coupon.getUseLimitType().intValue() == UseLimitType.AMOUNT_LIMIT.getCode()){
|
|
|
couponInfo.setUse_rule(MessageFormat.format(UseLimitType.AMOUNT_LIMIT.getText(),coupon.getUseLimitValue().intValue()));
|
|
|
if (coupon.getUseLimitType()!=null){
|
|
|
couponInfo.setUse_rule(MessageFormat.format(CouponUseLimitTypeEnum.of(String.valueOf(coupon.getUseLimitType())).get().getText(),coupon.getUseLimitValue().intValue()));
|
|
|
}
|
|
|
|
|
|
// product_limit_type product_limit_value 特定商品
|
|
|
if (coupon.getProductLimitType()!=null && coupon.getProductLimitType().intValue() == ProductLimitType.PRODUCT.getCode()){
|
|
|
couponInfo.setNotes(Arrays.asList(ProductLimitType.PRODUCT.getText()));
|
|
|
if (coupon.getProductLimitType()!=null){
|
|
|
couponInfo.setNotes(Arrays.asList(CouponProductLimitTypeEnum.of(String.valueOf(coupon.getProductLimitType())).get().getText()));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -97,7 +100,6 @@ public class CouponConvert { |
|
|
userCoupon.setCouponCode(couponCode);
|
|
|
int now = DateUtil.getCurrentTimeSecond();
|
|
|
userCoupon.setStartTime(now);
|
|
|
// TODO
|
|
|
userCoupon.setEndTime(couponAndType.getCoupon().getEndTime());
|
|
|
userCoupon.setCreateTime(now);
|
|
|
userCoupon.setOrderCode(0l);
|
...
|
...
|
|