|
@@ -2,6 +2,8 @@ package org.jeecg.modules.app.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.modules.app.service.IOrderService;
|
|
|
import org.jeecg.modules.app.vo.OrderVO;
|
|
|
import org.jeecg.modules.system.app.entity.AppCourses;
|
|
@@ -14,6 +16,7 @@ import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.Date;
|
|
@@ -51,15 +54,24 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
|
|
|
@Override
|
|
|
public OrderVO.PreviewOrderCourse previewOrderCourse(String courseId) {
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
OrderVO.PreviewOrderCourse previousOrderCourse = new OrderVO.PreviewOrderCourse();
|
|
|
AppCourses appCourses = appCoursesMapper.selectById(courseId);
|
|
|
+ boolean checkCourseDiscount = checkCourseDiscount(appCourses.getCategoryId(), user.getId());
|
|
|
previousOrderCourse.setId(appCourses.getId())
|
|
|
.setCover(appCourses.getCover())
|
|
|
.setName(appCourses.getName())
|
|
|
.setSellingPrice(appCourses.getSellingPrice())
|
|
|
- .setReminder(appCourses.getReminder());
|
|
|
-// .setHasDiscount();
|
|
|
- return null;
|
|
|
+ .setReminder(appCourses.getReminder())
|
|
|
+ .setHasDiscount(checkCourseDiscount);
|
|
|
+ if(checkCourseDiscount){
|
|
|
+ previousOrderCourse.setDiscountPrice(appCourses.getSellingPrice());
|
|
|
+ previousOrderCourse.setTotalDiscount(appCourses.getSellingPrice());
|
|
|
+ }else {
|
|
|
+ previousOrderCourse.setDiscountPrice(BigDecimal.ZERO);
|
|
|
+ previousOrderCourse.setTotalDiscount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ return previousOrderCourse;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -84,10 +96,12 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
.eq(AppOrder::getDelFlag, 0)
|
|
|
.eq(AppOrder::getType,2));
|
|
|
if (appOrders.isEmpty()) return true;
|
|
|
- appOrders.forEach(appOrder -> {
|
|
|
- AppCourses appCourses = appCoursesMapper.selectById(appOrder.getProductIds());
|
|
|
-// if(appCourses.getCategoryId().equals(categoryId)) success = Boolean.FALSE;
|
|
|
- });
|
|
|
+ for (AppOrder appOrder : appOrders) {
|
|
|
+ if (!appOrder.getProductIds().contains(categoryId)) {
|
|
|
+ success = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
return success;
|
|
|
}
|
|
|
}
|