...
|
...
|
@@ -14,10 +14,68 @@ import java.util.Objects; |
|
|
|
|
|
public class PromotionSupport {
|
|
|
|
|
|
private static final String AUTO_RECOMMENDED_DESC_FORMAT = "%d个可用 已推荐%d个";
|
|
|
|
|
|
/**
|
|
|
* 可使用券
|
|
|
*/
|
|
|
private static final String USABLE_DESC_FORMAT = "%d个可用";
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 券使用
|
|
|
*/
|
|
|
private static final String USE_DESC_FORMAT = "已选%d个";
|
|
|
|
|
|
private static final String NOT_MATCHED = "未参与";
|
|
|
|
|
|
/**
|
|
|
* 手动选择时使用
|
|
|
* @param useablePromotionList
|
|
|
* @param chargeResult
|
|
|
* @return
|
|
|
*/
|
|
|
public static ShoppingPromotionTips buildShoppingPromotionTips(List<ShoppingPromotion> useablePromotionList,
|
|
|
ChargeResult chargeResult
|
|
|
){
|
|
|
ShoppingPromotion shoppingPromotion = chargeResult.getShoppingPromotion();
|
|
|
PromotionMutexLock promotionMutexLock = chargeResult.getPromotionMutexLock();
|
|
|
|
|
|
int size = Objects.nonNull(useablePromotionList) ? useablePromotionList.size() : 0;
|
|
|
|
|
|
if (size == 0){
|
|
|
return null;
|
|
|
}
|
|
|
String amount;
|
|
|
String promotionIds=null;
|
|
|
String title = String.format(USABLE_DESC_FORMAT, size);
|
|
|
if (shoppingPromotion ==null){
|
|
|
amount = NOT_MATCHED;
|
|
|
}else {
|
|
|
if (promotionMutexLock.isUsePromotion()) {
|
|
|
title = String.format(USE_DESC_FORMAT, 1);
|
|
|
promotionIds = String.valueOf(shoppingPromotion.getPromotionId());
|
|
|
amount = OrderConstant.SUB_SIGN + MathUtils.formatCurrencyStr(shoppingPromotion.getCutAmount());
|
|
|
}else {
|
|
|
amount = NOT_MATCHED;
|
|
|
}
|
|
|
}
|
|
|
return ShoppingPromotionTips.builder()
|
|
|
.title(title)
|
|
|
.amount(amount)
|
|
|
.promotionIds(promotionIds)
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推荐促销时使用
|
|
|
* @param useablePromotionList
|
|
|
* @param chargeResult
|
|
|
* @return
|
|
|
*/
|
|
|
public static ShoppingPromotionTips buildRecommendedShoppingPromotionTips(List<ShoppingPromotion> useablePromotionList,
|
|
|
ChargeResult chargeResult
|
|
|
){
|
|
|
ShoppingPromotion recommendedPromotion = chargeResult.getShoppingPromotion();
|
|
|
PromotionMutexLock promotionMutexLock = chargeResult.getPromotionMutexLock();
|
|
|
|
...
|
...
|
@@ -28,18 +86,20 @@ public class PromotionSupport { |
|
|
}
|
|
|
String amount;
|
|
|
String promotionIds=null;
|
|
|
String title = String.format(USABLE_DESC_FORMAT, size);
|
|
|
if (recommendedPromotion ==null){
|
|
|
amount = "未参与";
|
|
|
amount = NOT_MATCHED;
|
|
|
}else {
|
|
|
if (promotionMutexLock.isUsePromotion()) {
|
|
|
title = String.format(AUTO_RECOMMENDED_DESC_FORMAT, size, 1);
|
|
|
promotionIds = String.valueOf(recommendedPromotion.getPromotionId());
|
|
|
amount = OrderConstant.SUB_SIGN + MathUtils.formatCurrencyStr(recommendedPromotion.getCutAmount());
|
|
|
}else {
|
|
|
amount = "未参与";
|
|
|
amount = NOT_MATCHED;
|
|
|
}
|
|
|
}
|
|
|
return ShoppingPromotionTips.builder()
|
|
|
.title(size + "个可用")
|
|
|
.title(title)
|
|
|
.amount(amount)
|
|
|
.promotionIds(promotionIds)
|
|
|
.build();
|
...
|
...
|
|