liurunyu
2024-09-14 1473f665730d9adc30011691e7a1ec04ce134709
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml
@@ -331,39 +331,81 @@
  <select id="getTransactionRecordCount" parameterType="java.util.Map" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM v_trade_details
    FROM se_card_operate ope
        INNER JOIN se_client cli ON ope.client_id = cli.id
        INNER JOIN se_client_card card ON card.id = ope.card_id
        LEFT JOIN se_payment_method pay ON ope.payment_id = pay.id
        INNER JOIN ba_user us ON ope.operator = us.id
    <where>
      AND ope.operate_type IN(1,2,3,5)
      <if test = "villageId != null and villageId > 0">
        AND villageId = #{villageId}
        AND cli.villageId = #{villageId}
      </if>
      <if test = "operateTimeStart != null and operateTimeStop != null">
        AND tradeTime BETWEEN #{operateTimeStart} AND #{operateTimeStop}
        AND ope.operate_dt BETWEEN #{operateTimeStart} AND #{operateTimeStop}
      </if>
      <if test = "cashierId != null and cashierId > 0">
        AND cashierId = #{cashierId}
        AND us.id = #{cashierId}
      </if>
    </where>
  </select>
  <!--根据指定条件获取交易记录-->
  <select id="getTransactions" resultType="com.dy.pipIrrGlobal.voSe.VoTradeDetails">
    SELECT * FROM v_trade_details
    SELECT
        ope.id AS orderNumber,
        cli.name AS clientName,
        card.cardNum AS cardNum,
        cli.idCard,
        cli.clientNum,
        cli.phone,
        (CASE ope.operate_type
            WHEN 1 THEN '开卡'
            WHEN 2 THEN '充值'
            WHEN 3 THEN '销卡'
            WHEN 5 THEN '补扣'
        END) AS operateType,
        (IFNULL(ope.trade_amount,0.00) + IFNULL(ope.card_cost,0.00)) AS tradeAmount,
        IFNULL(ope.trade_amount,0.00) AS waterCost,
        IFNULL(ope.card_cost,0.00) AS cardCost,
        IFNULL(ope.gift,0.00) AS gift,
        IFNULL(ope.refund_amount,0.00) AS refundAmount,
        ope.money,
        pay.name AS paymentName,
        ope.operate_dt as tradeTime,
        us.id AS cashierId,
        us.name AS cashierName,
        (CASE card.state
            WHEN 1 THEN '正常'
            WHEN 2 THEN '已注销'
            WHEN 3 THEN '已挂失'
        END) AS cardState,
        cli.districtTitle,
        cli.villageId AS villageId
    FROM se_card_operate ope
        INNER JOIN se_client cli ON ope.client_id = cli.id
        INNER JOIN se_client_card card ON card.id = ope.card_id
        LEFT JOIN se_payment_method pay ON ope.payment_id = pay.id
        INNER JOIN ba_user us ON ope.operator = us.id
    <where>
      AND ope.operate_type IN(1,2,3,5)
      <if test = "villageId != null and villageId > 0">
        AND villageId = #{villageId}
        AND cli.villageId = #{villageId}
      </if>
      <if test = "operateTimeStart != null and operateTimeStop != null">
        AND tradeTime BETWEEN #{operateTimeStart} AND #{operateTimeStop}
        AND ope.operate_dt BETWEEN #{operateTimeStart} AND #{operateTimeStop}
      </if>
      <if test = "cashierId != null and cashierId > 0">
        AND cashierId = #{cashierId}
        AND us.id = #{cashierId}
      </if>
    </where>
    ORDER BY tradeTime
    ORDER BY ope.operate_dt
    <trim prefix="limit ">
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}