From d41358fce9a436d81b9341d06fc1d8f3ddff92ff Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期一, 25 九月 2023 16:17:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java |  128 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 122 insertions(+), 6 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
index 5c556a6..74a3729 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -5,6 +5,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dsh.course.entity.*;
 import com.dsh.course.feignclient.account.AppUserClient;
@@ -12,6 +13,8 @@
 import com.dsh.course.feignclient.account.model.AppUser;
 import com.dsh.course.feignclient.account.model.Student;
 import com.dsh.course.feignclient.account.model.TCourseInfoRecord;
+import com.dsh.course.feignclient.activity.CouponClient;
+import com.dsh.course.feignclient.activity.model.Coupon;
 import com.dsh.course.feignclient.model.*;
 import com.dsh.course.feignclient.other.StoreClient;
 import com.dsh.course.feignclient.other.model.Store;
@@ -30,6 +33,9 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import net.bytebuddy.asm.Advice;
+import org.aspectj.weaver.ast.Var;
+import io.swagger.models.auth.In;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -106,12 +112,113 @@
 
     @Autowired
     private RestTemplate internalRestTemplate;
+    @Autowired
+    private CouponClient couponClient;
+    @Autowired
+    private StoreClient storeClient;
+    @Autowired
+    private TCoursePackageDiscountService discountService;
 
     @Resource
     private CoursePackageSchedulingMapper coursePackageSchedulingMapper;
 
 
     private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
+
+    /**
+     * 手动支付
+     * @return
+     */
+    @RequestMapping("/base/coursePackagePayment/changeState")
+    public Object changeState(@RequestBody CoursePackagePayDTO dto){
+
+        return packagePaymentService.changeState(dto);
+    }
+    /**
+     * 获取购课记录
+     */
+    @ResponseBody
+    @RequestMapping("/coursePackagePayment/listAll")
+    public List<CoursePackagePaymentVO> listAll(@RequestBody CoursePackagePaymentQuery query){
+        List<CoursePackagePaymentVO> res = packagePaymentService.listAll(query);
+        List<CoursePackagePaymentVO> result = new ArrayList<>();
+        for (CoursePackagePaymentVO re : res) {
+            if (re.getCashPayment()==null){
+                String value = String.valueOf(re.getPlayPaiCoin());
+                re.setCashPayment(new BigDecimal(value));
+            }
+
+            Store store = storeClient.queryStoreById(re.getStoreId());
+            AppUser appUser = appUserClient.queryAppUser(re.getAppUserId());
+            Student student = studentClient.queryStudentById(re.getStudentId());
+            re.setPayStudent(student.getName());
+            re.setPayUser(appUser.getName());
+            re.setPhone(appUser.getPhone());
+            re.setStoreName(store.getName());
+            if (query.getPayUser()== null || query.getPayUser().equals("") ){
+            }else{
+                List<AppUser> appUsers = appUserClient.queryAppUserListByName(query.getPayUser());
+                for (AppUser user : appUsers) {
+                    if (appUser.getName().equals(user.getName())){
+                        result.add(re);
+                    }
+                }
+            }
+            if (query.getPayStudent()== null || query.getPayStudent().equals("")){
+            }else{
+                List<Student> students = studentClient.queryStudentListByName(query.getPayStudent());
+                for (Student student1 : students) {
+                    if (student.getName().equals(student1.getName())){
+                        result.add(re);
+                    }
+                }
+            }
+
+            if (re.getPayType()==1){
+                re.setBuyTypeName("微信支付");
+            }else if(re.getPayType()==2){
+                re.setBuyTypeName("支付宝支付");
+            }else if(re.getPayType()==3){
+                re.setBuyTypeName("玩湃币支付");
+            }else if(re.getPayType()==4){
+                re.setBuyTypeName("积分支付");
+            }else if(re.getPayType()==5){
+                re.setBuyTypeName("积分+微信支付");
+            }else if(re.getPayType()==6){
+                re.setBuyTypeName("积分+支付宝支付");
+            }else if(re.getPayType()==7){
+                re.setBuyTypeName("手动支付"+"-"+re.getBuyTypeName());
+            }
+            // 如果支付用户类型为平台 则购买方式则为1线下购买
+            if (re.getPayUserType()== 2){
+                re.setBuyType(1);
+            }else{
+                // 如果当前课包有折扣 则为3折扣购买
+                if (discountService.list(new QueryWrapper<TCoursePackageDiscount>()
+                        .eq("coursePackageId",re.getCoursePackageId()).eq("auditStatus",2)).size()>0){
+                    re.setBuyType(3);
+                    re.setDiscountAmount(re.getOriginalPrice().subtract(re.getPayMoney()));
+                }else{
+                    re.setBuyType(2);
+                }
+            }
+            // 不为空则计算
+            if (re.getUserCouponId()!=null){
+
+            }
+            // todo 计算优惠金额
+//            Coupon coupon = couponClient.queryCouponById(re.getUserCouponId().intValue());
+        }
+        if (query.getPayStudent()== null || query.getPayStudent().equals("")){
+            if (query.getPayUser()== null || query.getPayUser().equals("")){
+                return res;
+            }else{
+                return result;
+            }
+        }else{
+            return result;
+        }
+    }
 
     /**
      * 获取 没有学员信息的图片配置
@@ -443,7 +550,6 @@
         }
     }
 
-
     /**
      * 课后视频课表
      */
@@ -497,7 +603,6 @@
         }
     }
 
-
     @ResponseBody
     @PostMapping("/api/startCource/payCourseInfo")
     @ApiOperation(value = "课后练习-购课详情(用于购课)", tags = {"APP-开始上课"})
@@ -511,7 +616,6 @@
             return ResultUtil.runErr();
         }
     }
-
 
     @ResponseBody
     @PostMapping("/api/startCource/getMyCourseList")
@@ -550,7 +654,6 @@
         }
     }
 
-
     /**
      * 更新课后视频学习状态
      */
@@ -571,7 +674,6 @@
             return ResultUtil.runErr();
         }
     }
-
 
 
     @ResponseBody
@@ -615,7 +717,6 @@
         }catch (Exception e){
             return ResultUtil.runErr();
         }
-
     }
 
 
@@ -933,6 +1034,11 @@
                 .eq("code",code));
     }
 
+
+    @PostMapping("/base/coursePack/getCoursePackagePaymentById")
+    public TCoursePackagePayment getCoursePackagePaymentById(@RequestBody Integer id){
+        return packagePaymentService.getById(id);
+    }
     @PostMapping("/base/coursePack/delPaymentCoursePackage")
     public boolean delPaymentCoursePackage(@RequestBody Integer payId){
         return packagePaymentService.removeById(payId);
@@ -1055,6 +1161,16 @@
     }
 
 
+    @ResponseBody
+    @PostMapping("/coursePackagePayment/CountqueryByClassId")
+   public   Integer  CountqueryByClassId(@RequestBody Integer id){
+        int coursePackageId = packagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", id));
+
+
+        return coursePackageId;
+    }
+
+
     /**
      * 修改数据
      * @param coursePackagePayment

--
Gitblit v1.7.1