提交 c06b69ae authored 作者: wudepeng's avatar wudepeng

full activity

上级 472551bf
......@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
public ResponseEntity<String> payForOrderByCard(@RequestParam("orderId") String orderId, @RequestBody FlutterWaveCard flutterWaveCard) {
RaveConstant.PUBLIC_KEY = PUBLIC_KEY;
RaveConstant.SECRET_KEY = SECRET_KEY;
RaveConstant.ENVIRONMENT = Environment.STAGING; //or live
RaveConstant.ENVIRONMENT = Environment.LIVE; //or live
// Result result = new Result();
Optional<TbCfOrder> byId = repository.findById(orderId);
......
......@@ -267,10 +267,10 @@ public class TbCfOrder {
itemOrderList.forEach(item -> {
BigDecimal itemPrice = item.getItemPriceTotal();
TbCfExpressTemplate template = item.getTemplate();
if (template != null) {
System.out.println(template.getHandlingFee());
System.out.println(template.getTariff());
}
// if (template != null) {
// System.out.println(template.getHandlingFee());
// System.out.println(template.getTariff());
// }
Optional<TbCfStationItem> optionalTbCfStationItem = itemRepository.findById(item.getItemId());
......@@ -290,6 +290,7 @@ public class TbCfOrder {
});
Map<String, List<TemplateVo>> map = templateList.stream().collect(Collectors.groupingBy(TemplateVo::getTemplateId));
//按模板分组计算商品价格
Integer itemSum=0;
List<TemplateVo> list = new ArrayList<>();
for (String key : map.keySet()) {
TemplateVo templateVo = new TemplateVo();
......@@ -299,6 +300,7 @@ public class TbCfOrder {
for (TemplateVo template : map.get(key)) {
totalPrice = totalPrice.add(template.getItemPrice());
count += template.getItemCount();
itemSum+=template.getItemCount();
_template = template.getTemplate();
}
templateVo.setTemplateId(key);
......@@ -329,7 +331,7 @@ public class TbCfOrder {
}
/**
* 活动模块:活动类型 1:满减 2:满折 3:满件打折(type)
* 使用类型 1:全场 2:分类商品 3:特定商品(use_type)
* 使用类型 1:全场 2:分类商品 3:特定商品(use_type)
*/
boolean act1 = activityRepository.existsByUseType(1);
if (act1) {
......@@ -338,17 +340,16 @@ public class TbCfOrder {
Activity activity = allAct.get();
String type = String.valueOf(activity.getType());
if ("1".equals(type)) {
// reduceAmount = caculateFullReduction(activity, itemsPrice);
caculateActFee(false, false, activity, itemsPrice, null);
reduceAmount= caculateActFee(false, false, activity, itemsPrice, null);
System.out.println("减免金额:"+reduceAmount);
} else if ("2".equals(type)) {
// BigDecimal discount = caculateFullReduction(activity, itemsPrice);
// BigDecimal rate = new BigDecimal(1).subtract(discount.divide(new BigDecimal(100)));
BigDecimal rate = caculateActFee(false, true, activity, itemsPrice, null);
System.out.println("折扣比例:"+rate);
itemsPrice = rate.multiply(itemsPrice);
} else if ("3".equals(type)) {
// BigDecimal discount = caculateFullCount(activity, itemOrderList.size());
// BigDecimal rate = new BigDecimal(1).subtract(discount.divide(new BigDecimal(100)));
BigDecimal rate = caculateActFee(true, true, activity, itemsPrice, itemOrderList.size());
BigDecimal rate = caculateActFee(true, true, activity, itemsPrice, itemSum);
System.out.println("购买件数:"+itemSum);
System.out.println("折扣比例:"+rate);
itemsPrice = rate.multiply(itemsPrice);
}
}
......@@ -363,11 +364,12 @@ public class TbCfOrder {
List<Condition> conList = JSONObject.parseArray(activity.getCondition(), Condition.class);
Collections.sort(conList, Comparator.comparing(Condition::getKey));
System.out.println(conList);
BigDecimal result = new BigDecimal("0.0");
for (int i = 0; i < conList.size(); i++) {
if (isCount) {
if (itemCount >= Integer.parseInt(conList.get(i).getKey())) {
if (itemCount >= conList.get(i).getKey()) {
result = new BigDecimal(conList.get(i).getValue());
}
} else {
......@@ -383,33 +385,7 @@ public class TbCfOrder {
return result;
}
// //计算活动减免费用
// public BigDecimal caculateFullReduction(Activity activity, BigDecimal itemsPrice) {
//
// List<Condition> conList = JSONObject.parseArray(activity.getCondition(), Condition.class);
// Collections.sort(conList, Comparator.comparing(Condition::getKey));
// BigDecimal result = new BigDecimal("0.0");
// for (Condition con : conList) {
// if (itemsPrice.compareTo(new BigDecimal(con.getKey())) >= 0) {
// result = new BigDecimal(con.getValue());
// }
// }
//
// return result;
// }
//
// public BigDecimal caculateFullCount(Activity activity, Integer itemCount) {
// List<Condition> conList = JSONObject.parseArray(activity.getCondition(), Condition.class);
// Collections.sort(conList, Comparator.comparing(Condition::getKey));
// BigDecimal result = new BigDecimal("0.0");
//
// for (int i = 0; i < conList.size(); i++) {
// if (itemCount >= Integer.parseInt(conList.get(i).getKey())) {
// result = new BigDecimal(conList.get(i).getValue());
// }
// }
// return result;
// }
@Transient
private TbCfCoupon coupon;
......
......@@ -14,7 +14,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
public class Condition {
private String key;
private String value;
private double key;
private double value;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论