提成详情

This commit is contained in:
xiezhijun 2021-03-27 19:29:15 +08:00
parent b1d2c60f4f
commit 4bee383358
6 changed files with 298 additions and 45 deletions

View File

@ -62,4 +62,10 @@ public class SysCommision extends BaseEntity {
//订单审核状态 //订单审核状态
private String reviewStatus; private String reviewStatus;
//服务开始时间用于计算该时间段的提成
private String serverScopeStartTime;
//服务结束时间用于计算该时间段的提成
private String serverScopeEndTime;
} }

View File

@ -18,6 +18,9 @@ public class SysOrderCommisionDayDetail extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**订单ID*/
private Long orderId;
/**订单成交时间*/ /**订单成交时间*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime orderTime; private LocalDateTime orderTime;
@ -66,6 +69,9 @@ public class SysOrderCommisionDayDetail extends BaseEntity {
/**每年每月对应提成*/ /**每年每月对应提成*/
private Map<String, BigDecimal> everyYearMonthServerCommission; private Map<String, BigDecimal> everyYearMonthServerCommission;
/**每年每月的提成是否发放**/
private Map<String, Boolean> everyYearMonthCommissionSendFlag;
//该笔订单成交的当月的总成交额用于确定提成比例 //该笔订单成交的当月的总成交额用于确定提成比例
private BigDecimal monthOrderTotalAmount; private BigDecimal monthOrderTotalAmount;

View File

@ -3,6 +3,7 @@ package com.stdiet.custom.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.*; import com.stdiet.custom.domain.*;
import com.stdiet.custom.dto.request.SysOrderCommision; import com.stdiet.custom.dto.request.SysOrderCommision;
import com.stdiet.custom.dto.response.EveryMonthTotalAmount; import com.stdiet.custom.dto.response.EveryMonthTotalAmount;
@ -138,7 +139,14 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
} }
//获取每个月的提成比例以及计算提成 //获取每个月的提成比例以及计算提成
Map<String, Float> rateMap = getRateByAmount(userId, postId, everyMonthTotalAmountMap); Map<String, Float> rateMap = getRateByAmount(userId, postId, everyMonthTotalAmountMap);
//总服务金额
BigDecimal totalServerAmount = BigDecimal.valueOf(0);
//总提成金额
BigDecimal totalCommission = BigDecimal.valueOf(0); BigDecimal totalCommission = BigDecimal.valueOf(0);
//已发放提成金额
BigDecimal totalSendCommission = BigDecimal.valueOf(0);
//未发放提成金额
BigDecimal totalNotSendCommission = BigDecimal.valueOf(0);
//根据用户ID获取对应订单列表 //根据用户ID获取对应订单列表
List<SysOrderCommisionDayDetail> orderDetailList = orderUserMap.get(userId); List<SysOrderCommisionDayDetail> orderDetailList = orderUserMap.get(userId);
for(SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList){ for(SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList){
@ -147,18 +155,42 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
sysOrderCommisionDayDetail.setCommissionRate(rateMap.get(yearMonth)); sysOrderCommisionDayDetail.setCommissionRate(rateMap.get(yearMonth));
//计算该笔订单总提成 //计算该笔订单总提成
sysOrderCommisionDayDetail.setOrderCommission(getMoney(sysOrderCommisionDayDetail.getOrderAmount().doubleValue() * sysOrderCommisionDayDetail.getCommissionRate() / 100D)); sysOrderCommisionDayDetail.setOrderCommission(getMoney(sysOrderCommisionDayDetail.getOrderAmount().doubleValue() * sysOrderCommisionDayDetail.getCommissionRate() / 100D));
//每年每月提成
Map<String, BigDecimal> everyYearMonthServerCommission = new TreeMap<>(new MyComparator()); Map<String, BigDecimal> everyYearMonthServerCommission = new TreeMap<>(new MyComparator());
//每年每月提成是否发放状态
Map<String, Boolean> everyYearMonthCommissionSendFlag = new TreeMap<>(new MyComparator());
//当前订单的提成总和
BigDecimal currentOrderCommission = BigDecimal.valueOf(0);
for (String everyMonth : sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().keySet()) { for (String everyMonth : sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().keySet()) {
everyYearMonthServerCommission.put(everyMonth, getMoney(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().get(everyMonth).doubleValue() * sysOrderCommisionDayDetail.getCommissionRate() / 100D)); if(everyMonth.equals(sysOrderCommisionDayDetail.getServerEndDate().getYear()+""+sysOrderCommisionDayDetail.getServerEndDate().getMonth().getValue())){
//最后一个月的提成直接相减避免误差
everyYearMonthServerCommission.put(everyMonth, sysOrderCommisionDayDetail.getOrderCommission().subtract(currentOrderCommission));
}else{
everyYearMonthServerCommission.put(everyMonth, getMoney(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().get(everyMonth).doubleValue() * sysOrderCommisionDayDetail.getCommissionRate() / 100D));
}
//判断是否已发放
if(isSendCommissionByYearMonth(everyMonth)){
everyYearMonthCommissionSendFlag.put(everyMonth, true);
totalSendCommission = totalSendCommission.add(everyYearMonthServerCommission.get(everyMonth));
}else{
everyYearMonthCommissionSendFlag.put(everyMonth, false);
totalNotSendCommission = totalNotSendCommission.add(everyYearMonthServerCommission.get(everyMonth));
}
currentOrderCommission = currentOrderCommission.add(everyYearMonthServerCommission.get(everyMonth));
} }
sysOrderCommisionDayDetail.setEveryYearMonthServerCommission(everyYearMonthServerCommission); sysOrderCommisionDayDetail.setEveryYearMonthServerCommission(everyYearMonthServerCommission);
sysOrderCommisionDayDetail.setEveryYearMonthCommissionSendFlag(everyYearMonthCommissionSendFlag);
totalCommission = totalCommission.add(sysOrderCommisionDayDetail.getOrderCommission()); totalCommission = totalCommission.add(sysOrderCommisionDayDetail.getOrderCommission());
totalServerAmount = totalServerAmount.add(sysOrderCommisionDayDetail.getOrderAmount());
} }
result = AjaxResult.success(); result = AjaxResult.success();
int total = sysOrderMapper.selectSimpleOrderMessageCount(sysCommision); int total = sysOrderMapper.selectSimpleOrderMessageCount(sysCommision);
result.put("total", total); result.put("total", total);
result.put("list", orderDetailList); result.put("list", orderDetailList);
result.put("totalServerAmount", totalServerAmount);
result.put("totalCommission", totalCommission); result.put("totalCommission", totalCommission);
result.put("totalSendCommission", totalSendCommission);
result.put("totalNotSendCommission", totalNotSendCommission);
return result; return result;
} }
@ -296,7 +328,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
continue; continue;
} }
//对每笔订单进行处理统计出该比订单在每年每月对应的服务天数金额暂停天数等 //对每笔订单进行处理统计出该比订单在每年每月对应的服务天数金额暂停天数等
SysOrderCommisionDayDetail sysOrderCommisionDayDetail = statisticsOrderMessage(sysOrder); SysOrderCommisionDayDetail sysOrderCommisionDayDetail = statisticsOrderMessage(sysOrder, sysCommision.getServerScopeStartTime(), sysCommision.getServerScopeEndTime());
if(sysOrder.getAfterSaleId() != null && sysOrder.getAfterSaleId() > 0L){ if(sysOrder.getAfterSaleId() != null && sysOrder.getAfterSaleId() > 0L){
addUserOrderResultMap(sysOrder.getAfterSaleId(), sysOrderCommisionDayDetail, userOrderResultMap); addUserOrderResultMap(sysOrder.getAfterSaleId(), sysOrderCommisionDayDetail, userOrderResultMap);
} }
@ -323,7 +355,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
/** /**
* 统计每笔订单的服务开始时间结束时间每年每月服务天数服务金额服务暂停天数等信息 * 统计每笔订单的服务开始时间结束时间每年每月服务天数服务金额服务暂停天数等信息
* */ * */
public SysOrderCommisionDayDetail statisticsOrderMessage(SysOrder sysOrder){ public SysOrderCommisionDayDetail statisticsOrderMessage(SysOrder sysOrder, String serverScopeStartTime, String serverScopeEndTime){
//提成计算开始时间与食谱计划开始时间可能不同 //提成计算开始时间与食谱计划开始时间可能不同
LocalDate serverStartDate = DateUtils.dateToLocalDate(sysOrder.getCommissStartTime()); LocalDate serverStartDate = DateUtils.dateToLocalDate(sysOrder.getCommissStartTime());
//订单总服务月数 //订单总服务月数
@ -349,9 +381,10 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
//每天对应金额 //每天对应金额
BigDecimal dayMoney = getMoney(orderAmount.doubleValue()/serverDay); BigDecimal dayMoney = getMoney(orderAmount.doubleValue()/serverDay);
//每年每月对于金额 //每年每月对于金额
Map<String, BigDecimal> everyYearMonthServerMoney = getEveryMonthServerMoney(everyYearMonthServerDay, orderAmount, dayMoney); Map<String, BigDecimal> everyYearMonthServerMoney = getEveryMonthServerMoney(everyYearMonthServerDay, orderAmount, dayMoney, serverEndDate);
SysOrderCommisionDayDetail sysOrderCommisionDayDetail = new SysOrderCommisionDayDetail(); SysOrderCommisionDayDetail sysOrderCommisionDayDetail = new SysOrderCommisionDayDetail();
sysOrderCommisionDayDetail.setOrderId(sysOrder.getOrderId());
sysOrderCommisionDayDetail.setOrderTime(DateUtils.dateToLocalDateTime(sysOrder.getOrderTime())); sysOrderCommisionDayDetail.setOrderTime(DateUtils.dateToLocalDateTime(sysOrder.getOrderTime()));
sysOrderCommisionDayDetail.setName(sysOrder.getCustomer()); sysOrderCommisionDayDetail.setName(sysOrder.getCustomer());
sysOrderCommisionDayDetail.setServerStartDate(serverStartDate); sysOrderCommisionDayDetail.setServerStartDate(serverStartDate);
@ -366,9 +399,50 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
sysOrderCommisionDayDetail.setEveryYearMonthServerDay(everyYearMonthServerDay); sysOrderCommisionDayDetail.setEveryYearMonthServerDay(everyYearMonthServerDay);
sysOrderCommisionDayDetail.setEveryYearMonthServerMoney(everyYearMonthServerMoney); sysOrderCommisionDayDetail.setEveryYearMonthServerMoney(everyYearMonthServerMoney);
if(StringUtils.isNotEmpty(serverScopeStartTime) && StringUtils.isNotEmpty(serverScopeEndTime)){
LocalDate realStartTime = DateUtils.stringToLocalDate(serverScopeStartTime, "yyyy-MM-dd");
LocalDate realEndTime = DateUtils.stringToLocalDate(serverScopeEndTime, "yyyy-MM-dd");
//计算该时间范围内的暂停时间
Map<String, Integer> realEveryYearMonthPauseDay = getRealEveryYearMonthPauseDay(sysOrder.getOrderPauseList(), serverStartDate, serverEndDate, realStartTime, realEndTime);
//暂停总天数
int realPauseTotalDay = getTotalByMap(realEveryYearMonthPauseDay);
//计算每年每月服务天数
Map<String, Integer> realEveryYearMonthServerDay = getRealEveryYearMonthDayCount(serverStartDate, serverEndDate, realStartTime, realEndTime, everyYearMonthPauseDay);
//服务总天数
int realServerDay = getTotalByMap(realEveryYearMonthServerDay);
//每年每月对于金额
Map<String, BigDecimal> realEveryYearMonthServerMoney = getEveryMonthServerMoney(realEveryYearMonthServerDay, orderAmount, dayMoney, serverEndDate);
//服务时间范围内暂停天数
sysOrderCommisionDayDetail.setPauseTotalDay(realPauseTotalDay);
sysOrderCommisionDayDetail.setEveryYearMonthPauseDay(realEveryYearMonthPauseDay);
sysOrderCommisionDayDetail.setServerDay(realServerDay);
sysOrderCommisionDayDetail.setEveryYearMonthServerDay(realEveryYearMonthServerDay);
sysOrderCommisionDayDetail.setEveryYearMonthServerMoney(realEveryYearMonthServerMoney);
sysOrderCommisionDayDetail.setOrderAmount(getBigDecimalTotalByMap(realEveryYearMonthServerMoney));
}
return sysOrderCommisionDayDetail; return sysOrderCommisionDayDetail;
} }
/**
* 获取真正服务时间范围内的每年每月暂停天数
* @Param list 暂停记录集合
* */
public Map<String, Integer> getRealEveryYearMonthPauseDay(List<SysOrderPause> list, LocalDate serverStartDate, LocalDate serverEndDate, LocalDate realStartDate, LocalDate realEndDate){
Map<String, Integer> pauseMap = new TreeMap<>(new MyComparator());
if(ChronoUnit.DAYS.between(realEndDate, serverStartDate) > 0 || ChronoUnit.DAYS.between(serverEndDate, realStartDate) > 0){
return pauseMap;
}
//更新服务开始时间
if(ChronoUnit.DAYS.between(serverStartDate,realStartDate) > 0){
serverStartDate = realStartDate;
}
//更新服务结束时间
if(ChronoUnit.DAYS.between(realEndDate,serverEndDate) > 0){
serverEndDate = realEndDate;
}
return getEveryYearMonthPauseDay(list, serverStartDate, serverEndDate);
}
/** /**
* 获取每年每月暂停天数 * 获取每年每月暂停天数
* @Param list 暂停记录集合 * @Param list 暂停记录集合
@ -423,6 +497,17 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
return total; return total;
} }
/**
* 获取Map<String, BigDecimal>集合中BigDecimal的总和
* */
public BigDecimal getBigDecimalTotalByMap(Map<String, BigDecimal> map){
BigDecimal totalBigDecimal = BigDecimal.valueOf(0);
for(String key : map.keySet()){
totalBigDecimal = totalBigDecimal.add(map.get(key));
}
return totalBigDecimal;
}
/** /**
* 获取订单服务时间范围中每年每月服务天数减去当月暂停天数 * 获取订单服务时间范围中每年每月服务天数减去当月暂停天数
* @Param server_start_date 服务开始时间 * @Param server_start_date 服务开始时间
@ -438,27 +523,50 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
* @Param everyMonthServerDay 每年每月服务天数 * @Param everyMonthServerDay 每年每月服务天数
* @Param orderMoney 订单总额 * @Param orderMoney 订单总额
* @Param dayMoney 每天对于金额 * @Param dayMoney 每天对于金额
* @Param serverEndTime 订单服务结束时间
* */ * */
public Map<String, BigDecimal> getEveryMonthServerMoney(Map<String, Integer> everyMonthServerDay, BigDecimal orderMoney, BigDecimal dayMoney){ public Map<String, BigDecimal> getEveryMonthServerMoney(Map<String, Integer> everyMonthServerDay, BigDecimal orderMoney, BigDecimal dayMoney, LocalDate serverEndTime){
Map<String, BigDecimal > everyMonthServerMoney = new TreeMap<>(new MyComparator()); Map<String, BigDecimal > everyMonthServerMoney = new TreeMap<>(new MyComparator());
Set<String> keySet = everyMonthServerDay.keySet(); Set<String> keySet = everyMonthServerDay.keySet();
int i = 1; int i = 1;
double totalMoney = 0.0; BigDecimal total = BigDecimal.valueOf(0);
for(String key : keySet){ for(String key : keySet){
if(i++ != keySet.size()){ //System.out.println(serverEndTime.getYear()+""+serverEndTime.getMonth().getValue());
everyMonthServerMoney.put(key, getMoney(everyMonthServerDay.get(key) * dayMoney.doubleValue())); //判断是否为最后一个月
totalMoney += everyMonthServerMoney.get(key).doubleValue(); if(key.equals(serverEndTime.getYear()+""+serverEndTime.getMonth().getValue())){
System.out.println(key);
//由于小数保留问题最后一个月的金额等于总额减去前几个月金额避免总数不一致
everyMonthServerMoney.put(key, orderMoney.subtract(total));
}else{ }else{
//由于小数点只保留一位最后一个月的金额等于总额减去前几个月金额避免总数不一致 everyMonthServerMoney.put(key, getMoney(everyMonthServerDay.get(key) * dayMoney.doubleValue()));
everyMonthServerMoney.put(key, getMoney(orderMoney.doubleValue() - totalMoney)); total = total.add(everyMonthServerMoney.get(key));
} }
} }
return everyMonthServerMoney; return everyMonthServerMoney;
} }
/**
* 根据订单服务开始日期订单服务结束日期营养师或售后实际开始时间营养师或售后实际结束时间统计出实际时间范围内每年每月对应的天数
* */
public Map<String, Integer> getRealEveryYearMonthDayCount(LocalDate startDate, LocalDate endDate, LocalDate realStartDate, LocalDate realEndDate, Map<String, Integer> lessDayMap){
Map<String, Integer> everyYearMonthServerDay = new TreeMap<>(new MyComparator());
if(ChronoUnit.DAYS.between(realEndDate, startDate) > 0 || ChronoUnit.DAYS.between(endDate, realStartDate) > 0){
return everyYearMonthServerDay;
}
//更新服务开始时间
if(ChronoUnit.DAYS.between(startDate,realStartDate) > 0){
startDate = realStartDate;
}
//更新服务结束时间
if(ChronoUnit.DAYS.between(realEndDate,endDate) > 0){
endDate = realEndDate;
}
return getEveryYearMonthDayCount(startDate, endDate, lessDayMap);
}
/** /**
* 根据开始日期结束日期统计出时间范围内每年每月对应的天数 * 根据订单开始日期订单结束日期统计出时间范围内每年每月对应的天数
* */ * */
public Map<String, Integer> getEveryYearMonthDayCount(LocalDate startDate, LocalDate endDate, Map<String, Integer> lessDayMap){ public Map<String, Integer> getEveryYearMonthDayCount(LocalDate startDate, LocalDate endDate, Map<String, Integer> lessDayMap){
Map<String, Integer> everyYearMonthServerDay = new TreeMap<>(new MyComparator()); Map<String, Integer> everyYearMonthServerDay = new TreeMap<>(new MyComparator());
@ -468,8 +576,8 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
LocalDate everyMonthLastDate = everyMonthFirstDate.with(TemporalAdjusters.lastDayOfMonth()); LocalDate everyMonthLastDate = everyMonthFirstDate.with(TemporalAdjusters.lastDayOfMonth());
int day = 0; int day = 0;
boolean breakFlag = false; boolean breakFlag = false;
//写100防止死循环 //写1000防止死循环
for(int i = 0; i < 100; i++){ for(int i = 0; i < 1000; i++){
if(ChronoUnit.DAYS.between(everyMonthLastDate, endDate) > 0){ if(ChronoUnit.DAYS.between(everyMonthLastDate, endDate) > 0){
day = Period.between(everyMonthFirstDate, everyMonthLastDate).getDays() + 1; day = Period.between(everyMonthFirstDate, everyMonthLastDate).getDays() + 1;
}else{ }else{

View File

@ -400,7 +400,8 @@
from sys_order o 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_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_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
where o.order_time >= '2021-01-01' and o.del_flag = 0 where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
and o.amount is not null
<if test="reviewStatus != null and reviewStatus != ''"> <if test="reviewStatus != null and reviewStatus != ''">
and review_status = #{reviewStatus} and review_status = #{reviewStatus}
</if> </if>
@ -410,6 +411,9 @@
<if test="endTime != null and endTime != ''"> <if test="endTime != null and endTime != ''">
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') &lt;= #{endTime} AND DATE_FORMAT(o.order_time,'%Y-%m-%d') &lt;= #{endTime}
</if> </if>
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
</if>
order by o.order_time desc order by o.order_time desc
</select> </select>
@ -419,7 +423,8 @@
from sys_order o 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_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_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
where o.order_time >= '2021-01-01' and o.del_flag = 0 where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
and o.amount is not null
<if test="reviewStatus != null and reviewStatus != ''"> <if test="reviewStatus != null and reviewStatus != ''">
and review_status = #{reviewStatus} and review_status = #{reviewStatus}
</if> </if>
@ -429,6 +434,9 @@
<if test="endTime != null and endTime != ''"> <if test="endTime != null and endTime != ''">
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') &lt;= #{endTime} AND DATE_FORMAT(o.order_time,'%Y-%m-%d') &lt;= #{endTime}
</if> </if>
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
</if>
order by o.order_time desc order by o.order_time desc
</select> </select>
@ -440,7 +448,8 @@
FROM sys_order o 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_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_user su_nutritionist ON su_nutritionist.user_id = o.nutritionist_id AND su_nutritionist.del_flag = 0
where o.order_time >= '2021-01-01' and o.del_flag = 0 where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR su_nutritionist.user_id is not null)
and o.amount is not null
<if test="reviewStatus != null and reviewStatus != ''"> <if test="reviewStatus != null and reviewStatus != ''">
and o.review_status = #{reviewStatus} and o.review_status = #{reviewStatus}
</if> </if>

View File

@ -5,19 +5,53 @@
:close-on-press-escape="false" :close-on-press-escape="false"
:visible.sync="visible" :visible.sync="visible"
@closed="handleOnClosed" @closed="handleOnClosed"
size="63%" size="65%"
> >
<div class="order_drawer_wrapper" height="84%"> <div class="order_drawer_wrapper" >
<div style="margin-left:40px">
<el-form
ref="queryForm"
:inline="true"
v-show="true"
label-width="100px"
>
<el-form-item label="服务时间范围" prop="dateScope">
<el-date-picker
v-model="serverDateScope"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="small" @click="fetchOrderList">搜索</el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetQueryForm">重置</el-button>
</el-form-item>
</el-form>
</div>
<div <div
class="header" class="order_total_data"
style="float: right; margin-bottom: 20px; margin-right: 60px"
> >
<span style="font-size14px;margin-top:-200px" <span class="order_total_data_span_right20">
当前页总服务金额{{totalServerAmount}}
</span>
<span class="order_total_data_span_right20"
>当前页总提成{{ totalCommission }}</span >当前页总提成{{ totalCommission }}</span
> >
<span class="order_total_data_span_right20"
>已发放总提成{{ totalSendCommission }}</span
>
<span class="order_total_data_span"
>未发放总提成{{ totalNotSendCommission }}</span
>
</div> </div>
<div style="width:100%;height:80%;overflow: auto">
<el-table :data="orderList" v-loading="loading"> <el-table :data="orderList" v-loading="loading" stripe>
<el-table-column <el-table-column
label="订单成交时间" label="订单成交时间"
prop="orderTime" prop="orderTime"
@ -31,7 +65,7 @@
width="100" width="100"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
label="订单金额" label="服务金额"
prop="orderAmount" prop="orderAmount"
align="center" align="center"
width="100" width="100"
@ -77,7 +111,7 @@
label="暂停天数" label="暂停天数"
prop="pauseTotalDay" prop="pauseTotalDay"
align="center" align="center"
width="100" width="80"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
@ -87,7 +121,7 @@
width="100" width="100"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
label="当月额" label="当月成交额"
prop="monthOrderTotalAmount" prop="monthOrderTotalAmount"
align="center" align="center"
width="100" width="100"
@ -96,7 +130,7 @@
label="提成比例" label="提成比例"
prop="commissionRate" prop="commissionRate"
align="center" align="center"
width="100" width="80"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.commissionRate + "%" }} {{ scope.row.commissionRate + "%" }}
@ -108,7 +142,7 @@
align="center" align="center"
width="100" width="100"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.orderCommission }} {{ scope.row.orderCommission }}
<el-popover <el-popover
placement="top-start" placement="top-start"
@ -117,7 +151,8 @@
trigger="hover" trigger="hover"
> >
<div <div
v-for="(item, index) in scope.row.everyYearMonthServerCommission" v-for="(item, index) in scope.row
.everyYearMonthServerCommission"
:key="index" :key="index"
> >
{{ item }} {{ item }}
@ -126,10 +161,36 @@
</el-popover> </el-popover>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
label="操作"
align="center"
width="100"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="handleOnDetailClick(scope.row)"
>订单详情</el-button
>
</template>
</el-table-column>
</el-table> </el-table>
</div>
<!--<div style="float: right; margin-right: 40px">
<span style="font-size14px;margin-top:-200px;margin-right:20px">
当前页总服务金额{{totalServerAmount}}
</span>
<span style="font-size14px;margin-top:-200px;margin-right:20px"
>当前页总提成{{ totalCommission }}</span
>
<span style="font-size14px;margin-top:-200px;margin-right:20px"
>已发放总提成{{ totalSendCommission }}</span
>
<span style="font-size14px;margin-top:-200px"
>未发放总提成{{ totalNotSendCommission }}</span
>
</div>-->
<pagination <pagination
v-show="total > 0" v-show="total > 0"
:total="total" :total="total"
@ -139,16 +200,22 @@
:pageSizes="[10, 15, 30, 50, 100]" :pageSizes="[10, 15, 30, 50, 100]"
> >
</pagination> </pagination>
</div> </div>
</el-drawer> </el-drawer>
<order-detail ref="orderDetailRef" />
</div> </div>
</template> </template>
<script> <script>
import { orderDetailDay } from "@/api/custom/commision"; import { orderDetailDay } from "@/api/custom/commision";
import OrderDetail from "@/components/OrderDetail";
export default { export default {
name: "OrdercommissDetail", name: "OrdercommissDetail",
components: {}, components: {
"order-detail": OrderDetail,
},
data() { data() {
return { return {
visible: false, visible: false,
@ -158,60 +225,98 @@ export default {
orderList: [], orderList: [],
queryParam: {}, queryParam: {},
total: 0, total: 0,
totalServerAmount: 0,
totalCommission: 0, totalCommission: 0,
serverDayList: ["1月30", "2月20"], totalSendCommission: 0,
totalNotSendCommission: 0,
serverDateScope: null,
}; };
}, },
computed: {}, computed: {},
methods: { methods: {
showDrawer(data) { showDrawer(data) {
this.data = data; this.data = data;
this.serverDateScope = null;
if (!this.data) { if (!this.data) {
return; return;
} }
(this.queryParam = { this.queryParam = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}), },
(this.queryParam.userId = this.data.userId); this.queryParam.userId = this.data.userId;
this.queryParam.reviewStatus = this.data.reviewStatus; this.queryParam.reviewStatus = this.data.reviewStatus;
this.queryParam.endTime = this.data.endTime; this.queryParam.endTime = this.data.endTime;
this.title = `${this.data.name}」订单提成列表`; this.title = `${this.data.name}`;
if (this.data.yearMonth) {
this.title += " 截止" + `${this.data.yearMonth}`;
}
if (this.queryParam.reviewStatus) {
this.title +=
this.queryParam.reviewStatus == "yes" ? " 已审核" : " 未审核";
}
this.title += " 订单提成列表」";
this.visible = true; this.visible = true;
this.fetchOrderList(); this.fetchOrderList();
}, },
fetchOrderList() { fetchOrderList() {
this.loading = true; this.loading = true;
this.queryParam.serverScopeStartTime = this.serverDateScope && this.serverDateScope.length > 0 ? this.serverDateScope[0] : null;
this.queryParam.serverScopeEndTime = this.serverDateScope && this.serverDateScope.length > 0 ? this.serverDateScope[1] : null;
orderDetailDay(this.queryParam).then((res) => { orderDetailDay(this.queryParam).then((res) => {
//console.log(res); //console.log(res);
if (res.code == 200) { if (res.code == 200) {
this.orderList = this.dealOrderList(res.list); this.orderList = this.dealOrderList(res.list);
this.total = res.total; this.total = res.total;
this.totalServerAmount = res.totalServerAmount;
this.totalCommission = res.totalCommission; this.totalCommission = res.totalCommission;
this.totalSendCommission = res.totalSendCommission;
this.totalNotSendCommission = res.totalNotSendCommission;
} }
this.loading = false; this.loading = false;
}); });
}, },
handleOnClosed() { handleOnClosed() {
this.data = undefined; this.data = undefined;
this.serverDateScope = null;
}, },
dealOrderList(orderList) { dealOrderList(orderList) {
// //
orderList.forEach((item, index) => { orderList.forEach((item, index) => {
let everyYearMonthServerDayArray = []; let everyYearMonthServerDayArray = [];
for (let yearMonth in item.everyYearMonthServerDay) { for (let yearMonth in item.everyYearMonthServerDay) {
everyYearMonthServerDayArray.push(yearMonth.slice(0, 4) +"-" + yearMonth.slice(4) + "" + item.everyYearMonthServerDay[yearMonth] + "天"); everyYearMonthServerDayArray.push(
yearMonth.slice(0, 4) +
"-" +
yearMonth.slice(4) +
"" +
item.everyYearMonthServerDay[yearMonth] +
"天"
);
} }
item.everyYearMonthServerDay = everyYearMonthServerDayArray; item.everyYearMonthServerDay = everyYearMonthServerDayArray;
let everyYearMonthServerCommissionArray = []; let everyYearMonthServerCommissionArray = [];
for (let commissYearMonth in item.everyYearMonthServerCommission) { for (let commissYearMonth in item.everyYearMonthServerCommission) {
everyYearMonthServerCommissionArray.push(commissYearMonth.slice(0, 4) +"-" +commissYearMonth.slice(4) +"" + item.everyYearMonthServerCommission[commissYearMonth]); everyYearMonthServerCommissionArray.push(
commissYearMonth.slice(0, 4) +
"-" +
commissYearMonth.slice(4) +
"" +
item.everyYearMonthServerCommission[commissYearMonth]
+ (item.everyYearMonthCommissionSendFlag[commissYearMonth] ? ' 已发放' : ' 未发放')
);
} }
item.everyYearMonthServerCommission = everyYearMonthServerCommissionArray; item.everyYearMonthServerCommission = everyYearMonthServerCommissionArray;
}); });
return orderList; return orderList;
}, },
resetQueryForm(){
this.serverDateScope = null;
this.fetchOrderList();
},
handleOnDetailClick(data) {
this.$refs.orderDetailRef.showDialog(data.orderId);
},
}, },
}; };
</script> </script>
@ -223,4 +328,23 @@ export default {
.order_drawer_wrapper { .order_drawer_wrapper {
height: calc(100vh - 77px); height: calc(100vh - 77px);
} }
.order_total_data {
float: right;
margin-right: 40px;
margin-bottom:20px
}
.order_total_data_span_right20 {
font-size:16px;
margin-top:-200px;
margin-right:20px;
}
.order_total_data_span {
font-size:16px;
margin-top:-200px;
}
</style> </style>

View File

@ -157,11 +157,11 @@
@click="openFormDialog('查看发放计划', scope.row)" @click="openFormDialog('查看发放计划', scope.row)"
>查看发放计划</el-button >查看发放计划</el-button
> >
<el-button <!--<el-button
type="text" type="text"
@click="handleDetailClick(scope.row)" @click="handleDetailClick(scope.row)"
>查看订单详情</el-button >查看订单详情</el-button
> >-->
</template> </template>
</el-table-column> </el-table-column>
@ -419,7 +419,7 @@ export default {
dayjs(this.month).startOf("month").format("YYYY-MM-DD"), dayjs(this.month).startOf("month").format("YYYY-MM-DD"),
dayjs(this.month).endOf("month").format("YYYY-MM-DD"), dayjs(this.month).endOf("month").format("YYYY-MM-DD"),
]; ];
this.$refs["ordercommissDetailRef"].showDrawer(this.addDateRange({'name': row.nickName, 'userId': row.userId, 'reviewStatus': this.queryParams.reviewStatus}, dateRange)); this.$refs["ordercommissDetailRef"].showDrawer(this.addDateRange({'yearMonth': dayjs(this.month).endOf("month").format("YYYY-MM-DD"),'name': row.nickName, 'userId': row.userId, 'reviewStatus': this.queryParams.reviewStatus}, dateRange));
}, },
getSummaries(param) { getSummaries(param) {
//param columns data {columns: Array[4], data: Array[5]}, //param columns data {columns: Array[4], data: Array[5]},