Files
chaozhanggui/pluss-dao-bundle/target/classes/mapper/MerchantOrder-sqlmap.xml
2023-01-28 15:57:27 +08:00

2985 lines
114 KiB
XML

<?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="cn.pluss.platform.mapper.MerchantOrderMapper">
<insert id="saveMerchantOrderBatch">
insert into
tb_pluss_merchant_order(orderNumber,merchantCode,merchantName,payTypeCode,payTypeName,consumeFee,transNo,memberCode,storeId,storeName,createDt,staffCode,status,rate,marketAmt)
VALUES
<foreach collection="list" item="item" index="index"
separator=",">
(#{orderNumber},#{merchantCode},#{merchantName},#{payTypeCode},#{payTypeName},#{consumeFee},#{transNo},#{memberCode},#{storeId},#{storeName},#{createDt},#{staffCode},#{status},#{rate},#{marketAmt}
)
</foreach>
</insert>
<select id="queryMerchantOrder"
parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT * from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="settlementType!= null">
and settlementType = #{settlementType}
</if>
</where>
</select>
<select id="getToDayTransSum1" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="endTime != null">
and createDt <![CDATA[<=]]> #{endTime}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
</where>
</select>
<select id="toDayTransZfbSum" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="endTime != null">
and createDt &lt;= #{endTime}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and (payTypeCode='leshuaPay0' or payTypeCode= 'aliPay' or payTypeCode='sxfPay0')
</where>
</select>
<select id="toDayTransWxSum" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="endTime != null">
and createDt &lt;= #{endTime}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and (payTypeCode='leshuaPay1' or payTypeCode= 'wechatPay' or payTypeCode='sxfPay1')
</where>
</select>
<select id="toDayTransYsfSum" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="endTime != null">
and createDt &lt;= #{endTime}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and payTypeCode='sxfPay2'
</where>
</select>
<select id="queryMerchantOrderList"
parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT * from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="settlementType!= null">
and settlementType = #{settlementType}
</if>
</where>
</select>
<select id="getOrderFeeSum1" parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order
<where>
<if test="merchantCode!= null and merchantCode!='' ">
and merchantCode = #{merchantCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
</where>
</select>
<select id="queryMerchantOrderPage"
parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT * from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber like CONCAT("%",#{orderNumber},"%")
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName like CONCAT("%",#{merchantName},"%")
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo like CONCAT("%",#{transNo},"%")
</if>
<if test="memberCode!= null">
and memberCode like CONCAT("%",#{memberCode},"%")
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName like CONCAT("%",#{storeName},"%")
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="startTime != null">
and createDt &gt;= #{startTime}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="endTime != null">
and createDt &lt;= #{endTime}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
<if test="settlementType!= null">
and settlementType = #{settlementType}
</if>
</where>
<!-- order by id desc limit #{pageSize} offset #{offset} -->
</select>
<!--给app 商户推广- 交易明细 接口调用的 -->
<select id="queryMerchantOrderPageApp"
parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT * from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="settlementType != null">
and settlementType = #{settlementType}
</if>
<if test="merchantCodeList!= null">
and merchantCode in
<foreach item="item" index="index" collection="merchantCodeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
order by id desc limit #{pageSize} offset #{offset}
</select>
<select id="queryMerchantOrderPageCountApp"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="settlementType!= null">
and settlementType = #{settlementType}
</if>
<if test="merchantCodeList!= null">
and merchantCode in
<foreach item="item" index="index" collection="merchantCodeList" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="queryMerchantOrderPageCount"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber like CONCAT("%",#{orderNumber},"%")
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo like CONCAT("%",#{transNo},"%")
</if>
<if test="memberCode!= null">
and memberCode like CONCAT("%",#{memberCode},"%")
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName like CONCAT("%",#{storeName},"%")
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
<if test="settlementType != null">
and settlementType = #{settlementType}
</if>
</where>
</select>
<!-- 今日支付宝收款笔数 -->
<select id="toDayTransZfbCount"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber like CONCAT("%",#{orderNumber},"%")
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo like CONCAT("%",#{transNo},"%")
</if>
<if test="memberCode!= null">
and memberCode like CONCAT("%",#{memberCode},"%")
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName like CONCAT("%",#{storeName},"%")
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and (payTypeCode='leshuaPay0' or payTypeCode= 'aliPay' or payTypeCode='sxfPay0')
</where>
</select>
<!-- 今日微信收款笔数 -->
<select id="toDayTransWxCount"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber like CONCAT("%",#{orderNumber},"%")
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo like CONCAT("%",#{transNo},"%")
</if>
<if test="memberCode!= null">
and memberCode like CONCAT("%",#{memberCode},"%")
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName like CONCAT("%",#{storeName},"%")
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and (payTypeCode='leshuaPay1' or payTypeCode= 'wechatPay' or payTypeCode='sxfPay1')
</where>
</select>
<select id="toDayTransYsfCount"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber like CONCAT("%",#{orderNumber},"%")
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo like CONCAT("%",#{transNo},"%")
</if>
<if test="memberCode!= null">
and memberCode like CONCAT("%",#{memberCode},"%")
</if>
<if test="storeId!= null">
and storeId = #{storeId}
</if>
<if test="storeName!= null">
and storeName like CONCAT("%",#{storeName},"%")
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="staffCode!= null">
and staffCode = #{staffCode}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aliPayTransNo!= null">
and thirdTransNo = #{aliPayTransNo}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="weChatTransNo!= null">
and thirdTransNo = #{weChatTransNo}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaTransNo!= null">
and thirdTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="stTime!= null">
and transDt <![CDATA[>=]]> #{stTime}
</if>
<if test="endTime!= null">
and transDt <![CDATA[<=]]> #{endTime}
</if>
and payTypeCode='sxfPay2'
</where>
</select>
<!-- 可提现总金额(提现规则 超过一个月的时间) -->
<select id="sumMerchantAllowCashMoney"
resultType="java.lang.Double">
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and createDt &lt;= (SELECT DATE_ADD(now(), INTERVAL -1 MONTH))
</select>
<!--不可提现金额 (为超过一个月 不可提现) -->
<select id="sumMerchantNotAllowCashMoney"
resultType="java.lang.Double">
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and createDt &gt; (SELECT DATE_ADD(now(), INTERVAL -1 MONTH))
</select>
<!-- 今日推广分润 -->
<select id="sumNowDayShareMoney" resultType="java.lang.Double">
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
and date (createDt) = curdate()
</select>
<!-- 累计推广分润 -->
<select id="sumAllShareMoney" resultType="java.lang.Double">
select sum(shareMoney)
from tb_pluss_merchant_order
where memberCode = #{memberCode}
</select>
<select id="queryMerchantOrderPageCountByTime"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeCode!= null">
and storeId = #{storeCode}
</if>
<if test="storeId!= null">
and
(
<foreach collection="storeId" item="item" index="index"
separator="or">
storeId = #{item}
</foreach>
)
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="staffCode!= null">
and
(
<foreach collection="staffCode" item="item" index="index"
separator="or">
staffCode = #{item}
</foreach>
)
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime != null">
and updateTime &lt;= #{endTime}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="settlementType != null">
and settlementType = #{settlementType}
</if>
<if test="payTypeCodeList!= null">
and (
<foreach collection="payTypeCodeList" item="item" index="index" separator="or">
payTypeCode = #{item}
</foreach>
)
</if>
<if test="merchantCodeList!= null">
and merchantCode in
<foreach collection="merchantCodeList" item="item" open="(" close=")" index="index" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="queryMerchantOrdeFeeByTime"
parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(consumeFee) from tb_pluss_merchant_order t
<where>
( SELECT count( 1 ) FROM tb_pluss_merchant_order t1 WHERE t1.orderNumber = t.orderNumber AND t1.status IN
(1, 2) ) = 1
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeCode!= null">
and storeId = #{storeCode}
</if>
<if test="storeId!= null">
and (
<foreach collection="storeId" item="item" index="index"
separator="or">
storeId = #{item}
</foreach>
)
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="staffCode!= null">
and (
<foreach collection="staffCode" item="item" index="index"
separator="or">
staffCode = #{item}
</foreach>
)
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="payTypeCodeList!= null">
and (
<foreach collection="payTypeCodeList" item="item" index="index" separator="or">
payTypeCode = #{item}
</foreach>
)
</if>
<if test="startDt!= null">
and createDt &gt; #{startDt}
</if>
<if test="endDt!= null">
and createDt &lt; #{startDt}
</if>
<if test="merchantCodeList!= null">
and merchantCode in
<foreach collection="merchantCodeList" item="item" open="(" close=")" index="index" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="queryMerchantOrderPageByTime"
parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT * from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCodeList!= null">
and (
<foreach collection="payTypeCodeList" item="item" index="index" separator="or">
payTypeCode = #{item}
</foreach>
)
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and (
<foreach collection="storeId" item="item" index="index"
separator="or">
storeId = #{item}
</foreach>
)
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="staffCode!= null">
and (
<foreach collection="staffCode" item="item" index="index"
separator="or">
staffCode = #{item}
</foreach>
)
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="enterFee!= null">
and enterFee = #{enterFee}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
</where>
order by createDt desc limit #{pageSize} offset #{offset}
</select>
<select id="queryOrderStatistics" parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.vo.OrderStatisticsVO">
select count(1) orderCount,sum(t.consumeFee)
orderFee,date_format(t.createDt,'%Y-%m-%d') orderDate
from
tb_pluss_merchant_order t
<where>
t.status='1'
<if test="merchantCode!=null and merchantCode!=''">
and merchantCode=#{merchantCode}
</if>
</where>
group by date_format(t.createDt,'%Y-%m-%d')
order by orderDate DESC
limit 7
</select>
<select id="queryPayTypeStatistics" parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.vo.PayTypeStatisticsVO">
select count(1) orderCount,sum(t.consumeFee)
orderFee,t.payTypeName
payTypeName
from tb_pluss_merchant_order t
<where>
t.status=1
<if test="merchantCode!=null and merchantCode!=''">
and merchantCode=#{merchantCode}
</if>
</where>
group by payTypeName
</select>
<!--汇总流水 -->
<select id="querySummaryOfWater" parameterType="java.util.Map"
resultType="cn.pluss.platform.vo.SummaryOfWaterVO">
select sum(case when t.status=1 then 1 end) as dealCount,
sum(case when
t.status=1 then consumeFee end) as dealSum,
sum(case when t.status=2
then consumeFee end) as actualMoney,
count(t.id) as 'refundCount' ,
SUM(t.consumeFee) as 'netRefund',
sum(t.shareMoney) as 'shareMoney'
from tb_pluss_merchant_order t
<where>
<if test="payTypeCodeList!=null">
AND (
<foreach collection="payTypeCodeList" item="payTypeCode"
index="index" separator="or">
t.payTypeCode=#{payTypeCode}
</foreach>
)
</if>
<if test="storeIdList!=null">
AND (
<foreach collection="storeIdList" item="storeId"
index="index" separator="or">
t.storeId=#{storeId}
</foreach>
)
</if>
<if test="staffCodeList!=null">
AND (
<foreach collection="staffCodeList" item="staffCode"
index="index" separator="or">
t.staffCode=#{staffCode}
</foreach>
)
</if>
<!--今天 -->
<if test="timeStatus!=null and timeStatus=='1'">
and date(t.createDt) = curdate()
</if>
<!-- 昨天 -->
<if test="timeStatus!=null and timeStatus=='2'">
and date(t.createDt) = date_sub(curdate(),interval 1 day)
</if>
<!-- 七天内 -->
<if test="time!=NULL and timeStatus=='3'">
<![CDATA[
and DATEDIFF(t.createDt,NOW())<=0 AND DATEDIFF(t.createDt,NOW())>-7
]]>
</if>
<!-- 30天内 -->
<if test="time!=NULL and timeStatus=='4'">
<![CDATA[
and DATEDIFF(t.createDt,NOW())<=0 AND DATEDIFF(t.createDt,NOW())>-30
]]>
</if>
<!--近三个月 -->
<if test="time!=NULL and timeStatus=='5'">
<![CDATA[
and DATEDIFF(t.createDt,NOW())<=0 AND DATEDIFF(t.createDt,NOW())>-90
]]>
</if>
<if test="merchantCode!=null">
and t.merchantCode=#{merchantCode}
</if>
</where>
</select>
<!-- 订单退款信息 -->
<select id="queryMerchantOrderRefundPage"
parameterType="java.util.Map"
resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT mo.* ,mbi.alias from tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mbi on
mbi.merchantCode = mo.merchantCode
<where>
<if test="payTypeCodeList!=null">
AND (
<foreach collection="payTypeCodeList" item="payTypeCode"
index="index" separator="or">
mo.payTypeCode=#{payTypeCode}
</foreach>
)
</if>
<if test="storeIdList!=null">
AND (
<foreach collection="storeIdList" item="storeId"
index="index" separator="or">
mo.storeId=#{storeId}
</foreach>
)
</if>
<if test="status!=null and status!=''">
and mo.status=#{status}
</if>
<if test="staffCodeList!=null">
AND (
<foreach collection="staffCodeList" item="staffCode"
index="index" separator="or">
mo.staffCode=#{staffCode}
</foreach>
)
</if>
<if test="orderNumber!=null">
AND mo.orderNumber=#{orderNumber}
</if>
<if test="orderType!=null">
AND mo.orderType=#{orderType}
</if>
<if test="consumeFee!=null">
AND mo.consumeFee=#{consumeFee}
</if>
<if test="merchantCode!=null">
AND mo.merchantCode=#{merchantCode}
</if>
<if test="aisleSwitch!= null">
and mo.aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and mo.leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="promoteruserId!= null">
and mo.promoteruserId = #{promoteruserId}
</if>
<!--今天 -->
<if test="timeStatus=='1'.toString()">
and date(createDt) = curdate()
</if>
<!-- 昨天 -->
<if test="timeStatus=='2'.toString()">
and date(createDt) = date_sub(curdate(),interval 1 day)
</if>
<!-- 七天内 -->
<if test="timeStatus=='3'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-7
]]>
</if>
<!-- 30天内 -->
<if test="timeStatus=='4'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-30
]]>
</if>
<!--近三个月 -->
<if test="timeStatus=='5'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-90
]]>
</if>
</where>
order by id desc
limit #{pageSize} offset #{offset}
</select>
<!--订单退款信息统计 -->
<select id="queryMerchantOrderRefundPageCount"
parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(*) FROM(SELECT * from tb_pluss_merchant_order
<where>
<if test="payTypeCodeList!=null">
AND (
<foreach collection="payTypeCodeList" item="payTypeCode"
index="index" separator="or">
payTypeCode=#{payTypeCode}
</foreach>
)
</if>
<if test="status!=null and status!=''">
and status=#{status}
</if>
<if test="storeIdList!=null">
AND (
<foreach collection="storeIdList" item="storeId"
index="index" separator="or">
storeId=#{storeId}
</foreach>
)
</if>
<if test="staffCodeList!=null">
AND (
<foreach collection="staffCodeList" item="staffCode"
index="index" separator="or">
staffCode=#{staffCode}
</foreach>
)
</if>
<if test="orderNumber!=null">
AND orderNumber=#{orderNumber}
</if>
<if test="orderType!=null">
AND orderType=#{orderType}
</if>
<if test="consumeFee!=null">
AND consumeFee=#{consumeFee}
</if>
<if test="merchantCode!=null">
AND merchantCode=#{merchantCode}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<!--今天 -->
<if test="timeStatus=='1'.toString()">
and date(createDt) = curdate()
</if>
<!-- 昨天 -->
<if test="timeStatus=='2'.toString()">
and date(createDt) = date_sub(curdate(),interval 1 day)
</if>
<!-- 七天内 -->
<if test="timeStatus=='3'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-7
]]>
</if>
<!-- 30天内 -->
<if test="timeStatus=='4'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-30
]]>
</if>
<!--近三个月 -->
<if test="timeStatus=='5'.toString()">
<![CDATA[
and DATEDIFF(createDt,NOW())<=0 AND DATEDIFF(createDt,NOW())>-90
]]>
</if>
</where>
)ORER
</select>
<select id="queryMerchantOrderShareMoney"
parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(shareMoney) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
</where>
</select>
<!--给wap端的定时任务使用的 暂定查3天内状态为5待支付的订单 -->
<select id="queryOrderTask"
parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.entity.MerchantOrder">
select * from tb_pluss_merchant_order where status=#{status}
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
</select>
<select id="queryMerchantOrderEnterFeeByTime"
parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(enterFee) from tb_pluss_merchant_order
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="merchantCode!= null">
and merchantCode = #{merchantCode}
</if>
<if test="merchantName!= null">
and merchantName = #{merchantName}
</if>
<if test="payTypeCode!= null">
and payTypeCode = #{payTypeCode}
</if>
<if test="payTypeName!= null">
and payTypeName = #{payTypeName}
</if>
<if test="consumeFee!= null">
and consumeFee = #{consumeFee}
</if>
<if test="transNo!= null">
and transNo = #{transNo}
</if>
<if test="memberCode!= null">
and memberCode = #{memberCode}
</if>
<if test="storeId!= null">
and (
<foreach collection="storeId" item="item" index="index"
separator="or">
storeId = #{item}
</foreach>
)
</if>
<if test="storeName!= null">
and storeName = #{storeName}
</if>
<if test="staffCode!= null">
and (
<foreach collection="staffCode" item="item" index="index"
separator="or">
staffCode = #{item}
</foreach>
)
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
<if test="promoteruserId!= null">
and promoteruserId = #{promoteruserId}
</if>
<if test="userImg!= null">
and userImg = #{userImg}
</if>
<if test="nickName!= null">
and nickName = #{nickName}
</if>
<if test="remark!= null">
and remark = #{remark}
</if>
<if test="transDt!= null">
and transDt = #{transDt}
</if>
<if test="staffName!= null">
and staffName = #{staffName}
</if>
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
</where>
</select>
<!-- 根据时间查询商户的分润金额 -->
<select id="queryMerchantOrderShareMoneyByTime"
parameterType="java.util.Map" resultType="java.lang.Double">
SELECT sum(shareMoney) from tb_pluss_merchant_order
<where>
<if test="startTime != null">
and updateTime &gt; #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt; #{endTime}
</if>
<if test="childList!= null">
and merchantCode in
<foreach collection="childList" item="item" open="("
close=")" index="index" separator=",">
#{item.merchantCode}
</foreach>
</if>
<if test="status!= null">
and status = #{status}
</if>
<if test="aisleSwitch!= null">
and aisleSwitch = #{aisleSwitch}
</if>
<if test="leshuaMerchantRefundId!= null">
and leshuaMerchantRefundId = #{leshuaMerchantRefundId}
</if>
<if test="leshuaTransNo!= null">
and leshuaTransNo = #{leshuaTransNo}
</if>
<if test="orderType!= null">
and orderType = #{orderType}
</if>
</where>
</select>
<select id="queryMerchantOrderPageShuju"
parameterType="java.util.Map"
resultType="cn.pluss.platform.vo.MerchantMangeOrderVO">
SELECT
mo.id,
mo.`status`,
mo.createDt,
mo.transDt,
mo.merchantCode,
mo.thirdTransNo,
mo.transNo,
mo.orderNumber,
mo.merchantName,
mo.orderType,
mo.payTypeName,
mo.payTypeCode,
mo.consumeFee,
mo.ip,
mo.ipAddress,
mo.mercOrderNo,
mo.drType,
mo.mercFee,
mo.enterFee,
mo.rate as mercRate,
mo.profitShareMoney,
mo.fansShareMoney,
mo.marketAmt,
mo.channelFee,
IF(mo.settlementType = 0,mo.consumeFee - mo.enterFee - mo.mercFee ,0) AS cashFee,
IFNULL(mo.channelRate,21) AS aisleRate,
IF(mo.`status` = 1 , IF(mo.orderType = 8 , mo.consumeFee,mo.consumeFee - mo.enterFee - mo.channelFee),0) as platformRevenue,
IF(mo.`status` = 1 , ((mo.consumeFee - mo.profitShareMoney - mo.fansShareMoney - mo.enterFee - channelFee) - ((mo.consumeFee - mo.enterFee - mo.mercFee) * 0.2)),0) as practical
FROM
tb_pluss_merchant_order mo
<where>
<if test="alias!=null and alias!=''">
and mo.merchantName = #{alias}
</if>
<if test="id!=null and id!=''">
and mo.id=#{id}
</if>
<if test="orderType!=null and orderType!=''">
and mo.orderType=#{orderType}
</if>
<if test="payTypeCode != null and payTypeCode !=''">
and
(
<foreach collection="payTypeCode" index="index" item="item" separator="or">
mo.payTypeCode = #{item}
</foreach>
)
</if>
<if test="orderNumber!=null and orderNumber!=''">
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
</if>
<if test="merchantName!=null and merchantName!=''">
and mo.merchantName like CONCAT("%",#{merchantName},"%")
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode=#{merchantCode}
</if>
<if test="storeName!=null and storeName!=''">
and mo.storename like CONCAT("%",#{storeName},"%")
</if>
<if test="payTypeName!=null and payTypeName!=''">
and mo.payTypeName=#{payTypeName}
</if>
<if test="status!=null and status!=''">
and mo.status=#{status}
</if>
<if test="settlementType != null and settlementType != '' or 0 == settlementType ">
and mo.settlementType=#{settlementType}
</if>
<if test="aisleSwitch != null and aisleSwitch != ''">
and mo.aisleSwitch=#{aisleSwitch}
</if>
<if test="startTime!= null and startTime!=''">
<![CDATA[
and DATE_FORMAT(mo.updateTime, '%Y-%m-%d %H:%i:%S')>=DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="endTime!= null and endTime!=''">
<![CDATA[
and DATE_FORMAT(mo.updateTime, '%Y-%m-%d %H:%i:%S')<=DATE_FORMAT(#{endTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
</where>
order by createDt desc
limit #{pageSize} offset #{offset}
</select>
<!-- <select id="queryMerchantOrderNoPageShuju"-->
<!-- parameterType="java.util.Map"-->
<!-- resultType="cn.pluss.platform.vo.MerchantMangeOrderVO">-->
<!-- SELECT-->
<!-- mo.id,-->
<!-- mo.orderNumber,-->
<!-- mbi.alias,-->
<!-- mo.orderType,-->
<!-- mo.payTypeName,-->
<!-- mo.payTypeCode,-->
<!-- mo.consumeFee,-->
<!-- mo.enterFee,-->
<!-- mo.marketAmt,-->
<!-- IFNULL((SELECT SUM(price) FROM tb_pluss_merchant_profit mp WHERE mo.merchantCode = mp.merchantCode AND-->
<!-- mp.orderNumber = mo.orderNumber),0.00) AS shareMoney,-->
<!-- (CASE WHEN mo.orderNumber = pf.orderNumber THEN pf.shareMoney ELSE 0 END) AS fansShareMoney,-->
<!-- IFNULL(mo.rate, 38) AS merchantRate,-->
<!-- 21 AS aisleRate,-->
<!-- ROUND( ( CASE WHEN STATUS = '1' THEN consumeFee ELSE 0 END ) *-->
<!-- IF(locate('SJ000',mo.orderNumber),1,((IFNULL(mo.rate, 38) - 21)/10000)), 2 ) AS platformRevenue,-->
<!-- ROUND(-->
<!-- ( ( CASE WHEN STATUS = '1' THEN consumeFee ELSE 0 END ) * IF(locate('SJ000',mo.orderNumber),1,((IFNULL(mo.rate,-->
<!-- 38) - 21)/10000))) - -->
<!-- IFNULL((SELECT SUM(price) FROM tb_pluss_merchant_profit mp WHERE mo.merchantCode = mp.merchantCode AND-->
<!-- mp.orderNumber = mo.orderNumber),0.00) - -->
<!-- ( CASE WHEN pf.lastMerchantCode is not null THEN pf.shareMoney ELSE 0 END ),2) AS practical,-->
<!-- ROUND( ( CASE WHEN STATUS = '1' THEN consumeFee ELSE 0 END ) * (IFNULL(mo.rate, 38)/10000), 2 ) AS aisleHold,-->
<!-- mo.`status`,-->
<!-- mo.createDt,-->
<!-- mo.transNo,-->
<!-- mbi.userId-->
<!-- FROM-->
<!-- tb_pluss_merchant_order mo-->
<!-- LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode-->
<!-- LEFT JOIN tb_pluss_fans pf ON mo.orderNumber = pf.orderNumber-->
<!-- <where>-->
<!-- <if test="alias!=null and alias!=''">-->
<!-- and mbi.alias like concat("%",#{alias},"%")-->
<!-- </if>-->
<!-- <if test="id!=null and id!=''">-->
<!-- and mo.id=#{id}-->
<!-- </if>-->
<!-- <if test="userId != null">-->
<!-- and mbi.userId = #{userId}-->
<!-- </if>-->
<!-- <if test="orderType!=null and orderType!=''">-->
<!-- and mo.orderType=#{orderType}-->
<!-- </if>-->
<!-- <if test="orderNumber!=null and orderNumber!=''">-->
<!-- and mo.orderNumber=#{orderNumber}-->
<!-- </if>-->
<!-- <if test="merchantName!=null and merchantName!=''">-->
<!-- and mo.merchantName like CONCAT("%",#{merchantName},"%")-->
<!-- </if>-->
<!-- <if test="merchantCode!=null and merchantCode!=''">-->
<!-- and mo.merchantCode IN (SELECT merchantCode-->
<!-- FROM tb_pluss_merchant_base_info-->
<!-- WHERE bindingCode = (SELECT bindingCode-->
<!-- FROM tb_pluss_merchant_base_info-->
<!-- where merchantCode = #{merchantCode}))-->
<!-- </if>-->
<!-- <if test="storeName!=null and storeName!=''">-->
<!-- and mo.storename like CONCAT("%",#{storeName},"%")-->
<!-- </if>-->
<!-- <if test="payTypeName!=null and payTypeName!=''">-->
<!-- and mo.payTypeName=#{payTypeName}-->
<!-- </if>-->
<!-- <if test="status!=null and status!=''">-->
<!-- and mo.status=#{status}-->
<!-- </if>-->
<!-- <if test="startTime!= null and startTime!=''">-->
<!-- <![CDATA[-->
<!-- and DATE_FORMAT(mo.createDt, '%Y-%m-%d %H:%i:%S')>=DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%S')-->
<!-- ]]>-->
<!-- </if>-->
<!-- <if test="endTime!= null and endTime!=''">-->
<!-- <![CDATA[-->
<!-- and DATE_FORMAT(mo.createDt, '%Y-%m-%d %H:%i:%S')<=DATE_FORMAT(#{endTime}, '%Y-%m-%d %H:%i:%S')-->
<!-- ]]>-->
<!-- </if>-->
<!-- </where>-->
<!-- order by createDt desc-->
<!-- limit #{pageSize} offset #{offset}-->
<!-- </select>-->
<select id="queryMerchantOrderPageCountShuju"
parameterType="java.util.Map" resultType="java.lang.Integer">
select count(*) from tb_pluss_merchant_order mo
<where>
<if test="alias != null and alias!=''">
and mo.merchantName = #{alias}
</if>
<if test="id!=null and id!=''">
and mo.id=#{id}
</if>
<if test="orderType!=null and orderType!=''">
and mo.orderType=#{orderType}
</if>
<if test="payTypeCode != null and payTypeCode !=''">
and
(
<foreach collection="payTypeCode" index="index" item="item" separator="or">
mo.payTypeCode = #{item}
</foreach>
)
</if>
<if test="orderNumber!=null and orderNumber!=''">
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
</if>
<if test="merchantName!=null and merchantName!=''">
and mo.merchantName = #{merchantName}
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode = #{merchantCode}
</if>
<if test="storeName!=null and storeName!=''">
and mo.storename = #{storeName}
</if>
<if test="payTypeName!=null and payTypeName!=''">
and mo.payTypeName = #{payTypeName}
</if>
<if test="status!=null and status!=''">
and mo.status = #{status}
</if>
<if test="settlementType != null and settlementType != '' or 0 == settlementType ">
and mo.settlementType = #{settlementType}
</if>
<if test="aisleSwitch != null and aisleSwitch != ''">
and mo.aisleSwitch = #{aisleSwitch}
</if>
<if test="startTime!= null and startTime!=''">
<![CDATA[
and DATE_FORMAT(mo.updateTime, '%Y-%m-%d %H:%i:%S')>=DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="endTime!= null and endTime!=''">
<![CDATA[
and DATE_FORMAT(mo.updateTime, '%Y-%m-%d %H:%i:%S')<=DATE_FORMAT(#{endTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
</where>
</select>
<!-- <select id="queryMerchantOrderNoPageCountShuju"-->
<!-- parameterType="java.util.Map" resultType="java.lang.Integer">-->
<!-- select count(*) from tb_pluss_merchant_order mo-->
<!-- <where>-->
<!-- <if test="id!=null and id!=''">-->
<!-- and mo.id=#{id}-->
<!-- </if>-->
<!-- <if test="alias!=null and alias!=''">-->
<!-- and mbi.alias like concat("%",#{alias},"%")-->
<!-- </if>-->
<!-- <if test="userId != null">-->
<!-- and mbi.userId = #{userId}-->
<!-- </if>-->
<!-- <if test="merchantCode!=null and merchantCode!=''">-->
<!-- and mo.merchantCode IN (SELECT merchantCode-->
<!-- FROM tb_pluss_merchant_base_info-->
<!-- WHERE bindingCode = (SELECT bindingCode-->
<!-- FROM tb_pluss_merchant_base_info-->
<!-- where merchantCode = #{merchantCode}))-->
<!-- </if>-->
<!-- <if test="orderType!=null and orderType!=''">-->
<!-- and mo.orderType=#{orderType}-->
<!-- </if>-->
<!-- <if test="orderNumber!=null and orderNumber!=''">-->
<!-- and mo.orderNumber=#{orderNumber}-->
<!-- </if>-->
<!-- <if test="merchantName!=null and merchantName!=''">-->
<!-- and mo.merchantName like CONCAT("%",#{merchantName},"%")-->
<!-- </if>-->
<!-- <if test="storeName!=null and storeName!=''">-->
<!-- and mo.storename like CONCAT("%",#{storeName},"%")-->
<!-- </if>-->
<!-- <if test="payTypeName!=null and payTypeName!=''">-->
<!-- and mo.payTypeName=#{payTypeName}-->
<!-- </if>-->
<!-- <if test="status!=null and status!=''">-->
<!-- and mo.status=#{status}-->
<!-- </if>-->
<!-- <if test="startTime != null">-->
<!-- and updateTime &gt;= #{startTime}-->
<!-- </if>-->
<!-- <if test="endTime!= null">-->
<!-- and updateTime &lt;= #{endTime}-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="querySumEarnings" parameterType="java.util.Map"
resultType="cn.pluss.platform.vo.MerchantMangeOrderVO">
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL(mo.fansShareMoney,0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.profitShareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mb.aliRate-0.0038),2))
as
platformRevenue,sum(truncate((mo.consumeFee*(mb.aliRate-0.0038)-mo.profitShareMoney-IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0038,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='aliPay'
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime!= null">
and updateTime &lt;= #{endTime}
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode=#{merchantCode}
</if>
union
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL((select pf.shareMoney from tb_pluss_fans pf where
pf.lastMerchantCode=mo.merchantCode and pf.orderNumber=mo.orderNumber),0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.shareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mb.wechatRate-0.0038),2)) as
platformRevenue,sum(truncate((mo.consumeFee*(mb.wechatRate-0.0038)-mo.profitShareMoney-IFNULL((select
pf.shareMoney
from tb_pluss_fans pf where pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0038,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='wechatPay'
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime != null">
and updateTime &lt;= #{endTime}
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode=#{merchantCode}
</if>
union
select
sum(mo.consumeFee) as consumeFee,sum(IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.lastMerchantCode=mo.merchantCode and
pf.orderNumber=mo.orderNumber),0.0))
as
fansShareMoney,sum(mo.enterFee) as enterFee,sum(mo.shareMoney) as
shareMoney,sum(truncate(mo.consumeFee*(mo.rate / 10000 - 0.0021),2))
as
platformRevenue,sum(truncate((mo.consumeFee*(mo.rate / 10000-0.0021)-mo.shareMoney-IFNULL((select
pf.shareMoney from tb_pluss_fans pf where
pf.orderNumber=mo.orderNumber),0.0)),2))
as practical,sum(truncate(mo.consumeFee*0.0021,2)) as aisleHold FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mb ON mo.merchantCode=mb.merchantCode WHERE
mo.status='1' and mo.payTypeCode='leshuaPay0' or mo.payTypeCode='leshuaPay1' or mo.payTypeCode='leshuaPay2'
<if test="startTime != null">
and updateTime &gt;= #{startTime}
</if>
<if test="endTime != null">
and updateTime &lt;= #{endTime}
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode=#{merchantCode}
</if>
</select>
<select id="promoterSumCash" resultType="cn.pluss.platform.vo.PromoterSumVO">
SELECT IFNULL(sum(truncate(mo.shareMoney, 2)), 0) as shareMoney,
IFNULL((SELECT sum(truncate(tc.cashAmt, 2))
from tb_pluss_cash tc
WHERE tc.`status` = '1'
and tc.type = '1'
and tc.userId = #{userId}), 0) as cashMoney
from tb_pluss_merchant_order mo
WHERE mo.promoteruserId = #{userId}
and mo.status = '1'
</select>
<select id="PlatformSum" resultType="cn.pluss.platform.vo.PlatformSumVO">
select
(SELECT count(id) from tb_pluss_merchant_base_info
<where>
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval
1 day)
</if>
</where>
) as merchantCount,
(SELECT count(id) from tb_pluss_merchant_store
<where>
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval
1 day)
</if>
</where>
) as storeCount,
mot.transSum, mot.transCount, mot.refundSum, mot.refundCount, mot.sharemoneySum,
(SELECT COUNT(id) FROM tb_pluss_merchant_menber
<where>
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval
1 day)
</if>
</where>
) as memberCount,
(SELECT COUNT(id) FROM tb_pluss_user_app WHERE userType='promoter'
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval 1
day)</if>) as promoterCount,
(SELECT IFNULL(SUM(shareMoney),0) FROM tb_pluss_fans
<where>
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval
1 day)
</if>
</where>
) as fansShareMoneySum,
0 aliSum,
0 wechatSum,
(
SELECT IFNULL(TRUNCATE((SUM(mo.consumeFee*(mo.rate / 10000-0.0021)-mo.fansShareMoney-(SELECT
IFNULL(sum(pf.shareMoney),0) as totalSum FROM tb_pluss_fans pf WHERE pf.payWay in('2-0','2-1')))),2),0) FROM
tb_pluss_merchant_order mo LEFT JOIN tb_pluss_merchant_base_info mi ON mo.merchantCode=mi.merchantCode WHERE
mo.`status`='1' AND mo.payTypeCode='leshuaPay0' or mo.payTypeCode='leshuaPay1' or mo.payTypeCode='leshuaPay2'
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(mo.createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(mo.createDt) = date_sub(curdate(),interval 1
day)
</if>
)as leshuaSum
FROM (
SELECT SUM(IF(`status` = 1, total, 0)) transSum, SUM(IF(`status` = 1, count, 0)) transCount, SUM(IF(`status` =
2, total, 0)) refundSum, SUM(IF(`status` = 2, count, 0)) refundCount, SUM(sharemoneySum) sharemoneySum FROM (
SELECT `status`, SUM(consumeFee) total, COUNT(id) count, IFNULL( sum( TRUNCATE ( IF(`status` = 1,
fansShareMoney, 0), 2 )), 0 ) sharemoneySum FROM tb_pluss_merchant_order WHERE `status` IN ('1', '2')
<if test="timeStatus!=null and timeStatus=='1'.toString()">and date(createDt) = curdate()</if>
<if test="timeStatus!=null and timeStatus=='2'.toString()">and date(createDt) = date_sub(curdate(),interval 1
day)
</if>
GROUP BY `status`
) t
) mot
</select>
<select id="sumConsumeFeebystoreId" resultType="cn.pluss.platform.vo.StoreVO">
SELECT (SELECT storeName FROM tb_pluss_merchant_store WHERE storeId = #{storeId}) as storeName,
(SELECT IFNULL(sum(consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status = '1' and storeId = #{storeId} and date(createDt) = curdate()) as nowDayConsumeFee,
(
SELECT IFNULL(sum (consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status='1' and storeId=#{storeId}) as sumConsumeFee
</select>
<select id="sumConsumeFeebymerchantCode" resultType="cn.pluss.platform.vo.StoreVO">
SELECT (SELECT alias FROM tb_pluss_merchant_base_info WHERE merchantCode = #{merchantCode}) as storeName,
(SELECT IFNULL(sum(consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status = '1'
and merchantCode = #{merchantCode}
and date(createDt) = curdate()) as nowDayConsumeFee,
(
SELECT IFNULL(sum (consumeFee), 0)
FROM tb_pluss_merchant_order
WHERE status='1' and merchantCode=#{merchantCode}) as sumConsumeFee
</select>
<select id="querySumCount" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
SUM( mo.consumeFee ) AS transAmountCount,
ROUND(
SUM( mo.consumeFee * (( IFNULL( mo.rate, 38 )- 21 )/ 10000 )) +
ROUND(SUM(IF(locate('YS',mo.orderNumber) and mo.settlementType = 0,IF(mo.consumeFee <![CDATA[<=]]> 100,0,IF(mo.consumeFee <![CDATA[>]]>
100 and mo.consumeFee <![CDATA[<=]]> 500, mo.consumeFee * 0.001 - 0.1,mo.consumeFee * 0.0008)),0)),2)
, 2 ) AS profitAmountCount,
ROUND( SUM( mp.shareAmountCount ) , 2 ) AS shareAmountCount,
ROUND( IFNULL( SUM( pf.shareMoney ), 0.00 ), 2 ) AS fansAmountCount,
ROUND(
SUM( mo.consumeFee * (( IFNULL( mo.rate, 38 )- 21 )/ 10000 )) , 2 ) -
ROUND( SUM( mp.shareAmountCount ), 2 ) -
ROUND( IFNULL( SUM( pf.shareMoney ), 0.00 ) +
ROUND(SUM(IF(locate('YS',mo.orderNumber) and mo.settlementType = 0,IF(mo.consumeFee <![CDATA[<=]]> 100,0,IF(mo.consumeFee <![CDATA[>]]>
100 and mo.consumeFee <![CDATA[<=]]> 500, mo.consumeFee * 0.001 - 0.1,mo.consumeFee * 0.0008)),0)),2)
, 2 ) AS actualAmountCount
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_fans pf ON mo.orderNumber = pf.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
LEFT JOIN ( SELECT orderNumber, SUM( price ) AS shareAmountCount FROM tb_pluss_merchant_profit GROUP BY
orderNumber ) mp ON mo.orderNumber = mp.orderNumber
<where>
<choose>
<when test="status != null and status != ''">
and mo.status = #{status}
</when>
<otherwise>
and mo.status = '1'
</otherwise>
</choose>
<if test="id != null and id != ''">
and mo.id = #{id}
</if>
<if test="userId != null and userId != ''">
and mbi.userId = #{userId}
</if>
<if test="orderNumber != null and orderNumber != ''">
and mo.orderNumber = #{orderNumber}
</if>
<if test="alias != null and alias != ''">
and mbi.alias like CONCAT('%',#{alias},'%')
</if>
<if test="storeName != null and storeName != ''">
and mo.storeName like CONCAT('%',#{storeName},'%')
</if>
<if test="orderType != null and orderType != ''">
and mo.orderType = #{orderType}
</if>
<if test="payTypeName != null and payTypeName != ''">
and mo.payTypeName = #{payTypeName}
</if>
<if test="payTypeCode != null and payTypeCode != ''">
and
(
<foreach collection="payTypeCode" index="index" item="item" separator="or">
mo.payTypeCode = #{item}
</foreach>
)
</if>
<if test="startTime != null and startTime != ''">
and mo.createDt <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and mo.createDt <![CDATA[<=]]> #{endTime}
</if>
</where>
</select>
<select id="selectGroupMerchantTotalConsumeMoney" resultType="java.util.Map">
SELECT sum(consumeFee) totalConsumeFee, status, merchantCode FROM tb_pluss_merchant_order tpmo
WHERE tpmo.status IN("1", "2") AND
tpmo.merchantCode IN
<foreach collection="merchantCodeList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
GROUP BY merchantCode, status
</select>
<select id="queryNextMercTransAmtCount" resultType="java.lang.Double" parameterType="java.util.List">
SELECT IFNULL(sum(consumeFee),0) FROM tb_pluss_merchant_order WHERE `status` = 1 and merchantCode in
<foreach collection="list" open="(" separator="," close=")" item="item" index="index">
#{item}
</foreach>
</select>
<select id="querySubMerchantTransMonthAmount" resultType="java.lang.Double">
SELECT SUM(tpmo.consumeFee)
FROM (SELECT t1.consumeFee, t1.orderNumber, t1.createDt, t1.merchantCode
FROM tb_pluss_merchant_order t1
LEFT JOIN tb_pluss_merchant_order t2
ON t1.orderNumber = t2.orderNumber AND t1.`status` = 1 AND t2.`status` = 2
WHERE t1.status = 1
AND t2.updateTime IS NULL) tpmo
LEFT JOIN tb_pluss_user_app tpua ON tpmo.merchantCode = tpua.merchantCode
WHERE tpua.parentId = #{parentId}
AND tpmo.createDt &gt; DATE_FORMAT(CURDATE(), "%Y-%m")
</select>
<select id="querySubMerchantTransLastMonthAmount" resultType="java.lang.Double">
SELECT SUM(tpmo.consumeFee)
FROM (SELECT t1.consumeFee, t1.orderNumber, t1.createDt, t1.merchantCode
FROM tb_pluss_merchant_order t1
LEFT JOIN tb_pluss_merchant_order t2
ON t1.orderNumber = t2.orderNumber AND t1.`status` = 1 AND t2.`status` = 2
WHERE t1.status = 1
AND t2.updateTime IS NULL) tpmo
LEFT JOIN tb_pluss_user_app tpua ON tpmo.merchantCode = tpua.merchantCode
WHERE tpua.parentId = #{parentId}
AND tpmo.createDt &lt; DATE_FORMAT(CURDATE(), "%Y-%m")
AND tpmo.createDt &gt; DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), "%Y-%m")
</select>
<update id="updateBatch" parameterType="java.util.List">
update tb_pluss_merchant_order
<trim prefix="set" suffixOverrides=",">
<trim prefix="enterFee = case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.enterFee != null">
when id=#{i.id} then #{i.enterFee}
</if>
</foreach>
</trim>
<trim prefix=" rate = case" suffix="end,">
<foreach collection="list" item="i" index="index">
<if test="i.rate != null">
when id=#{i.id} then #{i.rate}
</if>
</foreach>
</trim>
</trim>
where
<foreach collection="list" separator="or" item="i" index="index">
id=#{i.id}
</foreach>
</update>
<select id="getSuperMerchantToDayTradeMoneyCount" parameterType="java.util.Map" resultType="java.util.Map">
SELECT IFNULL(SUM(mo.consumeFee),0.00) AS tradeCountMoney,ua.parentId as agentId FROM tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_user_app ua ON mo.merchantCode = ua.merchantCode
WHERE mo.`status` = 1 AND mo.createDt BETWEEN #{firstDate}
AND #{lastDate} AND ua.parentId in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND ua.parentId is not null GROUP BY ua.parentId ;
</select>
<select id="queryDailyCount" resultType="java.util.Map">
SELECT DATE_ADD(t2.day, INTERVAL 1 DAY) date, SUM(t2.consumeFee) consumeFeeSum
FROM (
SELECT DATE_FORMAT(t.updateTime, "%Y-%m-%d") day, t.consumeFee FROM tb_pluss_merchant_order t
WHERE t.`status` = '1' AND t.merchantCode = #{merchantCode} AND t.updateTime BETWEEN #{start} AND #{end}
) t2
GROUP BY t2.day
</select>
<select id="selectProfitPage" resultType="cn.pluss.platform.vo.MerchantOrderProfitVO" parameterType="java.util.Map">
SELECT a.*,ui.phone AS 'onePhone',ua.userName AS 'oneName', t.phone AS 'twoPhone',ta.userName AS
'twoName',e.phone AS 'threePhone',ea.userName AS 'threeName',p.phone AS 'toUpPhone',pa.userName AS 'toUpName'
FROM (
SELECT
mbi.userId,
mo.orderNumber,
mbi.alias as merchantName,
mo.orderType,
mo.payTypeCode as payType,
mo.consumeFee,
mo.createDt,
IFNULL(mo.rate,38) AS mercRate,
ROUND((mo.consumeFee * (IFNULL(mo.rate,38))/10000),2) AS mercFee ,
IFNULL((SELECT SUM(price) FROM tb_pluss_merchant_profit mp WHERE mp.orderNumber = mo.orderNumber),0.00) AS
shareMoney,
SUM(CASE mp.type WHEN '1' THEN mp.price ELSE 0 END) 'oneFee',
SUM(CASE mp.type WHEN '2' THEN mp.price ELSE 0 END) 'twoFee',
SUM(CASE mp.type WHEN '3' THEN mp.price ELSE 0 END) 'threeFee',
SUM(CASE mp.type WHEN '4' THEN mp.price ELSE 0 END) 'toUpFee',
SUM(CASE mp.type WHEN '5' THEN mp.price ELSE 0 END) 'toAgentFeeCount',
GROUP_CONCAT(CASE mp.type WHEN '1' THEN mp.userId ELSE '' END SEPARATOR '') 'oneUserId',
GROUP_CONCAT(CASE mp.type WHEN '2' THEN mp.userId ELSE '' END SEPARATOR '') 'twoUserId',
GROUP_CONCAT(CASE mp.type WHEN '3' THEN mp.userId ELSE '' END SEPARATOR '') 'threeUserId',
GROUP_CONCAT(CASE mp.type WHEN '4' THEN mp.userId ELSE '' END SEPARATOR '') 'toUpUserId'
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_profit mp ON mp.orderNumber = mo.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
WHERE
mo.`status` = '1'
<if test="merchantName != null and merchantName != ''">
and mbi.alias like concat('%',#{merchantName},'%')
</if>
<if test="userId != null and userId != ''">
and mp.userId = #{userId}
</if>
<if test="profitCount != all">
and mp.price != '0.00'
</if>
<if test="orderNumber != null and orderNumber != ''">
and mo.orderNumber = #{orderNumber}
</if>
GROUP BY mo.orderNumber
ORDER BY
mo.createDt DESC
limit #{pageSize} offset #{offset}
) a
LEFT JOIN tb_pluss_user_info ui on
a.oneUserId = ui.id
LEFT JOIN tb_pluss_user_app ua ON
a.oneUserId = ua.userId
LEFT JOIN tb_pluss_user_info t ON
a.twoUserId = t.id
LEFT JOIN tb_pluss_user_app ta ON
a.twoUserId = ta.userId
LEFT JOIN tb_pluss_user_info e ON
a.threeUserId = e.id
LEFT JOIN tb_pluss_user_app ea ON
a.threeUserId = ea.userId
LEFT JOIN tb_pluss_user_info p ON
a.toUpUserId = p.id
LEFT JOIN tb_pluss_user_app pa ON
a.toUpUserId = pa.userId
ORDER BY a.createDt desc
</select>
<select id="selectProfitPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(1) FROM (
SELECT
mbi.userId
FROM
tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_profit mp ON mp.orderNumber = mo.orderNumber
LEFT JOIN tb_pluss_merchant_base_info mbi ON mo.merchantCode = mbi.merchantCode
WHERE
mo.`status` = '1'
<if test="merchantName != null and merchantName != ''">
and mbi.alias like concat('%',#{merchantName},'%')
</if>
<if test="userId != null and userId != ''">
and mp.userId = #{userId}
</if>
<if test="profitCount != all">
and mp.price != '0.00'
</if>
<if test="orderNumber != null and orderNumber != ''">
and mo.orderNumber = #{orderNumber}
</if>
GROUP BY mo.orderNumber
) a
</select>
<!-- <select id="getCountMaketAmt" parameterType="java.lang.String" resultType="java.util.Map">-->
<!-- SELECT-->
<!-- IFNULL(SUM(mo.marketAmt),0.00) AS marketAmtCount,-->
<!-- IFNULL(-->
<!-- SUM(-->
<!-- CASE-->
<!-- WHEN date_format( mo.createDt, '%Y%m' ) != date_format( NOW( ), '%Y%m' ) THEN-->
<!-- mo.marketAmt-->
<!-- END-->
<!-- )-->
<!-- ,0.00)AS useMarketAmtCount,-->
<!-- IFNULL(-->
<!-- SUM(-->
<!-- CASE-->
<!-- WHEN date_format( mo.createDt, '%Y%m' ) = date_format( NOW( ), '%Y%m' ) THEN-->
<!-- mo.marketAmt-->
<!-- END-->
<!-- )-->
<!-- ,0.00) AS useMonthMarketAmtCount-->
<!-- FROM-->
<!-- tb_pluss_merchant_order mo-->
<!-- left join tb_pluss_merchant_base_info mbi-->
<!-- on mo.merchantCode = mbi.merchantCode-->
<!-- WHERE mbi.userId = #{userId} and mo.`status` = 1-->
<!-- <if test="date != null">-->
<!-- and date_format(mo.createDt, '%Y-%m') = #{date}-->
<!-- </if>-->
<!-- <if test="auditDate != null">-->
<!-- and mo.createDate >= #{auditDate}-->
<!-- </if>-->
<!-- </select>-->
<select id="getCountTradeAmt" parameterType="java.lang.String" resultType="java.util.Map">
SELECT
IFNULL(SUM(mo.consumeFee - refundAmt),0.00) AS tradeAmtCount,
IFNULL(SUM(case when DATE_FORMAT(mo.transDt,'%Y-%m-%d') >= #{date} THEN mo.consumeFee END),0.00) AS dateAmt
FROM tb_pluss_merchant_order mo
WHERE mo.merchantCode = #{merchantCode} and mo.`status` = 1
<if test="startDate != null and startDate != ''">
<![CDATA[ and DATE_FORMAT(mo.createDt,'%Y-%m-%d') >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[ and DATE_FORMAT(mo.createDt,'%Y-%m-%d') <= #{endDate}]]>
</if>
</select>
<select id="getCountMaketAmtAndDate" parameterType="java.lang.String" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(mo.consumeFee), 0.00) AS tradeAmtCount
FROM tb_pluss_merchant_order mo
WHERE mo.merchantCode = #{merchantCode}
and mo.`status` = 1
and DATE_FORMAT(mo.transDt, '%Y-%m-%d') >= #{date}
</select>
<select id="pageWapInfo" parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.entity.MerchantOrder">
select consumeFee, ROUND(((38-IFNULL(rate,38))/10000)*consumeFee,2) as saveAmt,transDt FROM
tb_pluss_merchant_order
where status = #{order.status} and merchantCode = #{order.merchantCode}
<if test="order.startTime != null">
<![CDATA[ and createDt >= #{order.startTime}]]>
</if>
<if test="order.endTime != null">
<![CDATA[ and createDt <= #{order.endTime}]]>
</if>
order by createDt desc
</select>
<select id="getSaveMoneyCount" parameterType="java.lang.String" resultType="java.util.Map">
select
IFNULL(ROUND(SUM(((38-IFNULL(rate,38))/10000)*consumeFee),2),0.0) AS 'saveAmtCount',
IFNULL(SUM(case when DATE_FORMAT(transDt,'%Y-%m-%d') = #{date} THEN
ROUND((38-IFNULL(rate,38))/10000*consumeFee,2) END),0.00) AS saveDateAmt
FROM tb_pluss_merchant_order
where status = 1 and merchantCode = #{merchantCode}
<if test="startDate != null and startDate != ''">
<![CDATA[ and DATE_FORMAT(createDt,'%Y-%m-%d') >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[ and DATE_FORMAT(createDt,'%Y-%m-%d') <= #{endDate}]]>
</if>
</select>
<select id="pageInfo" parameterType="cn.pluss.platform.entity.MerchantOrder"
resultType="cn.pluss.platform.entity.MerchantOrder">
select mo.*,mbi.alias from tb_pluss_merchant_order mo
left join tb_pluss_merchant_base_info mbi
on mo.merchantCode = mbi.merchantCode
where mo.status = '1'
<if test="order.userId != null">
and mbi.userId = #{order.userId}
</if>
<if test="order.orderType != null">
and mo.orderType = #{order.orderType}
</if>
<if test="order.startTime != null">
and mo.transDt >= #{order.startTime}
</if>
<if test="order.endTime != null">
and mo.transDt <![CDATA[ <= ]]> #{order.endTime}
</if>
<if test="order.params != null and order.params.createDtStr != null">
and DATE_FORMAT(mo.createDt,'%Y-%m') = #{order.params.createDtStr}
</if>
<if test="order.params != null and order.params.marketAmt == 0.00">
and mo.marketAmt is not null and mo.marketAmt != 0.00
</if>
ORDER BY mo.id desc
</select>
<select id="sumData" resultType="cn.pluss.platform.entity.MerchantOrder">
SELECT IFNULL(SUM(CASE `status`
WHEN '1' THEN consumeFee
WHEN '2' THEN -consumeFee
ELSE 0
), 0) consumeFee,
IFNULL(SUM(CASE `status`
WHEN '1' THEN enterFee
WHEN '2' THEN -enterFee
ELSE 0
), 0) enterFee,
FROM tb_pluss_merchant_order ${ew.customSqlSegment}
</select>
<select id="getCountNowDateSettleAmt" parameterType="java.lang.String" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(mo.enterFee - IF(mro.payAmt, mo.enterFee, 0)), 0) as settleAmt
FROM tb_pluss_merchant_order mo
LEFT JOIN tb_pluss_merchant_refund_order mro ON mo.orderNumber = mro.orderNumber
WHERE mo.`status` = 1
and mo.orderType in (2, 3, 9, 10)
AND mo.merchantCode = #{merchantCode}
AND (mro.`status` is null or mro.`status` in (1, 2))
AND DATE_FORMAT(mo.transDt, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
</select>
<select id="getOrderCountData" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
SUM(IF( mo.STATUS = 1, mo.consumeFee, 0 )) AS transAmountCount,
SUM(IF( mo.STATUS = 2, IF ( mo.refundAmt = 0, mo.consumeFee, mo.refundAmt ), 0 )) AS refundAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.orderType = 8, mo.consumeFee, 0 )) AS upAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.orderType != 8, mo.mercFee - mo.channelFee, 0 )) AS transProfitAmountCount,
SUM(IF( mo.STATUS = 1 AND mo.settlementType = 0, IF(mo.cashFee = 0,mo.consumeFee - mo.enterFee - mo.mercFee,mo.cashFee),0)) numberAmountCount,
ROUND( SUM( mo.profitShareMoney ), 2 ) AS shareAmountCount,
ROUND( SUM( IFNULL( mo.fansShareMoney, 0 ) ), 2 ) AS fansAmountCount,
SUM(IF(mo.STATUS = 1,IF( mo.orderType = 8, mo.consumeFee, mo.consumeFee - mo.enterFee ) - mo.channelFee,0 )) AS profitAmountCount,
ROUND(SUM(IF(mo.`status` = 1,IF( mo.orderType = 8, mo.consumeFee, mo.consumeFee - mo.enterFee ) - mo.channelFee - mo.profitShareMoney - mo.fansShareMoney - IF(mo.settlementType = 0,IF(mo.cashFee = 0 ,mo.consumeFee - mo.enterFee - mo.mercFee , mo.cashFee) * 0.2,0),0 )),2) AS actualAmountCount
FROM
tb_pluss_merchant_order mo
<where>
mo.status in (1,2)
<if test="createDate != null">
and mo.createDate = #{createDate}
</if>
<if test="startCreateDate!= null and startCreateDate!=''">
and mo.createDate <![CDATA[>=]]> #{startCreateDate}
</if>
<if test="endCreateDate!= null and endCreateDate!=''">
and mo.createDate <![CDATA[<=]]> #{endCreateDate}
</if>
<if test="startUpdateDate!= null and startUpdateDate!=''">
and mo.updateDate <![CDATA[>=]]> #{startUpdateDate}
</if>
<if test="endUpdateDate!= null and endUpdateDate!=''">
and mo.updateDate <![CDATA[<=]]> #{endUpdateDate}
</if>
<if test="alias!=null and alias!=''">
and mo.merchantName = #{alias}
</if>
<if test="id!=null and id!=''">
and mo.id=#{id}
</if>
<if test="orderType!=null and orderType!=''">
and mo.orderType=#{orderType}
</if>
<if test="payTypeCode != null and payTypeCode !=''">
and
(
<foreach collection="payTypeCode" index="index" item="item" separator="or">
mo.payTypeCode = #{item}
</foreach>
)
</if>
<if test="orderNumber!=null and orderNumber!=''">
and (mo.orderNumber=#{orderNumber} or mo.transNo = #{orderNumber} or mo.thirdTransNo = #{orderNumber})
</if>
<if test="merchantName!=null and merchantName!=''">
and mo.merchantName like CONCAT("%",#{merchantName},"%")
</if>
<if test="merchantCode!=null and merchantCode!=''">
and mo.merchantCode=#{merchantCode}
</if>
<if test="storeName!=null and storeName!=''">
and mo.storename like CONCAT("%",#{storeName},"%")
</if>
<if test="payTypeName!=null and payTypeName!=''">
and mo.payTypeName=#{payTypeName}
</if>
<if test="status!=null and status!=''">
and mo.status=#{status}
</if>
<if test="settlementType != null and settlementType != '' or 0 == settlementType ">
and mo.settlementType=#{settlementType}
</if>
<if test="aisleSwitch != null and aisleSwitch != ''">
and mo.aisleSwitch=#{aisleSwitch}
</if>
<if test="startTime!= null and startTime!=''">
and mo.updateTime <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime!= null and endTime!=''">
and mo.updateTime <![CDATA[<=]]> #{endTime}
</if>
</where>
</select>
<select id="getPlatformOrderData" resultType="java.util.Map">
SELECT
SUM( consumeFee ) as toDayTransCount,
count(1) as toDayTransNum,
SUM(IF( payTypeCode = 'aliPay' OR payTypeCode = 'sxfPay0', consumeFee, 0 )) as toDayTransAliCount,
SUM(IF( payTypeCode = 'aliPay' OR payTypeCode = 'sxfPay0', 1, 0 )) as toDayTransAliNum,
SUM(IF( payTypeCode = 'wechatPay' OR payTypeCode = 'sxfPay1', consumeFee, 0 )) as toDayTransWxCount,
SUM(IF( payTypeCode = 'wechatPay' OR payTypeCode = 'sxfPay1', 1, 0 )) as toDayTransWxNum,
SUM(IF( payTypeCode = 'bank' OR payTypeCode = 'sxfPay2' , consumeFee, 0 )) as toDayTransUnionCount,
SUM(IF( payTypeCode = 'bank' OR payTypeCode = 'sxfPay2' , 1, 0 )) as toDayTransUnionNum
FROM
tb_pluss_merchant_order
WHERE
createDate = CURDATE() AND STATUS = 1;
</select>
<select id="getPlatformAmtData" resultType="java.util.Map">
SELECT
SUM(
IF
(orderType = 8,enterFee,IF(
settlementType = 1,
mercFee - channelFee,
consumeFee - enterFee - channelFee - (IF(cashFee = 0, consumeFee - enterFee - mercFee,cashFee) * 0.2)))
) AS toDayProfitCount,
SUM( profitShareMoney ) AS toDayShareCount,
SUM( fansShareMoney ) AS toDayFansCount
FROM
tb_pluss_merchant_order
WHERE
createDate = CURDATE()
AND `status` = 1
</select>
<select id="getOrderFlow" resultType="cn.pluss.platform.entity.UserProfit">
SELECT
ua.userId,
ua.parentId,
ua.roleCode,
ua.levelCode,
IFNUll(t.transNum,0) ownTransNum,
IFNUll(t2.transNum,0) transNum,
IFNULL( t2.teamTransFlow, 0 ) AS teamTransFlow,
IFNULL( t.ownTransFlow, 0 ) AS ownTransFlow,
IFNULL( t2.directTransFlow, 0 ) AS directTransFlow,
IFNULL( t2.indirectTransFlow, 0 ) AS indirectTransFlow,
IFNULL( t3.totalProfitAmt, 0 ) AS totalProfitAmt,
IFNULL( t3.directProfitAmt, 0 ) AS directProfitAmt,
IFNULL( t3.indirectProfitAmt, 0 ) AS indirectProfitAmt,
IFNULL( t3.otherProfitAmt, 0 ) AS otherProfitAmt
FROM
tb_pluss_user_app ua
LEFT JOIN (
SELECT
mo.merchantCode,
SUM(consumeFee - IFNULL(IFNULL(mro.refundAmt,mro.payAmt),0)) AS ownTransFlow,
count(1) as transNum
FROM
tb_pluss_merchant_order mo
LEFT JOIN
tb_pluss_merchant_refund_order mro ON mo.orderNumber = mro.orderNumber
WHERE
mo.createDate = #{date}
AND mo.`status` = 1
GROUP BY
mo.merchantCode
) t ON ua.merchantCode = t.merchantCode
LEFT JOIN (
SELECT
SUM( ups.ownTransFlow + ups.teamTransFlow ) teamTransFlow,
SUM( ups.ownTransFlow ) directTransFlow,
SUM( ups.directTransFlow ) indirectTransFlow,
SUM( ups.transNum + ups.ownTransNum) transNum,
ua.userId
FROM
tb_pluss_user_profit ups
LEFT JOIN tb_pluss_user_app ua ON ups.parentId = ua.userId
LEFT JOIN tb_pluss_user_level ul ON ul.levelCode = ua.levelCode
WHERE
ups.profitDate = #{date}
AND ua.sort = #{sort}
GROUP BY
ua.userId
) t2 ON t2.userId = ua.userId
LEFT JOIN (
SELECT
SUM(price) totalProfitAmt,
SUM(IF(type = 1,price,0)) AS directProfitAmt,
SUM(IF(type = 2,price,0)) AS indirectProfitAmt,
SUM(IF(type != 1 and type != 2,price,0)) AS otherProfitAmt,
userId
FROM tb_pluss_merchant_profit WHERE recordDate = #{date} AND price != 0 GROUP BY userId
) t3 ON ua.userId = t3.userId
LEFT JOIN tb_pluss_user_level ull ON ull.levelCode = ua.levelCode
WHERE
ua.sort = #{sort}
AND ua.userType NOT IN ( 'agent_staff', 'staff' )
ORDER BY
teamTransFlow DESC,
ownTransFlow DESC
</select>
<select id="getOrderMaxSort" resultType="java.lang.Integer">
SELECT
MAX(ua.sort)
FROM
(
SELECT
mo.merchantCode,
SUM( consumeFee ) AS transSumAmt,
mo.rate
FROM
tb_pluss_merchant_order mo
WHERE
mo.createDate = #{date}
AND mo.`status` = 1
GROUP BY
mo.merchantCode
) t
LEFT JOIN tb_pluss_user_app ua ON t.merchantCode = ua.merchantCode
WHERE ua.userType = 'promoter'
</select>
<select id="getPlatformTransData" resultType="java.util.Map">
SELECT
SUM( consumeFee ) AS transCount,
count( 1 ) AS transNum
FROM
tb_pluss_merchant_order
WHERE
`status` = 1
</select>
<select id="getAreaOrderCount" resultType="java.math.BigDecimal">
SELECT
IFNULL(SUM(consumeFee - refundAmt),0)
FROM
tb_pluss_merchant_order mo
WHERE status = 1
<choose>
<when test="flag == 1">
and createDate = #{date}
</when>
<otherwise>
and createDate <![CDATA[<=]]> #{date}
</otherwise>
</choose>
AND merchantCode in
<foreach collection="mercList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
</mapper>