Przeglądaj źródła

fix 学习记录

he2802 3 lat temu
rodzic
commit
237a0c8fa4

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsRefundService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.order.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.order.bo.OrderAddBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundAddBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundEditBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundQueryBo;
@@ -9,6 +10,7 @@ import com.zhongzheng.modules.order.vo.OrderGoodsRefundVo;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 订单商品退款Service接口
@@ -35,6 +37,8 @@ public interface IOrderGoodsRefundService extends IService<OrderGoodsRefund> {
 	 */
 	Boolean insertByAddBo(OrderGoodsRefundAddBo bo);
 
+	Map<String, String> placeRefundOrder(OrderGoodsRefundAddBo bo);
+
 	/**
 	 * 根据编辑业务对象修改订单商品退款
 	 * @param bo 订单商品退款编辑业务对象

+ 37 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsRefundServiceImpl.java

@@ -1,15 +1,23 @@
 package com.zhongzheng.modules.order.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundAddBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundEditBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundQueryBo;
+import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.domain.OrderGoodsRefund;
 import com.zhongzheng.modules.order.mapper.OrderGoodsRefundMapper;
 import com.zhongzheng.modules.order.service.IOrderGoodsRefundService;
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.vo.OrderGoodsRefundVo;
+import com.zhongzheng.modules.user.domain.User;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -19,6 +27,7 @@ import com.github.pagehelper.Page;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -30,6 +39,11 @@ import java.util.stream.Collectors;
 @Service
 public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMapper, OrderGoodsRefund> implements IOrderGoodsRefundService {
 
+    @Autowired
+    private IOrderGoodsService iOrderGoodsService;
+    @Autowired
+    private IGoodsService iGoodsService;
+
     @Override
     public OrderGoodsRefundVo queryById(Long refundId){
         OrderGoodsRefund db = this.baseMapper.selectById(refundId);
@@ -78,6 +92,29 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
         return this.save(add);
     }
 
+    @Override
+    public Map<String, String> placeRefundOrder(OrderGoodsRefundAddBo bo) {
+        OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderSn,bo.getOrderSn())
+                .eq(OrderGoods::getGoodsId, bo.getGoodsId()));
+        if(Validator.isEmpty(orderGoods)){
+            throw new CustomException("订单商品数据错误");
+        }
+        if(orderGoods.getPayStatus()!=3){
+            throw new CustomException("订单商品尚未完全收费");
+        }
+        if(orderGoods.getRefundStatus()==2){
+            throw new CustomException("订单商品已退款");
+        }
+        if(orderGoods.getRefundStatus()!=0){
+            throw new CustomException("订单商品目前无法退款");
+        }
+        //订单商品
+        Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId,bo.getGoodsId()));
+
+
+        return null;
+    }
+
     @Override
     public Boolean updateByEditBo(OrderGoodsRefundEditBo bo) {
         OrderGoodsRefund update = BeanUtil.toBean(bo, OrderGoodsRefund.class);

+ 6 - 6
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -320,9 +320,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ( SELECT s.school_name FROM school s WHERE s.id = g.school_id ) AS school_name,
         ( SELECT e.education_name FROM course_education_type e WHERE e.id = g.education_type_id ) AS education_name,
         (SELECT COUNT(a.id)+(SELECT COUNT(a.id) FROM goods_attached e LEFT JOIN question_chapter_exam a on e.major_id = a.chapter_exam_id where e.goods_id = g.goods_id and e.type=2)+(SELECT COUNT(h.id) FROM goods_attached e LEFT JOIN question_module_chapter a on e.major_id = a.module_exam_id LEFT JOIN question_chapter_exam h on a.chapter_exam_id = h.chapter_exam_id  where e.goods_id = g.goods_id and e.type=1) FROM goods_attached a where a.goods_id=g.goods_id and a.type = 3) as exam_num,
-        (SELECT create_time FROM user_bank_record r where r.goods_id=g.goods_id ORDER BY create_time ASC LIMIT 1) as start_time,
-        (SELECT create_time FROM user_bank_record r where r.goods_id=g.goods_id ORDER BY create_time DESC LIMIT 1) as end_time,
-        (SELECT COUNT(DISTINCT exam_id) FROM user_bank_record r where r.goods_id=g.goods_id) as stu_all_num
+        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY create_time ASC LIMIT 1) as start_time,
+        (SELECT create_time FROM user_exam_record r where r.goods_id=g.goods_id AND r.user_id = #{userId} ORDER BY create_time DESC LIMIT 1) as end_time,
+        (SELECT COUNT(DISTINCT exam_id) FROM user_exam_record r where r.goods_id=g.goods_id  AND r.user_id = #{userId}) as stu_all_num
         FROM
         goods g
         LEFT JOIN order_goods s ON g.goods_id = s.goods_id
@@ -343,7 +343,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         0 as chapter_num,
         1 as exam_num,
         (select COUNT(q.id) FROM exam_question q where e.exam_id = q.exam_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_bank_record r where r.goods_id = a.goods_id and r.exam_id = e.exam_id  <if test="userId != null and userId !=''">
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r where r.goods_id = a.goods_id and r.exam_id = e.exam_id  <if test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM
@@ -363,7 +363,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         1 as chapter_num,
         (SELECT COUNT(e.id) FROM question_chapter_exam e where c.chapter_exam_id=e.chapter_exam_id) as exam_num,
         (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m  on m.exam_id = q.exam_id where m.chapter_exam_id = a.major_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_bank_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id  where r.goods_id = a.goods_id and m.chapter_exam_id=c.chapter_exam_id   <if test="userId != null and userId !=''">
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id  where r.goods_id = a.goods_id and m.chapter_exam_id=c.chapter_exam_id   <if test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM
@@ -383,7 +383,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         (SELECT COUNT(e.id) FROM question_module_chapter e where c.module_exam_id=e.module_exam_id) as chapter_num,
         (SELECT COUNT(e.id) FROM question_chapter_exam e LEFT JOIN question_module_chapter r on e.chapter_exam_id = r.chapter_exam_id  where c.module_exam_id=r.module_exam_id) as exam_num,
         (select COUNT(q.id) FROM exam_question q LEFT JOIN question_chapter_exam m on m.exam_id = q.exam_id LEFT JOIN question_module_chapter r on m.chapter_exam_id = r.chapter_exam_id where r.module_exam_id = a.major_id) as question_num,
-        (SELECT COUNT(DISTINCT r.exam_id) FROM user_bank_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id LEFT JOIN question_module_chapter l on l.chapter_exam_id = m.chapter_exam_id where r.goods_id = a.goods_id and l.module_exam_id = a.major_id  <if test="userId != null and userId !=''">
+        (SELECT COUNT(DISTINCT r.exam_id) FROM user_exam_record r LEFT JOIN question_chapter_exam m on r.exam_id = m.exam_id LEFT JOIN question_module_chapter l on l.chapter_exam_id = m.chapter_exam_id where r.goods_id = a.goods_id and l.module_exam_id = a.major_id  <if test="userId != null and userId !=''">
         AND r.user_id = #{userId}
     </if> ) as record_num
         FROM