|
@@ -9,6 +9,7 @@ import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.system.vo.DictModel;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.modules.app.service.IDetailService;
|
|
@@ -142,6 +143,7 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
|
|
|
@Override
|
|
|
public CourseInfoVO getCourseInfo(String id, double latitude, double longitude) {
|
|
|
+ LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
CourseInfoVO courseInfoVO = appCoursesMapper.getCourseInfo(id);
|
|
|
AppSite appSite = appSiteMapper.selectById(courseInfoVO.getAddressSiteId());
|
|
|
if (appSite!=null&& ObjectUtils.isNotEmpty(appSite.getLatitude())&& ObjectUtils.isNotEmpty(appSite.getLongitude())){
|
|
@@ -157,9 +159,29 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
});
|
|
|
|
|
|
courseInfoVO.setCourseDetail(courseDetailVOList);
|
|
|
+ courseInfoVO.setHasDiscount(checkOrderOrFree(loginUser.getId(),courseInfoVO.getCategoryId()));
|
|
|
return courseInfoVO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验是否为第一次购买当前类目的课程
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param categoryId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean checkOrderOrFree(String userId, String categoryId) {
|
|
|
+ //查询当前用户的所有课程订单
|
|
|
+ List<AppOrder> appOrders = appOrderMapper.selectList(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getUserId, userId).eq(AppOrder::getType, CommonConstant.ORDER_TYPE_2));
|
|
|
+ for (AppOrder appOrder : appOrders) {
|
|
|
+ AppCourses appCours = appCoursesMapper.selectById(appOrder.getProductIds());
|
|
|
+ if (appCours.getCategoryId().equals(categoryId)) {
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<PlaceInfoVO.CourseInfoVO> courseInfoVOList(String categoryId,String id,double longitude,double latitude) {
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|