Authored by wujiexiang

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

@@ -297,7 +297,7 @@ public class ChargeService { @@ -297,7 +297,7 @@ public class ChargeService {
297 double newFinalAmount = YHMath.sub(oldFinalAmount, couponPayAmount); 297 double newFinalAmount = YHMath.sub(oldFinalAmount, couponPayAmount);
298 chargeResult.setFinalAmount(newFinalAmount); 298 chargeResult.setFinalAmount(newFinalAmount);
299 CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(activityCouponsBo.getCouponCode()) 299 CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(activityCouponsBo.getCouponCode())
300 - .couponAmount(couponPayAmount).couponTitle(activityCouponsBo.getCouponName()).couponType(activityCouponsBo.getCouponType()).build(); 300 + .couponAmount(couponPayAmount).couponType(activityCouponsBo.getCouponType()).build();
301 logger.info("[{}] step activity coupon charge,oldFinalAmount:{},newFinalAmount:{}", 301 logger.info("[{}] step activity coupon charge,oldFinalAmount:{},newFinalAmount:{}",
302 chargeContext.getChargeParam().getUid(), oldFinalAmount, chargeResult.getFinalAmount()); 302 chargeContext.getChargeParam().getUid(), oldFinalAmount, chargeResult.getFinalAmount());
303 return Optional.of(couponPayResult); 303 return Optional.of(couponPayResult);
@@ -323,7 +323,7 @@ public class ChargeService { @@ -323,7 +323,7 @@ public class ChargeService {
323 chargeResult.setFinalShippingAmount(finalShippingAmount); 323 chargeResult.setFinalShippingAmount(finalShippingAmount);
324 chargeResult.setFinalAmount(newFinalAmount); 324 chargeResult.setFinalAmount(newFinalAmount);
325 CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(shippingCouponsBo.getCouponCode()) 325 CouponPayResult couponPayResult = CouponPayResult.builder().couponCode(shippingCouponsBo.getCouponCode())
326 - .couponAmount(couponPayShippingAmount).couponTitle(shippingCouponsBo.getCouponName()).couponType(shippingCouponsBo.getCouponType()).build(); 326 + .couponAmount(couponPayShippingAmount).couponType(shippingCouponsBo.getCouponType()).build();
327 logger.info("[{}] step shipping coupon charge,oldShippingAmount:{},finalShippingAmount:{},oldFinalAmount:{},newFinalAmount:{}", 327 logger.info("[{}] step shipping coupon charge,oldShippingAmount:{},finalShippingAmount:{},oldFinalAmount:{},newFinalAmount:{}",
328 chargeContext.getChargeParam().getUid(), oldShippingAmount, chargeResult.getFinalShippingAmount(), oldFinalAmount, chargeResult.getFinalAmount()); 328 chargeContext.getChargeParam().getUid(), oldShippingAmount, chargeResult.getFinalShippingAmount(), oldFinalAmount, chargeResult.getFinalAmount());
329 return Optional.of(couponPayResult); 329 return Optional.of(couponPayResult);
@@ -19,13 +19,6 @@ public class CouponPayResult { @@ -19,13 +19,6 @@ public class CouponPayResult {
19 private String couponCode = ""; 19 private String couponCode = "";
20 20
21 /** 21 /**
22 - * 优惠券名称  
23 - *  
24 - * @var string  
25 - */  
26 - private String couponTitle = "";  
27 -  
28 - /**  
29 * 优惠券支付金额 <= 优惠券实际的面额 22 * 优惠券支付金额 <= 优惠券实际的面额
30 */ 23 */
31 private double couponAmount = 0; 24 private double couponAmount = 0;
@@ -34,5 +27,4 @@ public class CouponPayResult { @@ -34,5 +27,4 @@ public class CouponPayResult {
34 * 券类型 27 * 券类型
35 */ 28 */
36 private int couponType; 29 private int couponType;
37 -  
38 } 30 }
1 -package com.yohoufo.order.charge.model;  
2 -import lombok.Data;  
3 -import lombok.ToString;  
4 -  
5 -/**  
6 - * Created by jiexiang.wu on 2019/4/2.  
7 - * 推荐券支付结果,只能在结算时使用,其他时候请使用CouponPayResult  
8 - */  
9 -@Data  
10 -@ToString  
11 -public class RecommendedCouponPayResult extends CouponPayResult {  
12 - //可用券张数  
13 - private int usableCouponCount;  
14 -  
15 - public RecommendedCouponPayResult(String couponCode, String couponTitle, double couponAmount, int couponCount, int usableCouponCount) {  
16 - super(couponCode, couponTitle, couponAmount, couponCount);  
17 - this.usableCouponCount = usableCouponCount;  
18 - }  
19 -}  
@@ -364,8 +364,6 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -364,8 +364,6 @@ public class ShoppingServiceImpl implements IShoppingService {
364 364
365 logger.info("generate new orderCode:{}",orderCode); 365 logger.info("generate new orderCode:{}",orderCode);
366 366
367 - //优惠券支付结果  
368 - List<CouponPayResult> couponPayResults = chargeResult.getCouponPayResultList().getCouponPayResults();  
369 // 减库存,skup更新成不可售,入库 367 // 减库存,skup更新成不可售,入库
370 //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost); 368 //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost);
371 OrderBuilder orderBuilder = OrderBuilder.builder() 369 OrderBuilder orderBuilder = OrderBuilder.builder()
@@ -378,20 +376,13 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -378,20 +376,13 @@ public class ShoppingServiceImpl implements IShoppingService {
378 .channelNo(shoppingRequest.getChannelNo()) 376 .channelNo(shoppingRequest.getChannelNo())
379 .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) 377 .amount(BigDecimal.valueOf(chargeResult.getFinalAmount()))
380 .shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount())) 378 .shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount()))
381 - .couponBos(couponPayResults.stream().map(couponPayResult -> CouponBo.builder().couponCode(couponPayResult.getCouponCode()).couponAmount(BigDecimal.valueOf(couponPayResult.getCouponAmount())).build())  
382 - .collect(Collectors.toList())  
383 - ) 379 + .couponBos(buildOrderCouponBos(chargeResult))
384 .hiddenAddressInfo(userAddressPair.getRight()) 380 .hiddenAddressInfo(userAddressPair.getRight())
385 .addressInfo(userAddressPair.getLeft()) 381 .addressInfo(userAddressPair.getLeft())
386 .clientType(shoppingRequest.getClientType()) 382 .clientType(shoppingRequest.getClientType())
387 .attributes(buildOrderAttribute(psog).getCode()) 383 .attributes(buildOrderAttribute(psog).getCode())
388 .sellerOrderGoods(psog) 384 .sellerOrderGoods(psog)
389 - .activityBo(ActivityBo.builder().activityType(chargeResult.getActivityCutResult().getActivityType())  
390 - .userActivityId(chargeResult.getActivityCutResult().getUserActivityId())  
391 - //以计算结果为准  
392 - .activityCutAmount(BigDecimal.valueOf(chargeResult.getActivityCutResult().getActivityCutAmount()))  
393 - .build()  
394 - ) 385 + .activityBo(buildOrderActivityBo(chargeResult))
395 .amountDetailBo(buildOrderAmountDetailBo(chargeResult)) 386 .amountDetailBo(buildOrderAmountDetailBo(chargeResult))
396 .build(); 387 .build();
397 388
@@ -478,6 +469,37 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -478,6 +469,37 @@ public class ShoppingServiceImpl implements IShoppingService {
478 } 469 }
479 470
480 /** 471 /**
  472 + * 优惠券支付结果
  473 + *
  474 + * @param chargeResult
  475 + * @return
  476 + */
  477 + protected List<CouponBo> buildOrderCouponBos(ChargeResult chargeResult) {
  478 + return chargeResult.getCouponPayResultList().getCouponPayResults().stream()
  479 + .map(couponPayResult -> CouponBo.builder()
  480 + .couponCode(couponPayResult.getCouponCode())
  481 + .couponType(couponPayResult.getCouponType())
  482 + .couponAmount(BigDecimal.valueOf(couponPayResult.getCouponAmount()))
  483 + .build()
  484 + )
  485 + .collect(Collectors.toList());
  486 + }
  487 +
  488 + /**
  489 + * 活动优惠
  490 + *
  491 + * @param chargeResult
  492 + * @return
  493 + */
  494 + protected ActivityBo buildOrderActivityBo(ChargeResult chargeResult) {
  495 + return ActivityBo.builder().activityType(chargeResult.getActivityCutResult().getActivityType())
  496 + .userActivityId(chargeResult.getActivityCutResult().getUserActivityId())
  497 + //以计算结果为准
  498 + .activityCutAmount(BigDecimal.valueOf(chargeResult.getActivityCutResult().getActivityCutAmount()))
  499 + .build();
  500 + }
  501 +
  502 + /**
481 * 订单金额明细 503 * 订单金额明细
482 * @param chargeResult 504 * @param chargeResult
483 * @return 505 * @return