<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.webmanage.mapper.OrderInfoMapper">
|
|
<!-- 基础结果映射 -->
|
<resultMap id="BaseResultMap" type="com.webmanage.entity.OrderInfo">
|
<id column="order_id" property="orderId" jdbcType="VARCHAR"/>
|
<result column="product_id" property="productId" jdbcType="BIGINT"/>
|
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
<result column="unit_id" property="unitId" jdbcType="BIGINT"/>
|
<result column="product_name" property="productName" jdbcType="VARCHAR"/>
|
<result column="provider_name" property="providerName" jdbcType="VARCHAR"/>
|
<result column="provider_id" property="providerId" jdbcType="BIGINT"/>
|
<result column="apply_time" property="applyTime" jdbcType="TIMESTAMP"/>
|
<result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
|
<result column="total_amount" property="totalAmount" jdbcType="NUMERIC"/>
|
<result column="payment_type" property="paymentType" jdbcType="VARCHAR"/>
|
<result column="payment_status" property="paymentStatus" jdbcType="VARCHAR"/>
|
<result column="workflow_id" property="workflowId" jdbcType="VARCHAR"/>
|
<result column="current_step" property="currentStep" jdbcType="VARCHAR"/>
|
<result column="approval_flow" property="approvalFlow" jdbcType="LONGVARCHAR"/>
|
<result column="buyer_remarks" property="buyerRemarks" jdbcType="LONGVARCHAR"/>
|
<result column="seller_remarks" property="sellerRemarks" jdbcType="LONGVARCHAR"/>
|
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
|
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP"/>
|
<result column="deleted" property="deleted" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 基础字段列表 -->
|
<sql id="Base_Column_List">
|
order_id, product_id, user_id, unit_id, product_name, provider_name, provider_id,
|
apply_time, order_status, total_amount, payment_type, payment_status, workflow_id,
|
current_step, approval_flow, buyer_remarks, seller_remarks, created_at, updated_at, deleted
|
</sql>
|
|
<!-- 分页查询买家订单列表 -->
|
<select id="selectBuyerOrderPage" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM tb_order_info
|
WHERE deleted = 0
|
<if test="userId != null">
|
AND user_id = #{userId}
|
</if>
|
<if test="unitId != null and unitId != ''">
|
AND unit_id = #{unitId}
|
</if>
|
<if test="orderStatus != null and orderStatus != ''">
|
AND order_status = #{orderStatus}
|
</if>
|
<if test="paymentStatus != null and paymentStatus != ''">
|
AND payment_status = #{paymentStatus}
|
</if>
|
<if test="paymentType != null and paymentType != ''">
|
AND payment_type = #{paymentType}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="providerName != null and providerName != ''">
|
AND provider_name LIKE CONCAT('%', #{providerName}, '%')
|
</if>
|
<if test="orderId != null and orderId != ''">
|
AND order_id LIKE CONCAT('%', #{orderId}, '%')
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND apply_time >= #{applyTimeStart}::timestamp
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND apply_time <= #{applyTimeEnd}::timestamp
|
</if>
|
<if test="createTimeStart != null and createTimeStart != ''">
|
AND created_at >= #{createTimeStart}::timestamp
|
</if>
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
AND created_at <= #{createTimeEnd}::timestamp
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy != null and orderBy != ''">
|
${orderBy}
|
</when>
|
<otherwise>
|
created_at
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection != null and orderDirection == 'asc'">
|
ASC
|
</when>
|
<otherwise>
|
DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
<!-- 分页查询卖家订单列表 -->
|
<select id="selectSellerOrderPage" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM tb_order_info
|
WHERE deleted = 0
|
<if test="providerId != null and providerId != ''">
|
AND provider_id = #{providerId}
|
</if>
|
<if test="orderStatus != null and orderStatus != ''">
|
AND order_status = #{orderStatus}
|
</if>
|
<if test="paymentStatus != null and paymentStatus != ''">
|
AND payment_status = #{paymentStatus}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="orderId != null and orderId != ''">
|
AND order_id LIKE CONCAT('%', #{orderId}, '%')
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND apply_time >= #{applyTimeStart}::timestamp
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND apply_time <= #{applyTimeEnd}::timestamp
|
</if>
|
<if test="createTimeStart != null and createTimeStart != ''">
|
AND created_at >= #{createTimeStart}::timestamp
|
</if>
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
AND created_at <= #{createTimeEnd}::timestamp
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy != null and orderBy != ''">
|
${orderBy}
|
</when>
|
<otherwise>
|
created_at
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection != null and orderDirection == 'asc'">
|
ASC
|
</when>
|
<otherwise>
|
DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
<!-- 分页查询待审批订单列表 -->
|
<select id="selectPendingApprovalOrderPage" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM tb_order_info
|
WHERE deleted = 0
|
AND order_status IN ('待上传文件', '待授权', '待交易确认', '已完成', '已评价')
|
<if test="orderStatus != null and orderStatus != ''">
|
AND order_status = #{orderStatus}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="providerName != null and providerName != ''">
|
AND provider_name LIKE CONCAT('%', #{providerName}, '%')
|
</if>
|
<if test="orderId != null and orderId != ''">
|
AND order_id LIKE CONCAT('%', #{orderId}, '%')
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND apply_time >= #{applyTimeStart}::timestamp
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND apply_time <= #{applyTimeEnd}::timestamp
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy != null and orderBy != ''">
|
${orderBy}
|
</when>
|
<otherwise>
|
created_at
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection != null and orderDirection == 'asc'">
|
ASC
|
</when>
|
<otherwise>
|
DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
<!-- 分页查询买家订单列表(支持产品条件) -->
|
<select id="selectBuyerOrderPageWithProductConditions" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM tb_order_info
|
WHERE deleted = 0
|
<if test="userId != null">
|
AND user_id = #{userId}
|
</if>
|
<if test="unitId != null and unitId != ''">
|
AND unit_id = #{unitId}
|
</if>
|
<if test="orderStatus != null and orderStatus != ''">
|
AND order_status = #{orderStatus}
|
</if>
|
<if test="paymentStatus != null and paymentStatus != ''">
|
AND payment_status = #{paymentStatus}
|
</if>
|
<if test="paymentType != null and paymentType != ''">
|
AND payment_type = #{paymentType}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="providerName != null and providerName != ''">
|
AND provider_name LIKE CONCAT('%', #{providerName}, '%')
|
</if>
|
<if test="orderId != null and orderId != ''">
|
AND order_id LIKE CONCAT('%', #{orderId}, '%')
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND apply_time >= #{applyTimeStart}::timestamp
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND apply_time <= #{applyTimeEnd}::timestamp
|
</if>
|
<if test="createTimeStart != null and createTimeStart != ''">
|
AND created_at >= #{createTimeStart}::timestamp
|
</if>
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
AND created_at <= #{createTimeEnd}::timestamp
|
</if>
|
<if test="productIds != null and productIds.size() > 0">
|
AND product_id IN
|
<foreach collection="productIds" item="productId" open="(" separator="," close=")">
|
#{productId}
|
</foreach>
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy != null and orderBy != ''">
|
${orderBy}
|
</when>
|
<otherwise>
|
created_at
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection != null and orderDirection == 'asc'">
|
ASC
|
</when>
|
<otherwise>
|
DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
<!-- 分页查询卖家订单列表(支持产品条件) -->
|
<select id="selectSellerOrderPageWithProductConditions" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM tb_order_info
|
WHERE deleted = 0
|
<if test="providerId != null and providerId != ''">
|
AND provider_id = #{providerId}
|
</if>
|
<if test="orderStatus != null and orderStatus != ''">
|
AND order_status = #{orderStatus}
|
</if>
|
<if test="paymentStatus != null and paymentStatus != ''">
|
AND payment_status = #{paymentStatus}
|
</if>
|
<if test="productName != null and productName != ''">
|
AND product_name LIKE CONCAT('%', #{productName}, '%')
|
</if>
|
<if test="orderId != null and orderId != ''">
|
AND order_id LIKE CONCAT('%', #{orderId}, '%')
|
</if>
|
<if test="applyTimeStart != null and applyTimeStart != ''">
|
AND apply_time >= #{applyTimeStart}::timestamp
|
</if>
|
<if test="applyTimeEnd != null and applyTimeEnd != ''">
|
AND apply_time <= #{applyTimeEnd}::timestamp
|
</if>
|
<if test="createTimeStart != null and createTimeStart != ''">
|
AND created_at >= #{createTimeStart}::timestamp
|
</if>
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
AND created_at <= #{createTimeEnd}::timestamp
|
</if>
|
<if test="productIds != null and productIds.size() > 0">
|
AND product_id IN
|
<foreach collection="productIds" item="productId" open="(" separator="," close=")">
|
#{productId}
|
</foreach>
|
</if>
|
ORDER BY
|
<choose>
|
<when test="orderBy != null and orderBy != ''">
|
${orderBy}
|
</when>
|
<otherwise>
|
created_at
|
</otherwise>
|
</choose>
|
<choose>
|
<when test="orderDirection != null and orderDirection == 'asc'">
|
ASC
|
</when>
|
<otherwise>
|
DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
</mapper>
|