xin
2025-09-12 5d16a26a496323aa6d288362602513bbd0484012
订单退单sql优化
3 files modified
16 ■■■■■ changed files
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java 6 ●●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderMapper.xml 4 ●●● patch | view | raw | blame | history
oying-system/src/main/resources/mapper/sh/OrderReturnMapper.xml 6 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
@@ -103,8 +103,8 @@
        // 退款订单号
        String returnNum = redisUtils.generateSn(ORDER_RETURN_KEY, GenerateEnum.ORDER_RETURN.getKey());
        returnOrder.setReturnNum(returnNum);
        returnOrder.setReturnStatus(ReturnAuditEnum.ZERO.getKey());
        returnOrder.setReturnStatusDescribe(ReturnAuditEnum.ZERO.getValue());
        returnOrder.setReturnStatus(OrderStatusEnum.TEN.getKey());
        returnOrder.setReturnStatusDescribe(OrderStatusEnum.TEN.getValue());
        returnOrder.setOrderNum(resources.getOrderNum());
        returnOrder.setOrderTime(order.getOrderTime());
        returnOrder.setOrderStoreNum(order.getOrderStoreNum());
@@ -138,7 +138,7 @@
            }
        }
        productSnapshotService.saveBatch(productSnapshots);
        operationLogService.create(response, OrderStatusEnum.FIFTEEN, null);
        operationLogService.create(response, OrderStatusEnum.TEN, null);
    }
    private static OrderReturnProductSnapshot getSnapshot(OrderProductSnapshot snapshot, String returnNum) {
oying-system/src/main/resources/mapper/sh/OrderMapper.xml
@@ -46,6 +46,8 @@
        <result column="rider_name" property="riderName"/>
        <collection property="productSnapshots" ofType="com.oying.modules.sh.domain.OrderProductSnapshot">
            <id column="snapshot_id" property="snapshotId"/>
            <result column="order_num" property="orderNum"/>
            <result column="store_id" property="storeId"/>
            <result column="product_id" property="productId"/>
            <result column="product_code" property="productCode"/>
            <result column="product_barcode" property="productBarcode"/>
@@ -74,7 +76,7 @@
    </sql>
    <sql id="product_Column_List">
        p.snapshot_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title,
        p.snapshot_id, p.order_num, p.store_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title,
        p.product_main_image, p.product_description, p.param_data, p.unit_price, p.detail_count, p.original_price, p.paid_price,
        p.actually_pay_price, p.pay_state
    </sql>
oying-system/src/main/resources/mapper/sh/OrderReturnMapper.xml
@@ -41,6 +41,8 @@
        <result column="rider_name" property="riderName"/>
        <collection property="productSnapshots" ofType="com.oying.modules.sh.domain.OrderReturnProductSnapshot">
            <id column="snapshot_id" property="snapshotId"/>
            <result column="return_num" property="returnNum"/>
            <result column="store_id" property="storeId"/>
            <result column="product_id" property="productId"/>
            <result column="product_code" property="productCode"/>
            <result column="product_barcode" property="productBarcode"/>
@@ -67,7 +69,7 @@
    </sql>
    <sql id="Product_Column_List">
        p.snapshot_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title, p.product_main_image,
        p.snapshot_id, p.return_num, p.store_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title, p.product_main_image,
        p.product_description, p.param_data, p.unit_price, p.detail_count, p.original_price, p.paid_price, p.actually_pay_price
    </sql>
    <sql id="Where_sql">
@@ -161,7 +163,7 @@
        order by o.return_id desc
    </select>
    <select id="getByReturnNum" resultMap="BaseResultMap">
        select o.* from ( select
        select o.*, from ( select
        <include refid="Base_Column_List"/>
        from sh_order_return as o ) o
        left join sh_order_return_product_snapshot as p on p.return_num = o.return_num