Jelajahi Sumber

submit:退款列表改造

yangdamao 2 tahun lalu
induk
melakukan
42a44f6a79

+ 11 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/order/OrderGoodsRefundController.java

@@ -51,10 +51,20 @@ public class OrderGoodsRefundController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<OrderGoodsRefundVo> list(OrderGoodsRefundQueryBo bo) {
         startPage();
-        List<OrderGoodsRefundVo> list = iOrderGoodsRefundService.selectList(bo);
+        List<OrderGoodsRefundVo> list = iOrderGoodsRefundService.selectListByQuery(bo);
         return getDataTable(list);
     }
 
+    /**
+     * 查询订单商品退款列表
+     */
+    @ApiOperation("查询退款订单所有商品信息")
+    @GetMapping("/listAll/{orderSn}")
+    public AjaxResult<List<OrderGoodsRefundVo>> listByOrderSn(@PathVariable("orderSn") String orderSn) {
+        List<OrderGoodsRefundVo> list = iOrderGoodsRefundService.listByOrderSn(orderSn);
+        return AjaxResult.success(list);
+    }
+
 
 
     /**

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsRefundMapper.java

@@ -21,4 +21,7 @@ public interface OrderGoodsRefundMapper extends BaseMapper<OrderGoodsRefund> {
 
     Long selectCountFirstPeriod(@Param("userId") Long userId, @Param("refundId") Long refundId);
 
+    List<OrderGoodsRefundVo> selectListByQuery(OrderGoodsRefundQueryBo bo);
+
+    List<OrderGoodsRefundVo> selectListByOrderSn(@Param("orderSn") String orderSn);
 }

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

@@ -59,7 +59,11 @@ public interface IOrderGoodsRefundService extends IService<OrderGoodsRefund> {
 
 	List<OrderGoodsRefundVo> selectList(OrderGoodsRefundQueryBo bo);
 
+	List<OrderGoodsRefundVo> selectListByQuery(OrderGoodsRefundQueryBo bo);
+
 	Boolean confirmPeriod(List<OrderGoodsRefundEditBo> bos);
 
 	Boolean firstPeriod(List<OrderGoodsRefundEditBo> bos);
+
+	List<OrderGoodsRefundVo> listByOrderSn(String orderSn);
 }

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

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.exception.CustomException;
@@ -489,6 +490,20 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
         return baseMapper.selectListByBo(bo);
     }
 
+    @Override
+    public List<OrderGoodsRefundVo> selectListByQuery(OrderGoodsRefundQueryBo bo) {
+        List<OrderGoodsRefundVo> orderSns = baseMapper.selectListByQuery(bo);
+        if (CollectionUtils.isEmpty(orderSns)){
+            return new ArrayList<>();
+        }
+        return orderSns.stream().map(item -> {
+            List<OrderGoodsRefundVo> orderGoodsRefundVos = baseMapper.selectListByOrderSn(item.getOrderSn());
+            OrderGoodsRefundVo vo = orderGoodsRefundVos.stream().findFirst().orElse(null);
+            vo.setGoodsNum(orderGoodsRefundVos.size());
+            return vo;
+        }).collect(Collectors.toList());
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean confirmPeriod(List<OrderGoodsRefundEditBo> bos) {
@@ -632,4 +647,9 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
 
         return true;
     }
+
+    @Override
+    public List<OrderGoodsRefundVo> listByOrderSn(String orderSn) {
+        return  baseMapper.selectListByOrderSn(orderSn);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderGoodsRefundVo.java

@@ -136,4 +136,6 @@ public class OrderGoodsRefundVo {
 	@Excel(name = "退款时间")
 	@ApiModelProperty("退款时间")
 	private Long refundTime;
+	@ApiModelProperty("商品数量")
+	private Integer goodsNum;
 }

+ 4 - 4
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeMapper.xml

@@ -995,10 +995,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND (
             <foreach collection="subIds" item="id" index="index">
                 <if test="index != subIds.size()-1">
-                    FIND_IN_SET(g.subject_ids,#{id}) OR
+                    FIND_IN_SET(#{id},g.subject_ids) OR
                 </if>
                 <if test="index == subIds.size()-1">
-                    FIND_IN_SET(g.subject_ids,#{id})
+                    FIND_IN_SET(#{id},g.subject_ids)
                 </if>
             </foreach>
                 )
@@ -1017,10 +1017,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND (
             <foreach collection="subIds" item="id" index="index">
                 <if test="index != subIds.size()-1">
-                    FIND_IN_SET(g.subject_ids,#{id}) OR
+                    FIND_IN_SET(#{id},g.subject_ids) OR
                 </if>
                 <if test="index == subIds.size()-1">
-                    FIND_IN_SET(g.subject_ids,#{id})
+                    FIND_IN_SET(#{id},g.subject_ids)
                 </if>
             </foreach>
             )

+ 82 - 3
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsRefundMapper.xml

@@ -113,7 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND g.goods_type = #{goodsType}
         </if>
         <if test="searchKey != null and searchKey != '' ">
-            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or og.order_sn = #{searchKey})
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or gr.order_sn = #{searchKey})
         </if>
         <if test="searchStartTime != null and searchStartTime !='' ">
             AND og.create_time >=#{searchStartTime}
@@ -121,8 +121,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="searchEndTime != null and searchEndTime !='' ">
             AND #{searchEndTime} >= og.create_time
         </if>
---         ORDER BY gr.refund_id DESC
-        ORDER BY gr.order_sn ASC , gr.create_time ASC
+        ORDER BY gr.refund_id DESC
+--         ORDER BY gr.order_sn ASC , gr.create_time ASC
+    </select>
+
+
+    <select id="selectListByQuery" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsRefundQueryBo" resultMap="OrderGoodsRefundVoResult">
+        SELECT
+        gr.order_sn,MIN(gr.refund_id) as refund_id ,MIN(gr.create_time) as create_time
+        FROM
+        order_goods_refund gr
+        LEFT JOIN goods g ON gr.goods_id = g.goods_id
+        LEFT JOIN `user` u ON gr.user_id = u.user_id
+        LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
+        LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
+        LEFT JOIN course_business cb ON g.business_id = cb.id
+        LEFT JOIN order_goods og ON gr.order_goods_id = og.order_goods_id
+        WHERE
+        1 = 1
+        <if test="userId != null and userId != ''">
+            AND gr.user_id = #{userId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId != ''">
+            AND gr.order_goods_id = #{orderGoodsId}
+        </if>
+        <if test="type != null">
+            AND gr.type = #{type}
+        </if>
+        <if test="periodStatus != null ">
+            AND gr.period_status in
+            <foreach collection="periodStatus" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="goodsType != null and goodsType != ''">
+            AND g.goods_type = #{goodsType}
+        </if>
+        <if test="searchKey != null and searchKey != '' ">
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or gr.order_sn = #{searchKey})
+        </if>
+        <if test="searchStartTime != null and searchStartTime !='' ">
+            AND og.create_time >=#{searchStartTime}
+        </if>
+        <if test="searchEndTime != null and searchEndTime !='' ">
+            AND #{searchEndTime} >= og.create_time
+        </if>
+        GROUP BY
+        gr.order_sn
+        ORDER BY
+        refund_id ASC,
+        create_time ASC
+    </select>
+
+    <select id="selectListByOrderSn" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsRefundQueryBo" resultMap="OrderGoodsRefundVoResult">
+        SELECT
+            gr.*,
+            g.goods_name,
+            g.cover_url,
+            g.year,
+            u.realname,
+            u.id_card,
+            u.telphone,
+            cet.education_name,
+            cpt.project_name,
+            cb.business_name,
+            og.goods_received,
+            og.goods_real_price,
+            og.pay_status,
+            og.goods_price
+        FROM
+        order_goods_refund gr
+        LEFT JOIN goods g ON gr.goods_id = g.goods_id
+        LEFT JOIN `user` u ON gr.user_id = u.user_id
+        LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
+        LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
+        LEFT JOIN course_business cb ON g.business_id = cb.id
+        LEFT JOIN order_goods og ON gr.order_goods_id = og.order_goods_id
+        WHERE
+         gr.order_sn = #{orderSn}
     </select>
 
     <select id="selectCountConfirmPeriod" parameterType="map" resultType="Long">