|
@@ -657,13 +657,23 @@
|
|
|
</update>
|
|
|
<!-- 日统计 -->
|
|
|
<select id="getDayStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
- 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' -- 支付成功
|
|
|
+ select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
|
|
|
group by DATE_FORMAT( a.create_date,'%H')
|
|
@@ -682,13 +692,23 @@
|
|
|
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 from t_order a
|
|
|
- where a.status='1' -- 支付成功
|
|
|
+ count(1) as saleNum,sum(a.price) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
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') ]]>
|
|
@@ -698,13 +718,23 @@
|
|
|
|
|
|
<!-- 月统计 -->
|
|
|
<select id="getMonthStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
- 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' -- 支付成功
|
|
|
+ select DATE_FORMAT( a.create_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
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') ]]>
|
|
@@ -727,13 +757,23 @@
|
|
|
select '11月' as categorie from dual UNION all
|
|
|
select '12月' as categorie from dual) tab1
|
|
|
left join (
|
|
|
- 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' -- 支付成功
|
|
|
+ select concat(DATE_FORMAT( a.create_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
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') ]]>
|
|
@@ -743,53 +783,98 @@
|
|
|
|
|
|
<!-- 汇总统计-->
|
|
|
<select id="getMainStatistics" resultMap="chartBean">
|
|
|
- select 'day' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
-where date_format(a.create_date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
|
- and a.status='1'
|
|
|
+ select 'day' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
+ and date_format(a.create_date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
|
UNION all
|
|
|
-select 'week' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
-where YEARWEEK(date_format(a.create_date,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
|
|
- and a.status='1'
|
|
|
+select 'week' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
+ and YEARWEEK(date_format(a.create_date,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
|
|
UNION all
|
|
|
-select 'month' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
-where date_format(a.create_date,'%Y-%m') = date_format(now(),'%Y-%m')
|
|
|
- and a.status='1'
|
|
|
+select 'month' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
+ and date_format(a.create_date,'%Y-%m') = date_format(now(),'%Y-%m')
|
|
|
UNION all
|
|
|
-select 'year' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
-where date_format(a.create_date,'%Y') = date_format(now(),'%Y')
|
|
|
- and a.status='1'
|
|
|
+select 'year' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a where a.status='1' -- 支付成功
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a left join t_equipment b on a.client_id = b.client_id where 1=1
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and a.admin_id= #{adminId} -- 所属商家id
|
|
|
</if>
|
|
|
<if test="equipmentId != null and equipmentId !=''">
|
|
|
- and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ and b.id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</if>
|
|
|
+ and date_format(a.create_date,'%Y') = date_format(now(),'%Y')
|
|
|
</select>
|
|
|
|
|
|
<!-- 统计 机器销售-->
|
|
|
<select id="getEquipmentStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
select ifnull(b.name,SUBSTRING(a.client_id,1,4)) as categorie,count(1) as saleNum,sum(a.price) as salePrice
|
|
|
-from t_order a,t_equipment b
|
|
|
-where b.id = a.equipment_id
|
|
|
- and a.status='1'
|
|
|
+ <if test="ifForeign != null and ifForeign =='0'"> -- 国内用户
|
|
|
+ from t_order a,t_equipment b
|
|
|
+ where b.id = a.equipment_id and a.status='1'
|
|
|
+ </if>
|
|
|
+ <if test="ifForeign != null and ifForeign =='1'"> -- 国外用户
|
|
|
+ from t_coin_order a,t_equipment b
|
|
|
+ where a.client_id = b.client_id
|
|
|
+ </if>
|
|
|
<if test="adminId != null and adminId !=''">
|
|
|
and b.admin_id= #{adminId} -- 设备所属商家id
|
|
|
</if>
|