Authored by wujiexiang

订单金额明细

... ... @@ -257,26 +257,26 @@ public class ChargeService {
}
//特殊场景:运费券满足条件(商品条件及金额),但运费为0,不能使用运费券
Optional<CouponPayResult> couponPayResult = null;
Optional<CouponPayResult> couponPayResultOptional = null;
CouponTypeEnum couponTypeEnum = CouponTypeEnum.of(userCouponsBo.getCouponType()).orElse(null);
switch (couponTypeEnum) {
case ACTIVITY_COUPON: {
//活动券
couponPayResult = activityCouponUse(userCouponsBo, chargeContext);
couponPayResultOptional = activityCouponUse(userCouponsBo, chargeContext);
break;
}
case SHIPPING_COUPON: {
//运费券
couponPayResult = shippingCouponUse(userCouponsBo, chargeContext);
couponPayResultOptional = shippingCouponUse(userCouponsBo, chargeContext);
break;
}
default:
throw new UfoServiceException(500, "unknown couponType:" + userCouponsBo.getCouponType());
}
if (couponPayResult.isPresent()) {
couponPayResultList.addCouponPayResult(couponPayResult.get());
if (couponPayResultOptional.isPresent()) {
couponPayResultList.addCouponPayResult(couponPayResultOptional.get());
}
}
... ...
... ... @@ -50,9 +50,9 @@ public class CouponService {
*/
public List<CouponMatchResult> getRecommendedCoupons(ChargeContext chargeContext) {
ChargeParam chargeParam = chargeContext.getChargeParam();
Optional<List<UserCouponsBo>> userCouponsBos = couponProxyService.getUserAvailableCouponsWhenExceptionHappenedReturnNull(chargeParam.getUid());
if (userCouponsBos.isPresent()) {
List<UserCouponsBo> userCouponsBoToSort = userCouponsBos.get();
Optional<List<UserCouponsBo>> userCouponsBosOptional = couponProxyService.getUserAvailableCouponsWhenExceptionHappenedReturnNull(chargeParam.getUid());
if (userCouponsBosOptional.isPresent()) {
List<UserCouponsBo> userCouponsBoToSort = userCouponsBosOptional.get();
userCouponsBoToSort.sort(COUPON_COMPARATOR);
return matchAndGetUsableCoupons(userCouponsBoToSort, chargeContext);
}
... ...
... ... @@ -61,7 +61,6 @@ import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.context.annotation.Primary;
... ... @@ -504,7 +503,7 @@ public class ShoppingServiceImpl implements IShoppingService {
*/
protected AmountDetailBo buildOrderAmountDetailBo(ChargeResult chargeResult) {
//订单金额明细
AmountDetailBo amountDetailBo = new AmountDetailBo();
final AmountDetailBo amountDetailBo = new AmountDetailBo();
//商品金额
amountDetailBo.setGoodsAmount(chargeResult.getGoodsAmount());
//运费原价
... ... @@ -512,16 +511,13 @@ public class ShoppingServiceImpl implements IShoppingService {
//活动金额
amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount());
Optional<CouponPayResult> tempPayResult;
if ((tempPayResult = chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode())).isPresent()) {
//活动券减免金额
amountDetailBo.setCouponCutAmount(tempPayResult.get().getCouponAmount());
}
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()).
ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount()));
if ((tempPayResult = chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.SHIPPING_COUPON.getCode())).isPresent()) {
//运费券减免金额
amountDetailBo.setShippingCouponCutAmount(tempPayResult.get().getCouponAmount());
}
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.SHIPPING_COUPON.getCode()).
ifPresent(tempPayResult -> amountDetailBo.setShippingCouponCutAmount(tempPayResult.getCouponAmount()));
return amountDetailBo;
}
... ...