123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?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.szwl.mapper.TOrderMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.szwl.model.entity.TOrder">
- <id column="id" property="id" />
- <result column="create_date" property="createDate" />
- <result column="modify_date" property="modifyDate" />
- <result column="admin_id" property="adminId" />
- <result column="admin_proportion" property="adminProportion" />
- <result column="agency_id" property="agencyId" />
- <result column="agency_proportion" property="agencyProportion" />
- <result column="alt_info" property="altInfo" />
- <result column="client_id" property="clientId" />
- <result column="equipment_id" property="equipmentId" />
- <result column="frp_code" property="frpCode" />
- <result column="merchant_id" property="merchantId" />
- <result column="merchant_proportion" property="merchantProportion" />
- <result column="pay_date" property="payDate" />
- <result column="personage_id" property="personageId" />
- <result column="personage_proportion" property="personageProportion" />
- <result column="price" property="price" />
- <result column="product_id" property="productId" />
- <result column="product_name" property="productName" />
- <result column="refund_date" property="refundDate" />
- <result column="sn" property="sn" />
- <result column="status" property="status" />
- <result column="type" property="type" />
- <result column="trx_no" property="trxNo" />
- <result column="refund_trx_no" property="refundTrxNo" />
- <result column="es" property="es" />
- <result column="refund_amount" property="refundAmount" />
- <result column="note" property="note" />
- <result column="pay_platform" property="payPlatform" />
- <result column="is_settlement" property="isSettlement" />
- <result column="proportion_desc" property="proportionDesc" />
- </resultMap>
- <resultMap id="chartBean" type="com.szwl.model.bean.ChartBean">
- <result column="categorie" jdbcType="VARCHAR" property="categorie" />
- <!--<result column="saleNum" jdbcType="INTEGER" property="saleNum" />-->
- <result column="saleNum" jdbcType="FLOAT" property="saleNum" />
- <!--<result column="salePrice" jdbcType="DECIMAL" property="salePrice" />-->
- <result column="salePrice" jdbcType="FLOAT" property="salePrice" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, create_date, modify_date, admin_id, admin_proportion, agency_id, agency_proportion, alt_info, client_id, equipment_id, frp_code, merchant_id, merchant_proportion, pay_date, personage_id, personage_proportion, price, product_id, product_name, refund_date, sn, status, type, trx_no, refund_trx_no, es, refund_amount, note, pay_platform, is_settlement, proportion_desc
- </sql>
- <!-- 日统计select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice -->
- <select id="getDayStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_order a where a.status='1' -- 支付成功
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- select concat(DATE_FORMAT( a.pay_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_coin_order a where 1=1
- </if>
- <if test="adminId != null and adminId !=''">
- and a.admin_id= #{adminId} -- 所属商家id
- </if>
- <if test="agencyId != null and agencyId !=''">
- and a.agency_id= #{agencyId} and a.type > '1'
- </if>
- <if test="merchantId != null and merchantId !=''">
- and a.merchant_id= #{merchantId} and a.type > '2'
- </if>
- <if test="equipmentId != null and equipmentId !=''">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- and a.equipment_id= #{equipmentId} -- 设备id
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- and a.client_id= #{clientId} -- 设备编号
- </if>
- </if>
- <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
- and a.pay_type= #{payType} -- 国外支付方式
- </if>
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
- group by DATE_FORMAT( a.create_date,'%H')
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- and DATE_FORMAT( a.pay_date,'%Y/%m/%d') = #{startDate}
- group by DATE_FORMAT( a.pay_date,'%H')
- </if>
- order by categorie
- </select>
- <!--and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}-->
- <!--group by DATE_FORMAT( a.create_date,'%H')-->
- <!-- 周统计 -->
- <select id="getWeekStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
- SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
- select '周1' as categorie from dual UNION all
- select '周2' as categorie from dual UNION all
- select '周3' as categorie from dual UNION all
- select '周4' as categorie from dual UNION all
- select '周5' as categorie from dual UNION all
- select '周6' as categorie from dual UNION all
- select '周日' as categorie from dual) tab1
- left join (
- -- select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
- -- count(1) as saleNum,sum(a.price) as salePrice
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
- count(1) as saleNum,sum(a.price) as salePrice
- from t_order a where a.status='1' -- 支付成功
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- select case DATE_FORMAT( a.pay_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.pay_date,'%w')) end as categorie,
- count(1) as saleNum,sum(a.price) as salePrice
- from t_coin_order a where 1=1
- </if>
- <if test="adminId != null and adminId !=''">
- and a.admin_id= #{adminId} -- 所属商家id
- </if>
- <if test="agencyId != null and agencyId !=''">
- and a.agency_id= #{agencyId} and a.type > '1'
- </if>
- <if test="merchantId != null and merchantId !=''">
- and a.merchant_id= #{merchantId} and a.type > '2'
- </if>
- <if test="equipmentId != null and equipmentId !=''">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- and a.equipment_id= #{equipmentId} -- 设备id
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- and a.client_id= #{clientId} -- 设备编号
- </if>
- </if>
- <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
- and a.pay_type= #{payType} -- 国外支付方式
- </if>
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.create_date,'%w')
- ) tab2 on tab1.categorie = tab2.categorie
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.pay_date,'%w')
- ) tab2 on tab1.categorie = tab2.categorie
- </if>
- </select>
- <!-- 月统计 -->
- <select id="getMonthStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- select DATE_FORMAT( a.create_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_order a where a.status='1' -- 支付成功
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- select DATE_FORMAT( a.pay_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_coin_order a where 1=1
- </if>
- <if test="adminId != null and adminId !=''">
- and a.admin_id= #{adminId} -- 所属商家id
- </if>
- <if test="agencyId != null and agencyId !=''">
- and a.agency_id= #{agencyId} and a.type > '1'
- </if>
- <if test="merchantId != null and merchantId !=''">
- and a.merchant_id= #{merchantId} and a.type > '2'
- </if>
- <if test="equipmentId != null and equipmentId !=''">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- and a.equipment_id= #{equipmentId} -- 设备id
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- and a.client_id= #{clientId} -- 设备编号
- </if>
- </if>
- <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
- and a.pay_type= #{payType} -- 国外支付方式
- </if>
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.create_date,'%m月%d')
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.pay_date,'%m月%d')
- </if>
- </select>
- <!-- 年统计 -->
- <select id="getYearStatistics" resultMap="chartBean" parameterType="com.szwl.model.query.StatisticsParam">
- SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
- select '01月' as categorie from dual UNION all
- select '02月' as categorie from dual UNION all
- select '03月' as categorie from dual UNION all
- select '04月' as categorie from dual UNION all
- select '05月' as categorie from dual UNION all
- select '06月' as categorie from dual UNION all
- select '07月' as categorie from dual UNION all
- select '08月' as categorie from dual UNION all
- select '09月' as categorie from dual UNION all
- select '10月' as categorie from dual UNION all
- select '11月' as categorie from dual UNION all
- select '12月' as categorie from dual) tab1
- left join (
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- select concat(DATE_FORMAT( a.create_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_order a where a.status='1' -- 支付成功
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- select concat(DATE_FORMAT( a.pay_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice
- from t_coin_order a where 1=1
- </if>
- <if test="adminId != null and adminId !=''">
- and a.admin_id= #{adminId} -- 所属商家id
- </if>
- <if test="agencyId != null and agencyId !=''">
- and a.agency_id= #{agencyId} and a.type > '1'
- </if>
- <if test="merchantId != null and merchantId !=''">
- and a.merchant_id= #{merchantId} and a.type > '2'
- </if>
- <if test="equipmentId != null and equipmentId !=''">
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- and a.equipment_id= #{equipmentId} -- 设备id
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- and a.client_id= #{clientId} -- 设备编号
- </if>
- </if>
- <if test="ifForeign != null and ifForeign ==1 and payType != null"> -- 国外用户
- and a.pay_type= #{payType} -- 国外支付方式
- </if>
- <if test="ifForeign != null and ifForeign ==0"> -- 国内用户
- AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.create_date,'%m')
- ) tab2 on tab1.categorie = tab2.categorie
- </if>
- <if test="ifForeign != null and ifForeign ==1"> -- 国外用户
- AND a.pay_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
- <![CDATA[ AND a.pay_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
- group by DATE_FORMAT( a.pay_date,'%m')) tab2 on tab1.categorie = tab2.categorie
- </if>
- </select>
- </mapper>
|