diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCommisionController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCommisionController.java
index 11ec0ee1a..7a13103c0 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCommisionController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCommisionController.java
@@ -1,8 +1,11 @@
 package com.stdiet.web.controller.custom;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
 
+import com.stdiet.custom.domain.SysCommissionDayDetail;
+import com.stdiet.custom.service.ISysCommissionDayService;
 import com.stdiet.framework.web.domain.server.Sys;
 import com.stdiet.system.domain.CusSalesman;
 import com.stdiet.system.service.ISysUserService;
@@ -40,6 +43,9 @@ public class SysCommisionController extends BaseController {
     @Autowired
     private ISysUserService userService;
 
+    @Autowired
+    private ISysCommissionDayService sysCommissionDayService;
+
     /**
      * 查询业务提成比例列表
      */
@@ -181,4 +187,16 @@ public class SysCommisionController extends BaseController {
         }
         return getDataTable(list);
     }
+
+    /**
+     * 按天计算提成详细列表
+     * */
+    @PreAuthorize("@ss.hasPermi('commisionDay:detail:list')")
+    @GetMapping("/detailDay")
+    public TableDataInfo getDetailDay(SysCommision sysCommision) {
+        startPage();
+        return getDataTable(sysCommissionDayService.calculateCommissionByDay(sysCommision));
+    }
+
+
 }
diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java
index a326d3c4b..c1c85272d 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysOrderController.java
@@ -77,9 +77,9 @@ public class SysOrderController extends OrderBaseController {
                     order.setOperatorAssis(user.getNickName());
                 }
             }
-            if (order.getPhone() != null && !order.getPhone().equals("")) {
+            /*if (order.getPhone() != null && !order.getPhone().equals("")) {
                 order.setPhone(order.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
-            }
+            }*/
         }
         return getOrderDataTable(list, totalAmount);
     }
diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java
index fad84fe43..b85390db6 100644
--- a/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java
+++ b/stdiet-common/src/main/java/com/stdiet/common/utils/DateUtils.java
@@ -3,6 +3,10 @@ package com.stdiet.common.utils;
 import java.lang.management.ManagementFactory;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.Date;
 import org.apache.commons.lang3.time.DateFormatUtils;
 
@@ -152,4 +156,34 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         // long sec = diff % nd % nh % nm / ns;
         return day + "天" + hour + "小时" + min + "分钟";
     }
+
+    /**
+     * Date对象转LocalDateTime
+     * */
+    public static LocalDateTime dateToLocalDateTime(Date date){
+        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
+    }
+
+    /**
+     * LocalDateTime对象转Date
+     * */
+    public static Date localDateTimeToDate(LocalDateTime localDateTime){
+        ZonedDateTime zdt = LocalDateTime.now().atZone(ZoneId.systemDefault());
+        return Date.from(zdt.toInstant());
+    }
+
+    /**
+     * Date对象转LocalDate
+     * */
+    public static LocalDate dateToLocalDate(Date date){
+        return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+    }
+
+    /**
+     * LocalDate转Date
+     */
+    public static Date localDateToDate(LocalDate localDate) {
+        ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
+        return Date.from(zonedDateTime.toInstant());
+    }
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCommissionDayDetail.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCommissionDayDetail.java
new file mode 100644
index 000000000..20aaead1a
--- /dev/null
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCommissionDayDetail.java
@@ -0,0 +1,185 @@
+package com.stdiet.custom.domain;
+
+import com.stdiet.common.core.domain.BaseEntity;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+public class SysCommissionDayDetail extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    //用户ID
+    private Long userId;
+
+    //用户姓名
+    private String nickName;
+
+    //用户账户
+    private String userName;
+
+    //用户岗位ID
+    private Long postId;
+
+    //岗位名称
+    private String postName;
+
+    private BigDecimal totalCommissionAmount;
+
+    private BigDecimal totalHasSentCommissionAmount;
+
+    private BigDecimal totalNotSentCommissionAmount;
+
+    private List<Map<String, Object>> sendDetailList;
+
+
+    //提成比例
+    private Float rate;
+
+    //订单成交总额
+    private BigDecimal orderTotalAmount;
+
+    //服务总天数
+    private Integer serverTotalDay;
+
+    //服务总额(每笔订单的服务天数 * 每天金额,相加)
+    private BigDecimal serverTotalAmount;
+
+    //服务订单总数量
+    private Integer serverOrderTotalCount;
+
+    //服务暂停总天数
+    private Integer serverOrderPauseTotalDay;
+
+    //服务提成金额
+    private BigDecimal commissionTotalAmount;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getPostName() {
+        return postName;
+    }
+
+    public void setPostName(String postName) {
+        this.postName = postName;
+    }
+
+    public Float getRate() {
+        return rate;
+    }
+
+    public void setRate(Float rate) {
+        this.rate = rate;
+    }
+
+    public BigDecimal getOrderTotalAmount() {
+        return orderTotalAmount;
+    }
+
+    public void setOrderTotalAmount(BigDecimal orderTotalAmount) {
+        this.orderTotalAmount = orderTotalAmount;
+    }
+
+    public Integer getServerTotalDay() {
+        return serverTotalDay;
+    }
+
+    public void setServerTotalDay(Integer serverTotalDay) {
+        this.serverTotalDay = serverTotalDay;
+    }
+
+    public BigDecimal getServerTotalAmount() {
+        return serverTotalAmount;
+    }
+
+    public void setServerTotalAmount(BigDecimal serverTotalAmount) {
+        this.serverTotalAmount = serverTotalAmount;
+    }
+
+    public Integer getServerOrderTotalCount() {
+        return serverOrderTotalCount;
+    }
+
+    public void setServerOrderTotalCount(Integer serverOrderTotalCount) {
+        this.serverOrderTotalCount = serverOrderTotalCount;
+    }
+
+    public Integer getServerOrderPauseTotalDay() {
+        return serverOrderPauseTotalDay;
+    }
+
+    public void setServerOrderPauseTotalDay(Integer serverOrderPauseTotalDay) {
+        this.serverOrderPauseTotalDay = serverOrderPauseTotalDay;
+    }
+
+    public BigDecimal getCommissionTotalAmount() {
+        return commissionTotalAmount;
+    }
+
+    public void setCommissionTotalAmount(BigDecimal commissionTotalAmount) {
+        this.commissionTotalAmount = commissionTotalAmount;
+    }
+
+    public Long getPostId() {
+        return postId;
+    }
+
+    public void setPostId(Long postId) {
+        this.postId = postId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public BigDecimal getTotalCommissionAmount() {
+        return totalCommissionAmount;
+    }
+
+    public void setTotalCommissionAmount(BigDecimal totalCommissionAmount) {
+        this.totalCommissionAmount = totalCommissionAmount;
+    }
+
+    public BigDecimal getTotalHasSentCommissionAmount() {
+        return totalHasSentCommissionAmount;
+    }
+
+    public void setTotalHasSentCommissionAmount(BigDecimal totalHasSentCommissionAmount) {
+        this.totalHasSentCommissionAmount = totalHasSentCommissionAmount;
+    }
+
+    public BigDecimal getTotalNotSentCommissionAmount() {
+        return totalNotSentCommissionAmount;
+    }
+
+    public void setTotalNotSentCommissionAmount(BigDecimal totalNotSentCommissionAmount) {
+        this.totalNotSentCommissionAmount = totalNotSentCommissionAmount;
+    }
+
+    public List<Map<String, Object>> getSendDetailList() {
+        return sendDetailList;
+    }
+
+    public void setSendDetailList(List<Map<String, Object>> sendDetailList) {
+        this.sendDetailList = sendDetailList;
+    }
+}
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrder.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrder.java
index 533ed121c..eee9e056e 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrder.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrder.java
@@ -2,6 +2,7 @@ package com.stdiet.custom.domain;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -173,7 +174,7 @@ public class SysOrder extends BaseEntity {
      * 赠送时长
      */
     @Excel(name = "赠送时长", width = 30, suffix = "天")
-    private String giveServeDay;
+    private Integer giveServeDay;
 
     private Long serveTimeId;
 
@@ -187,6 +188,11 @@ public class SysOrder extends BaseEntity {
     @Excel(name = "成交时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date orderTime;
 
+    /**
+     * 订单暂停记录 非持久化字段
+     * */
+    private List<SysOrderPause> orderPauseList;
+
     @JsonFormat(pattern = "yyyy-MM-dd")
     public Date getStartTime() {
         return startTime;
@@ -454,14 +460,22 @@ public class SysOrder extends BaseEntity {
         return orderTime;
     }
 
-    public String getGiveServeDay() {
+    public Integer getGiveServeDay() {
         return giveServeDay;
     }
 
-    public void setGiveServeDay(String giveServeDay) {
+    public void setGiveServeDay(Integer giveServeDay) {
         this.giveServeDay = giveServeDay;
     }
 
+    public List<SysOrderPause> getOrderPauseList() {
+        return orderPauseList;
+    }
+
+    public void setOrderPauseList(List<SysOrderPause> orderPauseList) {
+        this.orderPauseList = orderPauseList;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderCommisionDayDetail.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderCommisionDayDetail.java
new file mode 100644
index 000000000..7d9ff4f04
--- /dev/null
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysOrderCommisionDayDetail.java
@@ -0,0 +1,152 @@
+package com.stdiet.custom.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.stdiet.common.annotation.Excel;
+import com.stdiet.common.core.domain.BaseEntity;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Map;
+
+/**
+ * 每个订单的提成详情
+ * */
+public class SysOrderCommisionDayDetail extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**订单成交时间*/
+    private LocalDateTime orderTime;
+
+    /**客户姓名*/
+    private String name;
+
+    /**服务结束时间*/
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "成交时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private LocalDate serverStartDate;
+
+    /**服务结束时间*/
+    private LocalDate serverEndDate;
+
+    /**服务月数*/
+    private Integer serverMonth;
+
+    /**赠送天数*/
+    private Integer giveDay;
+
+    /**订单金额*/
+    private BigDecimal orderAmount;
+
+    /**服务天数*/
+    private Integer serverDay;
+
+    /**每天金额*/
+    private BigDecimal dayMoney;
+
+    /**每年每月暂停天数*/
+    private Map<String, Integer> everyYearMonthPauseDay;
+
+    /**每年每月服务天数**/
+    private Map<String, Integer> everyYearMonthServerDay;
+
+    /**每年每月对应金额*/
+    private Map<String, BigDecimal> everyYearMonthServerMoney;
+
+    public LocalDateTime getOrderTime() {
+        return orderTime;
+    }
+
+    public void setOrderTime(LocalDateTime orderTime) {
+        this.orderTime = orderTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public LocalDate getServerStartDate() {
+        return serverStartDate;
+    }
+
+    public void setServerStartDate(LocalDate serverStartDate) {
+        this.serverStartDate = serverStartDate;
+    }
+
+    public LocalDate getServerEndDate() {
+        return serverEndDate;
+    }
+
+    public void setServerEndDate(LocalDate serverEndDate) {
+        this.serverEndDate = serverEndDate;
+    }
+
+    public Integer getServerMonth() {
+        return serverMonth;
+    }
+
+    public void setServerMonth(Integer serverMonth) {
+        this.serverMonth = serverMonth;
+    }
+
+    public Integer getGiveDay() {
+        return giveDay;
+    }
+
+    public void setGiveDay(Integer giveDay) {
+        this.giveDay = giveDay;
+    }
+
+    public BigDecimal getOrderAmount() {
+        return orderAmount;
+    }
+
+    public void setOrderAmount(BigDecimal orderAmount) {
+        this.orderAmount = orderAmount;
+    }
+
+    public Integer getServerDay() {
+        return serverDay;
+    }
+
+    public void setServerDay(Integer serverDay) {
+        this.serverDay = serverDay;
+    }
+
+    public BigDecimal getDayMoney() {
+        return dayMoney;
+    }
+
+    public void setDayMoney(BigDecimal dayMoney) {
+        this.dayMoney = dayMoney;
+    }
+
+    public Map<String, Integer> getEveryYearMonthPauseDay() {
+        return everyYearMonthPauseDay;
+    }
+
+    public void setEveryYearMonthPauseDay(Map<String, Integer> everyYearMonthPauseDay) {
+        this.everyYearMonthPauseDay = everyYearMonthPauseDay;
+    }
+
+    public Map<String, Integer> getEveryYearMonthServerDay() {
+        return everyYearMonthServerDay;
+    }
+
+    public void setEveryYearMonthServerDay(Map<String, Integer> everyYearMonthServerDay) {
+        this.everyYearMonthServerDay = everyYearMonthServerDay;
+    }
+
+    public Map<String, BigDecimal> getEveryYearMonthServerMoney() {
+        return everyYearMonthServerMoney;
+    }
+
+    public void setEveryYearMonthServerMoney(Map<String, BigDecimal> everyYearMonthServerMoney) {
+        this.everyYearMonthServerMoney = everyYearMonthServerMoney;
+    }
+}
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCommisionMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCommisionMapper.java
index a89d473c9..cca1dbfc3 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCommisionMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCommisionMapper.java
@@ -60,4 +60,6 @@ public interface SysCommisionMapper
     public int deleteSysCommisionByIds(Long[] ruleIds);
 
     public List<SysCommision> selectSysCommisionDetail(SysCommision sysCommision);
+
+    List<SysCommision> selectSysCommisionDayDetail(SysCommision sysCommision);
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderMapper.java
index f1d2b98f8..1ae261f20 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysOrderMapper.java
@@ -3,6 +3,7 @@ package com.stdiet.custom.mapper;
 import java.math.BigDecimal;
 import java.util.List;
 import com.stdiet.custom.domain.SysOrder;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 销售订单Mapper接口
@@ -66,4 +67,10 @@ public interface SysOrderMapper
      * @return
      */
     public BigDecimal selectAllOrderAmount(SysOrder sysOrder);
+
+    /**
+     * 获取订单信息
+     * @return
+     */
+    List<SysOrder> selectSimpleOrderMessage(@Param("userId") Long userId);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommisionService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommisionService.java
index bbfa7259a..e39a7ae56 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommisionService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommisionService.java
@@ -1,6 +1,8 @@
 package com.stdiet.custom.service;
 
 import java.util.List;
+import java.util.Set;
+
 import com.stdiet.custom.domain.SysCommision;
 
 /**
@@ -60,4 +62,6 @@ public interface ISysCommisionService
     public int deleteSysCommisionById(Long ruleId);
 
     public List<SysCommision> selectSysCommisionDetail(SysCommision sysCommision);
+
+    List<SysCommision> selectSysCommisionDayDetail(SysCommision sysCommision);
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommissionDayService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommissionDayService.java
new file mode 100644
index 000000000..c5693fea1
--- /dev/null
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCommissionDayService.java
@@ -0,0 +1,20 @@
+package com.stdiet.custom.service;
+
+import com.stdiet.custom.domain.SysCommision;
+import com.stdiet.custom.domain.SysCommissionDayDetail;
+import com.stdiet.custom.domain.SysOrderCommisionDayDetail;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 按天计算提成
+ *
+ * @author wonder
+ * @date 2020-09-24
+ */
+public interface ISysCommissionDayService {
+
+    List<SysCommissionDayDetail> calculateCommissionByDay(SysCommision sysCommision);
+
+}
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommisionServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommisionServiceImpl.java
index 8cfa7824e..b043f756e 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommisionServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommisionServiceImpl.java
@@ -98,4 +98,9 @@ public class SysCommisionServiceImpl implements ISysCommisionService
     public List<SysCommision> selectSysCommisionDetail(SysCommision sysCommision) {
         return sysCommisionMapper.selectSysCommisionDetail(sysCommision);
     }
+
+    @Override
+    public List<SysCommision> selectSysCommisionDayDetail(SysCommision sysCommision){
+        return sysCommisionMapper.selectSysCommisionDayDetail(sysCommision);
+    }
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java
new file mode 100644
index 000000000..452c16517
--- /dev/null
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java
@@ -0,0 +1,477 @@
+package com.stdiet.custom.service.impl;
+
+import com.stdiet.common.utils.DateUtils;
+import com.stdiet.common.utils.StringUtils;
+import com.stdiet.custom.domain.*;
+import com.stdiet.custom.mapper.SysCommisionMapper;
+import com.stdiet.custom.mapper.SysOrderMapper;
+import com.stdiet.custom.mapper.SysOrderPauseMapper;
+import com.stdiet.custom.service.ISysCommisionService;
+import com.stdiet.custom.service.ISysCommissionDayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
+import java.util.*;
+
+@Service
+public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
+
+    @Autowired
+    private SysCommisionMapper sysCommisionMapper;
+
+    @Autowired
+    private SysOrderMapper sysOrderMapper;
+
+    @Autowired
+    private SysOrderPauseMapper sysOrderPauseMapper;
+
+    @Override
+    public List<SysCommissionDayDetail> calculateCommissionByDay(SysCommision sysCommision){
+        List<SysCommissionDayDetail> result = new ArrayList<>();
+        //查询用户
+        List<SysCommision> list = sysCommisionMapper.selectSysCommisionDayDetail(sysCommision);
+        if(list != null && list.size() > 0){
+            Map<Long, List<SysOrderCommisionDayDetail>> orderDetailMap = getOrderByList(null);
+            SysCommissionDayDetail sysCommissionDayDetail = null;
+            for(SysCommision commision : list){
+                sysCommissionDayDetail = new SysCommissionDayDetail();
+                sysCommissionDayDetail.setUserId(commision.getUserId());
+                sysCommissionDayDetail.setNickName(commision.getUserName());
+                sysCommissionDayDetail.setPostId(commision.getPostId());
+                sysCommissionDayDetail.setPostName(commision.getPostName());
+                sysCommissionDayDetail.setOrderTotalAmount(commision.getAmount());
+                //获取查询时间
+                LocalDate localDate = StringUtils.isEmpty(sysCommision.getBeginTime()) ? LocalDate.now() : LocalDate.parse(sysCommision.getBeginTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                //dealServerOrderCommissionDetail2(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail, localDate.getYear()+""+localDate.getMonth().getValue());
+                dealServerOrderCommissionDetail2(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail);
+                result.add(sysCommissionDayDetail);
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * 根据用户ID统计出该用户在该月所有订单的服务数量、服务总天数、服务订单总额、暂停总天数
+     * **/
+    public void dealServerOrderCommissionDetail2(List<SysOrderCommisionDayDetail> orderDetailList, SysCommissionDayDetail sysCommissionDayDetail){
+        //总提成
+        double totalCommissionAmount = 0.0;
+        //已发放提成
+        double totalHasSentCommissionAmount = 0.0;
+        //未发放提成
+        double totalNotSentCommissionAmount = 0.0;
+        //未发放提成记录
+        List<Map<String, Object>> sendDetailList = new ArrayList<>();
+        if(orderDetailList != null){
+            //获取每个月的成交总额度
+            Map<String, Double> orderAmount = new TreeMap<>(new MyComparator());
+            Set<String> commissionMonthSet = new TreeSet<>(new MyComparator());
+            for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
+                String yearMonth = sysOrderCommisionDayDetail.getOrderTime().getYear()+""+sysOrderCommisionDayDetail.getOrderTime().getMonth().getValue();
+                if(orderAmount.containsKey(yearMonth)){
+                    orderAmount.put(yearMonth, orderAmount.get(yearMonth) + sysOrderCommisionDayDetail.getOrderAmount().doubleValue());
+                }else{
+                    orderAmount.put(yearMonth, sysOrderCommisionDayDetail.getOrderAmount().doubleValue());
+                }
+                commissionMonthSet.addAll(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().keySet());
+            }
+            //获取提成比例以及计算提成
+            Map<String, Float> rateMap = getRateByAmount2(sysCommissionDayDetail.getUserId(), sysCommissionDayDetail.getPostId(), orderAmount);
+
+            int i = 1;
+            double commissionA = 0D;
+            for (String ym : commissionMonthSet) {
+                double ym_mession = 0;
+                if(orderAmount.containsKey(ym)){
+                    totalCommissionAmount += orderAmount.get(ym) * rateMap.get(ym) / 100D;
+                }
+                for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
+                    Map<String, BigDecimal> everyYearMonthServerMoney = sysOrderCommisionDayDetail.getEveryYearMonthServerMoney();
+                    if(everyYearMonthServerMoney.containsKey(ym)){
+                        String orderYearMonth = sysOrderCommisionDayDetail.getOrderTime().getYear()+""+sysOrderCommisionDayDetail.getOrderTime().getMonth().getValue();
+                        double m = (everyYearMonthServerMoney.get(ym) == null) ? 0 : everyYearMonthServerMoney.get(ym).doubleValue();
+                        ym_mession += m * rateMap.get(orderYearMonth) / 100D;
+                    }
+                }
+                if(isSendCommissionByYearMonth(ym)){
+                    totalHasSentCommissionAmount += ym_mession;
+                }else{
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("yearMonth", ym);
+                    if(i++ != commissionMonthSet.size()){
+                        map.put("yearMonthCommission", getMoney(ym_mession, 1));
+                    }else{
+                        System.out.println("最后:"+commissionA);
+                        map.put("yearMonthCommission", getMoney(totalCommissionAmount - commissionA, 1));
+                    }
+                    sendDetailList.add(map);
+                }
+                commissionA += getMoney(ym_mession, 1).doubleValue();
+
+            }
+        }
+        sysCommissionDayDetail.setTotalCommissionAmount(getMoney(totalCommissionAmount,1));
+        sysCommissionDayDetail.setTotalHasSentCommissionAmount(getMoney(totalHasSentCommissionAmount,1));
+        sysCommissionDayDetail.setTotalNotSentCommissionAmount(getMoney(totalCommissionAmount - totalHasSentCommissionAmount,1));
+        sysCommissionDayDetail.setSendDetailList(sendDetailList);
+    }
+
+    public boolean isSendCommissionByYearMonth(String yearMonth){
+        LocalDate localDate = LocalDate.of(Integer.parseInt(yearMonth.substring(0,4)), Integer.parseInt(yearMonth.substring(4)), 1);
+        LocalDate nowDate = LocalDate.now();
+        if(localDate.getMonth().getValue() >= 0){
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 根据用户成交总额获取对应比例,再计算提成
+     * */
+    public Map<String, Float> getRateByAmount2(Long userId, Long postId, Map<String, Double> amountMap){
+        SysCommision tmpQueryCom = new SysCommision();
+        tmpQueryCom.setUserId(userId);
+        tmpQueryCom.setPostId(postId);
+        List<SysCommision> tmpComList = sysCommisionMapper.selectSysCommisionList(tmpQueryCom);
+        Map<String, Float> rateMap = new TreeMap<>(new MyComparator());
+        for(String yearMonth : amountMap.keySet()){
+            double orderAmount = amountMap.get(yearMonth);
+            rateMap.put(yearMonth, 0F);
+            if(tmpComList != null && tmpComList.size() > 0){
+                for (int i = 0; i < tmpComList.size(); i++) {
+                    SysCommision com = tmpComList.get(i);
+                    double cAmount = com.getAmount().floatValue();
+                    if (orderAmount <= cAmount && i == 0) {
+                        // 第一条规则
+                        rateMap.put(yearMonth,com.getRate());
+                        break;
+                    } else if (i == tmpComList.size() - 1 && orderAmount > cAmount) {
+                        // 最后一条规则
+                        rateMap.put(yearMonth,com.getRate());
+                        break;
+                    } else if (cAmount < orderAmount && orderAmount <= tmpComList.get(i + 1).getAmount().floatValue()) {
+                        // 中间规则
+                        rateMap.put(yearMonth,tmpComList.get(i + 1).getRate());
+                        break;
+                    }
+                }
+            }
+        }
+        return rateMap;
+    }
+
+    /**
+     * 根据用户ID统计出该用户在该月所有订单的服务数量、服务总天数、服务订单总额、暂停总天数
+     * **/
+    public void dealServerOrderCommissionDetail(List<SysOrderCommisionDayDetail> orderDetailList, SysCommissionDayDetail sysCommissionDayDetail, String yearMonth){
+        //服务订单数量
+        int serverOrderCount = 0;
+        //服务总天数
+        int serverTotalDay = 0;
+        //服务订单总金额
+        double serverTotalAmount = 0.0;
+        //暂停总天数
+        int pauseTotalDay = 0;
+        if(orderDetailList != null){
+            for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
+                //Map<String, Integer> dayMap = ((Map<String, Integer>)orderMap.get("everyYearMonthServerDay"));
+                if(sysOrderCommisionDayDetail.getEveryYearMonthServerDay() != null && sysOrderCommisionDayDetail.getEveryYearMonthServerDay().containsKey(yearMonth)){
+                    int day = sysOrderCommisionDayDetail.getEveryYearMonthServerDay().get(yearMonth).intValue();
+                    serverTotalDay += day;
+                    serverOrderCount += day > 0 ? 1 : 0;
+                }
+                if(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney() != null && sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().containsKey(yearMonth)){
+                    serverTotalAmount += sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().get(yearMonth).doubleValue();
+                }
+                //dayMap = ((Map<String, Integer>)orderMap.get("everyYearMonthPauseDay"));
+                if(sysOrderCommisionDayDetail.getEveryYearMonthPauseDay() != null && sysOrderCommisionDayDetail.getEveryYearMonthPauseDay().containsKey(yearMonth)){
+                    pauseTotalDay += sysOrderCommisionDayDetail.getEveryYearMonthPauseDay().get(yearMonth).intValue();
+                }
+            }
+        }
+        sysCommissionDayDetail.setServerOrderTotalCount(serverOrderCount);
+        sysCommissionDayDetail.setServerTotalDay(serverTotalDay);
+        sysCommissionDayDetail.setServerTotalAmount(getMoney(serverTotalAmount, 1));
+        sysCommissionDayDetail.setServerOrderPauseTotalDay(pauseTotalDay);
+        //获取提成比例以及计算提成
+        getRateByAmount(sysCommissionDayDetail);
+
+    }
+
+    /**
+     * 根据用户成交总额获取对应比例,再计算提成
+     * */
+    public void getRateByAmount(SysCommissionDayDetail sysCommissionDayDetail){
+        SysCommision tmpQueryCom = new SysCommision();
+        tmpQueryCom.setUserId(sysCommissionDayDetail.getUserId());
+        tmpQueryCom.setPostId(sysCommissionDayDetail.getPostId());
+        List<SysCommision> tmpComList = sysCommisionMapper.selectSysCommisionList(tmpQueryCom);
+        double orderAmount = sysCommissionDayDetail.getOrderTotalAmount().doubleValue();
+        sysCommissionDayDetail.setRate(0F);
+        sysCommissionDayDetail.setCommissionTotalAmount(getMoney(0.0D, 1));
+        if(tmpComList != null && tmpComList.size() > 0){
+            for (int i = 0; i < tmpComList.size(); i++) {
+                SysCommision com = tmpComList.get(i);
+                double cAmount = com.getAmount().floatValue();
+                if (orderAmount <= cAmount && i == 0) {
+                    // 第一条规则
+                    sysCommissionDayDetail.setRate(com.getRate());
+                    break;
+                } else if (i == tmpComList.size() - 1 && orderAmount > cAmount) {
+                    // 最后一条规则
+                    sysCommissionDayDetail.setRate(com.getRate());
+                    break;
+                } else if (cAmount < orderAmount && orderAmount <= tmpComList.get(i + 1).getAmount().floatValue()) {
+                    // 中间规则
+                    sysCommissionDayDetail.setRate(tmpComList.get(i + 1).getRate());
+                    break;
+                }
+            }
+        }
+        double serverAmount = sysCommissionDayDetail.getServerTotalAmount().doubleValue();
+        serverAmount = serverAmount * sysCommissionDayDetail.getRate() / 100D;
+        sysCommissionDayDetail.setCommissionTotalAmount(getMoney(serverAmount, 1));
+    }
+
+    /**
+     * 查询2021年1月份之后所有订单,对订单进行处理,得出每笔订单的相关信息
+     * */
+    public Map<Long, List<SysOrderCommisionDayDetail>> getOrderByList(Long userId){
+        //查询2021年1月份之后所有订单
+        List<SysOrder> orderList = sysOrderMapper.selectSimpleOrderMessage(userId);
+        //整理出每个用户对应的订单List
+        Map<Long, List<SysOrderCommisionDayDetail>> userOrderResultMap = new HashMap<>();
+        for (SysOrder sysOrder : orderList) {
+            //建档时间为空、售后人员ID为空、营养师ID为空、订单金额为空或小于0,都视为异常订单
+            if(sysOrder.getStartTime() == null || sysOrder.getAfterSaleId() == null || sysOrder.getNutritionistId() == null
+                    || sysOrder.getAmount() == null || sysOrder.getAmount().doubleValue() < 0){
+                System.out.println("客户:"+ sysOrder.getCustomer() +",营养师:"+sysOrder.getNutritionist() + ",售后" + sysOrder.getAfterSale());
+                continue;
+            }
+            //对每笔订单进行处理,统计出该比订单在每年每月对应的服务天数、金额、暂停天数等
+            SysOrderCommisionDayDetail sysOrderCommisionDayDetail = statisticsOrderMessage(sysOrder);
+            addUserOrderResultMap(sysOrder.getAfterSaleId(), sysOrderCommisionDayDetail, userOrderResultMap);
+            addUserOrderResultMap(sysOrder.getNutritionistId(), sysOrderCommisionDayDetail, userOrderResultMap);
+        }
+        return userOrderResultMap;
+    }
+
+    /**
+     * 根据用户ID将订单添加到对应用户的订单List
+     * */
+    public void addUserOrderResultMap(Long id, SysOrderCommisionDayDetail sysOrderCommisionDayDetail, Map<Long, List<SysOrderCommisionDayDetail>> map){
+        if(map.containsKey(id)){
+            map.get(id).add(sysOrderCommisionDayDetail);
+        }else{
+            List<SysOrderCommisionDayDetail> orderMessageMapList = new ArrayList<>();
+            orderMessageMapList.add(sysOrderCommisionDayDetail);
+            map.put(id, orderMessageMapList);
+        }
+    }
+
+    /**
+     * 统计每笔订单的服务开始时间、结束时间、每年每月服务天数、服务金额、服务暂停天数等信息
+     * */
+    public SysOrderCommisionDayDetail statisticsOrderMessage(SysOrder sysOrder){
+        //服务开始时间(客户建档时间)
+        LocalDate serverStartDate = DateUtils.dateToLocalDate(sysOrder.getStartTime());
+        //订单总服务月数
+        int serverMonth = sysOrder.getServeTimeId().intValue()/30;
+        //赠送时长
+        int giveDay = sysOrder.getGiveServeDay().intValue();
+        //订单金额
+        BigDecimal orderAmount = sysOrder.getAmount();
+        //每年每月暂停天数,key为年份加月份,如:2021年1月=20211
+        Map<String, Integer> everyYearMonthPauseDay = getEveryYearMonthPauseDay(sysOrder.getOrderPauseList());
+        //该笔订单暂停总天数
+        int pauseTotalDay = getTotalByMap(everyYearMonthPauseDay);
+        //根据开始时间、服务月数、赠送天数、暂停天数算出该笔订单服务到期时间
+        LocalDate serverEndDate = getServerEndDate(serverStartDate, serverMonth, giveDay, pauseTotalDay);
+        //计算每年每月服务天数
+        Map<String, Integer> everyYearMonthServerDay = getEveryYearMonthDayCount(serverStartDate, serverEndDate, everyYearMonthPauseDay);
+        //服务总天数
+        int serverDay = getTotalByMap(everyYearMonthServerDay);
+        //每天对应金额
+        BigDecimal dayMoney = getMoney(orderAmount.doubleValue()/serverDay, 1);
+        //每年每月对于金额
+        Map<String, BigDecimal> everyYearMonthServerMoney = getEveryMonthServerMoney(everyYearMonthServerDay, orderAmount, dayMoney);
+
+        SysOrderCommisionDayDetail sysOrderCommisionDayDetail = new SysOrderCommisionDayDetail();
+        sysOrderCommisionDayDetail.setOrderTime(DateUtils.dateToLocalDateTime(sysOrder.getOrderTime()));
+        sysOrderCommisionDayDetail.setName(sysOrder.getCustomer());
+        sysOrderCommisionDayDetail.setServerStartDate(serverStartDate);
+        sysOrderCommisionDayDetail.setServerEndDate(serverEndDate);
+        sysOrderCommisionDayDetail.setServerMonth(serverMonth);
+        sysOrderCommisionDayDetail.setGiveDay(giveDay);
+        sysOrderCommisionDayDetail.setOrderAmount(orderAmount);
+        sysOrderCommisionDayDetail.setServerDay(serverDay);
+        sysOrderCommisionDayDetail.setDayMoney(dayMoney);
+        sysOrderCommisionDayDetail.setEveryYearMonthPauseDay(everyYearMonthPauseDay);
+        sysOrderCommisionDayDetail.setEveryYearMonthServerDay(everyYearMonthServerDay);
+        sysOrderCommisionDayDetail.setEveryYearMonthServerMoney(everyYearMonthServerMoney);
+        return sysOrderCommisionDayDetail;
+    }
+
+    /**
+     * 获取每年每月暂停天数
+     * @Param list 暂停记录集合
+     * */
+    public Map<String, Integer> getEveryYearMonthPauseDay(List<SysOrderPause> list){
+        Map<String, Integer> pauseMap = new TreeMap<>(new MyComparator());
+        for (SysOrderPause sysOrderPause : list) {
+            if(sysOrderPause.getPauseStartDate() == null || sysOrderPause.getPauseEndDate() == null){
+                continue;
+            }
+            LocalDate pauseStartDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseStartDate());
+            LocalDate pauseEndDate = DateUtils.dateToLocalDate(sysOrderPause.getPauseEndDate());
+            //根据暂停记录获取该条记录在每年每月的暂停天数
+            Map<String, Integer> orderYearMonthPauseDay = getEveryYearMonthDayCount(pauseStartDate, pauseEndDate, null);
+            //每条暂停记录的暂停天数进行汇总
+            for (String key : orderYearMonthPauseDay.keySet()) {
+                if(pauseMap.containsKey(key)){
+                    pauseMap.put(key, pauseMap.get(key) + orderYearMonthPauseDay.get(key));
+                }else{
+                    pauseMap.put(key, orderYearMonthPauseDay.get(key));
+                }
+            }
+        }
+        return pauseMap;
+    }
+
+    /**
+     * 获取Map集合中Value的总和
+     * */
+    public int getTotalByMap(Map<String, Integer> map){
+        int total = 0;
+        for(String key : map.keySet()){
+            total += map.get(key).intValue();
+        }
+        return total;
+    }
+
+    /**
+     * 获取订单服务时间范围中每年每月服务天数,减去当月暂停天数
+     * @Param server_start_date 服务开始时间
+     * @Param server_end_date   服务到期时间
+     * @Param pauseDayMap       每年每月暂停天数Map
+     * */
+    public Map<String, Integer> getEveryMonthServerDay(LocalDate server_start_date, LocalDate server_end_date, Map<String, Integer> pauseDayMap){
+        return getEveryYearMonthDayCount(server_start_date, server_end_date, pauseDayMap);
+    }
+
+    /**
+     * 获取订单服务时间范围中每年每月服务金额
+     * @Param everyMonthServerDay 每年每月服务天数
+     * @Param orderMoney 订单总额
+     * @Param dayMoney 每天对于金额
+     * */
+    public Map<String, BigDecimal> getEveryMonthServerMoney(Map<String, Integer> everyMonthServerDay, BigDecimal orderMoney, BigDecimal dayMoney){
+        Map<String, BigDecimal > everyMonthServerMoney = new TreeMap<>(new MyComparator());
+        Set<String> keySet = everyMonthServerDay.keySet();
+        int i = 1;
+        double totalMoney = 0.0;
+        for(String key : keySet){
+            if(i++ != keySet.size()){
+                everyMonthServerMoney.put(key, getMoney(everyMonthServerDay.get(key) * dayMoney.doubleValue(), 1));
+                totalMoney += everyMonthServerMoney.get(key).doubleValue();
+            }else{
+                //由于小数点只保留一位,最后一个月的金额等于总额减去前几个月金额,避免总数不一致
+                everyMonthServerMoney.put(key, getMoney(orderMoney.doubleValue() - totalMoney, 1));
+            }
+        }
+        return everyMonthServerMoney;
+    }
+
+
+    /**
+     * 根据开始日期、结束日期统计出时间范围内每年每月对应的天数
+     * */
+    public Map<String, Integer> getEveryYearMonthDayCount(LocalDate startDate, LocalDate endDate, Map<String, Integer> lessDayMap){
+        Map<String, Integer> everyYearMonthServerDay = new TreeMap<>(new MyComparator());
+        //每月开始第一天
+        LocalDate everyMonthFirstDate = startDate;
+        //每月最后一天
+        LocalDate everyMonthLastDate = everyMonthFirstDate.with(TemporalAdjusters.lastDayOfMonth());
+        int day = 0;
+        boolean breakFlag = false;
+        //写100防止死循环
+        for(int i = 0; i < 100; i++){
+            if(ChronoUnit.DAYS.between(everyMonthLastDate, endDate) >= 0){
+                day = Period.between(everyMonthFirstDate, everyMonthLastDate).getDays() + 1;
+            }else{
+                day = Period.between(everyMonthFirstDate, endDate).getDays() + 1;
+                breakFlag = true;
+            }
+            String key = everyMonthFirstDate.getYear()+""+everyMonthFirstDate.getMonth().getValue();
+            day -= (lessDayMap == null || lessDayMap.get(key) == null) ? 0 : lessDayMap.get(key);
+            everyYearMonthServerDay.put(key, day >= 0 ? day : 0);
+            everyMonthFirstDate = (everyMonthFirstDate.plusMonths(1));
+            everyMonthFirstDate = everyMonthFirstDate.of(everyMonthFirstDate.getYear(), everyMonthFirstDate.getMonthValue(), 1);
+            everyMonthLastDate = everyMonthFirstDate.with(TemporalAdjusters.lastDayOfMonth());
+            if(breakFlag){
+                break;
+            }
+        }
+        return everyYearMonthServerDay;
+    }
+
+    /**
+     * 根据服务月数、赠送时长、暂停天数计算出服务截止日期
+     * **/
+    public LocalDate getServerEndDate(LocalDate server_start_date, int server_month, int give_daye, int pauseDayCount){
+        return server_start_date.plusMonths(server_month).plusDays(give_daye + pauseDayCount);
+    }
+
+    /**
+     * double转为BigDecimal,保留一位小数,向下舍去
+     * */
+    public BigDecimal getMoney(double money, int n){
+        return new BigDecimal(money).setScale(n, RoundingMode.DOWN);
+    }
+
+    /**
+     * 集合排序key值比较器
+     * */
+    class MyComparator implements Comparator<String>{
+
+        @Override
+        public int compare(String o1, String o2) {
+            return Integer.parseInt(o1) - Integer.parseInt(o2);
+        }
+    }
+
+    public static void main(String[] args){
+        DecimalFormat df = new DecimalFormat("#.#");
+        BigDecimal money = new BigDecimal(3300.00/91);
+        System.out.println(Period.between(LocalDate.of(2020,2, 28), LocalDate.of(2020,1, 27)).getDays());
+        System.out.println(ChronoUnit.DAYS.between(LocalDate.of(2021,2, 28), LocalDate.of(2021,3, 1)));
+        System.out.println(LocalDate.of(2020,1, 20).getYear());
+        System.out.println(LocalDate.of(2021,1, 30).plusMonths(1));
+
+        System.out.println("s" + LocalDate.of(2021,1, 30).getMonth().getValue());
+
+        System.out.println("----------------------------");
+        LocalDate server_end_date = LocalDate.now().plusMonths(3);
+        server_end_date = server_end_date.plusDays(7);
+        server_end_date = server_end_date.minusDays(7);
+        System.out.println(server_end_date);
+
+        System.out.println(LocalDate.now().getMonth().getValue());
+
+        Float f = 520.4F;
+        System.out.println(f * 1 / 100F);
+
+        System.out.println(new BigDecimal(f * 1 / 100F).setScale(1, RoundingMode.DOWN));
+    }
+
+
+
+}
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml
index 6757fd593..7be516ec3 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml
@@ -188,4 +188,12 @@
         </foreach>
     </delete>
 
+    <select id="selectSysCommisionDayDetail" parameterType="SysCommision" resultMap="SysCommisionResult">
+        SELECT su.user_id,su.nick_name as user_name,sp.post_id, sp.post_code,sp.post_name FROM sys_user su
+        LEFT JOIN sys_user_post sup ON sup.user_id = su.user_id
+        LEFT JOIN sys_post sp ON sp.post_id = sup.post_id
+        WHERE su.del_flag = 0 AND su.status = 0 AND sp.remark = 'sale_post' AND (sp.post_code = 'after_sale' OR sp.post_code = 'nutri')
+        <if test="postId != null and postId != ''">and sp.post_id = #{postId}</if>
+        <if test="userId != null and userId != ''">and su.user_id = #{userId}</if>
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
index 31bc9788d..9a18ec711 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
@@ -36,6 +36,9 @@
         <result property="serveTimeId" column="serve_time_id"/>
         <result property="reviewStatus" column="review_status"/>
         <result property="giveServeDay" column="give_serve_day"/>
+        <!-- 非持久化字段 -->
+        <result property="afterSale" column="afterSale_name"></result><!-- 售后名称  -->
+        <result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
     </resultMap>
 
     <sql id="selectSysOrderVo">
@@ -213,4 +216,75 @@
         </foreach>
     </delete>
 
+    <resultMap type="SysOrder" id="SysOrderResultExtended">
+        <result property="orderId" column="order_id"/>
+        <result property="customer" column="customer"/>
+        <result property="phone" column="phone"/>
+        <result property="amount" column="amount"/>
+        <result property="weight" column="weight"/>
+        <result property="startTime" column="start_time"/>
+        <result property="pauseTime" column="pause_time"/>
+        <result property="status" column="status"/>
+        <result property="payTypeId" column="pay_type_id"/>
+        <result property="payType" column="pay_type"/>
+        <result property="preSaleId" column="pre_sale_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="afterSaleId" column="after_sale_id"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="nutritionistId" column="nutritionist_id"/>
+        <result property="remark" column="remark"/>
+        <result property="nutriAssisId" column="nutri_assis_id"/>
+        <result property="accountId" column="account_id"/>
+        <result property="account" column="account"/>
+        <result property="plannerId" column="planner_id"/>
+        <result property="plannerAssisId" column="planner_assis_id"/>
+        <result property="operatorId" column="operator_id"/>
+        <result property="operatorAssisId" column="operator_assis_id"/>
+        <result property="recommender" column="recommender"/>
+        <result property="orderTime" column="order_time"/>
+        <result property="serveTime" column="serve_time"/>
+        <result property="serveTimeId" column="serve_time_id"/>
+        <result property="reviewStatus" column="review_status"/>
+        <result property="giveServeDay" column="give_serve_day"/>
+        <!-- 非持久化字段 -->
+        <result property="afterSale" column="afterSale_name"></result><!-- 售后名称  -->
+        <result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
+        <association property="orderPauseList" column="order_id" select="getOrderPauseByOrderId"/>
+    </resultMap>
+
+    <resultMap type="SysOrderPause" id="SysOrderPauseResult">
+        <result property="id"    column="id"    />
+        <result property="orderId"    column="order_id"    />
+        <result property="pauseStartDate"    column="pause_start_date"    />
+        <result property="pauseEndDate"    column="pause_end_date"    />
+        <result property="reason"    column="reason"    />
+        <result property="remarks"    column="remarks"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="delFlag"    column="del_flag"    />
+    </resultMap>
+
+    <select id="getOrderPauseByOrderId" parameterType="Long" resultMap="SysOrderPauseResult">
+        select id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_order_pause sop
+        where del_flag = 0 and order_id = #{order_id}
+    </select>
+
+    <!-- 查询订单信息(用于计算提成) -->
+    <select id="selectSimpleOrderMessage" resultMap="SysOrderResultExtended">
+      select o.order_id,o.order_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name,sc.create_time as start_time
+      from sys_order o
+      left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
+      left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
+      left join sys_customer sc on sc.phone = o.phone and sc.del_flag = 0
+      where o.order_time >= '2021-01-01'
+      <if test="userId != null">
+          and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
+      </if>
+      order by o.order_time desc
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-ui/src/api/custom/commision.js b/stdiet-ui/src/api/custom/commision.js
index 1cbb5c79c..cdf65ecf5 100644
--- a/stdiet-ui/src/api/custom/commision.js
+++ b/stdiet-ui/src/api/custom/commision.js
@@ -68,3 +68,12 @@ export function getSalesman() {
     method: 'get',
   })
 }
+
+// 查询按天计算提成明细(营养师、售后)
+export function detailDayCommision(query) {
+  return request({
+    url: '/custom/commision/detailDay',
+    method: 'get',
+    params: query
+  })
+}
diff --git a/stdiet-ui/src/views/custom/commision/detail_day/index.vue b/stdiet-ui/src/views/custom/commision/detail_day/index.vue
new file mode 100644
index 000000000..1ce53c99a
--- /dev/null
+++ b/stdiet-ui/src/views/custom/commision/detail_day/index.vue
@@ -0,0 +1,264 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="岗位" prop="postId">
+        <el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable size="small" @change="searchPostChange">
+          <el-option
+            v-for="dict in postIdOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="业务员" prop="userId">
+        <el-select v-model="queryParams.userId" placeholder="请选择业务员" clearable size="small">
+          <el-option
+            v-for="dict in searchUserIdOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <!--<el-form-item label="月份" prop="month">
+        <el-date-picker
+          v-model="month"
+          @change="monthRangeChange"
+          type="month"
+          placeholder="选择月">
+        </el-date-picker>
+      </el-form-item>-->
+      <el-form-item>
+        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <!--<el-col :span="1.5">
+        <el-button
+          type="warning"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['commision:detail:export']"
+        >导出
+        </el-button>
+      </el-col>-->
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="commisionList"
+              @selection-change="handleSelectionChange">
+      <el-table-column label="业务员" align="center" prop="nickName">
+        <template slot-scope="scope">
+          <span>{{ scope.row.nickName }}</span>
+        </template>
+
+      </el-table-column>
+
+      <el-table-column label="岗位" align="center" prop="postName"/>
+      <el-table-column label="总提成" align="center" prop="totalCommissionAmount">
+        <template scope="scope">
+          {{scope.row.totalCommissionAmount}}
+        </template>
+      </el-table-column>
+      <el-table-column label="已发放提成" align="center" prop="totalHasSentCommissionAmount">
+        <template scope="scope">
+          {{scope.row.totalHasSentCommissionAmount}}
+        </template>
+      </el-table-column>
+      <el-table-column label="未发放提成" align="center" prop="totalNotSentCommissionAmount">
+        <template scope="scope">
+          {{scope.row.totalNotSentCommissionAmount}}
+        </template>
+
+      </el-table-column>
+      <el-table-column label="操作" align="center">
+        <template slot-scope="scope">
+          <el-button type="text" @click="openFormDialog('查看发放计划', scope.row)">查看发放计划</el-button>
+        </template>
+      </el-table-column>
+
+      <!--<el-table-column label="提成" align="center" prop="commissionTotalAmount"></el-table-column>-->
+
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+
+    <el-dialog title="提成发放计划" :visible.sync="sendCommissionPlanTable" width="25%" align="center">
+      <el-table :data="sendCommissionPlan">
+        <el-table-column property="nickName" label="姓名" width="150"></el-table-column>
+        <el-table-column property="yearMonth" label="发放年月" width="200"></el-table-column>
+        <el-table-column property="yearMonthCommission" label="提成金额" width="100"></el-table-column>
+      </el-table>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import {
+    detailDayCommision,
+    exportCommision,
+  } from "@/api/custom/commision";
+
+  import {getOptions} from "@/api/custom/order";
+
+  import dayjs from 'dayjs';
+
+  export default {
+    name: "CommisionDayDetail",
+    data() {
+      return {
+        // 遮罩层
+        loading: true,
+        // 选中数组
+        ids: [],
+        // 非单个禁用
+        single: true,
+        // 非多个禁用
+        multiple: true,
+        // 显示搜索条件
+        showSearch: true,
+        // 总条数
+        total: 0,
+        //
+        month: dayjs(),
+        // 业务提成比例表格数据
+        commisionList: [],
+        // 是否显示弹出层
+        open: false,
+        // 业务员字典
+        userIdOptions: [],
+        //
+        postIdOptions: [],
+        //
+        totalUserIdOptions: [],
+        //
+        searchUserIdOptions: [],
+        //
+        options: {},
+        // 查询参数
+        queryParams: {
+          pageNum: 1,
+          pageSize: 20,
+          userId: null,
+          postId: null,
+        },
+        sendCommissionPlanTable: false,
+        sendCommissionPlan:[]
+      };
+    },
+    created() {
+      this.getList();
+      getOptions().then(response => {
+        this.options = response.data.reduce((opts, cur) => {
+            if (cur.postCode != ('after_sale') && cur.postCode != 'nutri') {
+              return opts;
+            }
+          if (!opts[cur.postId]) {
+            opts[cur.postId] = [];
+          }
+          opts[cur.postId].push({dictValue: cur.userId, dictLabel: cur.userName});
+
+          if (!this.postIdOptions.some(opt => opt.dictValue === cur.postId)) {
+            this.postIdOptions.push({dictValue: cur.postId, dictLabel: cur.postName});
+          }
+          if (!this.totalUserIdOptions.some(opt => opt.dictValue === cur.userId)) {
+            this.totalUserIdOptions.push({dictValue: cur.userId, dictLabel: cur.userName});
+          }
+          return opts;
+        }, {});
+        this.postIdOptions = this.postIdOptions.sort((a, b) => a.dictValue - b.dictValue);
+        this.searchUserIdOptions = this.totalUserIdOptions.slice();
+      })
+
+    },
+    methods: {
+      /** 查询业务提成比例列表 */
+      getList() {
+        this.loading = true;
+        const dateRange = [dayjs(this.month).startOf('month').format('YYYY-MM-DD'), dayjs(this.month).endOf('month').format('YYYY-MM-DD')];
+        console.log(dateRange)
+        detailDayCommision(this.addDateRange(this.queryParams, dateRange)).then(response => {
+          this.commisionList = response.rows;
+          this.total = response.total;
+          this.loading = false;
+        });
+      },
+      // 业务员字典翻译
+      userIdFormat(row, column) {
+        return this.selectDictLabel(this.userIdOptions, row.userId);
+      },
+      // 表单重置
+      reset() {
+        this.userIdOptions = [];
+        this.resetForm("form");
+      },
+      /** 搜索按钮操作 */
+      handleQuery() {
+        this.queryParams.pageNum = 1;
+        this.getList();
+      },
+      /** 重置按钮操作 */
+      resetQuery() {
+        this.resetForm("queryForm");
+        this.handleQuery();
+        this.searchUserIdOptions = this.totalUserIdOptions.slice();
+      },
+      // 多选框选中数据
+      handleSelectionChange(selection) {
+        this.ids = selection.map(item => item.ruleId)
+        this.single = selection.length !== 1
+        this.multiple = !selection.length
+      },
+      /** 导出按钮操作 */
+      handleExport() {
+        const queryParams = this.queryParams;
+        this.$confirm('是否确认导出所有业务提成比例数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function () {
+          return exportCommision(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+        }).catch(function () {
+        });
+      },
+      monthRangeChange(time) {
+        this.month = time;
+      },
+      postChange(postId) {
+        this.userIdOptions = this.options[postId];
+      },
+      searchPostChange(postId) {
+        if (!postId) {
+          this.searchUserIdOptions = this.totalUserIdOptions.slice();
+          return;
+        }
+        this.searchUserIdOptions = this.options[postId];
+        this.queryParams.userId = null;
+      },
+      openFormDialog(title, row){
+         this.sendCommissionPlan = row.sendDetailList;
+         var total = 0;
+         this.sendCommissionPlan.forEach(function(e){
+              e.nickName = row.nickName;
+              e.yearMonth = e.yearMonth.substring(0,4) + "年" + e.yearMonth.substring(4)+"月";
+              total += e.yearMonthCommission;
+         });
+        //this.sendCommissionPlan.push({'': })
+         this.sendCommissionPlanTable = true;
+      }
+    }
+  };
+</script>