Authored by wujiexiang

Merge branch 'dev-coupon-recommend' into test6.9.6

... ... @@ -297,7 +297,7 @@ public class ChargeService {
double newFinalAmount = YHMath.sub(oldFinalAmount, couponPayAmount);
chargeResult.setFinalAmount(newFinalAmount);
CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(activityCouponsBo.getCouponCode())
.couponAmount(couponPayAmount).couponTitle(activityCouponsBo.getCouponName()).couponType(activityCouponsBo.getCouponType()).build();
.couponAmount(couponPayAmount).couponType(activityCouponsBo.getCouponType()).build();
logger.info("[{}] step activity coupon charge,oldFinalAmount:{},newFinalAmount:{}",
chargeContext.getChargeParam().getUid(), oldFinalAmount, chargeResult.getFinalAmount());
return Optional.of(couponPayResult);
... ... @@ -323,7 +323,7 @@ public class ChargeService {
chargeResult.setFinalShippingAmount(finalShippingAmount);
chargeResult.setFinalAmount(newFinalAmount);
CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(shippingCouponsBo.getCouponCode())
.couponAmount(couponPayShippingAmount).couponTitle(shippingCouponsBo.getCouponName()).couponType(shippingCouponsBo.getCouponType()).build();
.couponAmount(couponPayShippingAmount).couponType(shippingCouponsBo.getCouponType()).build();
logger.info("[{}] step shipping coupon charge,oldShippingAmount:{},finalShippingAmount:{},oldFinalAmount:{},newFinalAmount:{}",
chargeContext.getChargeParam().getUid(), oldShippingAmount, chargeResult.getFinalShippingAmount(), oldFinalAmount, chargeResult.getFinalAmount());
return Optional.of(couponPayResult);
... ...
... ... @@ -19,13 +19,6 @@ public class CouponPayResult {
private String couponCode = "";
/**
* 优惠券名称
*
* @var string
*/
private String couponTitle = "";
/**
* 优惠券支付金额 <= 优惠券实际的面额
*/
private double couponAmount = 0;
... ... @@ -34,5 +27,4 @@ public class CouponPayResult {
* 券类型
*/
private int couponType;
}
... ...
package com.yohoufo.order.charge.model;
import lombok.Data;
import lombok.ToString;
/**
* Created by jiexiang.wu on 2019/4/2.
* 推荐券支付结果,只能在结算时使用,其他时候请使用CouponPayResult
*/
@Data
@ToString
public class RecommendedCouponPayResult extends CouponPayResult {
//可用券张数
private int usableCouponCount;
public RecommendedCouponPayResult(String couponCode, String couponTitle, double couponAmount, int couponCount, int usableCouponCount) {
super(couponCode, couponTitle, couponAmount, couponCount);
this.usableCouponCount = usableCouponCount;
}
}
\ No newline at end of file
... ... @@ -364,8 +364,6 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.info("generate new orderCode:{}",orderCode);
//优惠券支付结果
List<CouponPayResult> couponPayResults = chargeResult.getCouponPayResultList().getCouponPayResults();
// 减库存,skup更新成不可售,入库
//BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost);
OrderBuilder orderBuilder = OrderBuilder.builder()
... ... @@ -378,20 +376,13 @@ public class ShoppingServiceImpl implements IShoppingService {
.channelNo(shoppingRequest.getChannelNo())
.amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
.shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
.couponBos(couponPayResults.stream().map(couponPayResult -> CouponBo.builder().couponCode(couponPayResult.getCouponCode()).couponAmount(BigDecimal.valueOf(couponPayResult.getCouponAmount())).build())
.collect(Collectors.toList())
)
.couponBos(buildOrderCouponBos(chargeResult))
.hiddenAddressInfo(userAddressPair.getRight())
.addressInfo(userAddressPair.getLeft())
.clientType(shoppingRequest.getClientType())
.attributes(buildOrderAttribute(psog).getCode())
.sellerOrderGoods(psog)
.activityBo(ActivityBo.builder().activityType(chargeResult.getActivityCutResult().getActivityType())
.userActivityId(chargeResult.getActivityCutResult().getUserActivityId())
//以计算结果为准
.activityCutAmount(BigDecimal.valueOf(chargeResult.getActivityCutResult().getActivityCutAmount()))
.build()
)
.activityBo(buildOrderActivityBo(chargeResult))
.amountDetailBo(buildOrderAmountDetailBo(chargeResult))
.build();
... ... @@ -478,6 +469,37 @@ public class ShoppingServiceImpl implements IShoppingService {
}
/**
* 优惠券支付结果
*
* @param chargeResult
* @return
*/
protected List<CouponBo> buildOrderCouponBos(ChargeResult chargeResult) {
return chargeResult.getCouponPayResultList().getCouponPayResults().stream()
.map(couponPayResult -> CouponBo.builder()
.couponCode(couponPayResult.getCouponCode())
.couponType(couponPayResult.getCouponType())
.couponAmount(BigDecimal.valueOf(couponPayResult.getCouponAmount()))
.build()
)
.collect(Collectors.toList());
}
/**
* 活动优惠
*
* @param chargeResult
* @return
*/
protected ActivityBo buildOrderActivityBo(ChargeResult chargeResult) {
return ActivityBo.builder().activityType(chargeResult.getActivityCutResult().getActivityType())
.userActivityId(chargeResult.getActivityCutResult().getUserActivityId())
//以计算结果为准
.activityCutAmount(BigDecimal.valueOf(chargeResult.getActivityCutResult().getActivityCutAmount()))
.build();
}
/**
* 订单金额明细
* @param chargeResult
* @return
... ...