From f6ba3e15355e22767e69f8fc14ae22523f8db8dc Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 22 十一月 2023 19:33:58 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai

---
 cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java |  124 +++++++++++++++++++++++++++--------------
 1 files changed, 81 insertions(+), 43 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 3709539..ecd2b5c 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
@@ -298,12 +298,14 @@
             double originalPrice1 = coursePackageListVo.getOriginalPrice();
             double paymentPrice1 = coursePackageListVo.getPaymentPrice();
 
-            double minPrice = Math.min(vipPrice1, Math.min(originalPrice1, paymentPrice1));
-            double maxPrice = Math.max(vipPrice1, Math.max(originalPrice1, paymentPrice1));
-            coursePackageListVo.setPaymentPrice(minPrice);
-            coursePackageListVo.setOriginalPrice(maxPrice);
-            System.out.println("Minimum price: " + minPrice);
-            System.out.println("Maximum price: " + maxPrice);
+//            double minPrice = Math.min(vipPrice1, Math.min(originalPrice1, paymentPrice1));
+//            double maxPrice = Math.max(vipPrice1, Math.max(originalPrice1, paymentPrice1));
+//            coursePackageListVo.setPaymentPrice(minPrice);
+//            coursePackageListVo.setOriginalPrice(maxPrice);
+//            System.out.println("Minimum price: " + minPrice);
+
+
+
 //            }
 //            else{
 //                List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
@@ -318,6 +320,20 @@
 //                coursePackageListVo.setPaymentPrice(vipPrice);
 //                coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
 //            }
+
+            if (coursePackageListVo.getPaymentPrice()<coursePackageListVo.getVipPrice()){
+                coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
+//                coursePackageListVo.setVipPrice(null);
+            }
+
+            if(appUser.getIsVip() == 1) {
+                if (coursePackageListVo.getVipPrice() < coursePackageListVo.getPaymentPrice()) {
+                    coursePackageListVo.setPaymentPrice(coursePackageListVo.getVipPrice());
+                }
+            }else {
+                coursePackageListVo.setVipPrice(null);
+            }
+
 
             Map<String, Double> distance = GeodesyUtil.getDistance(coursePackageList.getLon() + "," + coursePackageList.getLat(), store.getLon() + "," + store.getLat());
             coursePackageListVo.setDistance(distance.get("WGS84") / 1000);
@@ -637,7 +653,7 @@
 
 //                coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType());
                 //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低)
-                if(appUser.getIsVip() == 0){//非会员
+//                if(appUser.getIsVip() == 0){//非会员
                     List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                             .eq("type", 1).eq("auditStatus", 2));
                     Double vipPrice = coursePackagePaymentConfig.getCashPayment();
@@ -728,42 +744,50 @@
 
 
 
-                    TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
-                            .eq("type", 2).eq("auditStatus", 2));
+//                    TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
+//                            .eq("type", 2).eq("auditStatus", 2));
+//
+//
+//                    //这里是续课优惠
+//                    Double continuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingUser");
+//                    Double vipcontinuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingMember");
+//
+//
+//                    if (coursePackagePaymentConfigVo.getPaymentPrice()>continuingMember){
+//                        coursePackagePaymentConfigVo.setPaymentPrice(continuingMember);
+//                    }
+//                    if (coursePackagePaymentConfigVo.getVipPrice()>vipcontinuingMember){
+//                        coursePackagePaymentConfigVo.setVipPrice(vipcontinuingMember);
+//                    }
+                if(appUser.getIsVip() == 1) {
+                        if (coursePackagePaymentConfigVo.getVipPrice()<coursePackagePaymentConfigVo.getPaymentPrice()){
+                            coursePackagePaymentConfigVo.setPaymentPrice(coursePackagePaymentConfigVo.getVipPrice());
+                        }
 
+                                }
 
-                    //这里是续课优惠
-                    Double continuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingUser");
-                    Double vipcontinuingMember = JSON.parseObject(discount.getContent()).getDouble("continuingMember");
-
-
-                    if (coursePackagePaymentConfigVo.getPaymentPrice()>continuingMember){
-                        coursePackagePaymentConfigVo.setPaymentPrice(continuingMember);
-                    }
-                    if (coursePackagePaymentConfigVo.getVipPrice()>vipcontinuingMember){
-                        coursePackagePaymentConfigVo.setVipPrice(vipcontinuingMember);
-                    }
-
-
-                    if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){
+                if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){
                         coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
                         coursePackagePaymentConfigVo.setVipPrice(null);
                     }
 
-                }
-                else{
-                    List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
-                            .eq("type", 1).eq("auditStatus", 2));
-                    Double vipPrice = coursePackagePaymentConfig.getCashPayment();
-                    for (TCoursePackageDiscount coursePackageDiscount : list2) {
-                        Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
-                        if(vipPrice.compareTo(num1) > 0){
-                            vipPrice = num1;
-                        }
-                    }
-                    coursePackagePaymentConfigVo.setPaymentPrice(vipPrice);
-                    coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
-                }
+
+
+
+//                }
+//                else{
+//                    List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
+//                            .eq("type", 1).eq("auditStatus", 2));
+//                    Double vipPrice = coursePackagePaymentConfig.getCashPayment();
+//                    for (TCoursePackageDiscount coursePackageDiscount : list2) {
+//                        Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
+//                        if(vipPrice.compareTo(num1) > 0){
+//                            vipPrice = num1;
+//                        }
+//                    }
+//                    coursePackagePaymentConfigVo.setPaymentPrice(vipPrice);
+//                    coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
+//                }
                 list.add(coursePackagePaymentConfigVo);
             });
             coursePackageInfo.setList(list);
@@ -872,6 +896,9 @@
                 }
                 price = new BigDecimal(price).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
             }
+            userCoupon.setStatus(2);
+           userCouponClient.edit(userCoupon);
+
         }
 
         if(paymentCourseVo.getPayType() == 1){//微信支付
@@ -1126,11 +1153,13 @@
 //                coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
 //                coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours());
 //                coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours());
-//                coursePackagePaymentServiceOne.setCode(code);
+                coursePackagePaymentServiceOne.setCode(code);
 //
-//                coursePackagePaymentServiceOne.setAppUserId(null);
+                coursePackagePaymentServiceOne.setPayStatus(2);
+                coursePackagePaymentServiceOne.setSalesName("续课");
+                coursePackagePaymentServiceOne.setAppUserId(null);
 //                coursePackagePaymentServiceOne.setPayStatus(2);
-//                coursePackagePaymentService.updateById(coursePackagePaymentServiceOne);
+                coursePackagePaymentService.updateById(coursePackagePaymentServiceOne);
 //
 //                Integer sId = null;
 //                Student student = studentClient.queryDefaultStudent(uid);
@@ -1165,6 +1194,8 @@
                 @Override
                 public void run() {
                     try {
+                        Thread.sleep(1000);
+
                         int num = 1;
                         int wait = 0;
                         while (num <= 10){
@@ -1173,10 +1204,11 @@
                             Thread.sleep(wait);
                             List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 2));
                             TCoursePackagePayment one = list.get(0);
+                            AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code);
                             if(one.getPayStatus() == 2){
                                 break;
                             }
-                            AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code);
+
                             if( one.getPayStatus() == 1){
                                 /**
                                  * WAIT_BUYER_PAY(交易创建,等待买家付款)、
@@ -1188,7 +1220,13 @@
 
                                 String tradeNo = alipayTradeQueryResponse.getTradeNo();
                                 if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){
-                                    for (TCoursePackagePayment coursePackagePayment : list) {
+                                        for (TCoursePackagePayment coursePackagePayment : list) {
+                                        if (coursePackagePayment.getStudentName()!=null){
+                                        if (coursePackagePayment.getStudentName().equals("续课")){
+                                            coursePackagePayment.setPayStatus(2);
+                                        }
+                                        }
+
                                         coursePackagePayment.setStatus(3);
                                     }
                                     coursePackagePaymentService.updateBatchById(list);
@@ -1632,7 +1670,7 @@
                 if (count == can) {
                     break;
                 }
-                int wei = DateUtil.dayOfWeek(date);
+                int wei = DateUtil.dayOfWeek(date)-1;
                 if (week.contains(wei)) {
                     for (int i1 = 0; i1 < split.length; i1++) {
                         if (count == can) {

--
Gitblit v1.7.1