From c321a119aa3dd4ff4bfa30b795b7f5386675f10c Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期五, 11 八月 2023 14:37:29 +0800
Subject: [PATCH] course模块:补充 课包排课记录 mapper和service

---
 cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java |   65 +++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java
index 2dbce49..86028ae 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java
@@ -5,6 +5,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.nacos.common.utils.UuidUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dsh.course.entity.CoursePackagePaymentConfig;
 import com.dsh.course.entity.TCoursePackage;
@@ -126,7 +127,7 @@
             Store store = storeClient.queryStoreById(coursePackage.getStoreId());
             Integer integer = coursePackagePaymentService.queryCountNumber(coursePackage.getId());
             CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getOne(new QueryWrapper<CoursePackagePaymentConfig>()
-                    .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours limit 0, 1"));
+                    .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours").last(" limit 0, 1"));
             CoursePackageListVo coursePackageListVo = new CoursePackageListVo();
             coursePackageListVo.setId(coursePackage.getId());
             coursePackageListVo.setName(coursePackage.getName());
@@ -135,7 +136,7 @@
             coursePackageListVo.setClassStartTime(coursePackage.getClassStartTime() + "-" + coursePackage.getClassEndTime());
             coursePackageListVo.setApplicantsNumber(integer);
             coursePackageListVo.setPayType(coursePackage.getPayType());
-            coursePackageListVo.setPlayPaiCoin(coursePackageListVo.getPlayPaiCoin());
+            coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin());
 
             //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低)
             if(appUser.getIsVip() == 0){//非会员
@@ -143,7 +144,7 @@
                         .eq("type", 1).eq("auditStatus", 2));
                 Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                 for (TCoursePackageDiscount coursePackageDiscount : list2) {
-                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1");
+                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
                     if(vipPrice.compareTo(num1) > 0){
                         vipPrice = num1;
                     }
@@ -232,7 +233,7 @@
                         .eq("type", 1).eq("auditStatus", 2));
                 Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                 for (TCoursePackageDiscount coursePackageDiscount : list2) {
-                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1");
+                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
                     if(vipPrice.compareTo(num1) > 0){
                         vipPrice = num1;
                     }
@@ -312,7 +313,7 @@
                         .eq("type", 1).eq("auditStatus", 2));
                 Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                 for (TCoursePackageDiscount coursePackageDiscount : list2) {
-                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1");
+                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
                     if(vipPrice.compareTo(num1) > 0){
                         vipPrice = num1;
                     }
@@ -401,7 +402,7 @@
                         .eq("type", 1).eq("auditStatus", 2));
                 Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                 for (TCoursePackageDiscount coursePackageDiscount : list2) {
-                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("num1");
+                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
                     if(vipPrice.compareTo(num1) > 0){
                         vipPrice = num1;
                     }
@@ -415,10 +416,13 @@
 
         Student student = studentClient.queryDefaultStudent(uid);
         StudentVo studentVo = new StudentVo();
-        studentVo.setId(student.getId());
-        studentVo.setPhone(student.getPhone());
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
-        studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(student.getBirthday())));
+        if(null != student){
+            studentVo.setId(student.getId());
+            studentVo.setPhone(student.getPhone());
+            studentVo.setName(student.getName());
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+            studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(student.getBirthday())));
+        }
         coursePackageInfo.setStudent(studentVo);
         return coursePackageInfo;
     }
@@ -476,8 +480,9 @@
             }
             if(coupon.getType() == 1){//满减
                 JSONObject jsonObject = JSON.parseObject(coupon.getContent());
-                Double num1 = jsonObject.getDouble("num1");
-                Double num2 = jsonObject.getDouble("num2");
+//                {"conditionalAmount":50,"deductionAmount":10,"experienceName":""}
+                Double num1 = jsonObject.getDouble("conditionalAmount");
+                Double num2 = jsonObject.getDouble("deductionAmount");
                 if(price.compareTo(num1) <= 0){
                     return ResultUtil.error("该优惠券无法使用");
                 }
@@ -486,7 +491,7 @@
             }
             if(coupon.getType() == 2){//代金券
                 JSONObject jsonObject = JSON.parseObject(coupon.getContent());
-                Double num1 = jsonObject.getDouble("num1");
+                Double num1 = jsonObject.getDouble("conditionalAmount");
                 if(price.compareTo(num1) <= 0){
                     return ResultUtil.error("该优惠券无法使用");
                 }
@@ -546,7 +551,7 @@
             coursePackagePaymentService.save(coursePackagePayment);
         }
 
-        ResultUtil weixinpay = payMoneyUtil.weixinpay("购买课程", "", code, paymentPrice.toString(), "/base/course/weChatPaymentCourseCallback", "APP");
+        ResultUtil weixinpay = payMoneyUtil.weixinpay("购买课程", "", code, paymentPrice.toString(), "/base/course/weChatPaymentCourseCallback", "APP", "");
         if(weixinpay.getCode() == 200){
             new Thread(new Runnable() {
                 @Override
@@ -643,7 +648,7 @@
             coursePackagePaymentService.save(coursePackagePayment);
         }
 
-        ResultUtil alipay = payMoneyUtil.alipay("购买课程", "", code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback");
+        ResultUtil alipay = payMoneyUtil.alipay("购买课程", "购买课程", "", code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback");
         if(alipay.getCode() == 200){
             new Thread(new Runnable() {
                 @Override
@@ -741,4 +746,34 @@
         appUserClient.updateAppUser(appUser);
         return ResultUtil.success();
     }
+
+
+    /**
+     * 获取课包管理列表数据
+     * @param queryCoursePackageLists
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> queryCoursePackageLists(Page<Map<String, Object>> page, QueryCoursePackageLists queryCoursePackageLists) {
+        List<Map<String, Object>> list = this.baseMapper.queryCoursePackageLists(page, queryCoursePackageLists);
+        for (Map<String, Object> map : list) {
+            Integer id = Integer.valueOf(map.get("id").toString());
+            Integer integer = coursePackagePaymentService.queryCountNumber(id);
+            map.put("paymentNumber", integer);
+
+            boolean cash = false;
+            boolean coin = false;
+            List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id));
+            for (CoursePackagePaymentConfig coursePackagePaymentConfig : coursePackagePaymentConfigs) {
+                if(0 != coursePackagePaymentConfig.getCashPayment()){
+                    cash = true;
+                }
+                if(0 != coursePackagePaymentConfig.getPlayPaiCoin()){
+                    coin = true;
+                }
+            }
+            map.put("payType", (cash ? "现金支付" : "") + (coin ?  cash ? "&玩湃币支付" : "玩湃币支付" : ""));
+        }
+        return list;
+    }
 }

--
Gitblit v1.7.1