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

update activity

上级 38c47dff
...@@ -53,16 +53,14 @@ public class ActivityController { ...@@ -53,16 +53,14 @@ public class ActivityController {
//查询商品活动 //查询商品活动
@GetMapping("item/{itemId}") @GetMapping("item/{itemId}")
public Result getItemActivity(@PathVariable("itemId") String itemId) throws ParseException, ExecutionException, InterruptedException { public Result getItemActivity(@PathVariable("itemId") String itemId) throws ParseException {
Result result = new Result(); Result result = new Result();
Activity activity = null; Activity activity = null;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//全场活动 //全场活动
if (activityRepository.existsByUseType(1)) { if (activityRepository.existsByUseType(1)) {
Optional<Activity> fullAct = activityRepository.findFirstByUseType(1); List<Activity> fullList = activityRepository.findAllByUseType(1);
if (fullAct.isPresent()) { activity = fullList.get(0);
activity = fullAct.get();
}
} }
//商品分类活动 //商品分类活动
......
...@@ -344,9 +344,8 @@ public class TbCfOrder { ...@@ -344,9 +344,8 @@ public class TbCfOrder {
*/ */
boolean fullAct = activityRepository.existsByUseType(1); boolean fullAct = activityRepository.existsByUseType(1);
if (this.open && fullAct) { if (this.open && fullAct) {
Optional<Activity> allAct = activityRepository.findFirstByUseType(1); Activity activity = activityRepository.findAllByUseType(1).get(0);
if (allAct.isPresent()) {
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);
...@@ -362,7 +361,6 @@ public class TbCfOrder { ...@@ -362,7 +361,6 @@ public class TbCfOrder {
itemsPrice = rate.multiply(itemsPrice); itemsPrice = rate.multiply(itemsPrice);
} }
} }
}
totalPrice = itemsPrice.add(fee).add(tax).add(expressCost).subtract(reduceAmount); totalPrice = itemsPrice.add(fee).add(tax).add(expressCost).subtract(reduceAmount);
......
...@@ -24,10 +24,10 @@ public interface ActivityRepository extends JpaRepository<Activity, String> { ...@@ -24,10 +24,10 @@ public interface ActivityRepository extends JpaRepository<Activity, String> {
boolean existsByUseType(Integer useType); boolean existsByUseType(Integer useType);
@Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 and use_type=:useType order by a.create_time desc limit 1", nativeQuery = true) // @Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 and use_type=:useType order by a.create_time desc limit 1", nativeQuery = true)
Optional<Activity> findFirstByUseType(Integer useType); // Optional<Activity> findFirstByUseType(Integer useType);
@Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 and use_type=:useType", nativeQuery = true) @Query(value = "select * from Activity a where CURRENT_TIMESTAMP between a.start_time and a.end_time and a.status=1 and a.use_type=:useType order by a.create_time desc ", nativeQuery = true)
List<Activity> findAllByUseType(Integer useType); List<Activity> findAllByUseType(Integer useType);
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论