瀏覽代碼

Merge branch 'feature-operating-report' of http://git.dayaedu.com/yonge/mec into feature-operating-report

zouxuan 4 年之前
父節點
當前提交
912e414247
共有 24 個文件被更改,包括 1612 次插入14 次删除
  1. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportDao.java
  2. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java
  3. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java
  4. 28 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentRouteOrderDto.java
  5. 238 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReport.java
  6. 345 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java
  7. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java
  8. 30 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellTypeEnum.java
  9. 62 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/OperatingReportQueryInfo.java
  10. 76 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/SellOrderQueryInfo.java
  11. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportService.java
  12. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java
  13. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderDetailService.java
  14. 70 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java
  15. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  16. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  17. 65 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java
  18. 54 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  19. 135 0
      mec-biz/src/main/resources/config/mybatis/OperatingReportMapper.xml
  20. 187 0
      mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
  21. 14 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml
  22. 127 0
      mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java
  23. 79 0
      mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java
  24. 5 5
      mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentRouteOrderController.java

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

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

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -0,0 +1,12 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.SellOrder;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
+
+    int batchInsert(@Param("sellOrders") List<SellOrder> sellOrders);
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java

@@ -80,6 +80,13 @@ public interface StudentPaymentOrderDetailDao extends BaseDAO<Long, StudentPayme
     StudentPaymentOrderDetail findApplyOrderMusical(@Param("orderId") Long orderId);
 
     /**
+     * 获取订单详细
+     * @param orderId
+     * @return
+     */
+    List<StudentPaymentOrderDetail> getOrderDetail(@Param("orderId") Long orderId);
+
+    /**
      *
      * @param orderId
      * @return

+ 28 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentRouteOrderDto.java

@@ -1,8 +1,10 @@
 package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
+import java.util.Map;
 
 public class StudentPaymentRouteOrderDto extends StudentPaymentOrder {
 
@@ -12,6 +14,12 @@ public class StudentPaymentRouteOrderDto extends StudentPaymentOrder {
     private Integer routeOrganId;
 
     /**
+     * 学校id
+     */
+    @ApiModelProperty(value = "学校id",required = true)
+    private Integer schoolId;
+
+    /**
      * 分润金额
      */
     private BigDecimal routeAmount;
@@ -27,10 +35,13 @@ public class StudentPaymentRouteOrderDto extends StudentPaymentOrder {
     private String merNo;
 
     /**
-     * 备注
+     * 是否承担手续费
      */
     private String feeFlag;
 
+    @ApiModelProperty(value = "商品 id->数量",required = true)
+    private Map<Integer, Integer> goodies;
+
     public Integer getRouteOrganId() {
         return routeOrganId;
     }
@@ -70,4 +81,20 @@ public class StudentPaymentRouteOrderDto extends StudentPaymentOrder {
     public void setRouteBalanceAmount(BigDecimal routeBalanceAmount) {
         this.routeBalanceAmount = routeBalanceAmount;
     }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public Map<Integer, Integer> getGoodies() {
+        return goodies;
+    }
+
+    public void setGoodies(Map<Integer, Integer> goodies) {
+        this.goodies = goodies;
+    }
 }

+ 238 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReport.java

@@ -0,0 +1,238 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel(value="com-ym-OperatingReport")
+public class OperatingReport {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    /**
+    * 分部id
+    */
+    @ApiModelProperty(value="分部id")
+    private Integer organId;
+
+    @ApiModelProperty(value="分部名称")
+    private String organName;
+
+    /**
+    * 学校id
+    */
+    @ApiModelProperty(value="学校id")
+    private Integer schoolId;
+
+    @ApiModelProperty(value="学校名称")
+    private String schoolName;
+
+    /**
+    * 销售收入
+    */
+    @ApiModelProperty(value="销售收入")
+    private BigDecimal sellAmount;
+
+    /**
+    * 服务收入
+    */
+    @ApiModelProperty(value="服务收入")
+    private BigDecimal serviceAmount;
+
+    /**
+    * 业务退费
+    */
+    @ApiModelProperty(value="业务退费")
+    private BigDecimal refundAmount;
+
+    /**
+    * 收入合计
+    */
+    @ApiModelProperty(value="收入合计")
+    private BigDecimal incomeTotal;
+
+    /**
+    * 销售成本
+    */
+    @ApiModelProperty(value="销售成本")
+    private BigDecimal sellCost;
+
+    /**
+    * 固定支出
+    */
+    @ApiModelProperty(value="固定支出")
+    private BigDecimal expensesAmount;
+
+    /**
+    * 变动支出
+    */
+    @ApiModelProperty(value="变动支出")
+    private BigDecimal variableCost;
+
+    /**
+    * 分摊费用
+    */
+    @ApiModelProperty(value="分摊费用")
+    private BigDecimal distributionAmount;
+
+    /**
+    * 成本费用合计
+    */
+    @ApiModelProperty(value="成本费用合计")
+    private BigDecimal costAmount;
+
+    /**
+    * 利润
+    */
+    @ApiModelProperty(value="利润")
+    private BigDecimal profit;
+
+    /**
+    * 月份
+    */
+    @ApiModelProperty(value="月份")
+    private Date month;
+
+    /**
+    * 生成时间
+    */
+    @ApiModelProperty(value="生成时间")
+    private Date createTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public BigDecimal getSellAmount() {
+        return sellAmount;
+    }
+
+    public void setSellAmount(BigDecimal sellAmount) {
+        this.sellAmount = sellAmount;
+    }
+
+    public BigDecimal getServiceAmount() {
+        return serviceAmount;
+    }
+
+    public void setServiceAmount(BigDecimal serviceAmount) {
+        this.serviceAmount = serviceAmount;
+    }
+
+    public BigDecimal getRefundAmount() {
+        return refundAmount;
+    }
+
+    public void setRefundAmount(BigDecimal refundAmount) {
+        this.refundAmount = refundAmount;
+    }
+
+    public BigDecimal getIncomeTotal() {
+        return incomeTotal;
+    }
+
+    public void setIncomeTotal(BigDecimal incomeTotal) {
+        this.incomeTotal = incomeTotal;
+    }
+
+    public BigDecimal getSellCost() {
+        return sellCost;
+    }
+
+    public void setSellCost(BigDecimal sellCost) {
+        this.sellCost = sellCost;
+    }
+
+    public BigDecimal getExpensesAmount() {
+        return expensesAmount;
+    }
+
+    public void setExpensesAmount(BigDecimal expensesAmount) {
+        this.expensesAmount = expensesAmount;
+    }
+
+    public BigDecimal getVariableCost() {
+        return variableCost;
+    }
+
+    public void setVariableCost(BigDecimal variableCost) {
+        this.variableCost = variableCost;
+    }
+
+    public BigDecimal getDistributionAmount() {
+        return distributionAmount;
+    }
+
+    public void setDistributionAmount(BigDecimal distributionAmount) {
+        this.distributionAmount = distributionAmount;
+    }
+
+    public BigDecimal getCostAmount() {
+        return costAmount;
+    }
+
+    public void setCostAmount(BigDecimal costAmount) {
+        this.costAmount = costAmount;
+    }
+
+    public BigDecimal getProfit() {
+        return profit;
+    }
+
+    public void setProfit(BigDecimal profit) {
+        this.profit = profit;
+    }
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+}

+ 345 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -0,0 +1,345 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel(value="com-ym-SellOrder")
+public class SellOrder {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    /**
+    * 分部id
+    */
+    @ApiModelProperty(value="分部id")
+    private Integer organId;
+
+    /**
+     * 学校id
+     */
+    @ApiModelProperty(value="学校id")
+    private Integer schoolId;
+
+    /**
+     * 学校名称
+     */
+    @ApiModelProperty(value="学校名称")
+    private String schoolName;
+
+    /**
+    * 交易流水号
+    */
+    @ApiModelProperty(value="交易流水号")
+    private String transNo;
+
+    /**
+     * 交易流水号
+     */
+    @ApiModelProperty(value="订单id")
+    private Long orderId;
+
+    private String organName;
+
+    /**
+    * 订单号
+    */
+    @ApiModelProperty(value="订单号")
+    private String orderNo;
+
+    /**
+    * 应付金额
+    */
+    @ApiModelProperty(value="应付金额")
+    private BigDecimal expectAmount;
+
+    /**
+    * 现金支付金额
+    */
+    @ApiModelProperty(value="现金支付金额")
+    private BigDecimal actualAmount;
+
+    /**
+    * 余额支付金额
+    */
+    @ApiModelProperty(value="余额支付金额")
+    private BigDecimal balanceAmount;
+
+    /**
+    * 销售成本
+    */
+    @ApiModelProperty(value="销售成本")
+    private BigDecimal sellCost;
+
+    /**
+     * 销售成本2
+     */
+    @ApiModelProperty(value="销售成本2")
+    private BigDecimal sellCost2;
+
+    /**
+    * 销售类型
+    */
+    @ApiModelProperty(value="销售类型")
+    private SellTypeEnum type;
+
+    /**
+    * 商品id
+    */
+    @ApiModelProperty(value="商品id")
+    private Integer goodsId;
+
+    /**
+     * 商品名称
+     */
+    @ApiModelProperty(value="商品名称")
+    private String goodsName;
+
+    /**
+    * 数量
+    */
+    @ApiModelProperty(value="数量")
+    private Integer num;
+
+    /**
+    * 用户id
+    */
+    @ApiModelProperty(value="用户id")
+    private Integer userId;
+
+    private String userName;
+
+    private String phone;
+
+    /**
+    * 交易方式
+    */
+    @ApiModelProperty(value="交易方式")
+    private String paymentChannel;
+
+    /**
+    * 收款账户
+    */
+    @ApiModelProperty(value="收款账户")
+    private String merNo;
+
+    /**
+    * 交易时间
+    */
+    @ApiModelProperty(value="交易时间")
+    private Date sellTime;
+
+    /**
+    * 创建时间
+    */
+    @ApiModelProperty(value="创建时间")
+    private Date createIme;
+
+    /**
+    * 更新时间
+    */
+    @ApiModelProperty(value="更新时间")
+    private Date updateTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public String getTransNo() {
+        return transNo;
+    }
+
+    public void setTransNo(String transNo) {
+        this.transNo = transNo;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public BigDecimal getExpectAmount() {
+        return expectAmount;
+    }
+
+    public void setExpectAmount(BigDecimal expectAmount) {
+        this.expectAmount = expectAmount;
+    }
+
+    public BigDecimal getActualAmount() {
+        return actualAmount;
+    }
+
+    public void setActualAmount(BigDecimal actualAmount) {
+        this.actualAmount = actualAmount;
+    }
+
+    public BigDecimal getBalanceAmount() {
+        return balanceAmount;
+    }
+
+    public void setBalanceAmount(BigDecimal balanceAmount) {
+        this.balanceAmount = balanceAmount;
+    }
+
+    public BigDecimal getSellCost() {
+        return sellCost;
+    }
+
+    public void setSellCost(BigDecimal sellCost) {
+        this.sellCost = sellCost;
+    }
+
+    public SellTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(SellTypeEnum type) {
+        this.type = type;
+    }
+
+    public Integer getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(Integer goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    public Integer getNum() {
+        return num;
+    }
+
+    public void setNum(Integer num) {
+        this.num = num;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getPaymentChannel() {
+        return paymentChannel;
+    }
+
+    public void setPaymentChannel(String paymentChannel) {
+        this.paymentChannel = paymentChannel;
+    }
+
+    public String getMerNo() {
+        return merNo;
+    }
+
+    public void setMerNo(String merNo) {
+        this.merNo = merNo;
+    }
+
+    public Date getSellTime() {
+        return sellTime;
+    }
+
+    public void setSellTime(Date sellTime) {
+        this.sellTime = sellTime;
+    }
+
+    public Date getCreateIme() {
+        return createIme;
+    }
+
+    public void setCreateIme(Date createIme) {
+        this.createIme = createIme;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getGoodsName() {
+        return goodsName;
+    }
+
+    public void setGoodsName(String goodsName) {
+        this.goodsName = goodsName;
+    }
+
+    public BigDecimal getSellCost2() {
+        return sellCost2;
+    }
+
+    public void setSellCost2(BigDecimal sellCost2) {
+        this.sellCost2 = sellCost2;
+    }
+
+    public Long getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Long orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 对应数据库表(student_payment_order_detail):
@@ -45,6 +46,8 @@ public class StudentPaymentOrderDetail {
 	//商品成本价
 	private String goodsPrices;
 
+	private List<Goods> goodsList;
+
 	//减免费用
 	private BigDecimal remitFee;
 
@@ -125,6 +128,14 @@ public class StudentPaymentOrderDetail {
 		this.goodsPrices = goodsPrices;
 	}
 
+	public List<Goods> getGoodsList() {
+		return goodsList;
+	}
+
+	public void setGoodsList(List<Goods> goodsList) {
+		this.goodsList = goodsList;
+	}
+
 	public BigDecimal getRemitFee() {
 		return remitFee;
 	}

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellTypeEnum.java

@@ -0,0 +1,30 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum SellTypeEnum implements BaseEnum<String, SellTypeEnum> {
+
+	INSTRUMENT("INSTRUMENT", "乐器销售"),
+	ACCESSORIES("ACCESSORIES", "配件销售"),
+	SCHOOL_BUY("SCHOOL_BUY", "学校采购"),
+	OTHER("OTHER", "书籍(其他)");
+
+	private String code;
+
+	private String desc;
+
+	private SellTypeEnum(String code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	@Override
+	public String getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 62 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OperatingReportQueryInfo.java

@@ -0,0 +1,62 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+public class OperatingReportQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "分部id", required = false)
+    private String organIdList;
+
+    @ApiModelProperty(value = "学校id", required = false)
+    private Integer schoolId;
+
+    @ApiModelProperty(value = "月份", required = false)
+    private Date month;
+
+    private Date startTime;
+
+    private Date endTime;
+
+    public String getOrganIdList() {
+        return organIdList;
+    }
+
+    public void setOrganIdList(String organIdList) {
+        this.organIdList = organIdList;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+}

+ 76 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/SellOrderQueryInfo.java

@@ -0,0 +1,76 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+public class SellOrderQueryInfo extends QueryInfo {
+
+    private String organIdList;
+
+    @ApiModelProperty(value = "商品名称",required = false)
+    private String goodsName;
+
+    @ApiModelProperty(value = "学校id",required = false)
+    private Integer schoolId;
+
+    @ApiModelProperty(value = "销售类型",required = false)
+    private SellTypeEnum type;
+
+    @ApiModelProperty(value = "开始时间",required = false)
+    private Date startTime;
+
+    @ApiModelProperty(value = "结束时间",required = false)
+    private Date endTime;
+
+
+    public String getOrganIdList() {
+        return organIdList;
+    }
+
+    public void setOrganIdList(String organIdList) {
+        this.organIdList = organIdList;
+    }
+
+    public String getGoodsName() {
+        return goodsName;
+    }
+
+    public void setGoodsName(String goodsName) {
+        this.goodsName = goodsName;
+    }
+
+    public Integer getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Integer schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public SellTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(SellTypeEnum type) {
+        this.type = type;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+}

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportService.java

@@ -0,0 +1,13 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.common.service.BaseService;
+
+import java.util.List;
+
+
+public interface OperatingReportService extends BaseService<Integer, OperatingReport> {
+
+    List<OperatingReport> statistics();
+
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java

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

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

@@ -71,6 +71,14 @@ public interface StudentPaymentOrderDetailService extends BaseService<Long, Stud
      */
     StudentPaymentOrderDetail findApplyOrderMusical(Long orderId);
 
+
+    /**
+     * 获取订单详细
+     * @param orderId
+     * @return
+     */
+    List<StudentPaymentOrderDetail> getOrderDetail(Long orderId);
+
     /**
      * 获取订单类型的详情
      * @param orderId

+ 70 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java

@@ -0,0 +1,70 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.service.OperatingReportService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.date.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, OperatingReport> implements OperatingReportService {
+
+    @Autowired
+    private OperatingReportDao operatingReportDao;
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+    private MusicGroupDao musicGroupDao;
+
+
+    @Override
+    public BaseDAO<Integer, OperatingReport> getDAO() {
+        return operatingReportDao;
+    }
+
+    @Override
+    public List<OperatingReport> statistics() {
+        Date nowDate = new Date();
+        Date startTime = DateUtil.addDays1(nowDate, -1);
+        Map<String, Object> params = new HashMap<>();
+        params.put("orderStartDate", DateUtil.getDate(startTime));
+        params.put("orderEndDate", DateUtil.getDate(startTime));
+        params.put("paymentStatus", "SUCCESS");
+
+//        APPLY("APPLY", "报名"),
+//                RENEW("RENEW", "续费"),
+//                SPORADIC("SPORADIC", "零星收费"),
+//                OTHER("OTHER", "其他"),
+//                SMALL_CLASS_TO_BUY("SMALL_CLASS_TO_BUY", "VIP购买"),
+//                PRACTICE_GROUP_BUY("PRACTICE_GROUP_BUY", "网管课购买"),
+//                PRACTICE_GROUP_RENEW("PRACTICE_GROUP_RENEW", "网管课续费"),
+//                COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
+//                LUCK("LUCK", "福袋活动"),
+//                TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
+//                REPAIR("REPAIR","乐器维修");
+
+        Map<String, OperatingReport> schoolOperating = new HashMap<>();
+        Map<String, OperatingReport> organOperating = new HashMap<>();
+        List<StudentPaymentOrder> orders = studentPaymentOrderDao.queryPageOrder(params);
+        for (StudentPaymentOrder order : orders) {
+            if(order.getType().equals(OrderTypeEnum.APPLY)){
+                continue;
+            }
+            if(order.getType().equals(OrderTypeEnum.RENEW)){
+                MusicGroup musicGroup = musicGroupDao.get(order.getMusicGroupId());
+            }
+
+        }
+
+        return null;
+
+    }
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+
+import com.ym.mec.biz.dal.dao.SellOrderDao;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.service.*;
+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 SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> implements SellOrderService {
+    @Autowired
+    private SellOrderDao sellOrderDao;
+
+    @Override
+    public BaseDAO<Integer, SellOrder> getDAO() {
+        return sellOrderDao;
+    }
+
+
+}

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -213,6 +213,11 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
     }
 
     @Override
+    public List<StudentPaymentOrderDetail> getOrderDetail(Long orderId) {
+        return studentPaymentOrderDetailDao.getOrderDetail(orderId);
+    }
+
+    @Override
     public List<String> getOrderDetailType(Long orderId) {
         return studentPaymentOrderDetailDao.getOrderDetailType(orderId);
     }

+ 65 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -1,14 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -34,6 +32,10 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
     private StudentPaymentOrderDao studentPaymentOrderDao;
     @Autowired
     private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SellOrderDao sellOrderDao;
+    @Autowired
+    private GoodsDao goodsDao;
 
     @Override
     public BaseDAO<Long, StudentPaymentRouteOrder> getDAO() {
@@ -79,20 +81,76 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
         Date nowDate = new Date();
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
+        studentPaymentRouteOrderDto.setMerNos(studentPaymentRouteOrderDto.getMerNo());
         studentPaymentRouteOrderDto.setOrderNo(orderNo);
         studentPaymentRouteOrderDto.setGroupType(GroupType.OUTORDER);
+        studentPaymentRouteOrderDto.setRouteOrganId(studentPaymentRouteOrderDto.getOrganId());
         studentPaymentRouteOrderDto.setExpectAmount(studentPaymentRouteOrderDto.getActualAmount());
         studentPaymentRouteOrderDto.setStatus(DealStatusEnum.SUCCESS);
-        studentPaymentRouteOrderDto.setCreateTime(nowDate);
         studentPaymentRouteOrderDto.setUpdateTime(nowDate);
+
         studentPaymentOrderDao.insert(studentPaymentRouteOrderDto);
         StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
         studentPaymentRouteOrder.setOrderNo(orderNo);
+        studentPaymentRouteOrder.setMerNo(studentPaymentRouteOrderDto.getMerNo());
         studentPaymentRouteOrder.setRouteOrganId(studentPaymentRouteOrderDto.getOrganId());
         studentPaymentRouteOrder.setRouteAmount(studentPaymentRouteOrderDto.getActualAmount());
         studentPaymentRouteOrder.setRouteBalanceAmount(BigDecimal.ZERO);
         studentPaymentRouteOrder.setFeeFlag("N");
         studentPaymentRouteOrderDao.insert(studentPaymentRouteOrder);
+
+        if (studentPaymentRouteOrderDto.getGoodies() != null && studentPaymentRouteOrderDto.getGoodies().size() > 0) {
+            List<SellOrder> sellOrders = new ArrayList<>();
+            BigDecimal hasRouteAmount = BigDecimal.ZERO;
+            BigDecimal goodsTotalPrice = BigDecimal.ZERO;
+
+            for (Map.Entry<Integer, Integer> goodsMap : studentPaymentRouteOrderDto.getGoodies().entrySet()) {
+                Goods goods = goodsDao.get(goodsMap.getKey());
+                goodsTotalPrice = goodsTotalPrice.add(goods.getGroupPurchasePrice().multiply(new BigDecimal(goodsMap.getValue())));
+            }
+
+            int i = 1;
+            for (Map.Entry<Integer, Integer> goodsMap : studentPaymentRouteOrderDto.getGoodies().entrySet()) {
+                Goods goods = goodsDao.get(goodsMap.getKey());
+
+                BigDecimal actualAmount = studentPaymentRouteOrderDto.getActualAmount().multiply(goods.getGroupPurchasePrice().multiply(new BigDecimal(goodsMap.getValue()))).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
+                if (i == studentPaymentRouteOrderDto.getGoodies().size()) {
+                    actualAmount = studentPaymentRouteOrderDto.getActualAmount().subtract(hasRouteAmount);
+                }
+                hasRouteAmount = hasRouteAmount.add(actualAmount);
+                i++;
+
+                BigDecimal agreeCostPrice = goods.getAgreeCostPrice() == null ? BigDecimal.ZERO : goods.getAgreeCostPrice();
+
+                SellOrder sellOrder = new SellOrder();
+                sellOrder.setOrganId(studentPaymentRouteOrderDto.getOrganId());
+                sellOrder.setSchoolId(studentPaymentRouteOrderDto.getSchoolId());
+                sellOrder.setTransNo(studentPaymentRouteOrderDto.getTransNo());
+                sellOrder.setOrderId(studentPaymentRouteOrderDto.getId());
+                sellOrder.setOrderNo(orderNo);
+                sellOrder.setActualAmount(actualAmount);
+                sellOrder.setBalanceAmount(BigDecimal.ZERO);
+                sellOrder.setExpectAmount(actualAmount);
+                sellOrder.setSellCost(goods.getDiscountPrice().multiply(new BigDecimal(goodsMap.getValue())));
+                sellOrder.setSellCost2(agreeCostPrice.multiply(new BigDecimal(goodsMap.getValue())));
+                sellOrder.setNum(goodsMap.getValue());
+                sellOrder.setUserId(studentPaymentRouteOrderDto.getUserId());
+                sellOrder.setPaymentChannel(studentPaymentRouteOrderDto.getPaymentChannel());
+                sellOrder.setMerNo(studentPaymentRouteOrderDto.getMerNos());
+                sellOrder.setSellTime(studentPaymentRouteOrderDto.getCreateTime());
+                sellOrder.setCreateIme(new Date());
+                sellOrder.setUpdateTime(new Date());
+                if (goods.getType().equals(GoodsType.INSTRUMENT)) {
+                    sellOrder.setType(SellTypeEnum.INSTRUMENT);
+                } else if (goods.getType().equals(GoodsType.ACCESSORIES)) {
+                    sellOrder.setType(SellTypeEnum.ACCESSORIES);
+                } else {
+                    sellOrder.setType(SellTypeEnum.OTHER);
+                }
+                sellOrders.add(sellOrder);
+            }
+            sellOrderDao.batchInsert(sellOrders);
+        }
         return studentPaymentRouteOrderDto;
     }
 

+ 54 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -92,6 +92,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private RedisCache<String, Object> redisCache;
+    @Autowired
+    private SellOrderDao sellOrderDao;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -892,8 +894,59 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
                 rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             }
-
             sysUserCashAccountDetailService.insert(paymentDetail);
+
+            //销售订单详情
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderDetail(studentPaymentOrder.getId());
+            if (orderDetails.size() > 0) {
+                List<SellOrder> sellOrders = new ArrayList<>();
+                BigDecimal remitFee = studentPaymentOrder.getRemitFee() != null ? studentPaymentOrder.getRemitFee() : BigDecimal.ZERO;
+                BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount() != null ? studentPaymentOrder.getBalancePaymentAmount() : BigDecimal.ZERO;
+                //总价格
+                BigDecimal totalPrice = studentPaymentOrder.getExpectAmount();
+                for (StudentPaymentOrderDetail orderDetail : orderDetails) {
+                    if (orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                        continue;
+                    }
+                    if (orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {
+                        orderDetail.setPrice(orderDetail.getPrice().subtract(remitFee));
+                    }
+
+                    BigDecimal goodsTotalPrice = orderDetail.getGoodsList().stream().map(Goods::getGroupPurchasePrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+                    for (Goods goods : orderDetail.getGoodsList()) {
+                        BigDecimal actualAmount = goods.getGroupPurchasePrice().multiply(orderDetail.getPrice()).multiply(studentPaymentOrder.getActualAmount()).divide(goodsTotalPrice.multiply(totalPrice), 2, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal balance = goods.getGroupPurchasePrice().multiply(orderDetail.getPrice()).multiply(balancePaymentAmount).divide(goodsTotalPrice.multiply(totalPrice), 2, BigDecimal.ROUND_HALF_UP);
+                        SellOrder sellOrder = new SellOrder();
+                        sellOrder.setOrganId(studentPaymentOrder.getOrganId());
+                        sellOrder.setSchoolId(musicGroup.getSchoolId());
+                        sellOrder.setTransNo(studentPaymentOrder.getTransNo());
+                        sellOrder.setOrderId(studentPaymentOrder.getId());
+                        sellOrder.setOrderNo(studentPaymentOrder.getOrderNo());
+                        sellOrder.setActualAmount(actualAmount);
+                        sellOrder.setBalanceAmount(balancePaymentAmount);
+                        sellOrder.setExpectAmount(actualAmount.add(balance));
+                        sellOrder.setSellCost(goods.getDiscountPrice());
+                        sellOrder.setSellCost2(goods.getAgreeCostPrice());
+                        sellOrder.setNum(1);
+                        sellOrder.setUserId(studentPaymentOrder.getUserId());
+                        sellOrder.setPaymentChannel(studentPaymentOrder.getPaymentChannel());
+                        sellOrder.setMerNo(studentPaymentOrder.getMerNos());
+                        sellOrder.setSellTime(studentPaymentOrder.getCreateTime());
+                        sellOrder.setCreateIme(new Date());
+                        sellOrder.setUpdateTime(new Date());
+                        if (goods.getType().equals(GoodsType.INSTRUMENT)) {
+                            sellOrder.setType(SellTypeEnum.INSTRUMENT);
+                        } else if (goods.getType().equals(GoodsType.ACCESSORIES)) {
+                            sellOrder.setType(SellTypeEnum.ACCESSORIES);
+                        } else {
+                            sellOrder.setType(SellTypeEnum.OTHER);
+                        }
+                        sellOrders.add(sellOrder);
+                    }
+                }
+                sellOrderDao.batchInsert(sellOrders);
+            }
+
             //三方乐团不发送缴费通知
             if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
                 //发送缴费成功通知(短信 + push)

+ 135 - 0
mec-biz/src/main/resources/config/mybatis/OperatingReportMapper.xml

@@ -0,0 +1,135 @@
+<?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.OperatingReportDao">
+  <resultMap id="OperatingReport" type="com.ym.mec.biz.dal.entity.OperatingReport">
+    <!--@mbg.generated-->
+    <!--@Table operating_report-->
+    <id column="id_" property="id" />
+    <result column="organ_id_" property="organId" />
+    <result column="organ_name_" property="organName"/>
+    <result column="school_id_" property="schoolId" />
+    <result column="school_name_" property="schoolName"/>
+    <result column="sell_amount_" property="sellAmount" />
+    <result column="service_amount_" property="serviceAmount" />
+    <result column="refund_amount_" property="refundAmount" />
+    <result column="income_total_" property="incomeTotal" />
+    <result column="sell_cost_" property="sellCost" />
+    <result column="expenses_amount_" property="expensesAmount" />
+    <result column="variable_cost_" property="variableCost" />
+    <result column="distribution_amount_" property="distributionAmount" />
+    <result column="cost_amount_" property="costAmount" />
+    <result column="profit_" property="profit" />
+    <result column="month_" property="month" />
+    <result column="create_time_" property="createTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id_, organ_id_, school_id_, sell_amount_, service_amount_, refund_amount_, income_total_, 
+    sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, cost_amount_, 
+    profit_, month_, create_time_
+  </sql>
+  <select id="get" parameterType="java.lang.Integer" resultMap="OperatingReport">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from operating_report
+    where id_ = #{id}
+  </select>
+  <delete id="delete" parameterType="java.lang.Integer">
+    <!--@mbg.generated-->
+    delete from operating_report
+    where id_ = #{id}
+  </delete>
+  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.OperatingReport" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into operating_report (organ_id_, school_id_, sell_amount_, service_amount_, refund_amount_, 
+      income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, 
+      cost_amount_, profit_, month_, create_time_)
+    values (#{organId}, #{schoolId}, #{sellAmount}, #{serviceAmount}, #{refundAmount}, 
+      #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount}, 
+      #{costAmount}, #{profit}, #{month}, #{createTime})
+  </insert>
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReport">
+    <!--@mbg.generated-->
+    update operating_report
+    <set>
+      <if test="organId != null">
+        organ_id_ = #{organId},
+      </if>
+      <if test="schoolId != null">
+        school_id_ = #{schoolId},
+      </if>
+      <if test="sellAmount != null">
+        sell_amount_ = #{sellAmount},
+      </if>
+      <if test="serviceAmount != null">
+        service_amount_ = #{serviceAmount},
+      </if>
+      <if test="refundAmount != null">
+        refund_amount_ = #{refundAmount},
+      </if>
+      <if test="incomeTotal != null">
+        income_total_ = #{incomeTotal},
+      </if>
+      <if test="sellCost != null">
+        sell_cost_ = #{sellCost},
+      </if>
+      <if test="expensesAmount != null">
+        expenses_amount_ = #{expensesAmount},
+      </if>
+      <if test="variableCost != null">
+        variable_cost_ = #{variableCost},
+      </if>
+      <if test="distributionAmount != null">
+        distribution_amount_ = #{distributionAmount},
+      </if>
+      <if test="costAmount != null">
+        cost_amount_ = #{costAmount},
+      </if>
+      <if test="profit != null">
+        profit_ = #{profit},
+      </if>
+      <if test="month != null">
+        month_ = #{month},
+      </if>
+      <if test="createTime != null">
+        create_time_ = #{createTime},
+      </if>
+    </set>
+    where id_ = #{id}
+  </update>
+
+
+  <!-- 分页查询 -->
+  <select id="queryPage" resultMap="OperatingReport" parameterType="map">
+    SELECT opr.*,o.name_ organ_name_,s.name_ school_name_ FROM operating_report opr
+    LEFT JOIN organization o ON o.id_ = opr.organ_id_
+    LEFT JOIN school s ON s.id_= opr.school_id_
+    <include refid="queryPageSql"/>
+    ORDER BY opr.month_ DESC,opr.organ_id_ ASC
+    <include refid="global.limit"/>
+  </select>
+
+  <!-- 查询当前表的总记录数 -->
+  <select id="queryCount" resultType="int">
+    SELECT COUNT(*) FROM operating_report opr
+    <include refid="queryPageSql"/>
+  </select>
+
+  <sql id="queryPageSql">
+    <where>
+      <if test="organIdList != null and organIdList != ''">
+        AND FIND_IN_SET(opr.organ_id_,#{organIdList})
+      </if>
+      <if test="schoolId != null">
+        AND opr.school_id_ = #{schoolId}
+      </if>
+      <if test="startTime != null">
+        AND opr.month_ >= #{startTime}
+      </if>
+      <if test="endTime != null">
+        AND opr.month_ &lt;= #{endTime}
+      </if>
+    </where>
+  </sql>
+</mapper>

+ 187 - 0
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -0,0 +1,187 @@
+<?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.SellOrderDao">
+    <resultMap id="SellOrder" type="com.ym.mec.biz.dal.entity.SellOrder">
+        <!--@mbg.generated-->
+        <!--@Table sell_order-->
+        <id column="id_" property="id"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="school_id_" property="schoolId"/>
+        <result column="school_name_" property="schoolName"/>
+        <result column="trans_no_" property="transNo"/>
+        <result column="order_no_" property="orderNo"/>
+        <result column="order_id_" property="orderId"/>
+        <result column="expect_amount_" property="expectAmount"/>
+        <result column="actual_amount_" property="actualAmount"/>
+        <result column="balance_amount_" property="balanceAmount"/>
+        <result column="type_" property="type"/>
+        <result column="goods_id_" property="goodsId"/>
+        <result column="goods_name_" property="goodsName"/>
+        <result column="sell_cost_" property="sellCost"/>
+        <result column="sell_cost2_" property="sellCost2"/>
+        <result column="num_" property="num"/>
+        <result column="user_id_" property="userId"/>
+        <result column="user_name_" property="userName"/>
+        <result column="phone_" property="phone"/>
+        <result column="organ_name_" property="organName"/>
+        <result column="user_id_" property="userId"/>
+        <result column="payment_channel_" property="paymentChannel"/>
+        <result column="mer_no_" property="merNo"/>
+        <result column="sell_time_" property="sellTime"/>
+        <result column="create_ime_" property="createIme"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id_, organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_, payment_channel_,
+        mer_no_, sell_time_, create_ime_, update_time_
+    </sql>
+    <select id="get" parameterType="java.lang.Integer" resultMap="SellOrder">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from sell_order
+        where id_ = #{id}
+    </select>
+    <delete id="delete" parameterType="java.lang.Integer">
+        <!--@mbg.generated-->
+        delete from sell_order
+        where id_ = #{id}
+    </delete>
+    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SellOrder"
+            useGeneratedKeys="true">
+        <!--@mbg.generated-->
+        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
+        mer_no_, sell_time_, create_ime_, update_time_)
+        values (#{organId}, #{schoolId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount}, #{actualAmount},
+        #{balanceAmount}, #{type}, #{goodsId}, #{goodsName}, #{sellCost}, #{sellCost2}, #{num}, #{userId},
+        #{paymentChannel},
+        #{merNo}, #{sellTime}, #{createIme}, #{updateTime})
+    </insert>
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
+        <!--@mbg.generated-->
+        update sell_order
+        <set>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="schoolId != null">
+                school_id_ = #{schoolId},
+            </if>
+            <if test="transNo != null">
+                trans_no_ = #{transNo},
+            </if>
+            <if test="orderId != null">
+                order_id_ = #{orderId},
+            </if>
+            <if test="orderNo != null">
+                order_no_ = #{orderNo},
+            </if>
+            <if test="expectAmount != null">
+                expect_amount_ = #{expectAmount},
+            </if>
+            <if test="actualAmount != null">
+                actual_amount_ = #{actualAmount},
+            </if>
+            <if test="balanceAmount != null">
+                balance_amount_ = #{balanceAmount},
+            </if>
+            <if test="type != null">
+                type_ = #{type},
+            </if>
+            <if test="goodsId != null">
+                goods_id_ = #{goodsId},
+            </if>
+            <if test="goodsName != null">
+                goods_name_ = #{goodsName},
+            </if>
+            <if test="sellCost != null">
+                sell_cost_ = #{sellCost},
+            </if>
+            <if test="sellCost2 != null">
+                sell_cost2_ = #{sellCost2},
+            </if>
+            <if test="num != null">
+                num_ = #{num},
+            </if>
+            <if test="userId != null">
+                user_id_ = #{userId},
+            </if>
+            <if test="paymentChannel != null">
+                payment_channel_ = #{paymentChannel},
+            </if>
+            <if test="merNo != null">
+                mer_no_ = #{merNo},
+            </if>
+            <if test="sellTime != null">
+                sell_time_ = #{sellTime},
+            </if>
+            <if test="createIme != null">
+                create_ime_ = #{createIme},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = #{updateTime},
+            </if>
+        </set>
+        where id_ = #{id}
+    </update>
+
+    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
+        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
+        mer_no_, sell_time_, create_ime_, update_time_)
+        VALUE
+        <foreach collection="sellOrders" separator="," item="sellOrder">
+            (#{sellOrder.organId},#{sellOrder.schoolId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
+            #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.goodsId},
+            #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
+            #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.sellTime},#{sellOrder.createIme},#{sellOrder.updateTime})
+        </foreach>
+    </insert>
+
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SellOrder" parameterType="map">
+        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,s.name_ school_name_ FROM sell_order so
+        LEFT JOIN sys_user su ON so.user_id_ = su.id_
+        LEFT JOIN organization o ON o.id_ = so.organ_id_
+        LEFT JOIN school s ON s.id_= so.school_id_
+        <include refid="queryPageSql"/>
+        ORDER BY so.sell_time_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*) FROM sell_order so
+        <include refid="queryPageSql"/>
+    </select>
+
+    <sql id="queryPageSql">
+        <where>
+            <if test="search != null and search != ''">
+                AND (so.order_no_ = #{search} OR so.trans_no_ = #{search})
+            </if>
+            <if test="organIdList != null and organIdList != ''">
+                AND FIND_IN_SET(so.organ_id_,#{organIdList})
+            </if>
+            <if test="goodsName != null and goodsName != ''">
+                AND so.goods_name_ = #{goodsName}
+            </if>
+            <if test="schoolId != null">
+                AND so.school_id_ = #{schoolId}
+            </if>
+            <if test="type != null">
+                AND so.type_ = #{type}
+            </if>
+            <if test="startTime != null">
+                AND so.sell_time_ >= #{startTime}
+            </if>
+            <if test="endTime != null">
+                AND so.sell_time_ &lt;= #{endTime}
+            </if>
+        </where>
+    </sql>
+</mapper>

+ 14 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -15,6 +15,14 @@
         <result column="update_time_" property="updateTime"/>
         <result column="payment_order_id_" property="paymentOrderId"/>
         <result column="kit_group_purchase_type_" property="kitGroupPurchaseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
+            <result column="goods_id_" property="id"/>
+            <result column="goods_name_" property="name"/>
+            <result column="group_purchase_price_" property="groupPurchasePrice"/>
+            <result column="discount_price_" property="discountPrice"/>
+            <result column="agree_cost_price_" property="agreeCostPrice"/>
+            <result column="goods_type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        </collection>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -164,6 +172,12 @@
         SELECT * FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId} AND type_ = 'MUSICAL' LIMIT 1
     </select>
 
+    <select id="getOrderDetail" resultMap="StudentPaymentOrderDetail">
+        SELECT spod.*,g.id_ goods_id_,g.name_ goods_name_,g.group_purchase_price_,g.discount_price_,g.agree_cost_price_,g.type_ good_type_ FROM student_payment_order_detail spod
+                          LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
+        WHERE spod.payment_order_id_ = #{orderId} AND spod.goods_id_list_ IS NOT NULL
+    </select>
+
     <select id="getOrderDetailType" resultType="java.lang.String">
         SELECT DISTINCT type_ FROM student_payment_order_detail WHERE payment_order_id_ = #{orderId}
     </select>

+ 127 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java

@@ -0,0 +1,127 @@
+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.dao.EmployeeDao;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.OperatingReport;
+import com.ym.mec.biz.dal.page.OperatingReportQueryInfo;
+import com.ym.mec.biz.service.OperatingReportService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@Api(tags = "经营报表服务")
+@RequestMapping("operatingReport")
+@RestController
+public class OperatingReportController extends BaseController {
+
+    @Autowired
+    private OperatingReportService operatingReportService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeDao employeeDao;
+
+    @ApiOperation("报表列表")
+    @GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('operatingReport/queryPage')")
+    public HttpResponseResult<PageInfo<OperatingReport>> queryPage(OperatingReportQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganIdList())) {
+                queryInfo.setOrganIdList(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                return failed("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
+                    return failed("非法请求");
+                }
+            }
+        }
+        if (queryInfo.getMonth() != null) {
+            queryInfo.setStartTime(DateUtil.getFirstDayOfMonth(queryInfo.getMonth()));
+            queryInfo.setEndTime(DateUtil.getLastDayOfMonth(queryInfo.getMonth()));
+        }
+        return succeed(operatingReportService.queryPage(queryInfo));
+    }
+
+
+    @ApiOperation(value = "经营报表导出")
+    @GetMapping("/export")
+    @PreAuthorize("@pcs.hasPermissions('operatingReport/export')")
+    public void operatingReport(OperatingReportQueryInfo queryInfo, HttpServletResponse response) throws IOException {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new IOException("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganIdList())) {
+                queryInfo.setOrganIdList(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                throw new IOException("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
+                    throw new IOException("非法请求");
+                }
+            }
+        }
+        queryInfo.setRows(65000);
+        PageInfo<OperatingReport> pageList = operatingReportService.queryPage(queryInfo);
+        if (pageList.getTotal() <= 0) {
+            response.setStatus(200);
+            response.setContentType("Content-Type: application/json;charset=UTF-8");
+            response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
+            response.flushBuffer();
+            return;
+        }
+        OutputStream outputStream = response.getOutputStream();
+        try {
+
+            String[] header = {"分部","学校","销售收入(元)","服务收入(元)","业务退费(元)","收入合计(元)","销售成本(元)","固定支出(元)", "变动支出(元)", "分摊费用(元)", "成本费用合计(元)", "利润(元)"};
+            String[] body = {"organName", "schoolName", "sellAmount", "serviceAmount", "refundAmount", "incomeTotal", "sellCost","expensesAmount","variableCost","distributionAmount","costAmount","profit"};
+            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=cooperationOrgan-" + 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();
+                }
+            }
+        }
+    }
+}

+ 79 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

@@ -0,0 +1,79 @@
+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.dao.EmployeeDao;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.SellOrder;
+import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
+import com.ym.mec.biz.dal.page.SellOrderQueryInfo;
+import com.ym.mec.biz.service.SellOrderService;
+import com.ym.mec.biz.service.StudentRepairService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.date.DateUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.snaker.engine.access.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@RequestMapping("sellOrder")
+@Api(tags = "销售列表")
+@RestController
+public class SellOrderController extends BaseController {
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private SellOrderService sellOrderService;
+    @Autowired
+    private EmployeeDao employeeDao;
+
+    @ApiOperation("获取维修列表")
+    @GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('sellOrder/queryPage')")
+    public HttpResponseResult<PageInfo<SellOrder>> queryPage(SellOrderQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganIdList())) {
+                queryInfo.setOrganIdList(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                return failed("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
+                    return failed("非法请求");
+                }
+            }
+        }
+        if (queryInfo.getEndTime() != null) {
+            queryInfo.setEndTime(DateUtil.getLastTimeWithDay(queryInfo.getEndTime()));
+        }
+        return succeed(sellOrderService.queryPage(queryInfo));
+    }
+
+    @ApiOperation("更新")
+    @PostMapping(value = "/update")
+    @PreAuthorize("@pcs.hasPermissions('sellOrder/update')")
+    public SellOrder update(SellOrder sellOrder) {
+        sellOrderService.update(sellOrder);
+        return sellOrder;
+    }
+
+}

+ 5 - 5
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentRouteOrderController.java

@@ -24,10 +24,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.util.Arrays;
@@ -86,9 +83,12 @@ public class StudentPaymentRouteOrderController extends BaseController {
     @ApiOperation(value = "添加订单")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('routeOrder/add')")
-    public HttpResponseResult<StudentPaymentRouteOrderDto> add(StudentPaymentRouteOrderDto studentPaymentRouteOrderDto) {
+    public HttpResponseResult<StudentPaymentRouteOrderDto> add(@RequestBody StudentPaymentRouteOrderDto studentPaymentRouteOrderDto) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         studentPaymentRouteOrderDto.setUserId(sysUser.getId());
+        if (studentPaymentRouteOrderDto.getSchoolId() != null) {
+            studentPaymentRouteOrderDto.setMusicGroupId(studentPaymentRouteOrderDto.getSchoolId().toString());
+        }
         return succeed(studentPaymentRouteOrderService.addOutOrder(studentPaymentRouteOrderDto));
     }