Forráskód Böngészése

Merge branch 'master' of http://git.zonelife.cn:3000/huangyang/national-motion-backend

zhangxin 4 hete
szülő
commit
d632ea8543

+ 22 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -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();

+ 5 - 5
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java

@@ -266,14 +266,14 @@ public class OrderServiceImpl implements IOrderService {
         previousOrderCourse.setId(appCourses.getId())
                 .setCover(list.get(0).split(",")[0])
                 .setName(appCourses.getName())
-                .setSellingPrice(appCourses.getSellingPrice())
+                .setSellingPrice(appCourses.getOriginalPrice())
                 .setReminder(appCourses.getReminder())
                 .setHasDiscount(checkCourseDiscount);
         if (checkCourseDiscount) {
-            previousOrderCourse.setDiscountPrice(appCourses.getSellingPrice());
-            previousOrderCourse.setTotalDiscount(appCourses.getSellingPrice());
+            previousOrderCourse.setDiscountPrice(appCourses.getOriginalPrice());
+            previousOrderCourse.setTotalDiscount(appCourses.getOriginalPrice());
             previousOrderCourse.setSubtotal(appCourses.getSellingPrice().subtract(appCourses.getSellingPrice()));
-            previousOrderCourse.setTotalPrice(appCourses.getSellingPrice().subtract(appCourses.getSellingPrice()));
+            previousOrderCourse.setTotalPrice(appCourses.getSellingPrice());
         } else {
             previousOrderCourse.setDiscountPrice(BigDecimal.ZERO);
             previousOrderCourse.setTotalDiscount(BigDecimal.ZERO);
@@ -1037,7 +1037,7 @@ public class OrderServiceImpl implements IOrderService {
         params.put("payer", payer);
 
         //拉起支付-返回JSAPI参数
-        Map<String, String> result = weChatPayService.wechatPay(params);
+//        Map<String, String> result = weChatPayService.wechatPay(params);
 //        payForm.setParams(result);
 
         //发布任务到redission延迟队列

+ 3 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/CourseInfoVO.java

@@ -24,6 +24,9 @@ public class CourseInfoVO {
     private Integer priceType;
     @Schema(description = "原价")
     private BigDecimal originalPrice;
+    private String categoryId;
+    @Schema(description = "是否有优惠")
+    private Boolean hasDiscount;
     @Schema(description = "售价")
     private BigDecimal sellingPrice;
     @Schema(description = "封面")

+ 1 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppCoursesMapper.xml

@@ -51,6 +51,7 @@
             a.fit_people,
             a.start_time,
             a.end_time,
+            a.category_id,
             COUNT( c.id ) AS classHour,
             a.limit_num,
             a.reminder,