IMRefundOrderMapper.xml 14.5 KB
<?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.sibu.orderHelper.integral.web.dao.IMRefundOrderDao">
    <select id="countRefundingOrderByOrderId" resultType="java.lang.Integer">
        select count(*) from im_order_refund where
        order_id = #{orderId} and refund_status != 7 and refund_status != 100 and refund_status != 101
    </select>
    <select id="findRefundMoneyAndGoodsAndDisagreeRefundMoneyStatusRefundOrders"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from im_order_refund where
        refund_status = 0
        and refund_type = 2
        and refund_status_last_update_dt is not null
        and refund_status_last_update_dt &lt; date_add(now(),interval -7 day);
    </select>
    <select id="findRefundMoneyAndGoodsAndDisagreeRefundGoodsStatusRefundOrders"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from im_order_refund where
        refund_status = 8
        and refund_type = 2
        and refund_status_last_update_dt is not null
        and refund_status_last_update_dt &lt; date_add(now(),interval -7 day);
    </select>

    <select id="findRefundMoneyAndDisagreeRefundMoneyStatusRefundOrders"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from im_order_refund where
        refund_status = 0
        and refund_type in (1,3)
        and refund_status_last_update_dt is not null
        and refund_status_last_update_dt &lt; date_add(now(),interval -3 day);
    </select>
    <update id="updateStatus">
        update im_order_refund set refund_status = #{newStatus} where refund_status= #{oldStatus} and refund_id = #{refundId}
    </update>
    <resultMap id="BaseResultMap" type="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
        <id column="refund_id" jdbcType="VARCHAR" property="refundId"/>
        <result column="refund_code" jdbcType="VARCHAR" property="refundCode"/>
        <result column="order_id" jdbcType="VARCHAR" property="orderId"/>
        <result column="order_code" jdbcType="VARCHAR" property="orderCode"/>
        <result column="order_from" jdbcType="TINYINT" property="orderFrom"/>
        <result column="member_id" jdbcType="VARCHAR" property="memberId"/>
        <result column="refund_type" jdbcType="INTEGER" property="refundType"/>
        <result column="refund_goods_status" jdbcType="INTEGER" property="refundGoodsStatus"/>
        <result column="refund_reason_id" jdbcType="INTEGER" property="refundReasonId"/>
        <result column="refund_reason" jdbcType="VARCHAR" property="refundReason"/>
        <result column="refund_money" jdbcType="DECIMAL" property="refundMoney"/>
        <result column="order_money" jdbcType="DECIMAL" property="orderMoney"/>
        <result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/>
        <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
        <result column="refund_status_last_update_dt" jdbcType="TIMESTAMP" property="refundStatusLastUpdateDt"/>
        <result column="apply_date" jdbcType="TIMESTAMP" property="applyDate"/>
        <result column="refund_money_success_flag" jdbcType="BIT" property="refundMoneySuccessFlag"/>
        <result column="refund_date" jdbcType="TIMESTAMP" property="refundDate"/>
        <result column="buyer_username" jdbcType="VARCHAR" property="buyerUsername"/>
        <result column="buyer_phone" jdbcType="VARCHAR" property="buyerPhone"/>
        <result column="refund_seller_phone" jdbcType="VARCHAR" property="refundSellerPhone"/>
        <result column="refund_seller_address" jdbcType="VARCHAR" property="refundSellerAddress"/>
        <result column="refund_seller_name" jdbcType="VARCHAR" property="refundSellerName"/>
        <result column="finish_date" jdbcType="TIMESTAMP" property="finishDate"/>
        <result column="refund_integral" jdbcType="BIGINT" property="refundIntegral"/>
        <result column="refund_goods_deliver_id" jdbcType="TINYINT" property="refundGoodsDeliverId"/>
        <result column="refund_goods_deliver_name" jdbcType="VARCHAR" property="refundGoodsDeliverName"/>
        <result column="refund_goods_waybill" jdbcType="VARCHAR" property="refundGoodsWaybill"/>
        <result column="refund_goods_remark" jdbcType="VARCHAR" property="refundGoodsRemark"/>
        <result column="refund_tips" jdbcType="VARCHAR" property="refundTips"/>
        <result column="receive_goods_flag" jdbcType="BIT" property="receiveGoodsFlag"/>
        <result column="receive_goods_dt" jdbcType="TIMESTAMP" property="receiveGoodsDt"/>
    </resultMap>
    <sql id="Base_Column_List">
    refund_id, refund_code, order_id, order_code, order_from, member_id, refund_type,
    refund_goods_status, refund_reason_id, refund_reason, refund_money, order_money,
    refund_remark, refund_status, refund_status_last_update_dt, apply_date, refund_money_success_flag,
    refund_date, buyer_username, buyer_phone, refund_seller_phone, refund_seller_address,
    refund_seller_name, finish_date, refund_integral, refund_goods_deliver_id, refund_goods_deliver_name,
    refund_goods_waybill, refund_goods_remark, refund_tips, receive_goods_flag, receive_goods_dt
  </sql>
    <select id="list" resultMap="BaseResultMap"
            parameterType="com.sibu.orderHelper.integral.request.RefundListPagerRequest">
        select
        <include refid="Base_Column_List"/>
        from im_order_refund
        where member_id = #{memberId}
        order by apply_date desc
        limit ${pageNow}, ${pageSize}
    </select>
    <select id="countList" resultType="java.lang.Integer"
            parameterType="com.sibu.orderHelper.integral.request.RefundListPagerRequest">
        select count(*) from im_order_refund where member_id = #{memberId}
    </select>

    <sql id="refund_order_column">
    	refund_id,refund_code,order_id,order_code,member_id,refund_type,refund_reason,
    	refund_money,order_money,refund_remark,apply_date,buyer_username,buyer_phone
    </sql>
    <select id="findOneByRefundIdAndMemberId" resultMap="BaseResultMap">
        select * from im_order_refund where refund_id = #{refundId} and member_id = #{memberId}
  </select>
    <select id="findOneByRefundId" resultMap="BaseResultMap">
        select * from im_order_refund where refund_id = #{refundId}
    </select>
    <insert id="addRefundOrder" parameterType="IMOrderRefundBean">
        insert into im_order_refund(<include refid="refund_order_column"/>)
        value(
        #{refundId},
        #{refundCode},
        #{orderId},
        #{orderCode},
        #{memberId},
        #{refundType},
        #{refundReason},
        #{refundMoney},
        #{orderMoney},
        #{refundRemark},
        NOW(),
        #{buyerUsername},
        ${buyerPhone}
        )
    </insert>
    <insert id="insert" parameterType="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
        insert into im_order_refund (refund_id, refund_code, order_id,
      order_code, order_from, member_id,
      refund_type, refund_goods_status, refund_reason_id,
      refund_reason, refund_money, order_money,
      refund_remark, refund_status, refund_status_last_update_dt,
      apply_date, refund_money_success_flag, refund_date,
      buyer_username, buyer_phone, refund_seller_phone,
      refund_seller_address, refund_seller_name,
      finish_date, refund_integral, refund_goods_deliver_id,
      refund_goods_deliver_name, refund_goods_waybill,
      refund_goods_remark, refund_tips, receive_goods_flag,
      receive_goods_dt)
    values (#{refundId,jdbcType=VARCHAR}, #{refundCode,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR},
      #{orderCode,jdbcType=VARCHAR}, #{orderFrom,jdbcType=TINYINT}, #{memberId,jdbcType=VARCHAR},
      #{refundType,jdbcType=INTEGER}, #{refundGoodsStatus,jdbcType=INTEGER}, #{refundReasonId,jdbcType=INTEGER},
      #{refundReason,jdbcType=VARCHAR}, #{refundMoney,jdbcType=DECIMAL}, #{orderMoney,jdbcType=DECIMAL},
      #{refundRemark,jdbcType=VARCHAR}, #{refundStatus,jdbcType=INTEGER}, #{refundStatusLastUpdateDt,jdbcType=TIMESTAMP},
      #{applyDate,jdbcType=TIMESTAMP}, #{refundMoneySuccessFlag,jdbcType=BIT}, #{refundDate,jdbcType=TIMESTAMP},
      #{buyerUsername,jdbcType=VARCHAR}, #{buyerPhone,jdbcType=VARCHAR}, #{refundSellerPhone,jdbcType=VARCHAR},
      #{refundSellerAddress,jdbcType=VARCHAR}, #{refundSellerName,jdbcType=VARCHAR},
      #{finishDate,jdbcType=TIMESTAMP}, #{refundIntegral,jdbcType=BIGINT}, #{refundGoodsDeliverId,jdbcType=TINYINT},
      #{refundGoodsDeliverName,jdbcType=VARCHAR}, #{refundGoodsWaybill,jdbcType=VARCHAR},
      #{refundGoodsRemark,jdbcType=VARCHAR}, #{refundTips,jdbcType=VARCHAR}, #{receiveGoodsFlag,jdbcType=BIT},
      #{receiveGoodsDt,jdbcType=TIMESTAMP})

    </insert>
    <update id="updateDeliveryInfoByRefundIdAndMemberId"
            parameterType="com.sibu.orderHelper.integral.request.UpdateDeliveryInfoRequest">
        update im_order_refund set   
        refund_goods_deliver_id=#{deliverId},
        refund_goods_deliver_name=#{deliverName},
        refund_goods_waybill=#{waybill},
        refund_goods_remark=#{remark}
        where refund_id = #{refundId} and member_id = #{memberId}
    </update>
    <update id="updateRefundStatusByRefundIdAndMemberId">
        update im_order_refund set
        refund_status=#{refundStatus}
        where refund_id = #{refundId} and member_id = #{memberId}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.sibu.orderHelper.integral.model.IMOrderRefundBean">
        update im_order_refund
        <set>
            <if test="refundCode != null">
                refund_code = #{refundCode,jdbcType=VARCHAR},
            </if>
            <if test="orderId != null">
                order_id = #{orderId,jdbcType=VARCHAR},
            </if>
            <if test="orderCode != null">
                order_code = #{orderCode,jdbcType=VARCHAR},
            </if>
            <if test="orderFrom != null">
                order_from = #{orderFrom,jdbcType=TINYINT},
            </if>
            <if test="memberId != null">
                member_id = #{memberId,jdbcType=VARCHAR},
            </if>
            <if test="refundType != null">
                refund_type = #{refundType,jdbcType=INTEGER},
            </if>
            <if test="refundGoodsStatus != null">
                refund_goods_status = #{refundGoodsStatus,jdbcType=INTEGER},
            </if>
            <if test="refundReasonId != null">
                refund_reason_id = #{refundReasonId,jdbcType=INTEGER},
            </if>
            <if test="refundReason != null">
                refund_reason = #{refundReason,jdbcType=VARCHAR},
            </if>
            <if test="refundMoney != null">
                refund_money = #{refundMoney,jdbcType=DECIMAL},
            </if>
            <if test="orderMoney != null">
                order_money = #{orderMoney,jdbcType=DECIMAL},
            </if>
            <if test="refundRemark != null">
                refund_remark = #{refundRemark,jdbcType=VARCHAR},
            </if>
            <if test="refundStatus != null">
                refund_status = #{refundStatus,jdbcType=INTEGER},
            </if>
            <if test="refundStatusLastUpdateDt != null">
                refund_status_last_update_dt = #{refundStatusLastUpdateDt,jdbcType=TIMESTAMP},
            </if>
            <if test="applyDate != null">
                apply_date = #{applyDate,jdbcType=TIMESTAMP},
            </if>
            <if test="refundMoneySuccessFlag != null">
                refund_money_success_flag = #{refundMoneySuccessFlag,jdbcType=BIT},
            </if>
            <if test="refundDate != null">
                refund_date = #{refundDate,jdbcType=TIMESTAMP},
            </if>
            <if test="buyerUsername != null">
                buyer_username = #{buyerUsername,jdbcType=VARCHAR},
            </if>
            <if test="buyerPhone != null">
                buyer_phone = #{buyerPhone,jdbcType=VARCHAR},
            </if>
            <if test="refundSellerPhone != null">
                refund_seller_phone = #{refundSellerPhone,jdbcType=VARCHAR},
            </if>
            <if test="refundSellerAddress != null">
                refund_seller_address = #{refundSellerAddress,jdbcType=VARCHAR},
            </if>
            <if test="refundSellerName != null">
                refund_seller_name = #{refundSellerName,jdbcType=VARCHAR},
            </if>
            <if test="finishDate != null">
                finish_date = #{finishDate,jdbcType=TIMESTAMP},
            </if>
            <if test="refundIntegral != null">
                refund_integral = #{refundIntegral,jdbcType=BIGINT},
            </if>
            <if test="refundGoodsDeliverId != null">
                refund_goods_deliver_id = #{refundGoodsDeliverId,jdbcType=TINYINT},
            </if>
            <if test="refundGoodsDeliverName != null">
                refund_goods_deliver_name = #{refundGoodsDeliverName,jdbcType=VARCHAR},
            </if>
            <if test="refundGoodsWaybill != null">
                refund_goods_waybill = #{refundGoodsWaybill,jdbcType=VARCHAR},
            </if>
            <if test="refundGoodsRemark != null">
                refund_goods_remark = #{refundGoodsRemark,jdbcType=VARCHAR},
            </if>
            <if test="refundTips != null">
                refund_tips = #{refundTips,jdbcType=VARCHAR},
            </if>
            <if test="receiveGoodsFlag != null">
                receive_goods_flag = #{receiveGoodsFlag,jdbcType=BIT},
            </if>
            <if test="receiveGoodsDt != null">
                receive_goods_dt = #{receiveGoodsDt,jdbcType=TIMESTAMP},
            </if>
        </set>
        where refund_id = #{refundId,jdbcType=VARCHAR}
    </update>
    <select id="getRefundRecodeResult" parameterType="java.util.Map" resultType="String">
    	select operator_remark from im_refund_procedure_record where refund_id = #{refundId} 
    </select>


    <select id="statisticsRefundingNum" resultType="java.lang.Integer">
        select count(*) from im_order_refund where member_id = #{memberId} and refund_status != 7 and refund_status != 100 and refund_status != 101
    </select>
    <select id="countOrderItemNotFinishHistory" resultType="java.lang.Integer">
        select count(*) from im_order_refund of
        inner join im_refund_order_item ofitem
        on of.order_id=#{orderId}
        and of.refund_status != 7 and of.refund_status != 100 and of.refund_status != 101
        and ofitem.order1_id=#{order1Id}
        and of.refund_id = ofitem.refund_id
    </select>
</mapper>