|
@@ -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.IDetailService;
|
|
|
import org.jeecg.modules.app.vo.CourseInfoVO;
|
|
|
import org.jeecg.modules.app.vo.PlaceInfoVO;
|
|
@@ -33,11 +35,18 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
private AppSitePriceRulesMapper appSitePriceRulesMapper;
|
|
|
@Resource
|
|
|
private AppInstructorMapper appInstructorMapper;
|
|
|
+ @Resource
|
|
|
+ private AppOrderMapper appOrderMapper;
|
|
|
|
|
|
@Override
|
|
|
public PlaceInfoVO getPlaceInfo(String id) {
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
AppSite appSite = appSiteMapper.selectById(id);
|
|
|
PlaceInfoVO placeInfo = appSiteMapper.getPlaceInfo(id);
|
|
|
+ AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery()
|
|
|
+ .eq(AppSitePriceRules::getSiteId, id)
|
|
|
+ .eq(AppSitePriceRules::getStatus, 0)
|
|
|
+ .last("limit 1"));
|
|
|
List<PlaceInfoVO.InstructorVO> instructorVOList = new ArrayList<>();
|
|
|
List<AppInstructor> appInstructors = appInstructorMapper.selectList(Wrappers.<AppInstructor>lambdaQuery()
|
|
|
.eq(AppInstructor::getOrgCode, appSite.getOrgCode()));
|
|
@@ -48,21 +57,44 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
instructorVOList.add(vo);
|
|
|
}
|
|
|
}
|
|
|
- AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery()
|
|
|
- .eq(AppSitePriceRules::getSiteId, id)
|
|
|
- .eq(AppSitePriceRules::getStatus, 0)
|
|
|
- .last("limit 1"));
|
|
|
- PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
|
|
|
- placeInfoMsgVO.setName(appSite.getName())
|
|
|
- .setSales(getPlaceSales(id))
|
|
|
- .setOriginalPrice(appSitePriceRules.getOriginalPrice())
|
|
|
- .setSellingPrice(appSitePriceRules.getSellingPrice());
|
|
|
- placeInfo.setInstructorVOList(instructorVOList)
|
|
|
- .setPlaceInfoMsgVO(placeInfoMsgVO);
|
|
|
- //todo 评价查询待添加
|
|
|
- return placeInfo;
|
|
|
+ List<PlaceInfoVO.CourseInfoVO> courseInfoVOList = new ArrayList<>();
|
|
|
+ appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
|
|
|
+ .eq(AppCourses::getSiteId, id)
|
|
|
+ .eq(AppCourses::getStatus, 0)
|
|
|
+ .eq(AppCourses::getDelFlag, 0)).forEach(appCourses -> {
|
|
|
+ PlaceInfoVO.CourseInfoVO courseInfoVO = new PlaceInfoVO.CourseInfoVO();
|
|
|
+ BeanUtils.copyProperties(courseInfoVO, appCourses);
|
|
|
+ courseInfoVO.setSales(getCourseSalesCount(appCourses.getId()));
|
|
|
+ courseInfoVO.setSalesYear(getCourseSales(appCourses.getId()));
|
|
|
+ courseInfoVO.setPriceType(isFirstPurchase(user.getId()));
|
|
|
+ courseInfoVOList.add(courseInfoVO);
|
|
|
+ });
|
|
|
+ placeInfo.setInstructorVOList(instructorVOList);
|
|
|
+ placeInfo.setCourseInfoVOList(courseInfoVOList);
|
|
|
+ if(appSite.getType() == 0){
|
|
|
+ //todo 评价查询待添加
|
|
|
+ PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
|
|
|
+ placeInfoMsgVO.setName(appSite.getName())
|
|
|
+ .setSales(getPlaceSales(id))
|
|
|
+ .setOriginalPrice(appSitePriceRules.getOriginalPrice())
|
|
|
+ .setSellingPrice(appSitePriceRules.getSellingPrice());
|
|
|
+ placeInfo.setPlaceInfoMsgVO(placeInfoMsgVO);
|
|
|
+ return placeInfo;
|
|
|
+ }else if(appSite.getType() == 1){
|
|
|
+// //todo 评价查询待添加
|
|
|
+ PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
|
|
|
+ placeInfoMsgVO.setName(appSite.getName())
|
|
|
+ .setSales(getPlaceSales(id))
|
|
|
+ .setOriginalPrice(appSitePriceRules.getOriginalPrice())
|
|
|
+ .setSellingPrice(appSitePriceRules.getSellingPrice());
|
|
|
+ placeInfo.setPlaceInfoMsgVO(placeInfoMsgVO);
|
|
|
+ return placeInfo;
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public CourseInfoVO getCourseInfo(String id, double latitude, double longitude) {
|
|
|
CourseInfoVO courseInfoVO = appCoursesMapper.getCourseInfo(id);
|
|
@@ -88,7 +120,7 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
* @Date 20:02 2025/7/7
|
|
|
* @Param
|
|
|
**/
|
|
|
- public int getPlaceSales(String id) {
|
|
|
+ private int getPlaceSales(String id) {
|
|
|
List<String> ids = appCoursesPriceRulesMapper.selectRuleIdsByCourseId(id);
|
|
|
int totalOrders = 0;
|
|
|
if (!ids.isEmpty()) {
|
|
@@ -120,4 +152,34 @@ public class DetailServiceImpl implements IDetailService {
|
|
|
.lt(AppOrderProduct::getCreateTime, Date.from(endOfYear.atZone(ZoneId.systemDefault()).toInstant())) // < 2026-01-01
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 计算当前课程销售数
|
|
|
+ * @Date 15:47 2025/7/8
|
|
|
+ * @Param id 课程id
|
|
|
+ * @return int 课程年销售数
|
|
|
+ **/
|
|
|
+ private int getCourseSalesCount(String id) {
|
|
|
+ return Math.toIntExact(appOrderProductMapper.selectCount(
|
|
|
+ Wrappers.<AppOrderProduct>lambdaQuery()
|
|
|
+ .eq(AppOrderProduct::getProductId, id)
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 查询用户是否为第一次购买
|
|
|
+ * @Date 16:54 2025/7/8
|
|
|
+ * @Param
|
|
|
+ * @return
|
|
|
+ **/
|
|
|
+ private int isFirstPurchase(String userId) {
|
|
|
+ AppOrder appOrder = appOrderMapper.selectOne(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getUpdateBy, userId).last("limit 1"));
|
|
|
+ if(null == appOrder){
|
|
|
+ return 1;
|
|
|
+ }else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|