瀏覽代碼

Merge branch 'online1' of http://git.dayaedu.com/yonge/mec

zouxuan 4 年之前
父節點
當前提交
be5c15f752
共有 19 個文件被更改,包括 1798 次插入431 次删除
  1. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ManagerDownloadDao.java
  2. 22 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RouteScaleDto.java
  3. 42 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java
  4. 118 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ManagerDownload.java
  5. 641 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ManagerDownloadExample.java
  6. 27 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java
  7. 31 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/ManagerDownloadQueryInfo.java
  8. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPaymentOrderQueryInfo.java
  9. 25 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java
  10. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ManagerDownloadService.java
  11. 622 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  12. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ManagerDownloadServiceImpl.java
  13. 10 19
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java
  14. 13 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  15. 84 0
      mec-biz/src/main/resources/config/mybatis/ManagerDownloadMapper.xml
  16. 3 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  17. 4 4
      mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml
  18. 61 403
      mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java
  19. 47 0
      mec-web/src/main/java/com/ym/mec/web/controller/ManagerDownloadController.java

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ManagerDownloadDao.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.ManagerDownload;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface ManagerDownloadDao extends BaseDAO<Integer,ManagerDownload> {
+
+}

+ 22 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RouteScaleDto.java

@@ -23,6 +23,12 @@ public class RouteScaleDto {
 
 
     private BigDecimal balance = BigDecimal.ZERO;
     private BigDecimal balance = BigDecimal.ZERO;
 
 
+    //销售费用
+    private BigDecimal saleAmount = BigDecimal.ZERO;
+
+    //服务费用
+    private BigDecimal serviceAmount = BigDecimal.ZERO;
+
     public Integer getOrganId() {
     public Integer getOrganId() {
         return organId;
         return organId;
     }
     }
@@ -55,7 +61,6 @@ public class RouteScaleDto {
         this.feeFlag = feeFlag;
         this.feeFlag = feeFlag;
     }
     }
 
 
-
     public Integer getScale() {
     public Integer getScale() {
         return scale;
         return scale;
     }
     }
@@ -87,4 +92,20 @@ public class RouteScaleDto {
     public void setBalance(BigDecimal balance) {
     public void setBalance(BigDecimal balance) {
         this.balance = balance;
         this.balance = balance;
     }
     }
+
+    public BigDecimal getSaleAmount() {
+        return saleAmount;
+    }
+
+    public void setSaleAmount(BigDecimal saleAmount) {
+        this.saleAmount = saleAmount;
+    }
+
+    public BigDecimal getServiceAmount() {
+        return serviceAmount;
+    }
+
+    public void setServiceAmount(BigDecimal serviceAmount) {
+        this.serviceAmount = serviceAmount;
+    }
 }
 }

+ 42 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java

@@ -49,6 +49,10 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     private BigDecimal degreeFee = BigDecimal.ZERO;
     private BigDecimal degreeFee = BigDecimal.ZERO;
     //其它费用
     //其它费用
     private BigDecimal otherFee = BigDecimal.ZERO;
     private BigDecimal otherFee = BigDecimal.ZERO;
+    //乐保费用
+    private BigDecimal maintenanceFee = BigDecimal.ZERO;
+    //商品乐保
+    private BigDecimal maintenanceProductFee = BigDecimal.ZERO;
 
 
     private String organName;
     private String organName;
     private String schoolName;
     private String schoolName;
@@ -70,6 +74,12 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     //分润余额
     //分润余额
     private BigDecimal routeBalance;
     private BigDecimal routeBalance;
 
 
+    //分润中的销售费用
+    private BigDecimal saleAmount = BigDecimal.ZERO;
+
+    //分润中的服务费用
+    private BigDecimal serviceAmount = BigDecimal.ZERO;
+
     private String feeFlag;
     private String feeFlag;
 
 
     public BigDecimal getSporadicAmount() {
     public BigDecimal getSporadicAmount() {
@@ -287,4 +297,36 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     public void setFeeFlag(String feeFlag) {
     public void setFeeFlag(String feeFlag) {
         this.feeFlag = feeFlag;
         this.feeFlag = feeFlag;
     }
     }
+
+    public BigDecimal getSaleAmount() {
+        return saleAmount;
+    }
+
+    public void setSaleAmount(BigDecimal saleAmount) {
+        this.saleAmount = saleAmount;
+    }
+
+    public BigDecimal getServiceAmount() {
+        return serviceAmount;
+    }
+
+    public void setServiceAmount(BigDecimal serviceAmount) {
+        this.serviceAmount = serviceAmount;
+    }
+
+    public BigDecimal getMaintenanceFee() {
+        return maintenanceFee;
+    }
+
+    public void setMaintenanceFee(BigDecimal maintenanceFee) {
+        this.maintenanceFee = maintenanceFee;
+    }
+
+    public BigDecimal getMaintenanceProductFee() {
+        return maintenanceProductFee;
+    }
+
+    public void setMaintenanceProductFee(BigDecimal maintenanceProductFee) {
+        this.maintenanceProductFee = maintenanceProductFee;
+    }
 }
 }

+ 118 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ManagerDownload.java

@@ -0,0 +1,118 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.enums.ExportTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+
+@ApiModel(value = "com-ym-mec-biz-dal-entity-ManagerDownload")
+public class ManagerDownload {
+    @ApiModelProperty(value = "")
+    private Integer id;
+
+    /**
+     * 下载人
+     */
+    @ApiModelProperty(value = "下载人")
+    private Integer userId;
+
+    /**
+     * 文件名
+     */
+    @ApiModelProperty(value = "文件名")
+    private String name;
+
+    /**
+     * 下载链接
+     */
+    @ApiModelProperty(value = "下载链接")
+    private String fileUrl;
+
+    /**
+     * 文件类型
+     */
+    @ApiModelProperty(value = "文件类型")
+    private ExportTypeEnum type;
+
+    /**
+     * 状态
+     */
+    @ApiModelProperty(value = "状态")
+    private Integer status=0;
+
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public void setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public ExportTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ExportTypeEnum type) {
+        this.type = type;
+    }
+}

+ 641 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ManagerDownloadExample.java

@@ -0,0 +1,641 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ManagerDownloadExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    public ManagerDownloadExample() {
+        oredCriteria = new ArrayList<>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Integer value) {
+            addCriterion("id_ =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Integer value) {
+            addCriterion("id_ <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Integer value) {
+            addCriterion("id_ >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("id_ >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Integer value) {
+            addCriterion("id_ <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Integer value) {
+            addCriterion("id_ <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Integer> values) {
+            addCriterion("id_ in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Integer> values) {
+            addCriterion("id_ not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Integer value1, Integer value2) {
+            addCriterion("id_ between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("id_ not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNull() {
+            addCriterion("user_id_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNotNull() {
+            addCriterion("user_id_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdEqualTo(Integer value) {
+            addCriterion("user_id_ =", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotEqualTo(Integer value) {
+            addCriterion("user_id_ <>", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThan(Integer value) {
+            addCriterion("user_id_ >", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("user_id_ >=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThan(Integer value) {
+            addCriterion("user_id_ <", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThanOrEqualTo(Integer value) {
+            addCriterion("user_id_ <=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIn(List<Integer> values) {
+            addCriterion("user_id_ in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotIn(List<Integer> values) {
+            addCriterion("user_id_ not in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdBetween(Integer value1, Integer value2) {
+            addCriterion("user_id_ between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("user_id_ not between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIsNull() {
+            addCriterion("name_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIsNotNull() {
+            addCriterion("name_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameEqualTo(String value) {
+            addCriterion("name_ =", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotEqualTo(String value) {
+            addCriterion("name_ <>", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThan(String value) {
+            addCriterion("name_ >", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThanOrEqualTo(String value) {
+            addCriterion("name_ >=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThan(String value) {
+            addCriterion("name_ <", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThanOrEqualTo(String value) {
+            addCriterion("name_ <=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLike(String value) {
+            addCriterion("name_ like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotLike(String value) {
+            addCriterion("name_ not like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIn(List<String> values) {
+            addCriterion("name_ in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotIn(List<String> values) {
+            addCriterion("name_ not in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameBetween(String value1, String value2) {
+            addCriterion("name_ between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotBetween(String value1, String value2) {
+            addCriterion("name_ not between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlIsNull() {
+            addCriterion("file_url_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlIsNotNull() {
+            addCriterion("file_url_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlEqualTo(String value) {
+            addCriterion("file_url_ =", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlNotEqualTo(String value) {
+            addCriterion("file_url_ <>", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlGreaterThan(String value) {
+            addCriterion("file_url_ >", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlGreaterThanOrEqualTo(String value) {
+            addCriterion("file_url_ >=", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlLessThan(String value) {
+            addCriterion("file_url_ <", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlLessThanOrEqualTo(String value) {
+            addCriterion("file_url_ <=", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlLike(String value) {
+            addCriterion("file_url_ like", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlNotLike(String value) {
+            addCriterion("file_url_ not like", value, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlIn(List<String> values) {
+            addCriterion("file_url_ in", values, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlNotIn(List<String> values) {
+            addCriterion("file_url_ not in", values, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlBetween(String value1, String value2) {
+            addCriterion("file_url_ between", value1, value2, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andFileUrlNotBetween(String value1, String value2) {
+            addCriterion("file_url_ not between", value1, value2, "fileUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNull() {
+            addCriterion("status_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNotNull() {
+            addCriterion("status_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusEqualTo(Integer value) {
+            addCriterion("status_ =", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotEqualTo(Integer value) {
+            addCriterion("status_ <>", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThan(Integer value) {
+            addCriterion("status_ >", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("status_ >=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThan(Integer value) {
+            addCriterion("status_ <", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("status_ <=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIn(List<Integer> values) {
+            addCriterion("status_ in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotIn(List<Integer> values) {
+            addCriterion("status_ not in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusBetween(Integer value1, Integer value2) {
+            addCriterion("status_ between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("status_ not between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time_ =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time_ <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time_ >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time_ >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time_ <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time_ <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time_ in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time_ not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time_ between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time_ not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time_ is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time_ is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time_ =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time_ <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time_ >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time_ >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time_ <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time_ <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time_ in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time_ not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time_ between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time_ not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java

@@ -0,0 +1,27 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum ExportTypeEnum implements BaseEnum<Integer, ExportTypeEnum> {
+	ORDER(1, "订单列表"),
+	ROUTE_ORDER(2, "财务管理");
+
+	private Integer code;
+
+	private String desc;
+
+	private ExportTypeEnum(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	@Override
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ManagerDownloadQueryInfo.java

@@ -0,0 +1,31 @@
+package com.ym.mec.biz.dal.page;
+
+
+import com.ym.mec.biz.dal.enums.ExportTypeEnum;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class ManagerDownloadQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "用户id", required = false)
+    private Integer userId = 0;
+
+    @ApiModelProperty(value = "文件类型", required = false)
+    private ExportTypeEnum type;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public ExportTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(ExportTypeEnum type) {
+        this.type = type;
+    }
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPaymentOrderQueryInfo.java

@@ -67,6 +67,8 @@ public class StudentPaymentOrderQueryInfo extends QueryInfo {
 
 
     private boolean isExport = false;
     private boolean isExport = false;
 
 
+    private String oldOrganId;
+
     public boolean getIsExport() {
     public boolean getIsExport() {
         return isExport;
         return isExport;
     }
     }
@@ -226,4 +228,12 @@ public class StudentPaymentOrderQueryInfo extends QueryInfo {
     public void setNoneTqType(Integer noneTqType) {
     public void setNoneTqType(Integer noneTqType) {
         this.noneTqType = noneTqType;
         this.noneTqType = noneTqType;
     }
     }
+
+    public String getOldOrganId() {
+        return oldOrganId;
+    }
+
+    public void setOldOrganId(String oldOrganId) {
+        this.oldOrganId = oldOrganId;
+    }
 }
 }

+ 25 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -0,0 +1,25 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.ManagerDownload;
+
+import java.util.Map;
+
+
+public interface ExportService {
+
+    /**
+     * 订单列表导出
+     * @param params
+     * @throws Exception
+     */
+    void orderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception;
+
+
+    /**
+     * 财务管理下载
+     * @param params
+     * @param managerDownload
+     * @throws Exception
+     */
+    void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception;
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ManagerDownloadService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.ManagerDownload;
+import com.ym.mec.common.service.BaseService;
+
+public interface ManagerDownloadService extends BaseService<Integer, ManagerDownload> {
+
+}

+ 622 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -0,0 +1,622 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.FeeFlagNumDto;
+import com.ym.mec.biz.dal.dto.PracticeCourseDto;
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
+import com.ym.mec.biz.service.ExportService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.thirdparty.storage.StoragePluginContext;
+import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
+import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
+import com.ym.mec.util.upload.UploadUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.system.ApplicationHome;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class ExportServiceImpl implements ExportService {
+
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
+    @Autowired
+    private VipGroupDao vipGroupDao;
+    @Autowired
+    private PracticeGroupDao practiceGroupDao;
+    @Autowired
+    private SellOrderDao sellOrderDao;
+    @Autowired
+    private StudentRegistrationDao studentRegistrationDao;
+    @Autowired
+    private MusicGroupDao musicGroupDao;
+    @Autowired
+    private StoragePluginContext storagePluginContext;
+    @Autowired
+    private ManagerDownloadDao managerDownloadDao;
+
+    @Override
+    @Async
+    public void orderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception {
+        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
+        long i = 1;
+        for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
+            if (row.getActualAmount() == null) {
+                row.setActualAmount(BigDecimal.ZERO);
+            }
+            if (row.getBalancePaymentAmount() == null) {
+                row.setBalancePaymentAmount(BigDecimal.ZERO);
+            }
+            if (row.getMemo() == null) {
+                row.setMemo("");
+            }
+            BigDecimal transferFee = BigDecimal.ZERO;
+            if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
+                FeeFlagNumDto countFeeFlagNum = studentPaymentRouteOrderDao.getCountFeeFlagNum(row.getOrderNo());
+                if (countFeeFlagNum.getTotalNum() > countFeeFlagNum.getYesNum()) {
+                    transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                }
+                if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
+                    List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(row.getOrderNo());
+                    for (StudentPaymentRouteOrder routeOrder : routeOrders) {
+                        transferFee = transferFee.add(routeOrder.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
+                    }
+                }
+            }
+            row.setTransferFee(transferFee);
+
+            String goodsName = "";
+            if (row.getOrderDetailList() != null) {
+                for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
+                    switch (orderDetail.getType()) {
+                        case COURSE:
+                        case CLASSROOM:
+                        case SINGLE:
+                        case MIX:
+                        case COMPREHENSIVE:
+                        case ENLIGHTENMENT:
+                        case TRAINING_SINGLE:
+                        case TRAINING_MIX:
+                        case MUSIC_NETWORK:
+                        case HIGH:
+                        case HIGH_ONLINE:
+                        case HIGH_ONLINE_COURSE:
+                            row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
+                            break;
+                        case MUSICAL:
+                            if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                                BigDecimal leaseFee = BigDecimal.ZERO;
+                                if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                                    leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                                }
+                                row.setLeaseFee(leaseFee);
+                            } else {
+                                row.setMusicalFee(orderDetail.getPrice());
+                            }
+                            break;
+                        case ACCESSORIES:
+                        case TEACHING:
+                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
+                            break;
+                        case OTHER:
+                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
+                        case MAINTENANCE:
+                            BigDecimal repairFee = BigDecimal.ZERO;
+                            if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                                repairFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                            }
+                            row.setMaintenanceFee(repairFee);
+                        default:
+                            break;
+                    }
+                }
+            }
+            if (row.getGoodsList() != null) {
+                goodsName = row.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
+            }
+            if (StringUtils.isNotBlank(goodsName)) {
+                row.setMemo(goodsName);
+            }
+            //专业
+            if (row.getGroupType().equals(GroupType.VIP)) {
+                row.setVipCourseFee(row.getActualAmount());
+                VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
+                if (vipGroupInfo != null) {
+                    row.setSchoolName(vipGroupInfo.getSchoolName());
+                    row.setSubjectName(vipGroupInfo.getSubjectName());
+                }
+            } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
+                //考级报名
+                if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
+                    String[] feeTypes = row.getMemo().split(";");
+                    List<String> feeTypeList = Arrays.asList(feeTypes);
+                    for (String feeTypeStr : feeTypeList) {
+                        int index = feeTypeStr.lastIndexOf(":");
+                        if (index < 0) {
+                            continue;
+                        }
+                        BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
+                        if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                            typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                        }
+                        if (feeTypeStr.contains("VIP")) {
+                            row.setVipCourseFee(typeFee);
+                        } else if (feeTypeStr.contains("网管课")) {
+                            row.setPracticeCourseFee(typeFee);
+                        } else if (feeTypeStr.contains("乐理课")) {
+                            row.setTheoryCourseFee(typeFee);
+                        }
+                    }
+                    row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
+                } else {
+                    if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
+                        row.setDegreeFee(row.getActualAmount());
+                    } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
+                        row.setPracticeCourseFee(row.getActualAmount());
+                    } else {
+                        row.setOtherFee(row.getActualAmount());
+                    }
+                }
+                if (row.getChargeType() != null) {
+                    for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
+                        if (!chargeType.getCode().equals(row.getChargeType())) continue;
+                        row.setSporadicType(chargeType.getMsg());
+                    }
+                }
+            } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
+                row.setPracticeCourseFee(row.getActualAmount());
+                PracticeCourseDto practiceGroup = practiceGroupDao.findByGroupId(Integer.parseInt(row.getMusicGroupId()));
+                if (practiceGroup != null) {
+                    row.setSubjectName(practiceGroup.getSubjectName());
+                }
+            } else {
+                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
+                row.setMusicalFee(feeByType.getMusicalFee());
+                row.setTeachingFee(feeByType.getTeachingFee());
+                row.setMaintenanceProductFee(feeByType.getRepairFee());
+                row.setOtherFee(feeByType.getOtherFee());
+                if (row.getGroupType().equals(GroupType.MUSIC)) {
+                    StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
+                    if (studentRegistration != null) {
+                        row.setSubjectName(studentRegistration.getSubjectName());
+                        row.setSchoolName(studentRegistration.getSchoolName());
+                        row.setCooperationOrganName(studentRegistration.getRemark());
+                    }
+                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()));
+                } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
+                    row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
+                } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
+                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()));
+                    row.setTransferFee(BigDecimal.ZERO);
+                }
+            }
+            //如果合作单位不存在取学员的第一个乐团的合作单位和教学点
+            if (row.getCooperationOrganName() == null) {
+                CooperationOrgan cooperationOrgan = musicGroupDao.findUserMusicGroupCooperationOrgan(row.getUserId());
+                if (cooperationOrgan != null) {
+                    row.setCooperationOrganName(cooperationOrgan.getName());
+                }
+            }
+            if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
+                row.setMusicGroupId("");
+            }
+            String paymentChannel = "";
+            if (row.getPaymentChannel() == null) {
+            } else if (row.getPaymentChannel().equals("YQPAY")) {
+                paymentChannel = "双乾";
+            } else if (row.getPaymentChannel().equals("ADAPAY")) {
+                paymentChannel = "汇付";
+            } else if (row.getPaymentChannel().equals("BALANCE")) {
+                paymentChannel = "余额";
+            }
+            row.setPaymentChannel(paymentChannel);
+            row.setId(i);
+            row.setRepairFee(row.getRepairFee().add(row.getMaintenanceFee()).add(row.getMaintenanceProductFee()));
+            i++;
+        }
+
+        String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
+        File file = new File(basePath + "/" + managerDownload.getName());
+        FileOutputStream fileOutputStream = new FileOutputStream(file);
+
+        HSSFWorkbook workbook = null;
+        try {
+            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
+                    "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
+            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
+                    "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
+            workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
+            workbook.write(fileOutputStream);
+            fileOutputStream.getFD().sync();
+            fileOutputStream.close();
+
+            String folder = "download/" + UploadUtil.getFileFloder();
+            String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, folder, file);
+            //把记录插入下载表
+            managerDownload.setFileUrl(url);
+            managerDownload.setStatus(1);
+            managerDownloadDao.update(managerDownload);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                fileOutputStream.close();
+                workbook.close();
+                file.delete();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    @Async
+    public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) throws Exception {
+        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage(params);
+        long i = 1;
+        for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
+            if (row.getActualAmount() == null) {
+                row.setActualAmount(BigDecimal.ZERO);
+            }
+            if (row.getBalancePaymentAmount() == null) {
+                row.setBalancePaymentAmount(BigDecimal.ZERO);
+            }
+            if (row.getRouteAmount() == null) {
+                row.setRouteAmount(BigDecimal.ZERO);
+            }
+            if (row.getMemo() == null) {
+                row.setMemo("");
+            }
+            BigDecimal transferFee = BigDecimal.ZERO;
+            if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
+                FeeFlagNumDto countFeeFlagNum = studentPaymentRouteOrderDao.getCountFeeFlagNum(row.getOrderNo());
+                if (countFeeFlagNum.getTotalNum() > countFeeFlagNum.getYesNum() && row.getFeeFlag().equals("Y")) {
+                    transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                }
+                if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
+                    transferFee = row.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                }
+            }
+            row.setTransferFee(transferFee);
+
+            String goodsName = "";
+            if (row.getOrderDetailList() != null) {
+                for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
+                    switch (orderDetail.getType()) {
+                        case COURSE:
+                        case CLASSROOM:
+                        case SINGLE:
+                        case MIX:
+                        case COMPREHENSIVE:
+                        case ENLIGHTENMENT:
+                        case TRAINING_SINGLE:
+                        case TRAINING_MIX:
+                        case MUSIC_NETWORK:
+                        case HIGH:
+                        case HIGH_ONLINE:
+                        case HIGH_ONLINE_COURSE:
+                            row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
+                            break;
+                        case MUSICAL:
+                            if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                                BigDecimal leaseFee = orderDetail.getPrice();
+                                if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                                    leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                                }
+                                row.setLeaseFee(leaseFee);
+                            } else {
+                                row.setMusicalFee(orderDetail.getPrice());
+                            }
+                            break;
+                        case ACCESSORIES:
+                        case TEACHING:
+                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
+                            break;
+                        case OTHER:
+                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
+                        case MAINTENANCE:
+                            BigDecimal maintenanceFee = BigDecimal.ZERO;
+                            if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                                maintenanceFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                            }
+                            row.setMaintenanceFee(maintenanceFee);
+                        default:
+                            break;
+                    }
+                }
+            }
+            if (row.getGoodsList() != null) {
+                goodsName = row.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
+            }
+            if (StringUtils.isNotBlank(goodsName)) {
+                row.setMemo(goodsName);
+            }
+            //专业
+            if (row.getGroupType().equals(GroupType.VIP)) {
+                row.setVipCourseFee(row.getActualAmount());
+                VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
+                if (vipGroupInfo != null) {
+                    row.setSchoolName(vipGroupInfo.getSchoolName());
+                    row.setSubjectName(vipGroupInfo.getSubjectName());
+                }
+            } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
+                //考级报名
+                if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
+                    String[] feeTypes = row.getMemo().split(";");
+                    List<String> feeTypeList = Arrays.asList(feeTypes);
+                    for (String feeTypeStr : feeTypeList) {
+                        int index = feeTypeStr.lastIndexOf(":");
+                        if (index < 0) {
+                            continue;
+                        }
+                        BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
+                        if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                            typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                        }
+                        if (feeTypeStr.contains("VIP")) {
+                            row.setVipCourseFee(typeFee);
+                        } else if (feeTypeStr.contains("网管课")) {
+                            row.setPracticeCourseFee(typeFee);
+                        } else if (feeTypeStr.contains("乐理课")) {
+                            row.setTheoryCourseFee(typeFee);
+                        }
+                    }
+                    row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
+                } else {
+                    if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
+                        row.setDegreeFee(row.getActualAmount());
+                    } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
+                        row.setPracticeCourseFee(row.getActualAmount());
+                    } else {
+                        row.setOtherFee(row.getActualAmount());
+                    }
+                }
+                if (row.getChargeType() != null) {
+                    for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
+                        if (!chargeType.getCode().equals(row.getChargeType())) continue;
+                        row.setSporadicType(chargeType.getMsg());
+                    }
+                }
+            } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
+                row.setPracticeCourseFee(row.getActualAmount());
+                PracticeCourseDto practiceGroup = practiceGroupDao.findByGroupId(Integer.parseInt(row.getMusicGroupId()));
+                if (practiceGroup != null) {
+                    row.setSubjectName(practiceGroup.getSubjectName());
+                }
+            } else {
+                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
+                row.setMusicalFee(feeByType.getMusicalFee());
+                row.setTeachingFee(feeByType.getTeachingFee());
+                row.setMaintenanceProductFee(feeByType.getRepairFee());
+                row.setOtherFee(feeByType.getOtherFee());
+                if (row.getGroupType().equals(GroupType.MUSIC)) {
+                    StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
+                    if (studentRegistration != null) {
+                        row.setSubjectName(studentRegistration.getSubjectName());
+                        row.setSchoolName(studentRegistration.getSchoolName());
+                        row.setCooperationOrganName(studentRegistration.getRemark());
+                    }
+                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()));
+                } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
+                    row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
+                } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
+                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()));
+                    row.setTransferFee(BigDecimal.ZERO);
+                }
+            }
+            //如果合作单位不存在取学员的第一个乐团的合作单位和教学点
+            if (row.getCooperationOrganName() == null) {
+                CooperationOrgan cooperationOrgan = musicGroupDao.findUserMusicGroupCooperationOrgan(row.getUserId());
+                if (cooperationOrgan != null) {
+                    row.setCooperationOrganName(cooperationOrgan.getName());
+                }
+            }
+            if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
+                row.setMusicGroupId("");
+            }
+            String paymentChannel = "";
+            if (row.getPaymentChannel() == null) {
+            } else if (row.getPaymentChannel().equals("YQPAY")) {
+                paymentChannel = "双乾";
+            } else if (row.getPaymentChannel().equals("ADAPAY")) {
+                paymentChannel = "汇付";
+            } else if (row.getPaymentChannel().equals("BALANCE")) {
+                paymentChannel = "余额";
+            }
+            row.setPaymentChannel(paymentChannel);
+            i++;
+        }
+
+        Map<Long, List<StudentPaymentOrderExportDto>> orderMap = studentPaymentOrderExportDtos.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
+        orderMap.forEach((orderId, orders) -> {
+            int j = 1;
+            BigDecimal routeMusicGroupCourseFee = BigDecimal.ZERO;
+            BigDecimal routeVipCourseFee = BigDecimal.ZERO;
+            BigDecimal routePracticeCourseFee = BigDecimal.ZERO;
+            BigDecimal routeTheoryCourseFee = BigDecimal.ZERO;
+            BigDecimal routeDegreeFee = BigDecimal.ZERO;
+            BigDecimal routeRepairFee = BigDecimal.ZERO;
+            BigDecimal routeMaintenanceFee = BigDecimal.ZERO;
+            BigDecimal routeMaintenanceProductFee = BigDecimal.ZERO;
+            BigDecimal routeLeaseFee = BigDecimal.ZERO;
+            BigDecimal routeMusicalFee = BigDecimal.ZERO;
+            BigDecimal routeTeachingFee = BigDecimal.ZERO;
+            BigDecimal routeOtherFee = BigDecimal.ZERO;
+            for (StudentPaymentOrderExportDto order : orders) {
+                Date endDate = DateUtil.stringToDate("2021-04-01", "yyyy-MM-dd");
+                if (order.getPayTime() == null || order.getPayTime().compareTo(endDate) < 0) {
+                    break;
+                }
+                if (order.getSaleAmount().compareTo(BigDecimal.ZERO) > 0 && order.getServiceAmount().compareTo(BigDecimal.ZERO) == 0) {
+                    order.setMusicGroupCourseFee(BigDecimal.ZERO);
+                    order.setVipCourseFee(BigDecimal.ZERO);
+                    order.setPracticeCourseFee(BigDecimal.ZERO);
+                    order.setTheoryCourseFee(BigDecimal.ZERO);
+                    order.setDegreeFee(BigDecimal.ZERO);
+                    order.setRepairFee(order.getMaintenanceProductFee());
+                    continue;
+                } else if (order.getSaleAmount().compareTo(BigDecimal.ZERO) == 0 && order.getServiceAmount().compareTo(BigDecimal.ZERO) > 0) {
+                    order.setRepairFee(order.getRepairFee().add(order.getMaintenanceFee()));
+                    order.setMusicalFee(BigDecimal.ZERO);
+                    order.setTeachingFee(BigDecimal.ZERO);
+                    order.setOtherFee(BigDecimal.ZERO);
+                    order.setLeaseFee(BigDecimal.ZERO);
+                    continue;
+                }
+                BigDecimal musicGroupCourseFee = BigDecimal.ZERO;
+                BigDecimal vipCourseFee = BigDecimal.ZERO;
+                BigDecimal practiceCourseFee = BigDecimal.ZERO;
+                BigDecimal theoryCourseFee = BigDecimal.ZERO;
+                BigDecimal degreeFee = BigDecimal.ZERO;
+                BigDecimal repairFee = BigDecimal.ZERO;
+                BigDecimal maintenanceFee = BigDecimal.ZERO;
+                BigDecimal maintenanceProductFee = BigDecimal.ZERO;
+                BigDecimal leaseFee = BigDecimal.ZERO;
+                BigDecimal musicalFee = BigDecimal.ZERO;
+                BigDecimal teachingFee = BigDecimal.ZERO;
+                BigDecimal otherFee = BigDecimal.ZERO;
+
+                if (order.getActualAmount() != null && order.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
+                    musicGroupCourseFee = order.getMusicGroupCourseFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    vipCourseFee = order.getVipCourseFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    practiceCourseFee = order.getPracticeCourseFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    theoryCourseFee = order.getTheoryCourseFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    degreeFee = order.getDegreeFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    repairFee = order.getRepairFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    maintenanceFee = order.getMaintenanceFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    maintenanceProductFee = order.getMaintenanceProductFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    leaseFee = order.getLeaseFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    musicalFee = order.getMusicalFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    teachingFee = order.getTeachingFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                    otherFee = order.getOtherFee().multiply(order.getRouteAmount()).divide(order.getActualAmount(), 2, BigDecimal.ROUND_DOWN);
+                }
+
+                if (order.getGroupType().equals(GroupType.VIP)) {
+                    vipCourseFee = order.getRouteAmount();
+                } else if (order.getGroupType().equals(GroupType.SPORADIC)) {
+                    //考级报名
+                    if (order.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
+                        degreeFee = order.getRouteAmount().subtract(vipCourseFee).subtract(practiceCourseFee).subtract(theoryCourseFee);
+                    } else {
+                        if (order.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(order.getChargeType())) {
+                            degreeFee = order.getRouteAmount();
+                        } else if (order.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(order.getChargeType())) {
+                            practiceCourseFee = order.getRouteAmount();
+                        } else {
+                            otherFee = order.getRouteAmount();
+                        }
+                    }
+                } else if (order.getGroupType().equals(GroupType.PRACTICE)) {
+                    practiceCourseFee = order.getRouteAmount();
+                } else {
+                    if (order.getGroupType().equals(GroupType.MUSIC)) {
+                        musicGroupCourseFee = order.getRouteAmount().subtract(musicalFee).subtract(teachingFee).subtract(maintenanceFee).subtract(maintenanceProductFee).subtract(otherFee).subtract(leaseFee);
+                    } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
+                        repairFee = order.getRouteAmount().subtract(musicalFee).subtract(teachingFee).subtract(otherFee);
+                    } else if (order.getType().equals(OrderTypeEnum.OUTORDER)) {
+                        musicGroupCourseFee = order.getRouteAmount().subtract(musicalFee).subtract(teachingFee).subtract(maintenanceProductFee).subtract(otherFee);
+                    }
+                }
+
+                if (j == orders.size()) {
+                    musicGroupCourseFee = order.getMusicGroupCourseFee().subtract(routeMusicGroupCourseFee);
+                    vipCourseFee = order.getVipCourseFee().subtract(routeVipCourseFee);
+                    practiceCourseFee = order.getPracticeCourseFee().subtract(routePracticeCourseFee);
+                    theoryCourseFee = order.getTheoryCourseFee().subtract(routeTheoryCourseFee);
+                    degreeFee = order.getDegreeFee().subtract(routeDegreeFee);
+                    repairFee = order.getRepairFee().subtract(routeRepairFee);
+                    maintenanceFee = order.getMaintenanceFee().subtract(routeMaintenanceFee);
+                    maintenanceProductFee = order.getMaintenanceProductFee().subtract(routeMaintenanceProductFee);
+                    leaseFee = order.getLeaseFee().subtract(routeLeaseFee);
+                    musicalFee = order.getMusicalFee().subtract(routeMusicalFee);
+                    teachingFee = order.getTeachingFee().subtract(routeTeachingFee);
+                    otherFee = order.getOtherFee().subtract(routeOtherFee);
+                }
+                j++;
+
+                routeMusicGroupCourseFee = routeMusicGroupCourseFee.add(musicGroupCourseFee);
+                routeVipCourseFee = routeVipCourseFee.add(vipCourseFee);
+                routePracticeCourseFee = routePracticeCourseFee.add(practiceCourseFee);
+                routeTheoryCourseFee = routeTheoryCourseFee.add(theoryCourseFee);
+                routeDegreeFee = routeDegreeFee.add(degreeFee);
+                routeRepairFee = routeRepairFee.add(repairFee);
+                routeMaintenanceFee = routeMaintenanceFee.add(maintenanceFee);
+                routeMaintenanceProductFee = routeMaintenanceProductFee.add(maintenanceProductFee);
+                routeLeaseFee = routeLeaseFee.add(leaseFee);
+                routeMusicalFee = routeMusicalFee.add(musicalFee);
+                routeTeachingFee = routeTeachingFee.add(teachingFee);
+                routeOtherFee = routeOtherFee.add(otherFee);
+
+                order.setMusicGroupCourseFee(musicGroupCourseFee);
+                order.setVipCourseFee(vipCourseFee);
+                order.setPracticeCourseFee(practiceCourseFee);
+                order.setTheoryCourseFee(theoryCourseFee);
+                order.setDegreeFee(degreeFee);
+                order.setRepairFee(repairFee.add(maintenanceFee).add(maintenanceProductFee).add(repairFee));
+                order.setMaintenanceFee(maintenanceFee);
+                order.setMaintenanceProductFee(maintenanceProductFee);
+                order.setLeaseFee(leaseFee);
+                order.setMusicalFee(musicalFee);
+                order.setTeachingFee(teachingFee);
+                order.setOtherFee(otherFee);
+            }
+        });
+        String[] organIdArr = params.get("oldOrganId").toString().split(",");
+        List<String> organIds = Arrays.asList(organIdArr);
+        studentPaymentOrderExportDtos.removeIf(order -> !organIds.contains(order.getOrganId().toString()));
+
+        String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();
+        File file = new File(basePath + "/" + managerDownload.getName());
+        FileOutputStream fileOutputStream = new FileOutputStream(file);
+
+        HSSFWorkbook workbook = null;
+        try {
+            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "分润账户", "分润金额", "分润余额", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
+                    "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
+            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
+                    "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
+            workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
+            workbook.write(fileOutputStream);
+            fileOutputStream.getFD().sync();
+            fileOutputStream.close();
+
+            String folder = "download/" + UploadUtil.getFileFloder();
+            String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, folder, file);
+            //把记录插入下载表
+            managerDownload.setFileUrl(url);
+            managerDownload.setStatus(1);
+            managerDownloadDao.update(managerDownload);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                fileOutputStream.close();
+                workbook.close();
+                file.delete();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ManagerDownloadServiceImpl.java

@@ -0,0 +1,22 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.ManagerDownloadDao;
+import com.ym.mec.biz.dal.entity.ManagerDownload;
+import com.ym.mec.biz.service.ManagerDownloadService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ManagerDownloadServiceImpl extends BaseServiceImpl<Integer, ManagerDownload> implements ManagerDownloadService {
+
+    @Autowired
+    private ManagerDownloadDao managerDownloadDao;
+
+    @Override
+    public BaseDAO<Integer, ManagerDownload> getDAO() {
+        return managerDownloadDao;
+    }
+
+}

+ 10 - 19
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -308,6 +308,8 @@ public class PayServiceImpl implements PayService {
                 } else {
                 } else {
                     routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
                     routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
                     routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
                     routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
+                    routeScaleDto.setSaleAmount(routeScaleDto.getSaleAmount().add(scaleDto.getSaleAmount()));
+                    routeScaleDto.setServiceAmount(routeScaleDto.getServiceAmount().add(scaleDto.getServiceAmount()));
                 }
                 }
             }
             }
             newRouteScaleDtos.add(routeScaleDto);
             newRouteScaleDtos.add(routeScaleDto);
@@ -327,7 +329,6 @@ public class PayServiceImpl implements PayService {
         List<Map<String, Object>> tempRoutingList = new ArrayList<>();
         List<Map<String, Object>> tempRoutingList = new ArrayList<>();
 
 
         PaymentChannelEnum payType = null;
         PaymentChannelEnum payType = null;
-        boolean feeFlag = false;
         Set<String> routingMerNoSet = new HashSet<>();
         Set<String> routingMerNoSet = new HashSet<>();
         for (RouteScaleDto routeScaleDto : routeScaleDtos) {
         for (RouteScaleDto routeScaleDto : routeScaleDtos) {
             payType = routeScaleDto.getPayType();
             payType = routeScaleDto.getPayType();
@@ -382,6 +383,8 @@ public class PayServiceImpl implements PayService {
             studentPaymentRouteOrder.setRouteAmount(routingMoney);
             studentPaymentRouteOrder.setRouteAmount(routingMoney);
             studentPaymentRouteOrder.setRouteBalanceAmount(routeBalanceAmount);
             studentPaymentRouteOrder.setRouteBalanceAmount(routeBalanceAmount);
             studentPaymentRouteOrder.setMerNo(routeScaleDto.getMerNo());
             studentPaymentRouteOrder.setMerNo(routeScaleDto.getMerNo());
+            studentPaymentRouteOrder.setSaleAmount(routeScaleDto.getSaleAmount());
+            studentPaymentRouteOrder.setServiceAmount(routeScaleDto.getServiceAmount());
             RouteOrders.add(studentPaymentRouteOrder);
             RouteOrders.add(studentPaymentRouteOrder);
             routingMerNoSet.add(routeScaleDto.getMerNo());
             routingMerNoSet.add(routeScaleDto.getMerNo());
         }
         }
@@ -470,9 +473,11 @@ public class PayServiceImpl implements PayService {
             if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SERVICE)) {
             if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SERVICE)) {
                 serviceHasRouteMoney = serviceHasRouteMoney.add(routingMoney);
                 serviceHasRouteMoney = serviceHasRouteMoney.add(routingMoney);
                 serviceHasRouteBalance = serviceHasRouteBalance.add(routingBalance);
                 serviceHasRouteBalance = serviceHasRouteBalance.add(routingBalance);
+                routeScaleDto.setServiceAmount(routingMoney);
             } else {
             } else {
                 sellHasRouteMoney = sellHasRouteMoney.add(routingMoney);
                 sellHasRouteMoney = sellHasRouteMoney.add(routingMoney);
                 sellHasRouteBalance = sellHasRouteBalance.add(routingBalance);
                 sellHasRouteBalance = sellHasRouteBalance.add(routingBalance);
+                routeScaleDto.setSaleAmount(routingMoney);
             }
             }
 
 
             if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
             if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
@@ -492,7 +497,6 @@ public class PayServiceImpl implements PayService {
         Map<String, List<RouteScaleDto>> routeScaleDtosMap = routeScaleDtos.stream().collect(Collectors.groupingBy(RouteScaleDto::getMerNo));
         Map<String, List<RouteScaleDto>> routeScaleDtosMap = routeScaleDtos.stream().collect(Collectors.groupingBy(RouteScaleDto::getMerNo));
 
 
         //合并同账号的数据
         //合并同账号的数据
-        BigDecimal maxAmount = BigDecimal.ZERO;
         List<RouteScaleDto> newRouteScaleDtos = new ArrayList<>();
         List<RouteScaleDto> newRouteScaleDtos = new ArrayList<>();
         for (Map.Entry<String, List<RouteScaleDto>> groupRouteScaleDtos : routeScaleDtosMap.entrySet()) {
         for (Map.Entry<String, List<RouteScaleDto>> groupRouteScaleDtos : routeScaleDtosMap.entrySet()) {
             RouteScaleDto routeScaleDto = null;
             RouteScaleDto routeScaleDto = null;
@@ -502,24 +506,12 @@ public class PayServiceImpl implements PayService {
                 } else {
                 } else {
                     routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
                     routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
                     routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
                     routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
+                    routeScaleDto.setSaleAmount(routeScaleDto.getSaleAmount().add(scaleDto.getSaleAmount()));
+                    routeScaleDto.setServiceAmount(routeScaleDto.getServiceAmount().add(scaleDto.getServiceAmount()));
                 }
                 }
             }
             }
-            if (routeScaleDto != null && routeScaleDto.getAmount().compareTo(maxAmount) > 0) {
-                maxAmount = routeScaleDto.getAmount();
-            }
             newRouteScaleDtos.add(routeScaleDto);
             newRouteScaleDtos.add(routeScaleDto);
         }
         }
-
-        //金额最大的账号承担手续费
-        boolean hasFeeFlag = false;
-        for (RouteScaleDto routeScaleDto : newRouteScaleDtos) {
-            if (!hasFeeFlag && routeScaleDto.getAmount().compareTo(maxAmount) == 0) {
-                routeScaleDto.setFeeFlag("Y");
-                hasFeeFlag = true;
-            } else {
-                routeScaleDto.setFeeFlag("N");
-            }
-        }
         return newRouteScaleDtos;
         return newRouteScaleDtos;
     }
     }
 
 
@@ -556,14 +548,13 @@ public class PayServiceImpl implements PayService {
 //                redisTemplate.expire(key, 600, TimeUnit.SECONDS);// 保留10分钟内的key
 //                redisTemplate.expire(key, 600, TimeUnit.SECONDS);// 保留10分钟内的key
 //            }
 //            }
 //        }else {
 //        }else {
-            BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(routeScaleDto.getOrganId(), paymentChannelList, dayStartTime);
-            monthHasReceipt = monthHasReceipt == null ? BigDecimal.ZERO : monthHasReceipt;
+        BigDecimal monthHasReceipt = studentPaymentRouteOrderDao.getRouteOrderAmount(routeScaleDto.getOrganId(), paymentChannelList, dayStartTime);
+        monthHasReceipt = monthHasReceipt == null ? BigDecimal.ZERO : monthHasReceipt;
 //            monthHasReceipt.multiply(new BigDecimal(100));
 //            monthHasReceipt.multiply(new BigDecimal(100));
 //
 //
 //        }
 //        }
 
 
 
 
-
         if (routeScaleDto.getAmount().add(monthHasReceipt).compareTo(monthMaxReceipt) > 0) {
         if (routeScaleDto.getAmount().add(monthHasReceipt).compareTo(monthMaxReceipt) > 0) {
             routeScaleDto.setMerNo(hfmember.getRouteMemberId());
             routeScaleDto.setMerNo(hfmember.getRouteMemberId());
             routeScaleDto.setOrganId(hfmember.getRouteOrganId());
             routeScaleDto.setOrganId(hfmember.getRouteOrganId());

+ 13 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -78,7 +78,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         //已分配的商品余额
         //已分配的商品余额
         BigDecimal hasRouteBalance = BigDecimal.ZERO;
         BigDecimal hasRouteBalance = BigDecimal.ZERO;
         //已分配的商品现金
         //已分配的商品现金
-        BigDecimal hasRouteActualAmount= BigDecimal.ZERO;
+        BigDecimal hasRouteActualAmount = BigDecimal.ZERO;
         //商品占用的的余额
         //商品占用的的余额
         BigDecimal goodsTotalBalance = totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
         BigDecimal goodsTotalBalance = totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
         //商品占用的总现金
         //商品占用的总现金
@@ -396,6 +396,13 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 return sellAmount;
                 return sellAmount;
             }
             }
 
 
+            BigDecimal totalAmount = order.getExpectAmount().add(repairInfo.getExemptionAmount());
+            if (totalAmount.compareTo(BigDecimal.ZERO) <= 0) {
+                sellAmount.put("actualAmount", BigDecimal.ZERO);
+                sellAmount.put("balance", BigDecimal.ZERO);
+                return sellAmount;
+            }
+
             BigDecimal goodsTotalPrice = BigDecimal.ZERO;
             BigDecimal goodsTotalPrice = BigDecimal.ZERO;
             goodies = goodsDao.getGoodies(goodsIds);
             goodies = goodsDao.getGoodies(goodsIds);
             int i = 1;
             int i = 1;
@@ -408,8 +415,10 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 }
                 }
             }
             }
             BigDecimal balance = order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount();
             BigDecimal balance = order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount();
-            BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(order.getExpectAmount(), 2, BigDecimal.ROUND_HALF_UP);
-            sellAmount.put("actualAmount", goodsTotalPrice.subtract(goodsTotalBalance));
+
+            BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
+            BigDecimal goodsTotalActualAmount = goodsTotalPrice.multiply(order.getActualAmount()).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
+            sellAmount.put("actualAmount", goodsTotalActualAmount);
             sellAmount.put("balance", goodsTotalBalance);
             sellAmount.put("balance", goodsTotalBalance);
             return sellAmount;
             return sellAmount;
         }
         }
@@ -424,7 +433,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             //商品总付款
             //商品总付款
             BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
             BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
             //商品销售占的余额
             //商品销售占的余额
-            BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_DOWN);
 
 
             sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance));
             sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance));
             sellAmount.put("balance", detailTotalBalance);
             sellAmount.put("balance", detailTotalBalance);

+ 84 - 0
mec-biz/src/main/resources/config/mybatis/ManagerDownloadMapper.xml

@@ -0,0 +1,84 @@
+<?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.ym.mec.biz.dal.dao.ManagerDownloadDao">
+    <resultMap id="ManagerDownload" type="com.ym.mec.biz.dal.entity.ManagerDownload">
+        <!--@mbg.generated-->
+        <!--@Table manager_download-->
+        <id column="id_" property="id"/>
+        <result column="user_id_" property="userId"/>
+        <result column="name_" property="name"/>
+        <result column="file_url_" property="fileUrl"/>
+        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="status_" property="status"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
+
+    <select id="get" parameterType="java.lang.Integer" resultMap="ManagerDownload">
+        <!--@mbg.generated-->
+        select * from manager_download
+        where id_ = #{id}
+    </select>
+    <delete id="delete" parameterType="java.lang.Integer">
+        <!--@mbg.generated-->
+        delete from manager_download
+        where id_ = #{id,jdbcType=INTEGER}
+    </delete>
+    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.ManagerDownload"
+            useGeneratedKeys="true">
+        <!--@mbg.generated-->
+        insert into manager_download (user_id_, name_, file_url_,type_,
+        status_, create_time_, update_time_
+        )
+        values (#{userId}, #{name}, #{fileUrl},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{status}, #{createTime}, #{updateTime}
+        )
+    </insert>
+
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.ManagerDownload">
+        <!--@mbg.generated-->
+        update manager_download
+        <set>
+            <if test="userId != null">
+                user_id_ = #{userId},
+            </if>
+            <if test="name != null">
+                name_ = #{name},
+            </if>
+            <if test="fileUrl != null">
+                file_url_ = #{fileUrl},
+            </if>
+            <if test="status != null">
+                status_ = #{status},
+            </if>
+            create_time_ = NOW(),
+            update_time_ = NOW(),
+        </set>
+        where id_ = #{id}
+    </update>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="ManagerDownload" parameterType="map">
+        SELECT * FROM manager_download
+        <include refid="queryPageSql"/>
+        ORDER BY id_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*) FROM manager_download
+        <include refid="queryPageSql"/>
+    </select>
+
+    <sql id="queryPageSql">
+        <where>
+            <if test="userId != null">
+                AND user_id_ = #{userId}
+            </if>
+            <if test="type != null">
+                AND type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+        </where>
+    </sql>
+</mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -497,6 +497,9 @@
         <result column="routeMerNo" property="routeMerNo"/>
         <result column="routeMerNo" property="routeMerNo"/>
         <result column="routeAmount" property="routeAmount"/>
         <result column="routeAmount" property="routeAmount"/>
         <result column="routeBalance" property="routeBalance"/>
         <result column="routeBalance" property="routeBalance"/>
+        <result column="sale_amount_" property="saleAmount"/>
+        <result column="service_amount_" property="serviceAmount"/>
+        <result column="routeBalance" property="routeBalance"/>
         <result column="feeFlag" property="feeFlag"/>
         <result column="feeFlag" property="feeFlag"/>
         <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
         <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
             <result column="detail_id_" property="id"/>
             <result column="detail_id_" property="id"/>

+ 4 - 4
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -256,7 +256,7 @@
                 AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
                 AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
             </if>
             <if test="noneTqType != null">
             <if test="noneTqType != null">
-                AND spo.mer_nos_ != '淘器微信'
+                AND (spo.mer_nos_ IS NULL OR spo.mer_nos_ != '淘器微信')
             </if>
             </if>
         </where>
         </where>
     </sql>
     </sql>
@@ -285,7 +285,7 @@
         SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
         SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
         detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
         detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
         sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name,spro.route_amount_
         sci.charge_type_,g.id_ goods_id, g.name_ goods_name,o.name_ organ_name,spro.route_amount_
-        routeAmount,spro.route_balance_amount_ routeBalance,
+        routeAmount,spro.route_balance_amount_ routeBalance,spro.sale_amount_,spro.service_amount_,
         spro.mer_no_ routeMerNo,spro.fee_flag_ feeFlag
         spro.mer_no_ routeMerNo,spro.fee_flag_ feeFlag
         FROM student_payment_order spo
         FROM student_payment_order spo
         LEFT JOIN student_payment_route_order spro ON spro.order_no_ = spo.order_no_
         LEFT JOIN student_payment_route_order spro ON spro.order_no_ = spo.order_no_
@@ -352,7 +352,7 @@
                 </if>
                 </if>
             </if>
             </if>
             <if test="noneTqType != null">
             <if test="noneTqType != null">
-                and spro.mer_no_ != '淘器微信'
+                and (spro.mer_no_ IS NULL OR spro.mer_no_ != '淘器微信')
             </if>
             </if>
         </where>
         </where>
 		order by spro.id_ desc
 		order by spro.id_ desc
@@ -383,7 +383,7 @@
         		</if>
         		</if>
         	</if>
         	</if>
             <if test="noneTqType != null">
             <if test="noneTqType != null">
-                and spro.mer_no_ != '淘器微信'
+                and (spro.mer_no_ IS NULL OR spro.mer_no_ != '淘器微信')
             </if>
             </if>
         </where>
         </where>
 		order by spro.id_ desc
 		order by spro.id_ desc

+ 61 - 403
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -6,6 +6,8 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.service.IdGeneratorService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 
 
@@ -23,13 +25,11 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -129,6 +129,12 @@ public class ExportController extends BaseController {
     private GoodsService goodsService;
     private GoodsService goodsService;
     @Autowired
     @Autowired
     private ClassGroupService classGroupService;
     private ClassGroupService classGroupService;
+    @Autowired
+    private ExportService exportService;
+    @Autowired
+    private ManagerDownloadDao managerDownloadDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
 
 
     @ApiOperation(value = "班级列表导出")
     @ApiOperation(value = "班级列表导出")
     @PostMapping("export/classGroup")
     @PostMapping("export/classGroup")
@@ -463,7 +469,7 @@ public class ExportController extends BaseController {
         List<TeacherSalaryComplaints> rows = teacherSalaryComplaintsService.queryPage(queryInfo).getRows();
         List<TeacherSalaryComplaints> rows = teacherSalaryComplaintsService.queryPage(queryInfo).getRows();
         OutputStream outputStream = response.getOutputStream();
         OutputStream outputStream = response.getOutputStream();
         try {
         try {
-            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "老师ID", "老师姓名", "课酬归属时间", "申提交时间", "状态",
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "老师ID", "老师姓名", "课酬归属时间", "申提交时间", "状态",
                     "申述处理者"}, new String[]{
                     "申述处理者"}, new String[]{
                     "organName", "teacherId", "realName", "salarySettlementMonth", "createTime", "statusEnum.msg",
                     "organName", "teacherId", "realName", "salarySettlementMonth", "createTime", "statusEnum.msg",
                     "operatorRealName"}, rows);
                     "operatorRealName"}, rows);
@@ -971,7 +977,7 @@ public class ExportController extends BaseController {
     @PostMapping("order/musicalListDetailExport")
     @PostMapping("order/musicalListDetailExport")
     @PreAuthorize("@pcs.hasPermissions('order/musicalListDetailExport')")
     @PreAuthorize("@pcs.hasPermissions('order/musicalListDetailExport')")
     public void musicalListDetailExport(HttpServletResponse response, String musicGroupId) throws IOException {
     public void musicalListDetailExport(HttpServletResponse response, String musicGroupId) throws IOException {
-        List<MusicalListDetailDto> musicalList = studentPaymentOrderDetailService.getMusicalListDetail(musicGroupId,null);
+        List<MusicalListDetailDto> musicalList = studentPaymentOrderDetailService.getMusicalListDetail(musicGroupId, null);
         if (musicalList.size() > 50000) {
         if (musicalList.size() > 50000) {
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
         }
         }
@@ -1009,7 +1015,7 @@ public class ExportController extends BaseController {
         if (studentApplyDetail.size() <= 0) {
         if (studentApplyDetail.size() <= 0) {
             throw new BizException("没有可导出的记录");
             throw new BizException("没有可导出的记录");
         }
         }
-        List<MusicalListDetailDto> musicalListDetails = studentPaymentOrderDetailService.getMusicalListDetail(queryInfo.getMusicGroupId(),null);
+        List<MusicalListDetailDto> musicalListDetails = studentPaymentOrderDetailService.getMusicalListDetail(queryInfo.getMusicGroupId(), null);
         for (StudentApplyDetailDto studentApplyDetailDto : studentApplyDetail) {
         for (StudentApplyDetailDto studentApplyDetailDto : studentApplyDetail) {
             for (MusicalListDetailDto musicalListDetail : musicalListDetails) {
             for (MusicalListDetailDto musicalListDetail : musicalListDetails) {
                 if (!musicalListDetail.getUserId().equals(studentApplyDetailDto.getStudentId())) continue;
                 if (!musicalListDetail.getUserId().equals(studentApplyDetailDto.getStudentId())) continue;
@@ -1076,7 +1082,7 @@ public class ExportController extends BaseController {
     @ApiOperation(value = "订单列表导出")
     @ApiOperation(value = "订单列表导出")
     @RequestMapping("export/orderList")
     @RequestMapping("export/orderList")
     @PreAuthorize("@pcs.hasPermissions('export/orderList')")
     @PreAuthorize("@pcs.hasPermissions('export/orderList')")
-    public void orderList(StudentPaymentOrderQueryInfo queryInfo, HttpServletResponse response) throws IOException {
+    public HttpResponseResult orderList(StudentPaymentOrderQueryInfo queryInfo) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Employee employee = employeeDao.get(sysUser.getId());
         Employee employee = employeeDao.get(sysUser.getId());
         if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && "3".equals(queryInfo.getOrderType())) {
         if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && "3".equals(queryInfo.getOrderType())) {
@@ -1093,207 +1099,31 @@ public class ExportController extends BaseController {
             queryInfo.setUserIds(userIds);
             queryInfo.setUserIds(userIds);
         }
         }
         queryInfo.setPage(1);
         queryInfo.setPage(1);
-        queryInfo.setRows(49999);
+        queryInfo.setRows(50000);
         queryInfo.setIsExport(true);
         queryInfo.setIsExport(true);
-        Map<String, Object> params = new HashMap<String, Object>();
+        Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         MapUtil.populateMap(params, queryInfo);
-        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
-        if (studentPaymentOrderExportDtos.size() > 50000) {
-            throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
-        }
-        OutputStream outputStream = response.getOutputStream();
-        long i = 1;
-        for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
-            if (row.getActualAmount() == null) {
-                row.setActualAmount(BigDecimal.ZERO);
-            }
-            if (row.getBalancePaymentAmount() == null) {
-                row.setBalancePaymentAmount(BigDecimal.ZERO);
-            }
-            if (row.getMemo() == null) {
-                row.setMemo("");
-            }
-            BigDecimal transferFee = BigDecimal.ZERO;
-            if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
-                FeeFlagNumDto countFeeFlagNum = studentPaymentRouteOrderDao.getCountFeeFlagNum(row.getOrderNo());
-                if (countFeeFlagNum.getTotalNum() > countFeeFlagNum.getYesNum()) {
-                    transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
-                }
-                if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
-                    List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(row.getOrderNo());
-                    for (StudentPaymentRouteOrder routeOrder : routeOrders) {
-                        transferFee = transferFee.add(routeOrder.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
-                    }
-                }
-            }
-            row.setTransferFee(transferFee);
-
-            String goodsName = "";
-            if (row.getOrderDetailList() != null) {
-                for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
-                    switch (orderDetail.getType()) {
-                        case COURSE:
-                        case CLASSROOM:
-                        case SINGLE:
-                        case MIX:
-                        case COMPREHENSIVE:
-                        case ENLIGHTENMENT:
-                        case TRAINING_SINGLE:
-                        case TRAINING_MIX:
-                        case MUSIC_NETWORK:
-                        case HIGH:
-                        case HIGH_ONLINE:
-                        case HIGH_ONLINE_COURSE:
-                            row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
-                            break;
-                        case MUSICAL:
-                            if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                                BigDecimal leaseFee = orderDetail.getPrice();
-                                if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-                                    leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
-                                }
-                                row.setLeaseFee(leaseFee);
-                            } else {
-                                row.setMusicalFee(orderDetail.getPrice());
-                            }
-                            break;
-                        case ACCESSORIES:
-                        case TEACHING:
-                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
-                            break;
-                        case OTHER:
-                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
-                        default:
-                            break;
-                    }
-                }
-            }
-            if (row.getGoodsList() != null) {
-                goodsName = row.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
-            }
-            if (StringUtils.isNotBlank(goodsName)) {
-                row.setMemo(goodsName);
-            }
-            //专业
-            if (row.getGroupType().equals(GroupType.VIP)) {
-                row.setVipCourseFee(row.getActualAmount());
-                VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
-                if (vipGroupInfo != null) {
-                    row.setSchoolName(vipGroupInfo.getSchoolName());
-                    row.setSubjectName(vipGroupInfo.getSubjectName());
-                }
-            } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
-                //考级报名
-                if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
-                    String[] feeTypes = row.getMemo().split(";");
-                    List<String> feeTypeList = Arrays.asList(feeTypes);
-                    for (String feeTypeStr : feeTypeList) {
-                        int index = feeTypeStr.lastIndexOf(":");
-                        if (index < 0) {
-                            continue;
-                        }
-                        BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
-                        if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-                            typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
-                        }
-                        if (feeTypeStr.contains("VIP")) {
-                            row.setVipCourseFee(typeFee);
-                        } else if (feeTypeStr.contains("网管课")) {
-                            row.setPracticeCourseFee(typeFee);
-                        } else if (feeTypeStr.contains("乐理课")) {
-                            row.setTheoryCourseFee(typeFee);
-                        }
-                    }
-                    row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
-                } else {
-                    if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
-                        row.setDegreeFee(row.getActualAmount());
-                    } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
-                        row.setPracticeCourseFee(row.getActualAmount());
-                    } else {
-                        row.setOtherFee(row.getActualAmount());
-                    }
-                }
-                if (row.getChargeType() != null) {
-                    for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
-                        if (!chargeType.getCode().equals(row.getChargeType())) continue;
-                        row.setSporadicType(chargeType.getMsg());
-                    }
-                }
-            } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
-                row.setPracticeCourseFee(row.getActualAmount());
-                PracticeCourseDto practiceGroup = practiceGroupDao.findByGroupId(Integer.parseInt(row.getMusicGroupId()));
-                if (practiceGroup != null) {
-                    row.setSubjectName(practiceGroup.getSubjectName());
-                }
-            } else {
-                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
-                row.setMusicalFee(feeByType.getMusicalFee());
-                row.setTeachingFee(feeByType.getTeachingFee());
-                row.setRepairFee(feeByType.getRepairFee());
-                row.setOtherFee(feeByType.getOtherFee());
-                if (row.getGroupType().equals(GroupType.MUSIC)) {
-                    StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
-                    if (studentRegistration != null) {
-                        row.setSubjectName(studentRegistration.getSubjectName());
-                        row.setSchoolName(studentRegistration.getSchoolName());
-                        row.setCooperationOrganName(studentRegistration.getRemark());
-                    }
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()));
-                } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
-                    row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
-                } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()));
-                    row.setTransferFee(BigDecimal.ZERO);
-                }
-            }
-            //如果合作单位不存在取学员的第一个乐团的合作单位和教学点
-            if (row.getCooperationOrganName() == null) {
-                CooperationOrgan cooperationOrgan = musicGroupDao.findUserMusicGroupCooperationOrgan(row.getUserId());
-                if (cooperationOrgan != null) {
-                    row.setCooperationOrganName(cooperationOrgan.getName());
-                }
-            }
-            if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
-                row.setMusicGroupId("");
-            }
-            String paymentChannel = "";
-            if (row.getPaymentChannel() == null) {
-            } else if (row.getPaymentChannel().equals("YQPAY")) {
-                paymentChannel = "双乾";
-            } else if (row.getPaymentChannel().equals("ADAPAY")) {
-                paymentChannel = "汇付";
-            } else if (row.getPaymentChannel().equals("BALANCE")) {
-                paymentChannel = "余额";
-            }
-            row.setPaymentChannel(paymentChannel);
-            row.setId(i);
-            i++;
-        }
-
-        try {
-            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
-                    "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
-            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
-                    "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
-            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
-            response.setContentType("application/octet-stream");
-            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
-            response.flushBuffer();
-            outputStream = response.getOutputStream();
-            workbook.write(outputStream);
-            outputStream.flush();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (outputStream != null) {
-                try {
-                    outputStream.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
+        int count = studentPaymentOrderDao.queryCount(params);
+        if (count <= 0) {
+            return failed("没有可导出的数据");
+        }
+
+        if (count > 50000) {
+            return failed("数据集太大,不能导出.最大数据集不能超过50000");
+        }
+        Date nowDate = new Date();
+        String no = idGeneratorService.generatorId("download") + "";
+        String fileName = "orderList-" + no + "-" + DateUtil.getDate(nowDate) + ".xls";
+        ManagerDownload managerDownload = new ManagerDownload();
+        managerDownload.setType(ExportTypeEnum.ORDER);
+        managerDownload.setUserId(sysUser.getId());
+        managerDownload.setName(fileName);
+        managerDownload.setFileUrl("");
+        managerDownload.setCreateTime(nowDate);
+        managerDownload.setUpdateTime(nowDate);
+        managerDownloadDao.insert(managerDownload);
+        exportService.orderList(params, managerDownload);
+        return succeed(fileName+"导出申请已提交,请到【报表中心-下载列表查看】");
     }
     }
 
 
 
 
@@ -2187,11 +2017,12 @@ public class ExportController extends BaseController {
     @ApiOperation(value = "财务管理导出")
     @ApiOperation(value = "财务管理导出")
     @RequestMapping("export/routeOrderList")
     @RequestMapping("export/routeOrderList")
     @PreAuthorize("@pcs.hasPermissions('export/routeOrderList')")
     @PreAuthorize("@pcs.hasPermissions('export/routeOrderList')")
-    public void routeOrderList(StudentPaymentOrderQueryInfo queryInfo, HttpServletResponse response) throws IOException {
+    public HttpResponseResult routeOrderList(StudentPaymentOrderQueryInfo queryInfo) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Employee employee = employeeDao.get(sysUser.getId());
         Employee employee = employeeDao.get(sysUser.getId());
         if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && queryInfo.getOrderType().equals("3")) {
         if (StringUtils.isEmpty(queryInfo.getRoutingOrganId()) && queryInfo.getOrderType().equals("3")) {
             queryInfo.setRoutingOrganId(employee.getOrganIdList());
             queryInfo.setRoutingOrganId(employee.getOrganIdList());
+            queryInfo.setOldOrganId(employee.getOrganIdList());
         } else if (StringUtils.isEmpty(queryInfo.getOrganId())) {
         } else if (StringUtils.isEmpty(queryInfo.getOrganId())) {
             queryInfo.setOrganId(employee.getOrganIdList());
             queryInfo.setOrganId(employee.getOrganIdList());
         }
         }
@@ -2204,208 +2035,35 @@ public class ExportController extends BaseController {
             queryInfo.setUserIds(userIds);
             queryInfo.setUserIds(userIds);
         }
         }
         queryInfo.setPage(1);
         queryInfo.setPage(1);
-        queryInfo.setRows(49999);
+        queryInfo.setRows(50000);
         queryInfo.setIsExport(true);
         queryInfo.setIsExport(true);
         queryInfo.setOrderType("3");
         queryInfo.setOrderType("3");
         Map<String, Object> params = new HashMap<String, Object>();
         Map<String, Object> params = new HashMap<String, Object>();
         MapUtil.populateMap(params, queryInfo);
         MapUtil.populateMap(params, queryInfo);
-        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage(params);
-        if (studentPaymentOrderExportDtos.size() > 50000) {
-            throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
-        }
-        OutputStream outputStream = response.getOutputStream();
-        long i = 1;
-        for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
-            if (row.getActualAmount() == null) {
-                row.setActualAmount(BigDecimal.ZERO);
-            }
-            if (row.getBalancePaymentAmount() == null) {
-                row.setBalancePaymentAmount(BigDecimal.ZERO);
-            }
-            if (row.getRouteAmount() == null) {
-                row.setRouteAmount(BigDecimal.ZERO);
-            }
-            if (row.getMemo() == null) {
-                row.setMemo("");
-            }
-            BigDecimal transferFee = BigDecimal.ZERO;
-            if (row.getPaymentChannel() != null && row.getPaymentChannel().equals("ADAPAY")) {
-                FeeFlagNumDto countFeeFlagNum = studentPaymentRouteOrderDao.getCountFeeFlagNum(row.getOrderNo());
-                if (countFeeFlagNum.getTotalNum() > countFeeFlagNum.getYesNum() && row.getFeeFlag().equals("Y")) {
-                    transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
-                }
-                if (countFeeFlagNum.getTotalNum().equals(countFeeFlagNum.getYesNum())) {
-                    transferFee = row.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
-                }
-            }
-            row.setTransferFee(transferFee);
-
-            String goodsName = "";
-            if (row.getOrderDetailList() != null) {
-                for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
-                    switch (orderDetail.getType()) {
-                        case COURSE:
-                        case CLASSROOM:
-                        case SINGLE:
-                        case MIX:
-                        case COMPREHENSIVE:
-                        case ENLIGHTENMENT:
-                        case TRAINING_SINGLE:
-                        case TRAINING_MIX:
-                        case MUSIC_NETWORK:
-                        case HIGH:
-                        case HIGH_ONLINE:
-                        case HIGH_ONLINE_COURSE:
-                            row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
-                            break;
-                        case MUSICAL:
-                            if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                                BigDecimal leaseFee = orderDetail.getPrice();
-                                if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-                                    leaseFee = orderDetail.getPrice().multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
-                                }
-                                row.setLeaseFee(leaseFee);
-                            } else {
-                                row.setMusicalFee(orderDetail.getPrice());
-                            }
-                            break;
-                        case ACCESSORIES:
-                        case TEACHING:
-                            row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
-                            break;
-                        case OTHER:
-                            row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
-                        default:
-                            break;
-                    }
-                }
-            }
-            if (row.getGoodsList() != null) {
-                goodsName = row.getGoodsList().stream().map(Goods::getName).collect(Collectors.joining("|"));
-            }
-            if (StringUtils.isNotBlank(goodsName)) {
-                row.setMemo(goodsName);
-            }
-            //专业
-            if (row.getGroupType().equals(GroupType.VIP)) {
-                row.setVipCourseFee(row.getActualAmount());
-                VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
-                if (vipGroupInfo != null) {
-                    row.setSchoolName(vipGroupInfo.getSchoolName());
-                    row.setSubjectName(vipGroupInfo.getSubjectName());
-                }
-            } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
-                //考级报名
-                if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
-                    String[] feeTypes = row.getMemo().split(";");
-                    List<String> feeTypeList = Arrays.asList(feeTypes);
-                    for (String feeTypeStr : feeTypeList) {
-                        int index = feeTypeStr.lastIndexOf(":");
-                        if (index < 0) {
-                            continue;
-                        }
-                        BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
-                        if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
-                            typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
-                        }
-                        if (feeTypeStr.contains("VIP")) {
-                            row.setVipCourseFee(typeFee);
-                        } else if (feeTypeStr.contains("网管课")) {
-                            row.setPracticeCourseFee(typeFee);
-                        } else if (feeTypeStr.contains("乐理课")) {
-                            row.setTheoryCourseFee(typeFee);
-                        }
-                    }
-                    row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
-                } else {
-                    if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
-                        row.setDegreeFee(row.getActualAmount());
-                    } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
-                        row.setPracticeCourseFee(row.getActualAmount());
-                    } else {
-                        row.setOtherFee(row.getActualAmount());
-                    }
-                }
-                if (row.getChargeType() != null) {
-                    for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
-                        if (!chargeType.getCode().equals(row.getChargeType())) continue;
-                        row.setSporadicType(chargeType.getMsg());
-                    }
-                }
-            } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
-                row.setPracticeCourseFee(row.getActualAmount());
-                PracticeCourseDto practiceGroup = practiceGroupDao.findByGroupId(Integer.parseInt(row.getMusicGroupId()));
-                if (practiceGroup != null) {
-                    row.setSubjectName(practiceGroup.getSubjectName());
-                }
-            } else {
-                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
-                row.setMusicalFee(feeByType.getMusicalFee());
-                row.setTeachingFee(feeByType.getTeachingFee());
-                row.setRepairFee(feeByType.getRepairFee());
-                row.setOtherFee(feeByType.getOtherFee());
-                if (row.getGroupType().equals(GroupType.MUSIC)) {
-                    StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
-                    if (studentRegistration != null) {
-                        row.setSubjectName(studentRegistration.getSubjectName());
-                        row.setSchoolName(studentRegistration.getSchoolName());
-                        row.setCooperationOrganName(studentRegistration.getRemark());
-                    }
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()));
-                } else if (row.getType().equals(OrderTypeEnum.REPAIR)) {
-                    row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
-                } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
-                    row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getRepairFee()).subtract(feeByType.getOtherFee()));
-                    row.setTransferFee(BigDecimal.ZERO);
-                }
-            }
-            //如果合作单位不存在取学员的第一个乐团的合作单位和教学点
-            if (row.getCooperationOrganName() == null) {
-                CooperationOrgan cooperationOrgan = musicGroupDao.findUserMusicGroupCooperationOrgan(row.getUserId());
-                if (cooperationOrgan != null) {
-                    row.setCooperationOrganName(cooperationOrgan.getName());
-                }
-            }
-            if (row.getMusicGroupId() != null && row.getMusicGroupId().equals("null")) {
-                row.setMusicGroupId("");
-            }
-            String paymentChannel = "";
-            if (row.getPaymentChannel() == null) {
-            } else if (row.getPaymentChannel().equals("YQPAY")) {
-                paymentChannel = "双乾";
-            } else if (row.getPaymentChannel().equals("ADAPAY")) {
-                paymentChannel = "汇付";
-            } else if (row.getPaymentChannel().equals("BALANCE")) {
-                paymentChannel = "余额";
-            }
-            row.setPaymentChannel(paymentChannel);
-            row.setId(i);
-            i++;
-        }
 
 
-        try {
-            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "分润账户", "分润金额", "分润余额", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "押金", "乐器", "教辅费用", "其它", "手续费", "到账时间",
-                    "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "备注"};
-            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "leaseFee", "musicalFee", "teachingFee", "otherFee", "transferFee", "payTime", "musicGroupId",
-                    "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "memo"};
-            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
-            response.setContentType("application/octet-stream");
-            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls"); //    //收款账户
-            response.flushBuffer();
-            outputStream = response.getOutputStream();
-            workbook.write(outputStream);
-            outputStream.flush();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (outputStream != null) {
-                try {
-                    outputStream.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
+        int count = studentPaymentRouteOrderDao.queryCount(params);
+        if (count <= 0) {
+            return failed("没有可导出的数据");
+        }
+
+        if (count > 50000) {
+            return failed("数据集太大,不能导出.最大数据集不能超过50000");
+        }
+        queryInfo.setRoutingOrganId(null);
+
+        Date nowDate = new Date();
+        String no = idGeneratorService.generatorId("download") + "";
+        String fileName = "routeOrderList-" + no + "-" + DateUtil.getDate(nowDate) + ".xls";
+        ManagerDownload managerDownload = new ManagerDownload();
+        managerDownload.setType(ExportTypeEnum.ROUTE_ORDER);
+        managerDownload.setUserId(sysUser.getId());
+        managerDownload.setName(fileName);
+        managerDownload.setFileUrl("");
+        managerDownload.setCreateTime(nowDate);
+        managerDownload.setUpdateTime(nowDate);
+        managerDownloadDao.insert(managerDownload);
+        exportService.routeOrderList(params, managerDownload);
+        return succeed(fileName+"导出申请已提交,请到【报表中心-下载列表查看】");
     }
     }
 
 
 
 

+ 47 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ManagerDownloadController.java

@@ -0,0 +1,47 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.page.ManagerDownloadQueryInfo;
+import com.ym.mec.biz.dal.page.OrganizationQueryInfo;
+import com.ym.mec.biz.service.ManagerDownloadService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("managerDownload")
+@Api(tags = "下载列表")
+@RestController
+public class ManagerDownloadController extends BaseController {
+
+    @Autowired
+    private ManagerDownloadService managerDownloadService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "分页查询列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('managerDownload/queryPage')")
+    public Object queryPage(ManagerDownloadQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        queryInfo.setUserId(sysUser.getId());
+        return succeed(managerDownloadService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "删除")
+    @PostMapping("/del/{id}")
+    @PreAuthorize("@pcs.hasPermissions('managerDownload/del')")
+    public Object del(@ApiParam(value = "下载记录id", required = true) @PathVariable("id") Integer id) {
+        return succeed(managerDownloadService.delete(id));
+    }
+
+}