@@ -1,9 +1,12 @@
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				package   com.stdiet.custom.service.impl ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.alibaba.fastjson.JSONArray ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.common.core.domain.AjaxResult ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.common.utils.DateUtils ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.common.utils.StringUtils ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.domain.* ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.dto.request.SysOrderCommision ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.dto.response.EveryMonthTotalAmount ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.mapper.SysCommisionMapper ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.mapper.SysOrderMapper ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				import   com.stdiet.custom.mapper.SysOrderPauseMapper ; 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -49,7 +52,8 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 sysCommissionDayDetail . setNickName ( commision . getUserName ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 sysCommissionDayDetail . setPostId ( commision . getPostId ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 sysCommissionDayDetail . setPostName ( commision . getPostName ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 dealServerOrderCommissionDetail ( orderDetailMap . get ( sysCommissionDayDetail . getUserId ( ) ) ,   sysCommissionDayDetail ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 dealServerOrderCommissionDetail ( sysCommision ,   orderDetailMap . get ( sysCommissionDayDetail . getUserId ( ) ) ,   sysCommissionDayDetail ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 result . add ( sysCommissionDayDetail ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 //统计所以用户总提成、已发放提成、未发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 total . setTotalCommissionAmount ( total . getTotalCommissionAmount ( ) . add ( sysCommissionDayDetail . getTotalCommissionAmount ( ) ) ) ; 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -103,72 +107,199 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         return   serverEndDate ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /** 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * 计算订单提成详情 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @param sysCommision 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     */ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     @Override 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   AjaxResult   calculateOrderCommissionDetail ( SysCommision   sysCommision ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         AjaxResult   result   =   AjaxResult . error ( " 参数错误 " ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( sysCommision . getUserId ( )   = =   null ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return   result ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //分页查询2021年1月份之后所有订单 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < Long ,   List < SysOrderCommisionDayDetail > >   orderUserMap   =   getOrderByList ( sysCommision ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( orderUserMap   = =   null   | |   ! orderUserMap . containsKey ( sysCommision . getUserId ( ) ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return   result ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //查询用户 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < SysCommision >   list   =   sysCommisionMapper . getAfterSaleAndNutri ( sysCommision ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( list   = =   null   | |   list . size ( )   = =   0 ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return   result ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Long   userId   =   list . get ( 0 ) . getUserId ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Long   postId   =   list . get ( 0 ) . getPostId ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //获取每个月的成交总额度 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < EveryMonthTotalAmount >   everyMonthTotalAmountList   =   sysOrderMapper . getTotalAmountByUserId ( sysCommision ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( everyMonthTotalAmountList   = =   null   | |   everyMonthTotalAmountList . size ( )   = =   0 ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return   result ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   BigDecimal >   everyMonthTotalAmountMap   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for   ( EveryMonthTotalAmount   everyMonthTotalAmount   :   everyMonthTotalAmountList )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             everyMonthTotalAmountMap . put ( everyMonthTotalAmount . getYearMonth ( ) ,   everyMonthTotalAmount . getTotalAmount ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //获取每个月的提成比例以及计算提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   Float >   rateMap   =   getRateByAmount ( userId ,   postId ,   everyMonthTotalAmountMap ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //总服务金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalServerAmount   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //总提成金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //已发放提成金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalSendCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放提成金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalNotSendCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //根据用户ID获取对应订单列表 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < SysOrderCommisionDayDetail >   orderDetailList   =   orderUserMap . get ( userId ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for ( SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   :   orderDetailList ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //处理订单提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             dealCommissionByOrderCommisionDayDetail ( sysOrderCommisionDayDetail ,   everyMonthTotalAmountMap ,   rateMap ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalCommission   =   totalCommission . add ( sysOrderCommisionDayDetail . getOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalServerAmount   =   totalServerAmount . add ( sysOrderCommisionDayDetail . getOrderAmount ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalSendCommission   =   totalSendCommission . add ( sysOrderCommisionDayDetail . getHasSendOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalNotSendCommission   =   totalNotSendCommission . add ( sysOrderCommisionDayDetail . getNotHasSendOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result   =   AjaxResult . success ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         int   total   =   sysOrderMapper . selectSimpleOrderMessageCount ( sysCommision ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " total " ,   total ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " list " ,   orderDetailList ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " totalServerAmount " ,   totalServerAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " totalCommission " ,   totalCommission ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " totalSendCommission " ,   totalSendCommission ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         result . put ( " totalNotSendCommission " ,   totalNotSendCommission ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         return   result ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /** 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * 根据用户ID统计出该用户在该月所有订单的服务数量、服务总天数、服务订单总额、暂停总天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * **/ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   void   dealServerOrderCommissionDetail ( List < SysOrderCommisionDayDetail >   orderDetailList ,   SysCommissionDayDetail   sysCommissionDayDetail ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   void   dealServerOrderCommissionDetail ( SysCommision   commisionParam ,    List< SysOrderCommisionDayDetail >   orderDetailList ,   SysCommissionDayDetail   sysCommissionDayDetail ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //总提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   t otalCommissionAmount  =   new   BigDecimal ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //已发放 提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   t otalHasSentCommissionAmount  =   new   BigDecimal ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放 提成记录  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < Map < String ,   Object > >   sendDetailList   =   new   ArrayList < > ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( orderDetailList   ! =   null ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //获取每个月的成交总额度  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             Map < String ,   BigDecimal >   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 ) . add ( sysOrderCommisionDayDetail . getOrderAmount ( ) ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     orderAmount . put ( yearMonth ,   sysOrderCommisionDayDetail . getOrderAmount ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 commissionMonthSet . addAll ( sysOrderCommisionDayDetail . getEveryYearMonthServerMoney ( ) . keySet ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //获取提成比例以及计算提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             Map < String ,   Float >   rateMap   =   getRateByAmount ( sysCommissionDayDetail . getUserId ( ) ,   sysCommissionDayDetail . getPostId ( ) ,   orderAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setT otalCommissionAmount( BigDecimal . valueOf  (0 ) )  ;
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //总共 已发提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setT otalHasSentCommissionAmount( BigDecimal . valueOf  (0 ) )  ;
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //总共 未发提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setTotalNotSentCommissionAmount ( BigDecimal . valueOf ( 0 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //提成发放计划 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        sysCommissionDayDetail . setSendDetailList ( new   ArrayList < > ( ) ) ;  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        //下月应发提成  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        sysCommissionDayDetail . setNextMonthCommission ( BigDecimal . valueOf ( 0  ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             int   i    =   1 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             BigDecimal   commissionA   =   new   BigDecimal ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             for   ( String   ym   :   commissionMonthSet )   {  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 BigDecimal   ym_mession   =   new   BigDecimal ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 if ( orderAmount . containsKey ( ym ) ) {  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     totalCommissionAmount   =   totalCommissionAmount . add ( getMoney ( orderAmount . get ( ym ) . doubleValue ( )    *   rateMap . get ( ym )   /   100D ,   1 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        if ( orderDetailList   = =   null   | |   orderDetailList . size ( )    = =   0   ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        }  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        //总提成  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        BigDecimal   totalCommissionAmount    =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //已发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalHasSentCommissionAmount   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalNotHasSentCommissionAmount   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //已发放提成记录 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < Map < String ,   Object > >   hasSendYearMonthDetailList   =   new   ArrayList < > ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放提成计划 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < Map < String ,   Object > >   notHasSendYearMonthDetailList   =   new   ArrayList < > ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //获取每个月的成交总额度 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         commisionParam . setUserId ( sysCommissionDayDetail . getUserId ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         List < EveryMonthTotalAmount >   everyMonthTotalAmountList   =   sysOrderMapper . getTotalAmountByUserId ( commisionParam ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         if ( everyMonthTotalAmountList   = =   null   | |   everyMonthTotalAmountList . size ( )   = =   0 ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   BigDecimal >   everyMonthTotalAmountMap   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for   ( EveryMonthTotalAmount   everyMonthTotalAmount   :   everyMonthTotalAmountList )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             everyMonthTotalAmountMap . put ( everyMonthTotalAmount . getYearMonth ( ) ,   everyMonthTotalAmount . getTotalAmount ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //获取每个月的提成比例以及计算提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   Float >   rateMap   =   getRateByAmount ( sysCommissionDayDetail . getUserId ( ) ,   sysCommissionDayDetail . getPostId ( ) ,   everyMonthTotalAmountMap ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //存在提成的年月 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Set < String >   commissionYearMonthSet   =   new   TreeSet < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for   ( SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   :   orderDetailList )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //处理订单提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             dealCommissionByOrderCommisionDayDetail ( sysOrderCommisionDayDetail ,   everyMonthTotalAmountMap ,   rateMap ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //合并每个订单的年月日 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             commissionYearMonthSet . addAll ( sysOrderCommisionDayDetail . getEveryYearMonthServerCommission ( ) . keySet ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //合计总提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalCommissionAmount   =   totalCommissionAmount . add ( sysOrderCommisionDayDetail . getOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //合计已发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalHasSentCommissionAmount   =   totalHasSentCommissionAmount . add ( sysOrderCommisionDayDetail . getHasSendOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //合计未发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             totalNotHasSentCommissionAmount   =   totalNotHasSentCommissionAmount . add ( sysOrderCommisionDayDetail . getNotHasSendOrderCommission ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for   ( String   yearMonth   :   commissionYearMonthSet )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             Map < String ,   Object >   map   =   new   HashMap < > ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             BigDecimal   yearMonthCommiss   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             for   ( SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   :   orderDetailList )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 if ( sysOrderCommisionDayDetail . getEveryYearMonthServerCommission ( ) . containsKey ( yearMonth ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     yearMonthCommiss   =   yearMonthCommiss . add ( sysOrderCommisionDayDetail . getEveryYearMonthServerCommission ( ) . get ( yearMonth ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 for   ( SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   :   orderDetailList )   {  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                      M ap< String ,   BigDecimal >   everyYearMonthServerMoney   =   sysOrderCommisionDayDetail . getEveryYearMonthServerMoney ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     if ( everyYearMonthServerMoney . containsKey ( ym  ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         String   orderYearMonth   =   sysOrder CommisionDayDetail . getOrderTime ( ) . getYear ( ) + " " + sysOrderCommisionDayDetail . getOrderTime ( ) . get Month (  ). getValue (  ); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         BigDecimal   m   =   ( everyYearMonthServerMoney . get ( ym )   = =   null )   ?   new   BigDecimal ( 0 )   :   everyYearMonthServerMoney  . get ( y m) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         ym_mession   =   ym_mession . add ( getMoney ( m . doubleValue ( )   *   rateMap . get ( orderYearMonth )   /   100D ,   1 ) ) ;  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     }  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 if ( isSendCommissionByYearMonth ( ym ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     totalHasSentCommissionAmount   =   totalHasSentCommissionAmount . add ( ym_mession ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     Map < String ,   Object >   map   =   new   HashMap < > ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     map . put ( " yearMonth " ,   ym ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     if ( i   ! =   commissionMonthSet . size ( ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         //计算未发放的提成(除最后一个月) 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         commissionA   =   commissionA . add ( ym_mession ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         map . put ( " yearMonthCommission " ,   ym_mession ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         //最后一个月除去已发放的月份的提成,再减去前面未发放提成,防止出现误差 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         map . put ( " yearMonthCommission " ,   totalCommissionAmount . subtract ( totalHasSentCommissionAmount ) . subtract ( commissionA ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     sendDetailList . add ( map ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 i + + ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            }  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             m ap. put ( " yearMonth " ,   yearMonth ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            map . put ( " yearMonthCommission " ,   yearMonthCommiss  ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            if ( isSend Commiss ionByYearMonth ( year Month ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                hasSendYearMonthDetailList  . add ( map  ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            } else {  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                notHasSendYearMonthDetailList . add ( map ) ;  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setTotalCommissionAmount ( totalCommissionAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setTotalHasSentCommissionAmount ( totalHasSentCommissionAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放提成 = 总提成 - 已发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setTotalNotSentCommissionAmoun t ( t otalCommissionAmount . subtract ( totalHasSentCommissionAmount ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setSendDetailList ( sendDetailList  ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setNextMonthCommission ( sendDetailList . size ( )   >   0   ?   ( BigDecimal ) sendDetailList . get ( 0 ) . get ( " yearMonthCommission " )   :   new   BigDecimal ( 0 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setTotalNotSentCommissionAmount ( totalNotHasSentCommissionAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setSendDetailLis t ( n otHasSendYearMonthDetailList ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysCommissionDayDetail . setNextMonthCommission ( notHasSendYearMonthDetailList . size ( )   >   0   ?   ( BigDecimal ) notHasSendYearMonthDetailList . get ( 0 ) . get ( " yearMonthCommission " )   :   new   BigDecimal ( 0 )  ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /** 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * 处理每个订单的提成,包括已发放、未发放提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @param sysOrderCommisionDayDetail 订单服务详情对象 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @param everyMonthTotalAmountMap 每个月成交总额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @param rateMap 提成比例 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     */ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   void   dealCommissionByOrderCommisionDayDetail ( SysOrderCommisionDayDetail   sysOrderCommisionDayDetail ,   Map < String ,   BigDecimal >   everyMonthTotalAmountMap ,   Map < String ,   Float >   rateMap ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         String   yearMonth   =   sysOrderCommisionDayDetail . getOrderTime ( ) . getYear ( )   +   " "   +   sysOrderCommisionDayDetail . getOrderTime ( ) . getMonth ( ) . getValue ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //该笔订单当月的成交总额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setMonthOrderTotalAmount ( everyMonthTotalAmountMap . get ( yearMonth ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //该笔订单对应提成比例 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setCommissionRate ( rateMap . get ( yearMonth ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //计算该笔订单总提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setOrderCommission ( getMoney ( sysOrderCommisionDayDetail . getOrderAmount ( ) . doubleValue ( )   *   sysOrderCommisionDayDetail . getCommissionRate ( )   /   100D ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //每年每月提成 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   BigDecimal >   everyYearMonthServerCommission   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //每年每月提成是否发放状态 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   Boolean >   everyYearMonthCommissionSendFlag   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //当前订单的提成总和,用于最后一个月相减 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   currentOrderCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //已发放提成金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalSendCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //未发放提成金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   totalNotSendCommission   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for   ( String   everyMonth   :   sysOrderCommisionDayDetail . getEveryYearMonthServerMoney ( ) . keySet ( ) )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             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 . setEveryYearMonthCommissionSendFlag ( everyYearMonthCommissionSendFlag ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setHasSendOrderCommission ( totalSendCommission ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setNotHasSendOrderCommission ( totalNotSendCommission ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /**判断该月提成是否已发放*/ 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -237,7 +368,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 continue ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //对每笔订单进行处理,统计出该比订单在每年每月对应的服务天数、金额、暂停天数等 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   =   statisticsOrderMessage ( sysOrder ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             SysOrderCommisionDayDetail   sysOrderCommisionDayDetail   =   statisticsOrderMessage ( sysOrder ,   sysCommision . getServerScopeStartTime ( ) ,   sysCommision . getServerScopeEndTime ( )  ); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             if ( sysOrder . getAfterSaleId ( )   ! =   null   & &   sysOrder . getAfterSaleId ( )   >   0L ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 addUserOrderResultMap ( sysOrder . getAfterSaleId ( ) ,   sysOrderCommisionDayDetail ,   userOrderResultMap ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -264,7 +395,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 ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //订单总服务月数 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -288,26 +419,70 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //服务总天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         int   serverDay   =   getTotalByMap ( everyYearMonthServerDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //每天对应金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   dayMoney   =   getMoney ( orderAmount . doubleValue ( ) / serverDay ,   1  ); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         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 . setOrderId ( sysOrder . getOrderId ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setOrderTime ( DateUtils . dateToLocalDateTime ( sysOrder . getOrderTime ( ) ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setName ( sysOrder . getCustomer ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setServerStartDate ( serverStartDate ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setServerEndDate ( serverEndDate ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setServerMonth ( serverMonth ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setGiveDay ( giveDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setPauseTotalDay ( pauseTotalDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setOrderAmount ( orderAmount ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setServerDay ( serverDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setDayMoney ( dayMoney ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setEveryYearMonthPauseDay ( everyYearMonthPauseDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         sysOrderCommisionDayDetail . setEveryYearMonthServerDay ( everyYearMonthServerDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         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   =   getRealEveryMonthServerMoney ( realEveryYearMonthServerDay ,   orderAmount ,   dayMoney ,   serverEndDate ,   everyYearMonthServerDay ,   everyYearMonthServerMoney ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //服务时间范围内暂停天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setPauseTotalDay ( realPauseTotalDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setEveryYearMonthPauseDay ( realEveryYearMonthPauseDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setServerDay ( realServerDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setEveryYearMonthServerDay ( realEveryYearMonthServerDay ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setEveryYearMonthServerMoney ( realEveryYearMonthServerMoney ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             sysOrderCommisionDayDetail . setOrderAmount ( getBigDecimalTotalByMap ( realEveryYearMonthServerMoney ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         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 暂停记录集合 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -362,6 +537,17 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         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 服务开始时间 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -377,27 +563,81 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param everyMonthServerDay 每年每月服务天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param orderMoney 订单总额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @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 ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Set < String >   keySet   =   everyMonthServerDay . keySet ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         int   i   =   1 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         double   totalMoney   =   0 . 0 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   total   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for ( String   key   :   keySet ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             if ( i + +   ! =   keySet . size ( ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   getMoney ( everyMonthServerDay . get ( key )   *   dayMoney . double Value ( ) ,   1  )) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 totalMoney   + =   everyMonthServerMoney . get ( key ) . doubleValue ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //判断是否为最后一个月 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            if ( key . equals ( serverEndTime . getYear ( ) + " " + serverEndTime . getMonth ( ) . get Value ( ) ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 //由于小数保留问题,最后一个月的金额等于总额减去前几个月金额,避免总数不一致 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   orderMoney . subtract ( total ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 //由于小数点只保留一位,最后一个月的金额等于总额减去前几个月金额,避免总数不一致 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   getMoney ( orderMoney . doubleValue ( )   -   totalMoney ,   1 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   getMoney ( everyMonthServerDay . get ( key )   *   dayMoney . doubleValue ( ) ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 total   =   total . add ( everyMonthServerMoney . get ( key ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         return   everyMonthServerMoney ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /** 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * 获取订单服务时间范围中每年每月服务金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param everyMonthServerDay 真正每年每月服务天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param orderMoney 订单总额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param dayMoney 每天对于金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param serverEndTime 订单服务结束时间 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param everyYearMonthServerDay 整个订单的每年每月服务天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * @Param everyYearMonthServerMoney 整个订单的每年每月服务金额 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * */ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   Map < String ,   BigDecimal >   getRealEveryMonthServerMoney ( Map < String ,   Integer >   realEveryMonthServerDay ,   BigDecimal   orderMoney ,   BigDecimal   dayMoney ,   LocalDate   serverEndTime , 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                                                                 Map < String ,   Integer >   everyYearMonthServerDay ,   Map < String ,   BigDecimal >   everyYearMonthServerMoney ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   BigDecimal   >   everyMonthServerMoney   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Set < String >   keySet   =   realEveryMonthServerDay . keySet ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         BigDecimal   total   =   null ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         String   lastMonth   =   serverEndTime . getYear ( ) + " " + serverEndTime . getMonth ( ) . getValue ( ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for ( String   key   :   keySet ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             //判断是否为最后一个月,以及实际这个月的服务时间是否等于该整个订单最后一个月的天数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             if ( key . equals ( lastMonth )   & &   realEveryMonthServerDay . get ( key ) . intValue ( )   = =   everyYearMonthServerDay . get ( key ) . intValue ( )   ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 //由于小数保留问题,最后一个月的金额等于总额减去前几个月金额,避免总数不一致 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 total   =   BigDecimal . valueOf ( 0 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 //获取该笔订单除最后一个月的金额总和 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 for   ( String   orderYearMonth   :   everyYearMonthServerMoney . keySet ( ) )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     if ( ! orderYearMonth . equals ( lastMonth ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                         total   =   total . add ( everyYearMonthServerMoney . get ( orderYearMonth ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   orderMoney . subtract ( total ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 everyMonthServerMoney . put ( key ,   getMoney ( realEveryMonthServerDay . get ( key )   *   dayMoney . doubleValue ( ) ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         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 ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Map < String ,   Integer >   everyYearMonthServerDay   =   new   TreeMap < > ( new   MyComparator ( ) ) ; 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -407,8 +647,8 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         LocalDate   everyMonthLastDate   =   everyMonthFirstDate . with ( TemporalAdjusters . lastDayOfMonth ( ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         int   day   =   0 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         boolean   breakFlag   =   false ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //写100防止死循环 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for ( int   i   =   0 ;   i   <   100 ;   i + + ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         //写1000 防止死循环 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         for ( int   i   =   0 ;   i   <   1000  ;   i + + ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             if ( ChronoUnit . DAYS . between ( everyMonthLastDate ,   endDate )   >   0 ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 day   =   Period . between ( everyMonthFirstDate ,   everyMonthLastDate ) . getDays ( )   +   1 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } else { 
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -436,9 +676,9 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     /** 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * double转为BigDecimal,  保留一 位小数,向下舍去  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * double转为BigDecimal,  保留2 位小数,四舍五入  
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     * */ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   BigDecimal   getMoney ( Double   money ,   int   n  ){ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   BigDecimal   getMoney ( Double   money ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         return   new   BigDecimal ( money . toString ( ) ) . setScale ( 2 ,   BigDecimal . ROUND_HALF_UP ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
	
		
			
				
					
					
						
					 
				
			
			 
			 
			
				@@ -449,31 +689,12 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         @Override 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         public   int   compare ( String   o1 ,   String   o2 )   { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             return   Integer . parseInt ( o1 )   -   Integer . parseInt ( o2 ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             if ( o1 . substring ( 0 , 4 ) . equals ( o2 . substring ( 0 , 4 ) ) ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 return   Integer . parseInt ( o1 . substring ( 4 ) )   -   Integer . parseInt ( o2 . substring ( 4 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } else { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				                 return   Integer . parseInt ( o1 . substring ( 0 , 4 ) )   -   Integer . parseInt ( o2 . substring ( 0 , 4 ) ) ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				             } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     public   static   void   main ( String [ ]   args ) { 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         Double   s   =   31190 . 1 ; 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        /* NumberFormat nf = NumberFormat.getNumberInstance(); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        // 保留小数位数 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        nf.setMaximumFractionDigits(1); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        // 如果不需要四舍五入,可以使用 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        nf.setRoundingMode(RoundingMode.DOWN); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(Double.parseDouble(nf.format(s))); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println( new BigDecimal(nf.format(s)).doubleValue());*/ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         /*System.out.println(new BigDecimal(s).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        LocalDate localDate = LocalDate.of(2020, 1, 15); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(ChronoUnit.MONTHS.between(localDate, LocalDate.now())); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(localDate.getDayOfMonth()); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(localDate.getDayOfWeek()); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(localDate.getDayOfYear()); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(ChronoUnit.DAYS.between(LocalDate.of(2021, 1,14), LocalDate.now()));*/ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				         /*System.out.println(ts(109792.8 * 6 / 100D, 1)); 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        System.out.println(ts(6587.8,2).doubleValue());*/ 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				     } 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}