fubojin 1 день тому
батько
коміт
6357e73909

+ 46 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/param/OrderRefundCountParam.java

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.bean.param;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+@Data
+@Api("退款单模块(数据统计)")
+public class OrderRefundCountParam {
+
+    @ApiModelProperty("全部数量")
+    private Integer allCount;
+
+    @ApiModelProperty("卖家申请(10)")
+    private Integer sellerApplyCount;
+
+    @ApiModelProperty("卖家拒绝(30)")
+    private Integer sellerRejectCount;
+
+    @ApiModelProperty("撤回申请(40)")
+    private Integer withdrawApplyCount;
+
+    @ApiModelProperty("卖家接受(60)")
+    private Integer sellerAcceptCount;
+
+    @ApiModelProperty("买家发货(65)")
+    private Integer buyerDeliveryCount;
+
+    @ApiModelProperty("配送中数量(40)")
+    private Integer shippingCount;
+
+    @ApiModelProperty("退款完成(70)")
+    private Integer refundCompleteCount;
+
+}

+ 62 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/param/OrderRefundStaisticsParam.java

@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.bean.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@Data
+public class OrderRefundStaisticsParam {
+
+    /**
+     * 店铺id
+     */
+    private Long shopId;
+    /**
+     * 订购流水号
+     */
+    private String orderNumber;
+    /**
+     * 退款编号
+     */
+    private String refundSn;
+    /**
+     * 电话号码
+     */
+    private String buyerMobile;
+
+    /**
+     * 申请类型:1,仅退款,2退款退货,5差价退款
+     */
+    private Integer applyType;
+    /**
+     * 开始时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date endTime;
+
+    /**
+     * 退款单状态 10:待审核 20:处理中 30:驳回退款 40:撤销退款 60:待退货(一审同意) 65:待确认收货(二审待审核) 70:退款完成
+     */
+    @ApiModelProperty("退款单状态 10:待审核 20:处理中 30:驳回退款 40:撤销退款 60:待退货(一审同意) 65:待确认收货(二审待审核) 70:退款完成")
+    private Integer returnMoneySts;
+
+
+}

+ 22 - 11
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/OrderRefundController.java

@@ -6,8 +6,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.yami.shop.bean.dto.OrderRefundDto;
 import com.yami.shop.bean.model.OrderRefund;
+import com.yami.shop.bean.model.OrderRefundSku;
+import com.yami.shop.bean.param.OrderRefundCountParam;
+import com.yami.shop.bean.param.OrderRefundStaisticsParam;
 import com.yami.shop.common.util.PageParam;
+import com.yami.shop.dao.OrderRefundSkuMapper;
 import com.yami.shop.service.OrderRefundService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -21,12 +27,14 @@ import com.yami.shop.common.util.R;
  * @version 1.0.0
  * @since 2018-09-15
  */
+@Api(tags = "订单退款管理")
 @RestController
 @AllArgsConstructor
 @RequestMapping("/platform/orderRefund")
 public class OrderRefundController {
 
     private final OrderRefundService orderRefundService;
+    private final OrderRefundSkuMapper orderRefundskuMapper;
 
     /**
      * 分页查询
@@ -59,18 +67,21 @@ public class OrderRefundController {
     /**
      * 后管端分页获取退款订单列表
      */
+    @ApiOperation("后台分页获取退款订单列表")
     @GetMapping("/orderRefundPage")
-    public R<IPage<OrderRefund>> orderRefundPage(PageParam<OrderRefund> page, OrderRefund orderRefund) {
-        LambdaQueryWrapper<OrderRefund> wrapper = new LambdaQueryWrapper<OrderRefund>()
-                .eq(orderRefund.getShopId() != null, OrderRefund::getShopId, orderRefund.getShopId())
-                .like(orderRefund.getOrderNumber() != null, OrderRefund::getOrderNumber, orderRefund.getOrderNumber())
-                .like(orderRefund.getRefundSn() != null, OrderRefund::getRefundSn, orderRefund.getRefundSn())
-                .eq(orderRefund.getReturnMoneySts() != null, OrderRefund::getReturnMoneySts, orderRefund.getReturnMoneySts())
-                .eq(orderRefund.getBuyerMobile() != null, OrderRefund::getBuyerMobile, orderRefund.getBuyerMobile())
-                .eq(orderRefund.getApplyType() != null, OrderRefund::getApplyType, orderRefund.getApplyType());
-        IPage<OrderRefund> page1 = orderRefundService.page(page, wrapper);
-
-
+    public R<IPage<OrderRefund>> orderRefundPage(PageParam<OrderRefund> page, OrderRefundStaisticsParam orderRefund) {
+        IPage<OrderRefund> page1 = orderRefundService.orderRefundPage(page, orderRefund);
+        page1.getRecords().forEach(c -> c.setOrderRefundSkuList(orderRefundskuMapper.selectList(new LambdaQueryWrapper<OrderRefundSku>()
+        .eq(OrderRefundSku::getOrderRefundId, c.getRefundId()))));
         return R.SUCCESS(page1);
     }
+
+    /**
+     * 统计退款订单数量
+     */
+    @ApiOperation("统计退款订单数量")
+    @GetMapping("/orderRefundCount")
+    public R<OrderRefundCountParam> orderRefundCount(OrderRefundStaisticsParam orderRefund) {
+        return R.SUCCESS(orderRefundService.orderRefundCount(orderRefund));
+    }
 }

+ 0 - 1
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ShopSkuController.java

@@ -29,7 +29,6 @@ public class ShopSkuController {
 
     private final ShopSkuService shopProdService;
 
-
     /**
      * 新建店铺
      */

+ 16 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/OrderRefundMapper.java

@@ -18,7 +18,10 @@ import com.yami.shop.bean.dto.OrderRefundDto;
 import com.yami.shop.bean.model.OrderRefund;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yami.shop.bean.param.OrderRefundCountParam;
+import com.yami.shop.bean.param.OrderRefundStaisticsParam;
 import com.yami.shop.bean.param.StatisticsRefundParam;
+import com.yami.shop.common.util.PageParam;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
@@ -80,4 +83,17 @@ public interface OrderRefundMapper extends BaseMapper<OrderRefund> {
     Integer getRefundCount(@Param("userId") String userId);
 
     Integer countRefundByOrderItem(@Param("orderItemId") Long orderItemId, @Param("returnMoneySts0") Integer returnMoneySts0, @Param("returnMoneySts1") Integer returnMoneySts1);
+
+    /**
+     * 获取退款订单统计数量
+     */
+    OrderRefundCountParam orderRefundCount(OrderRefundStaisticsParam orderRefund);
+
+    /**
+     * 获取退款订单统计
+     * @param page 分页参数
+     * @param orderRefund 订单退款参数
+     * @return 订单退款分页
+     */
+    IPage<OrderRefund> orderRefundPage(@Param("page") PageParam<OrderRefund> page, @Param("orderRefund") OrderRefundStaisticsParam orderRefund);
 }

+ 1 - 1
yami-shop-service/src/main/java/com/yami/shop/dao/ShopSkuMapper.java

@@ -25,5 +25,5 @@ public interface ShopSkuMapper extends BaseMapper<ShopSku> {
      * 根据商品id删除门店商品
      * @param prodId 商品id
      */
-    void deleteByProdId(@Param("skuId")Long prodId);
+    void deleteByProdId(@Param("prodId")Long prodId);
 }

+ 18 - 0
yami-shop-service/src/main/java/com/yami/shop/service/OrderRefundService.java

@@ -9,8 +9,11 @@ import com.yami.shop.bean.dto.OrderRefundDto;
 import com.yami.shop.bean.model.Order;
 import com.yami.shop.bean.model.OrderRefund;
 import com.yami.shop.bean.model.RefundDelivery;
+import com.yami.shop.bean.param.OrderRefundCountParam;
 import com.yami.shop.bean.param.OrderRefundParam;
+import com.yami.shop.bean.param.OrderRefundStaisticsParam;
 import com.yami.shop.bean.param.StatisticsRefundParam;
+import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.hb.HBR;
 import org.apache.ibatis.annotations.Param;
 
@@ -192,4 +195,19 @@ public interface OrderRefundService extends IService<OrderRefund> {
      * @return 退款订单响应报文
      */
     HBR createResult(JSONObject hBRequest);
+
+    /**
+     * 获取退款订单统计信息
+     * @param orderRefund 退款单对象
+     * @return 退款订单统计信息
+     */
+    OrderRefundCountParam orderRefundCount(OrderRefundStaisticsParam orderRefund);
+
+    /**
+     * 获取退款订单列表
+     * @param page 分页参数
+     * @param orderRefund 退款单对象
+     * @return 退款订单列表
+     */
+    IPage<OrderRefund> orderRefundPage(PageParam<OrderRefund> page, OrderRefundStaisticsParam orderRefund);
 }

+ 12 - 3
yami-shop-service/src/main/java/com/yami/shop/service/impl/OrderRefundServiceImpl.java

@@ -21,15 +21,14 @@ import com.yami.shop.bean.enums.*;
 import com.yami.shop.bean.event.OrderRefundSuccessEvent;
 import com.yami.shop.bean.event.ReceiptOrderEvent;
 import com.yami.shop.bean.model.*;
-import com.yami.shop.bean.param.OrderPayParam;
-import com.yami.shop.bean.param.OrderRefundParam;
-import com.yami.shop.bean.param.StatisticsRefundParam;
+import com.yami.shop.bean.param.*;
 import com.yami.shop.bean.pay.RefundInfoDto;
 import com.yami.shop.common.config.Constant;
 import com.yami.shop.common.enums.PayType;
 import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.exception.YamiShopBindException;
 import com.yami.shop.common.util.Arith;
+import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.hb.HBR;
 import com.yami.shop.dao.*;
 import com.yami.shop.service.*;
@@ -1268,5 +1267,15 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
         return HBR.success();
     }
 
+    @Override
+    public OrderRefundCountParam orderRefundCount(OrderRefundStaisticsParam orderRefund) {
+        return orderRefundMapper.orderRefundCount(orderRefund);
+    }
+
+    @Override
+    public IPage<OrderRefund> orderRefundPage(PageParam<OrderRefund> page, OrderRefundStaisticsParam orderRefund) {
+        return orderRefundMapper.orderRefundPage(page, orderRefund);
+    }
+
 
 }

+ 1 - 0
yami-shop-service/src/main/resources/mapper/OrderMapper.xml

@@ -672,6 +672,7 @@
             temp.offset_points,
             temp.pay_time,
             temp.dvy_type,
+            temp.comm_sts,
             temp.order_id, temp.create_time, temp.freight_amount,temp.order_number,temp.actual_total,temp.shop_id,temp.addr_order_id FROM tz_order temp
         WHERE temp.user_id = #{userId}
         <if test="status != null">

+ 78 - 16
yami-shop-service/src/main/resources/mapper/OrderRefundMapper.xml

@@ -3,9 +3,6 @@
 <mapper namespace="com.yami.shop.dao.OrderRefundMapper">
 
     <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.OrderRefund">
-        <!--
-          WARNING - @mbg.generated
-        -->
         <id column="refund_id" property="refundId"/>
         <result column="refund_sn" property="refundSn"/>
         <result column="shop_id" property="shopId"/>
@@ -171,14 +168,14 @@
 
     <sql id="selectJoinAll">
         SELECT r.*,
-               o.dvy_type      as o_dvy_type,
-               o.pay_time      as o_pay_time,
-               o.order_number  AS o_order_number,
-               o.actual_total  AS o_actual_total,
-               o.hb_order_status        AS o_status,
-               s.pay_no        AS s_order_pay_no,
-               sp.shop_name    AS shop_name,
-               s.settlement_id AS s_settlement_id,
+               o.dvy_type        as o_dvy_type,
+               o.pay_time        as o_pay_time,
+               o.order_number    AS o_order_number,
+               o.actual_total    AS o_actual_total,
+               o.hb_order_status AS o_status,
+               s.pay_no          AS s_order_pay_no,
+               sp.shop_name      AS shop_name,
+               s.settlement_id   AS s_settlement_id,
                d.*
         FROM tz_order_refund r
                  LEFT JOIN tz_order o ON r.order_id = o.order_id
@@ -378,10 +375,10 @@
         WHERE r.`order_id` = #{orderId}
           --         买家撤回申请
           AND r.`return_money_sts` != 6
-           --         商家拒绝
-           AND r.`return_money_sts` != 7
-           --         退款关闭
-           AND r.`return_money_sts` != - 1
+          --         商家拒绝
+          AND r.`return_money_sts` != 7
+          --         退款关闭
+          AND r.`return_money_sts` != - 1
     </select>
     <select id="sumRefundSuccessPlatformAmountByOrderId" resultType="double">
         select ifnull(sum(platform_refund_amount), 0)
@@ -394,7 +391,8 @@
         FROM tz_order_refund
         WHERE order_id = (SELECT order_id
                           FROM tz_order_refund
-                          WHERE refund_sn = #{refundSn } AND return_money_sts IN (1, 2, 3, 4, 5))
+                          WHERE refund_sn = #{refundSn }
+                            AND return_money_sts IN (1, 2, 3, 4, 5))
     </select>
     <select id="countRefundByOrderItem" resultType="java.lang.Integer">
         SELECT COUNT(refund_id)
@@ -402,4 +400,68 @@
         WHERE order_item_id = #{orderItemId}
           AND (return_money_sts &gt;= #{returnMoneySts0} AND return_money_sts &lt;= #{returnMoneySts1})
     </select>
+
+
+    <select id="orderRefundCount" resultType="com.yami.shop.bean.param.OrderRefundCountParam">
+        SELECT
+        COUNT(return_money_sts) AS allCount,
+        COUNT(CASE WHEN return_money_sts = 10 THEN 1 END) AS sellerApplyCount,
+        COUNT(CASE WHEN return_money_sts = 30 THEN 1 END) AS sellerRejectCount,
+        COUNT(CASE WHEN return_money_sts = 40 THEN 1 END) AS withdrawApplyCount,
+        COUNT(CASE WHEN return_money_sts = 60 THEN 1 END) AS sellerAcceptCount,
+        COUNT(CASE WHEN return_money_sts = 65 THEN 1 END) AS buyerDeliveryCount,
+        COUNT(CASE WHEN return_money_sts = 40 THEN 1 END) AS shippingCount,
+        COUNT(CASE WHEN return_money_sts = 70 THEN 1 END) AS refundCompleteCount
+        FROM tz_order_refund
+        <where>
+            <if test="orderNumber != null">
+                and order_number = #{orderRefund.orderNumber}
+            </if>
+            <if test="refundSn != null">
+                and refund_sn = #{orderRefund.refundSn}
+            </if>
+            <if test="buyerMobile != null">
+                and buyer_mobile = #{orderRefund.buyerMobile}
+            </if>
+            <if test="applyType != null">
+                and apply_type = #{orderRefund.applyType}
+            </if>
+            <if test="returnMoneySts != null">
+                and return_money_sts = #{orderRefund.returnMoneySts}
+            </if>
+            <if test="orderParam.startTime != null">
+                AND create_time &gt;= #{orderRefund.startTime}
+            </if>
+            <if test="orderParam.endTime != null">
+                AND create_time &lt;= #{orderRefund.endTime}
+            </if>
+        </where>
+
+    </select>
+    <select id="orderRefundPage" resultMap="BaseResultMap">
+        select refund.* from tz_order_refund refund
+        <where>
+            <if test="orderNumber != null">
+                and refund.order_number = #{orderRefund.orderNumber}
+            </if>
+            <if test="refundSn != null">
+                and refund.refund_sn = #{orderRefund.refundSn}
+            </if>
+            <if test="buyerMobile != null">
+                and refund.buyer_mobile = #{orderRefund.buyerMobile}
+            </if>
+            <if test="applyType != null">
+                and refund.apply_type = #{orderRefund.applyType}
+            </if>
+            <if test="returnMoneySts != null">
+                and refund.return_money_sts = #{orderRefund.returnMoneySts}
+            </if>
+            <if test="orderParam.startTime != null">
+                AND refund.create_time &gt;= #{orderRefund.startTime}
+            </if>
+            <if test="orderParam.endTime != null">
+                AND refund.create_time &lt;= #{orderRefund.endTime}
+            </if>
+        </where>
+    </select>
 </mapper>