提交 d5ad1527 authored 作者: 吴德鹏's avatar 吴德鹏

update

上级 bb9dd46e
...@@ -166,6 +166,8 @@ public class TbCfOrder { ...@@ -166,6 +166,8 @@ public class TbCfOrder {
@Transient @Transient
private Map<String, Object> couponMap; private Map<String, Object> couponMap;
public Map<String, Object> getCouponMap() { public Map<String, Object> getCouponMap() {
return couponMap; return couponMap;
} }
...@@ -273,7 +275,11 @@ public class TbCfOrder { ...@@ -273,7 +275,11 @@ public class TbCfOrder {
// } // }
Optional<TbCfStationItem> optionalTbCfStationItem = itemRepository.findById(item.getItemId()); Optional<TbCfStationItem> optionalTbCfStationItem = itemRepository.findById(item.getItemId());
boolean categoriesAct = activityRepository.existsByUseType(2);
boolean specialAct = activityRepository.existsByUseType(3);
if (categoriesAct || specialAct) {
}
if (optionalTbCfStationItem.isPresent()) { if (optionalTbCfStationItem.isPresent()) {
TbCfStationItem stationItem = optionalTbCfStationItem.get(); TbCfStationItem stationItem = optionalTbCfStationItem.get();
if (stationItem.getExpress() != null) { if (stationItem.getExpress() != null) {
...@@ -290,7 +296,7 @@ public class TbCfOrder { ...@@ -290,7 +296,7 @@ public class TbCfOrder {
}); });
Map<String, List<TemplateVo>> map = templateList.stream().collect(Collectors.groupingBy(TemplateVo::getTemplateId)); Map<String, List<TemplateVo>> map = templateList.stream().collect(Collectors.groupingBy(TemplateVo::getTemplateId));
//按模板分组计算商品价格 //按模板分组计算商品价格
Integer itemSum=0; Integer itemSum = 0;
List<TemplateVo> list = new ArrayList<>(); List<TemplateVo> list = new ArrayList<>();
for (String key : map.keySet()) { for (String key : map.keySet()) {
TemplateVo templateVo = new TemplateVo(); TemplateVo templateVo = new TemplateVo();
...@@ -300,7 +306,7 @@ public class TbCfOrder { ...@@ -300,7 +306,7 @@ public class TbCfOrder {
for (TemplateVo template : map.get(key)) { for (TemplateVo template : map.get(key)) {
totalPrice = totalPrice.add(template.getItemPrice()); totalPrice = totalPrice.add(template.getItemPrice());
count += template.getItemCount(); count += template.getItemCount();
itemSum+=template.getItemCount(); itemSum += template.getItemCount();
_template = template.getTemplate(); _template = template.getTemplate();
} }
templateVo.setTemplateId(key); templateVo.setTemplateId(key);
...@@ -335,21 +341,21 @@ public class TbCfOrder { ...@@ -335,21 +341,21 @@ public class TbCfOrder {
*/ */
boolean fullAct = activityRepository.existsByUseType(1); boolean fullAct = activityRepository.existsByUseType(1);
if (fullAct) { if (fullAct) {
Optional<Activity> allAct = activityRepository.findFirstByUseTypeOrderByCreateTimeDesc(1); Optional<Activity> allAct = activityRepository.findFirstByUseType(1);
if (allAct.isPresent()) { if (allAct.isPresent()) {
Activity activity = allAct.get(); Activity activity = allAct.get();
String type = String.valueOf(activity.getType()); String type = String.valueOf(activity.getType());
if ("1".equals(type)) { if ("1".equals(type)) {
reduceAmount= caculateActFee(false, false, activity, itemsPrice, null); reduceAmount = caculateActFee(false, false, activity, itemsPrice, null);
System.out.println("减免金额:"+reduceAmount); System.out.println("减免金额:" + reduceAmount);
} else if ("2".equals(type)) { } else if ("2".equals(type)) {
BigDecimal rate = caculateActFee(false, true, activity, itemsPrice, null); BigDecimal rate = caculateActFee(false, true, activity, itemsPrice, null);
System.out.println("折扣比例:"+rate); System.out.println("折扣比例:" + rate);
itemsPrice = rate.multiply(itemsPrice); itemsPrice = rate.multiply(itemsPrice);
} else if ("3".equals(type)) { } else if ("3".equals(type)) {
BigDecimal rate = caculateActFee(true, true, activity, itemsPrice, itemSum); BigDecimal rate = caculateActFee(true, true, activity, itemsPrice, itemSum);
System.out.println("购买件数:"+itemSum); System.out.println("购买件数:" + itemSum);
System.out.println("折扣比例:"+rate); System.out.println("折扣比例:" + rate);
itemsPrice = rate.multiply(itemsPrice); itemsPrice = rate.multiply(itemsPrice);
} }
} }
...@@ -386,7 +392,6 @@ public class TbCfOrder { ...@@ -386,7 +392,6 @@ public class TbCfOrder {
} }
@Transient @Transient
private TbCfCoupon coupon; private TbCfCoupon coupon;
......
...@@ -22,5 +22,6 @@ public interface ActivityRepository extends JpaRepository<Activity,String> { ...@@ -22,5 +22,6 @@ public interface ActivityRepository extends JpaRepository<Activity,String> {
boolean existsByUseType(Integer useType); boolean existsByUseType(Integer useType);
Optional<Activity> findFirstByUseTypeOrderByCreateTimeDesc(Integer useType); @Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 order by a.create_time desc limit 1",nativeQuery = true)
Optional<Activity> findFirstByUseType(Integer useType);
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论