|
- <?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.iformall.mapper.WxProfitSharingOrderMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxProfitSharingOrder">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="out_settle_no" jdbcType="BIGINT" property="outSettleNo" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
- <result column="pay_merchant_id" jdbcType="BIGINT" property="payMerchantId" />
- <result column="pay_merchant_mch_id" jdbcType="VARCHAR" property="payMerchantMchId" />
- <result column="sharing_merchant_id" jdbcType="BIGINT" property="sharingMerchantId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/>
- <result column="pay_version" jdbcType="INTEGER" property="payVersion"/>
- <result column="mch_type" jdbcType="INTEGER" property="mchType"/>
- <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
- <result column="single_order_amount" jdbcType="INTEGER" property="singleOrderAmount" />
- <result column="single_order_id" jdbcType="BIGINT" property="singleOrderId" />
- <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd" />
- <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart" />
- <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
- <result column="sharing_order_no" jdbcType="VARCHAR" property="sharingOrderNo" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="point_deduction" jdbcType="VARCHAR" property="pointDeduction" />
- <result column="receivers" jdbcType="VARCHAR" property="receivers" />
- <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
- <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`out_settle_no`,`merchant_id`,`b_tenant_id`,`pay_merchant_id`,`pay_merchant_mch_id`,`sharing_merchant_id`,`order_id`,`pay_vendor`,`pay_version`,`mch_type`,`pay_amount`,
- `single_order_amount`,`single_order_id`,`pay_time_end`,`pay_time_start`,`transaction_id`,`sharing_order_no`,`type`,`point_deduction`,`receivers`,`error_msg`,`sharing_status`,`update_time`,`create_time`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where `tenant_id` = #{tenantId}
-
- <if test=" null != id ">
- and `id` = #{id}
-
- </if>
-
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != outSettleNo ">
- and `out_settle_no` = #{outSettleNo}
-
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != bTenantId ">
- and `b_tenant_id` = #{bTenantId}
- </if>
-
- <if test=" null != payMerchantId ">
- and `pay_merchant_id` = #{payMerchantId}
- </if>
-
- <if test=" null != payMerchantMchId and '' != payMerchantMchId">
- and `pay_merchant_mch_id` = #{payMerchantMchId}
- </if>
-
- <if test=" null != sharingMerchantId ">
- and `sharing_merchant_id` = #{sharingMerchantId}
- </if>
-
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
- </if>
-
- <if test=" null != singleOrderId ">
- and `single_order_id` = #{singleOrderId}
- </if>
-
- <if test=" null != payVendor ">
- and `pay_vendor` = #{payVendor}
- </if>
- <if test=" null != payVersion ">
- and `pay_version` = #{payVersion}
- </if>
- <if test=" null != mchType ">
- and `mch_type` = #{mchType}
- </if>
-
- <if test=" null != type ">
- and `type` = #{type}
-
- </if>
-
- <if test=" null != payAmount ">
- and `pay_amount` = #{payAmount}
-
- </if>
-
- <if test=" null != payTimeEnd ">
- and `pay_time_end` = #{payTimeEnd}
-
- </if>
-
- <if test=" null != payTimeStart ">
- and `pay_time_start` = #{payTimeStart}
-
- </if>
-
- <if test=" null != transactionId ">
- and `transaction_id` = #{transactionId}
-
- </if>
-
- <if test=" null != sharingOrderNo ">
- and `sharing_order_id` = #{sharingOrderId}
-
- </if>
-
- <if test=" null != errorMsg ">
- and `error_msg` like concat('%', #{errorMsg},'%')
-
- </if>
-
- <if test=" null != sharingStatus ">
- and `sharing_status` = #{sharingStatus}
-
- </if>
-
- <if test=" null != updateTime ">
- and `update_time` = #{updateTime}
-
- </if>
-
- <if test=" null != createTime ">
- and `create_time` = #{createTime}
-
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxProfitSharingOrder" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_profit_sharing_order
- <include refid="dynamicWhereConditions" />
- </select>
-
-
- <resultMap id="orderMap" type="com.iformall.domain.vo.WxProfitSharingOrderVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
- <result column="pay_merchant_id" jdbcType="BIGINT" property="payMerchantId" />
- <result column="pay_merchant_mch_id" jdbcType="VARCHAR" property="payMerchantMchId" />
- <result column="sharing_merchant_id" jdbcType="BIGINT" property="sharingMerchantId" />
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
- <result column="pay_merchant_name" jdbcType="VARCHAR" property="payMerchantName" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
- <result column="single_order_amount" jdbcType="INTEGER" property="singleOrderAmount" />
- <result column="single_order_id" jdbcType="BIGINT" property="singleOrderId" />
- <result column="pay_time_end" jdbcType="TIMESTAMP" property="payTimeEnd" />
- <result column="pay_time_start" jdbcType="TIMESTAMP" property="payTimeStart" />
- <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
- <result column="sharing_order_no" jdbcType="VARCHAR" property="sharingOrderNo" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="point_deduction" jdbcType="VARCHAR" property="pointDeduction" />
- <result column="receivers" jdbcType="VARCHAR" property="receivers" />
- <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
- <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- </resultMap>
-
-
- <select id="findOrderList" parameterType="com.iformall.domain.vo.WxProfitSharingOrderQueryVo" resultMap="orderMap">
- select pso.*,m.`name` merchant_name,m1.`name` pay_merchant_name
- from wx_profit_sharing_order pso
- left join wx_merchant m on pso.merchant_id=m.id
- left join wx_merchant m1 on pso.pay_merchant_id=m1.id
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and pso.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and pso.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="id!=null">
- and pso.id =#{id}
- </if>
- <if test="merchantName!=null and ''!=merchantName">
- and m.`name` like concat('%',#{merchantName},'%')
- </if>
- <if test="startdate!=null and enddate!=null">
- and pso.create_time between #{startdate} and #{enddate}
- </if>
- <if test="sharingStatus!=null">
- and pso.sharing_status = #{sharingStatus}
- </if>
- <if test="type!=null">
- and pso.type = #{type}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and pso.`b_tenant_id` = #{bTenantId}
- </if>
-
- </where>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by pso.id desc</if>
-
- <if test=" null != begin ">
- limit #{begin}, #{limit}
- </if>
-
-
- </select>
-
- <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
- select count(*) merchantCount from (
- select distinct merchant_id from wx_profit_sharing_order
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startdate!=null and enddate!=null">
- and create_time between #{startdate} and #{enddate}
- </if>
- </where>
- ) o
- </select>
-
- <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
- select ifnull(sum(pay_amount),0) payment from wx_profit_sharing_order
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startdate!=null and enddate!=null">
- and create_time between #{startdate} and #{enddate}
- </if>
- </where>
- </select>
-
- <resultMap id="orderDetailsMap" type="com.iformall.domain.vo.WxProfitSharingOrderDetailsVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="pay_amount" jdbcType="INTEGER" property="payAmount" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="sharing_status" jdbcType="INTEGER" property="sharingStatus" />
- <result column="finish_time" jdbcType="VARCHAR" property="finishTime" />
- <result column="failed_reason" jdbcType="VARCHAR" property="failedReason" />
- <result column="description" jdbcType="VARCHAR" property="description" />
- <result column="sharing_receiver_id" jdbcType="BIGINT" property="sharingReceiverId" />
- <result column="receiver_type" jdbcType="INTEGER" property="receiverType" />
- <result column="receiver_account" jdbcType="VARCHAR" property="receiverAccount" />
- <result column="receiver_comments" jdbcType="VARCHAR" property="receiverComments" />
- <result column="sharing_type" jdbcType="INTEGER" property="sharingType" />
- <result column="status" jdbcType="VARCHAR" property="status" />
-
- </resultMap>
-
- <select id="findOrderDetails" parameterType="java.util.HashMap" resultMap="orderDetailsMap">
- select psr.id,psr.tenant_id,psr.parent_tenant_id,psr.pay_amount,psr.create_time,sharing_status,finish_time,failed_reason,description,
- psr.sharing_receiver_id,psre.receiver_type,psre.receiver_account,psre.receiver_comments,psre.sharing_type,psre.`status`
- from wx_profit_sharing_result psr
- left join wx_profit_sharing_receiver psre on psr.sharing_receiver_id = psre.id
- where psr.sharing_order_id = #{id} and psr.tenant_id = #{tenantId}
- <if test=" null != isPrivate ">
- and psr.`is_private` = #{isPrivate}
-
- </if>
- </select>
-
- </mapper>
|