Browse Source

增加 国外用户统计判断

吴洪双 5 years ago
parent
commit
17d52ea5ca

+ 31 - 25
src/main/java/com/shawn/model/entity/TAdmin.java

@@ -1,7 +1,5 @@
 package com.shawn.model.entity;
 package com.shawn.model.entity;
 
 
-import java.util.Date;
-import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -10,7 +8,9 @@ import lombok.NoArgsConstructor;
 import lombok.Setter;
 import lombok.Setter;
 import lombok.ToString;
 import lombok.ToString;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
-import com.shawn.web.exception.MyException;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 
 @Accessors(chain = true)
 @Accessors(chain = true)
 @NoArgsConstructor
 @NoArgsConstructor
@@ -19,80 +19,86 @@ import com.shawn.web.exception.MyException;
 @ToString
 @ToString
 public class TAdmin {
 public class TAdmin {
     
     
-	@ApiModelProperty(value="ID")
+	@ApiModelProperty(value="")
 	private Long id;
 	private Long id;
 
 
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-	@ApiModelProperty(value="添加时间")
+	@ApiModelProperty(value="")
 	private Date createDate;
 	private Date createDate;
 
 
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-	@ApiModelProperty(value="修改时间")
+	@ApiModelProperty(value="")
 	private Date modifyDate;
 	private Date modifyDate;
 
 
-	@ApiModelProperty(value="所属代理商id")
+	@ApiModelProperty(value="")
 	private Long agencyId;
 	private Long agencyId;
 
 
-	@ApiModelProperty(value="地区id")
+	@ApiModelProperty(value="")
 	private Long areaId;
 	private Long areaId;
 
 
-	@ApiModelProperty(value="部门")
+	@ApiModelProperty(value="")
 	private String department;
 	private String department;
 
 
-	@ApiModelProperty(value="email")
+	@ApiModelProperty(value="")
 	private String email;
 	private String email;
 
 
-	@ApiModelProperty(value="是否是正常管理员,false:等级商 , true:管理员")
+	@ApiModelProperty(value="")
 	private Boolean isAdmined;
 	private Boolean isAdmined;
 
 
-	@ApiModelProperty(value="是否启用")
+	@ApiModelProperty(value="")
 	private Boolean isEnabled;
 	private Boolean isEnabled;
 
 
-	@ApiModelProperty(value="是否锁定")
+	@ApiModelProperty(value="")
 	private Boolean isLocked;
 	private Boolean isLocked;
 
 
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-	@ApiModelProperty(value="锁定日期")
+	@ApiModelProperty(value="")
 	private Date lockedDate;
 	private Date lockedDate;
 
 
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-	@ApiModelProperty(value="最后登录日期")
+	@ApiModelProperty(value="")
 	private Date loginDate;
 	private Date loginDate;
 
 
-	@ApiModelProperty(value="连续登录失败次数")
+	@ApiModelProperty(value="")
 	private Integer loginFailureCount;
 	private Integer loginFailureCount;
 
 
-	@ApiModelProperty(value="最后登录IP")
+	@ApiModelProperty(value="")
 	private String loginIp;
 	private String loginIp;
 
 
-	@ApiModelProperty(value="所属商家id")
+	@ApiModelProperty(value="")
 	private Long merchantId;
 	private Long merchantId;
 
 
-	@ApiModelProperty(value="名称")
+	@ApiModelProperty(value="")
 	private String name;
 	private String name;
 
 
-	@ApiModelProperty(value="上级")
+	@ApiModelProperty(value="")
 	private Long parentId;
 	private Long parentId;
 
 
-	@ApiModelProperty(value="密码")
+	@ApiModelProperty(value="")
 	private String password;
 	private String password;
 
 
-	@ApiModelProperty(value="所属个人商家id")
+	@ApiModelProperty(value="")
 	private Long personageId;
 	private Long personageId;
 
 
-	@ApiModelProperty(value="类型")
+	@ApiModelProperty(value="")
 	private Integer type;
 	private Integer type;
 
 
-	@ApiModelProperty(value="用户名")
+	@ApiModelProperty(value="")
 	private String username;
 	private String username;
 
 
-	@ApiModelProperty(value="电话号码")
+	@ApiModelProperty(value="")
 	private String phone;
 	private String phone;
 
 
+	@ApiModelProperty(value="")
+	private String isRefund;
+
+	@ApiModelProperty(value="")
+	private String ifForeign;
+
 	/**自定义统一方法设置主键**/
 	/**自定义统一方法设置主键**/
 	public void setPrimaryKey(Long primaryKey) {
 	public void setPrimaryKey(Long primaryKey) {
 		 setId(primaryKey);
 		 setId(primaryKey);

+ 142 - 2
src/main/java/com/shawn/model/entity/TAdminExample.java

@@ -94,7 +94,7 @@ public class TAdminExample {
     }
     }
 
 
     /**
     /**
-     * t_admin 2019-08-23
+     * t_admin 2019-12-03
      */
      */
     protected abstract static class GeneratedCriteria {
     protected abstract static class GeneratedCriteria {
         protected List<Criterion> criteria;
         protected List<Criterion> criteria;
@@ -1526,6 +1526,146 @@ public class TAdminExample {
             addCriterion("phone not between", value1, value2, "phone");
             addCriterion("phone not between", value1, value2, "phone");
             return (Criteria) this;
             return (Criteria) this;
         }
         }
+
+        public Criteria andIsRefundIsNull() {
+            addCriterion("is_refund is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundIsNotNull() {
+            addCriterion("is_refund is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundEqualTo(String value) {
+            addCriterion("is_refund =", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundNotEqualTo(String value) {
+            addCriterion("is_refund <>", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundGreaterThan(String value) {
+            addCriterion("is_refund >", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundGreaterThanOrEqualTo(String value) {
+            addCriterion("is_refund >=", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundLessThan(String value) {
+            addCriterion("is_refund <", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundLessThanOrEqualTo(String value) {
+            addCriterion("is_refund <=", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundLike(String value) {
+            addCriterion("is_refund like", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundNotLike(String value) {
+            addCriterion("is_refund not like", value, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundIn(List<String> values) {
+            addCriterion("is_refund in", values, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundNotIn(List<String> values) {
+            addCriterion("is_refund not in", values, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundBetween(String value1, String value2) {
+            addCriterion("is_refund between", value1, value2, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsRefundNotBetween(String value1, String value2) {
+            addCriterion("is_refund not between", value1, value2, "isRefund");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignIsNull() {
+            addCriterion("if_foreign is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignIsNotNull() {
+            addCriterion("if_foreign is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignEqualTo(String value) {
+            addCriterion("if_foreign =", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignNotEqualTo(String value) {
+            addCriterion("if_foreign <>", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignGreaterThan(String value) {
+            addCriterion("if_foreign >", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignGreaterThanOrEqualTo(String value) {
+            addCriterion("if_foreign >=", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignLessThan(String value) {
+            addCriterion("if_foreign <", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignLessThanOrEqualTo(String value) {
+            addCriterion("if_foreign <=", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignLike(String value) {
+            addCriterion("if_foreign like", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignNotLike(String value) {
+            addCriterion("if_foreign not like", value, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignIn(List<String> values) {
+            addCriterion("if_foreign in", values, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignNotIn(List<String> values) {
+            addCriterion("if_foreign not in", values, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignBetween(String value1, String value2) {
+            addCriterion("if_foreign between", value1, value2, "ifForeign");
+            return (Criteria) this;
+        }
+
+        public Criteria andIfForeignNotBetween(String value1, String value2) {
+            addCriterion("if_foreign not between", value1, value2, "ifForeign");
+            return (Criteria) this;
+        }
     }
     }
 
 
     /**
     /**
@@ -1539,7 +1679,7 @@ public class TAdminExample {
     }
     }
 
 
     /**
     /**
-     * t_admin 2019-08-23
+     * t_admin 2019-12-03
      */
      */
     public static class Criterion {
     public static class Criterion {
         private String condition;
         private String condition;

+ 2 - 0
src/main/java/com/shawn/model/param/StatisticsParam.java

@@ -34,4 +34,6 @@ public class StatisticsParam {
     @ApiModelProperty(value="统计类型")
     @ApiModelProperty(value="统计类型")
     private String chartType;
     private String chartType;
 
 
+    @ApiModelProperty(value="是否外国")
+    private String ifForeign = "0";
 }
 }

+ 26 - 0
src/main/java/com/shawn/service/impl/TOrderServiceImpl.java

@@ -20,6 +20,7 @@ import com.shawn.service.interfac.TOrderServiceInterface;
 import com.shawn.web.exception.MyException;
 import com.shawn.web.exception.MyException;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -53,8 +54,27 @@ public class TOrderServiceImpl extends BaseService<TOrder, TOrderExample, TOrder
     @Autowired
     @Autowired
     private TAdminServiceInterface tAdminService;
     private TAdminServiceInterface tAdminService;
 
 
+    /**
+     * 判断查询用户是否为外国
+     * @return
+     */
+    private String isForeignUser(String userId){
+        if(StringUtils.isNotEmpty(userId)){
+            try {
+                Optional<TAdmin> op = tAdminService.selectById(Long.parseLong(userId));
+                if(op.isPresent()){
+                    TAdmin entity = op.get();
+                    return entity.getIfForeign();
+                }
+            } catch (NumberFormatException e) {
+            }
+        }
+        return "0";
+    }
     @Override
     @Override
     public ChartColumn getStatistics(StatisticsParam param) {
     public ChartColumn getStatistics(StatisticsParam param) {
+        //  判断是否为外国
+        param.setIfForeign(isForeignUser(param.getAdminId()));
 
 
         List<ChartBean> list = new ArrayList<>();
         List<ChartBean> list = new ArrayList<>();
         String msg = "";
         String msg = "";
@@ -84,6 +104,9 @@ public class TOrderServiceImpl extends BaseService<TOrder, TOrderExample, TOrder
 
 
     @Override
     @Override
     public List<ChartBean> getMainStatistics(StatisticsParam param) {
     public List<ChartBean> getMainStatistics(StatisticsParam param) {
+        //  判断是否为外国
+        param.setIfForeign(isForeignUser(param.getAdminId()));
+
         List<ChartBean> list = tOrderMapper.getMainStatistics(param);
         List<ChartBean> list = tOrderMapper.getMainStatistics(param);
         if (CollectionUtils.isEmpty(list)) {
         if (CollectionUtils.isEmpty(list)) {
             throw new MyException("获取数据为空");
             throw new MyException("获取数据为空");
@@ -98,6 +121,9 @@ public class TOrderServiceImpl extends BaseService<TOrder, TOrderExample, TOrder
      */
      */
     @Override
     @Override
     public ChartColumn getEquipmentStatistics(StatisticsParam param) {
     public ChartColumn getEquipmentStatistics(StatisticsParam param) {
+        //  判断是否为外国
+        param.setIfForeign(isForeignUser(param.getAdminId()));
+
         List<ChartBean> list = new ArrayList<>();
         List<ChartBean> list = new ArrayList<>();
         String msg = "";
         String msg = "";
         if (ChartType.day.toString().equals(param.getChartType())) {
         if (ChartType.day.toString().equals(param.getChartType())) {

File diff suppressed because it is too large
+ 45 - 7
src/main/resources/com/shawn/repository/mybatis/TAdminMapper.xml


+ 116 - 31
src/main/resources/com/shawn/repository/mybatis/TOrderMapper.xml

@@ -657,13 +657,23 @@
   </update>
   </update>
   <!-- 日统计 -->
   <!-- 日统计 -->
   <select id="getDayStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
   <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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
     and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
     and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
     group by DATE_FORMAT( a.create_date,'%H')
     group by DATE_FORMAT( a.create_date,'%H')
@@ -682,13 +692,23 @@
     select '周日' as categorie from dual) tab1
     select '周日' as categorie from dual) tab1
     left join (
     left join (
     select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
     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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
       AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
       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') ]]>
       <![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 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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
     AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
     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') ]]>
     <![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 '11月' as categorie from dual UNION all
     select '12月' as categorie from dual) tab1
     select '12月' as categorie from dual) tab1
     left join (
     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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
     AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
     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') ]]>
     <![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 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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
+    and date_format(a.create_date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
 UNION all
 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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
+    and YEARWEEK(date_format(a.create_date,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
 UNION all
 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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
+    and date_format(a.create_date,'%Y-%m') = date_format(now(),'%Y-%m')
 UNION all
 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 !=''">
     <if test="adminId != null and adminId !=''">
       and a.admin_id= #{adminId} -- 所属商家id
       and a.admin_id= #{adminId} -- 所属商家id
     </if>
     </if>
     <if test="equipmentId != null and equipmentId !=''">
     <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>
     </if>
+    and date_format(a.create_date,'%Y') = date_format(now(),'%Y')
   </select>
   </select>
 
 
   <!-- 统计 机器销售-->
   <!-- 统计 机器销售-->
   <select id="getEquipmentStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
   <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
    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 !=''">
     <if test="adminId != null and adminId !=''">
       and b.admin_id= #{adminId} -- 设备所属商家id
       and b.admin_id= #{adminId} -- 设备所属商家id
     </if>
     </if>