Browse Source

导出技术员奖金等

limin 7 years ago
parent
commit
bc46c601f7

+ 1 - 0
src/main/java/com/goafanti/common/dao/TOrderBonusMapper.java

@@ -111,5 +111,6 @@ public interface TOrderBonusMapper {
 	int updateByPrimaryKey(TOrderBonus record);
 	List<TOrderBonusBo> getDeptBySome(TOrderBonusBo bonusBo);
 	List<TOrderBonusBo> getBonusData(TOrderBonusBo bonusBo);
+	List<TOrderBonusBo> getSaleBounsList(TOrderBonusBo bonusBo);
 	
 }

+ 6 - 0
src/main/java/com/goafanti/common/dao/TOrderMonthReportMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 
 import com.goafanti.common.model.TOrderMonthReport;
 import com.goafanti.common.model.TOrderMonthReportExample;
+import com.goafanti.common.model.TOrderNew;
 import com.goafanti.order.bo.OrderReportBo;
 
 public interface TOrderMonthReportMapper {
@@ -82,4 +83,9 @@ public interface TOrderMonthReportMapper {
 	List<OrderReportBo> exportMonthData(OrderReportBo orderReportBo);
 	
 	int checkData(OrderReportBo orderReportBo);
+	
+	List<OrderReportBo> getMonthReportByMonth(OrderReportBo orderReportBo);
+	List<OrderReportBo> getYearReportByYear(OrderReportBo orderReportBo);
+	
+	int proofDataBySomeBody(TOrderNew orderNew);
 }

+ 94 - 43
src/main/java/com/goafanti/common/mapper/TOrderBonusMapper.xml

@@ -361,24 +361,27 @@
   		left join admin a on a.id = t.task_receiver 
   		left join admin oa on oa.id = o.salesman_id
   		left join admin ga on ga.id = b.grant_by 
-  		where b.grant_status = 1
+  		where  b.grant_type = 1
   		<if test="b.grantBy != null">
   		and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.targetName != null and b.targetName != &quot;&quot;">
+  		<if test='b.targetName != null and b.targetName != ""'>
   		<bind name="tn" value="'%' + b.targetName + '%'" />
   		and a.name like #{tn,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.salesName != null and b.salesName != &quot;&quot;">
+  		<if test='b.salesName != null and b.salesName != ""'>
   		<bind name="sn" value="'%' + b.salesName + '%'" />
   		and oa.name like #{sn,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.departmentId != null and b.departmentId !=&quot;&quot;">
+  		<if test='b.departmentId != null and b.departmentId != ""'>
   		and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.startTime != null and b.startTime != &quot;&quot; and b.endTime != null and b.endTime != &quot;&quot;">
-  		<bind name="a" value="b.startTime + ' 00:00:00'" />
-  		<bind name="e" value="b.endTime + ' 23:59:59'" />
+  		<if test="b.grantStatus != null">
+		and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
+		</if>
+  		<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+  		<bind name="a" value="b.startTime +'-01'"/>
+  		<bind name="e" value="b.endTime +'-31'"/>
   		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
   		</if>
   		order by b.grant_status ,b.create_time 
@@ -393,24 +396,27 @@
   		left join t_order_task t on t.order_no = b.order_no and t.main=1
   		left join admin a on a.id = t.task_receiver 
   		left join admin oa on oa.id = o.salesman_id
-  		where b.grant_status = 1
+  		where b.grant_type = 1
   		<if test="b.grantBy != null">
   		and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.targetName != null and b.targetName != &quot;&quot;">
+  		<if test='b.targetName != null and b.targetName != ""'>
   		<bind name="tn" value="'%' + b.targetName + '%'" />
   		and a.name like #{tn,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.salesName != null and b.salesName != &quot;&quot;">
+  		<if test='b.salesName != null and b.salesName != ""'>
   		<bind name="sn" value="'%' + b.salesName + '%'" />
   		and oa.name like #{sn,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.departmentId != null and b.departmentId !=&quot;&quot;">
+  		<if test='b.departmentId != null and b.departmentId != ""'>
   		and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
   		</if>
-  		<if test="b.startTime != null and b.startTime != &quot;&quot; and b.endTime != null and b.endTime != &quot;&quot;">
-  		<bind name="a" value="b.startTime + ' 00:00:00'" />
-  		<bind name="e" value="b.endTime + ' 23:59:59'" />
+  		<if test="b.grantStatus != null">
+		and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
+		</if>
+  		<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+  		<bind name="a" value="b.startTime +'-01'"/>
+  		<bind name="e" value="b.endTime +'-31'"/>
   		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
   		</if>
   </select>
@@ -420,27 +426,31 @@
 	o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount, 
 	o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
 	o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
-	o.proof_count as proofCount, b.grant_status as grant_status, a.name as salesName
-	
+	o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName, o.proof_status as proofStatus,
+	ad.name as byName
 	from t_order_bonus b
 	left join t_order_new o on o.order_no = b.order_no
 	left join admin a on o.salesman_id = a.id
 	left join `user` u on o.buyer_id = u.id
-	where b.grant_status = 0
+	left join admin ad on b.grant_by = ad.id
+	where b.grant_type = 0
 	
 	<if test="b.grantBy != null">
 	and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
 	</if>
-	<if test="b.salesName != null and b.salesName != &quot;&quot;">
+	<if test='b.salesName != null and b.salesName != ""'>
 	<bind name="sn" value="'%' + b.salesName + '%'" />
 	and a.name like #{sn,jdbcType=VARCHAR}
 	</if>
-	<if test="b.departmentId != null and b.departmentId !=&quot;&quot;">
+	<if test='b.departmentId != null and b.departmentId !=""'>
 	and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
 	</if>
-	<if test="b.startTime != null and b.startTime != &quot;&quot; and b.endTime != null and b.endTime != &quot;&quot;">
-	<bind name="a" value="b.startTime + ' 00:00:00'" />
-	<bind name="e" value="b.endTime + ' 23:59:59'" />
+	<if test="b.grantStatus != null">
+	and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
+	</if>
+	<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+	<bind name="a" value="b.startTime +'-01'"/>
+	<bind name="e" value="b.endTime +'-31'"/>
 	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
 	</if>
 	order by b.grant_status , b.create_time
@@ -455,20 +465,23 @@
 	left join t_order_new o on o.order_no = b.order_no
 	left join admin a on o.salesman_id = a.id
 	left join `user` u on o.buyer_id = u.id
-	where b.grant_status = 0
+	where b.grant_type = 0
 	<if test="b.grantBy != null">
 	and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
 	</if>
-	<if test="b.salesName != null and b.salesName != &quot;&quot;">
+	<if test='b.salesName != null and b.salesName != ""'>
 	<bind name="sn" value="'%' + b.salesName + '%'" />
 	and a.name like #{sn,jdbcType=VARCHAR}
 	</if>
-	<if test="b.departmentId != null and b.departmentId !=&quot;&quot;">
+	<if test='b.departmentId != null and b.departmentId !=""'>
 	and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
 	</if>
-	<if test="b.startTime != null and b.startTime != &quot;&quot; and b.endTime != null and b.endTime != &quot;&quot;">
-	<bind name="a" value="b.startTime + ' 00:00:00'" />
-	<bind name="e" value="b.endTime + ' 23:59:59'" />
+	<if test="b.grantStatus != null">
+	and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
+	</if>
+	<if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
+	<bind name="a" value="b.startTime +'-01'"/>
+	<bind name="e" value="b.endTime +'-31'"/>
 	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
 	</if>
   </select>
@@ -481,21 +494,24 @@
 	left join admin a on b.grant_target = a.id
 	left join `user` u on o.buyer_id = u.id
 	left join department d on d.id = a.department_id
-	where b.grant_status = 0
+	where  b.grant_type = #{grantType,jdbcType=INTEGER}
 	<if test="grantBy != null">
 	and b.grant_by = #{grantBy,jdbcType=VARCHAR}
 	</if>
-	<if test="salesName != null and salesName != &quot;&quot;">
+	<if test='salesName != null and salesName != ""'>
 	<bind name="sn" value="'%' + salesName + '%'" />
 	and a.name like #{sn,jdbcType=VARCHAR}
 	</if>
-	<if test="departmentId != null and departmentId !=&quot;&quot;">
+	<if test='departmentId != null and departmentId != ""'>
 	and a.department_id = #{departmentId,jdbcType=VARCHAR}
 	</if>
-	<if test="startTime != null and startTime != &quot;&quot; and endTime != null and endTime != &quot;&quot;">
-	<bind name="a" value="startTime + ' 00:00:00'" />
-	<bind name="e" value="endTime + ' 23:59:59'" />
-	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+	<if test="grantStatus != null">
+	and b.grant_status = #{grantStatus,jdbcType=INTEGER}
+	</if>
+	<if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
+	<bind name="a" value="startTime +'-01'"/>
+ 	<bind name="e" value="endTime +'-31'"/>
+ 	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
 	</if>
   </select>
   <!-- 获得及技术员奖金数据 -->
@@ -511,26 +527,61 @@
   		left join admin a on a.id = t.task_receiver 
   		left join admin oa on oa.id = o.salesman_id
   		left join admin ga on ga.id = b.grant_by 
-  		where b.grant_status = 0
+  		where b.grant_type = 1
   		<if test="grantBy != null">
   		and b.grant_by = #{grantBy,jdbcType=VARCHAR}
   		</if>
-  		<if test="targetName != null and targetName != &quot;&quot;">
+  		<if test='targetName != null and targetName != ""'>
   		<bind name="tn" value="'%' + targetName + '%'" />
   		and a.name like #{tn,jdbcType=VARCHAR}
   		</if>
-  		<if test="salesName != null and salesName != &quot;&quot;">
+  		<if test='salesName != null and salesName != ""'>
   		<bind name="sn" value="'%' + salesName + '%'" />
   		and oa.name like #{sn,jdbcType=VARCHAR}
   		</if>
-  		<if test="departmentId != null and departmentId !=&quot;&quot;">
+  		<if test='departmentId != null and departmentId !=""'>
   		and a.department_id = #{departmentId,jdbcType=VARCHAR}
   		</if>
-  		<if test="startTime != null and startTime != &quot;&quot; and endTime != null and endTime != &quot;&quot;">
-  		<bind name="a" value="b.startTime + ' 00:00:00'" />
-  		<bind name="e" value="b.endTime + ' 23:59:59'" />
-  		and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+  		<if test="grantStatus != null">
+		and b.grant_status = #{grantStatus,jdbcType=INTEGER}
+		</if>
+  		<if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
+  		<bind name="a" value="startTime +'-01'"/>
+	 	<bind name="e" value="endTime +'-31'"/>
+	 	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
   		</if>
   		order by b.grant_status ,b.create_time 
   </select>
+  <!-- 查看营销员的奖金数据 -->
+  <select id="getSaleBounsList" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
+  select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
+	o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount, 
+	o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
+	o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
+	o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName
+	
+	from t_order_bonus b
+	left join t_order_new o on o.order_no = b.order_no
+	left join admin a on o.salesman_id = a.id
+	left join `user` u on o.buyer_id = u.id
+	where b.grant_type = 0
+	<if test="grantBy != null">
+	and b.grant_by = #{grantBy,jdbcType=VARCHAR}
+	</if>
+	<if test='salesName != null and salesName != ""'>
+	<bind name="sn" value="'%' + salesName + '%'" />
+	and a.name like #{sn,jdbcType=VARCHAR}
+	</if>
+	<if test='departmentId != null and departmentId !=""'>
+	and a.department_id = #{departmentId,jdbcType=VARCHAR}
+	</if>
+	<if test="grantStatus != null">
+	and b.grant_status = #{grantStatus,jdbcType=INTEGER}
+	</if>
+	<if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
+	<bind name="a" value="startTime +'-01'"/>
+	<bind name="e" value="endTime +'-31'"/>
+	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
+	</if>
+  </select>
 </mapper>

+ 40 - 0
src/main/java/com/goafanti/common/mapper/TOrderMonthReportMapper.xml

@@ -404,4 +404,44 @@
 	where salemans_id = #{salemansId,jdbcType=VARCHAR} and `month` = #{month,jdbcType=INTEGER}
 	and type = #{type,jdbcType=INTEGER}
  </select>
+ <!-- 查看某时间范围内的月统计 -->
+ <select id="getMonthReportByMonth" parameterType="com.goafanti.order.bo.OrderReportBo" resultType="com.goafanti.order.bo.OrderReportBo">
+ 	select salemans_id as salemansId, sum(case `type` when 0 then proof_count else 0 end) renzm ,sum(case `type` when 1 then proof_count else 0 end) kejim
+	from 
+	t_order_month_report
+	where `month` between  #{month,jdbcType=INTEGER} and #{month1,jdbcType=INTEGER}
+	<if test="salemansId != null">
+		and salemans_id = #{salemansId,jdbcType=VARCHAR}
+	</if>
+	<if test="salemansId == null">
+		group by salemans_id
+	</if>
+ </select>
+ <!-- 查看某时间范围内的年统计 -->
+ <select id="getYearReportByYear" parameterType="com.goafanti.order.bo.OrderReportBo" resultType="com.goafanti.order.bo.OrderReportBo">
+ 	select sum(case `type` when 0 then proof_count else 0 end) renzy ,sum(case `type` when 1 then proof_count else 0 end) kejiy
+	from 
+	t_order_year_report
+	where `year` between #{month,jdbcType=INTEGER} and #{month1,jdbcType=INTEGER}
+	<if test="salemansId != null">
+		and salemans_id = #{salemansId,jdbcType=VARCHAR}
+	</if>
+	<if test="salemansId == null">
+		group by salemans_id
+	</if>
+ </select>
+ <!-- 更新某人某月份某类型的数据 -->
+ <update id="proofDataBySomeBody" parameterType="com.goafanti.common.model.TOrderNew">
+ UPDATE t_order_month_report m,
+	(select sum(proof_count) as proof_count, sum(total_amount) as amount , order_type, salesman_id  from t_order_new 
+	  	where  
+	  	proof_status = 1 
+	  	and salesman_id = #{salesmanId,jdbcType=VARCHAR} 
+	  	and order_type = #{orderType,jdbcType=INTEGER}
+	  	and date_format( sign_time , '%Y%m' )  = date_format( #{signTime,jdbcType=DATE}, '%Y%m' )) as o
+  	
+  	SET m.proof_count = o.proof_count, m.amount = o.amount
+  	
+  	WHERE  m.type = o.order_type and m.salemans_id = o.salesman_id and m.month =  date_format( #{signTime,jdbcType=DATE}, '%Y%m' )
+ </update>
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -1251,7 +1251,7 @@
   
   <!-- 财务同意退款邮件通知需要的数据  -->
   <select id="agreeEmailData" parameterType="java.lang.Integer" resultType="com.goafanti.order.bo.TOrderNewBo">
-  	select u.nickname as userName, r.order_no as orderNo, o.order_status as orderStaus, o.salesman_id as salesmanId
+  	select u.nickname as userName, r.order_no as orderNo, o.order_status as orderStatus, o.salesman_id as salesmanId,
   		concat(a.email,"," , ifnull(t.email,"")) as email , concat(a.name,"," , ifnull(t.name,"")) as salesmanName
   		from t_order_refund r
   		left join t_order_new o on r.order_no = o.order_no

+ 13 - 24
src/main/java/com/goafanti/common/mapper/TOrderRefundMapper.xml

@@ -459,24 +459,24 @@
   	 left join `user` u on o.buyer_id = u.id
   	 left join admin a on o.salesman_id = a.id
   	where accept = #{r.accept,jdbcType=VARCHAR}
-  	and refund_status &lt; 2
+  	<if test='r.refundStatus != null and r.refundStatus != ""'>
+  		and r.refund_status = #{r.refundStatus,jdbcType=INTEGER} - 1
+  	</if>
+  	<if test='r.refundStatus == null or r.refundStatus == ""'>
+  		and refund_status &lt; 2
+  	</if>
   	<if test='r.id != null and r.id != ""'>
-  		and id= #{r.id,jdbcType=INTEGER}
+  		and r.id= #{r.id,jdbcType=INTEGER}
   	</if>
   	<if test='r.orderNo != null and r.orderNo != ""'>
-  		and order_no = #{r.orderNo,jdbcType=VARCHAR}
+  		and r.order_no = #{r.orderNo,jdbcType=VARCHAR}
   	</if>
   	<if test='r.buyName != null and r.buyName != ""'>
 	  	<bind name="a" value="'%' + r.buyName + '%'"/>
   		and u.nickname like #{a,jdbcType=VARCHAR}
   	</if>
-  	<if test='r.refundStatus != null and r.refundStatus != ""'>
-  		and r.refundStatus = #{refundStatus,jdbcType=INTEGER}
-  	</if>
   	<if test='r.startTime != null and r.startTime != "" and r.endTime != null and r.endTime != ""'>
-	  	<bind name="a" value="r.startTime + ' 00:00:00'"/>
-	  	<bind name="b" value="r.endTime + ' 23:59:59'"/>
-	  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
+	  	and o.sign_time between #{r.startTime,jdbcType=VARCHAR} and #{r.endTime,jdbcType=VARCHAR}
 	</if>
 	order by r.refund_status
   	<if test="page_sql!=null">
@@ -490,12 +490,12 @@
   	 left join `user` u on o.buyer_id = u.id
   	 left join admin a on o.salesman_id = a.id
   	where accept = #{r.accept,jdbcType=VARCHAR}
+  	<if test='r.refundStatus != null and r.refundStatus != ""'>
+  		and r.refund_status = #{r.refundStatus,jdbcType=INTEGER}
+  	</if>
   	<if test='r.refundStatus == null or r.refundStatus == ""'>
   		and refund_status &lt; 2
   	</if>
-  	<if test='r.refundStatus != null and r.refundStatus != ""'>
-  		and r.refundStatus = #{refundStatus,jdbcType=INTEGER}
-  	</if>
   	<if test='r.id != null and r.id != ""'>
   		and id= #{r.id,jdbcType=INTEGER}
   	</if>
@@ -507,9 +507,7 @@
   		and u.nickname like #{a,jdbcType=VARCHAR}
   	</if>
   	<if test='r.startTime != null and r.startTime != "" and r.endTime != null and r.endTime != ""'>
-	  	<bind name="a" value="r.startTime + ' 00:00:00'"/>
-	  	<bind name="b" value="r.endTime + ' 23:59:59'"/>
-	  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
+	  	and o.sign_time between #{r.startTime,jdbcType=VARCHAR} and #{r.endTime,jdbcType=VARCHAR}
 	</if>
   </select>
   <!-- 修改退款数据 -->
@@ -534,15 +532,6 @@
       <if test="result != null">
         result = #{result,jdbcType=VARCHAR},
       </if>
-      <if test="reasonAttachmentUrl != null">
-        reason_attachment_url = #{reasonAttachmentUrl,jdbcType=LONGVARCHAR},
-      </if>
-      <if test="contractUrl != null">
-        contract_url = #{contractUrl,jdbcType=LONGVARCHAR},
-      </if>
-      <if test="applicationUrl != null">
-        application_url = #{applicationUrl,jdbcType=LONGVARCHAR},
-      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>

+ 71 - 6
src/main/java/com/goafanti/common/utils/ExportExcelUtil.java

@@ -13,11 +13,6 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@@ -519,6 +514,76 @@ public class ExportExcelUtil {
 		return wb;
 	}
 	
-	
+	/**
+	 * 导出营销部部门奖金的数据
+	 * @param map
+	 * @param deptnames
+	 * @return
+	 */
+	public static XSSFWorkbook exportDeptBonusInfoS(Map<String,List<TOrderBonusBo>> map,String[] deptnames){
+		String comment[] = {"订单编号", "订单负责人", "签单日期", "客户名称", "签单金额", "首付款", "已收","已退","订单状态","项目状态","发放类型",
+							"校对后单量","发放状态","当月认证项目数量","当月科技项目数量","年度认证项目数量","年度科技项目数量"};
+		//map 数据 ,deptnames 部门名称,comment表头 (列名称)
+		//1,创建一个workbook,对应的是一个excel文件
+		XSSFWorkbook wb = new XSSFWorkbook();
+		int count = 0;
+		//遍历map
+		for (Map.Entry<String,List<TOrderBonusBo>> entry : map.entrySet()) {
+			//2.创建一个sheet
+			XSSFSheet sheet = wb.createSheet(entry.getKey());
+			//3。创建一个row
+			XSSFRow row = sheet.createRow(0);
+			//4.创建一个cell
+			XSSFCell cell = row.createCell(0);
+			cell.setCellValue(deptnames[count]+" 奖金记录");
+			count ++;
+			XSSFCellStyle style1 = setCellStyle1(wb);
+			cell.setCellStyle(style1);
+			//合并列
+			sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, comment.length-1));//合并单元格
+			//创建表头
+			XSSFRow row2 = sheet.createRow(1);
+			for(int i = 0; i < comment.length; i++){
+				sheet.setColumnWidth(i, 3000);//设置列宽
+				XSSFCell c = row2.createCell(i);
+				c.setCellValue(comment[i]);
+				c.setCellStyle(style1);
+			}
+			//填充表格数据
+			//int rowmnum = sheet.getLastRowNum();//获得当前行数据
+			List<TOrderBonusBo> list = entry.getValue();
+			if(list == null){
+				continue;
+			}
+			for (TOrderBonusBo ob : list) {
+				//新增一行
+//				String comment[] = {"订单编号", "订单负责人", "签单日期", "客户名称", "签单金额", "首付款", "已收","已退","订单状态","项目状态","发放类型",
+//						"校对后单量","发放状态","当月认证项目数量","当月科技项目数量","年度认证项目数量","年度科技项目数量"};
+				XSSFRow r = sheet.createRow(sheet.getLastRowNum()+1);
+				r.createCell(0).setCellValue(ob.getOrderNo());
+				r.createCell(1).setCellValue(ob.getSalesName());
+				r.createCell(2).setCellValue(ob.getSignTime());
+				r.createCell(3).setCellValue(ob.getBuyName());
+				r.createCell(4).setCellValue(ob.getTotalAmount().toString());
+				r.createCell(5).setCellValue(ob.getFirstAmount().toString());
+				r.createCell(6).setCellValue(ob.getSettlementAmount().toString());
+				r.createCell(7).setCellValue(ob.getRefundAmount().toString());
+				
+				r.createCell(8).setCellValue(OrderNewState.getValueByCode(ob.getOrderStatus()));
+				r.createCell(9).setCellValue(ProjectNewStage.getValueByCode(ob.getProjectStatus()));
+				
+				r.createCell(10).setCellValue(BonusSubject.getValueByCode(ob.getBonusSubject()));
+				r.createCell(11).setCellValue(ob.getProofCount());
+				r.createCell(12).setCellValue(ob.getGrantStatus() == 0? "未发放":"已发放");
+				
+				r.createCell(13).setCellValue(ob.getRenzm());
+				r.createCell(14).setCellValue(ob.getKejim());
+				r.createCell(15).setCellValue(ob.getRenzy());
+				r.createCell(16).setCellValue(ob.getRenzy());
+				
+			}
+		}
+		return wb;
+	}
 	
 }

+ 22 - 1
src/main/java/com/goafanti/common/utils/SendEmailUtil.java

@@ -18,13 +18,34 @@ import javax.mail.internet.MimeUtility;
 import com.goafanti.common.bo.EmailBo;
 import com.goafanti.order.enums.OrderNewState;
 
+
+//public class Singleton {
+//
+//    private static volatile Singleton singleton;
+//
+//    private Singleton() {}
+//
+//    public static Singleton getInstance() {
+//        if (singleton == null) {
+//            synchronized (Singleton.class) {
+//                if (singleton == null) {
+//                    singleton = new Singleton();
+//                }
+//            }
+//        }
+//        return singleton;
+//    }
+//}
+
 public class SendEmailUtil {
 	public static final String HOST = "smtp.163.com";
 	public static final String PORT = "465";
 	public static final String AUTH_USER_NICKNAME = "湖南科德信息咨询有限公司";
-	public static final String FROM = "13077305639@163.com";// 发件人的email
+	public static final String FROM = "13875952633@163.com";// 发件人的email
 	public static final String PWD = "kede2018";// 发件人密码
 	public static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
+	
+	
 
 	private static Session getSession() {
 		Properties props = new Properties();

+ 0 - 7
src/main/java/com/goafanti/order/bo/OrderRefundBo.java

@@ -12,7 +12,6 @@ public class OrderRefundBo extends TOrderRefund {
 	private String saleId;
 	private String startTime;
 	private String endTime;
-	private Integer refundStatus;
 	public String getBuyName() {
 		return buyName;
 	}
@@ -61,10 +60,4 @@ public class OrderRefundBo extends TOrderRefund {
 	public void setEndTime(String endTime) {
 		this.endTime = endTime;
 	}
-	public Integer getRefundStatus() {
-		return refundStatus;
-	}
-	public void setRefundStatus(Integer refundStatus) {
-		this.refundStatus = refundStatus;
-	}
 }

+ 28 - 0
src/main/java/com/goafanti/order/bo/OrderReportBo.java

@@ -9,6 +9,10 @@ public class OrderReportBo  extends TOrderMonthReport{
 	private Integer month1;
 	private Integer rowNumber;
 	private String mobile;
+	private String kejim;
+	private String renzm;
+	private String kejiy;
+	private String renzy;
 	
 	public String getSaleName() {
 		return saleName;
@@ -46,5 +50,29 @@ public class OrderReportBo  extends TOrderMonthReport{
 	public void setRowNumber(Integer rowNumber) {
 		this.rowNumber = rowNumber;
 	}
+	public String getKejim() {
+		return kejim;
+	}
+	public void setKejim(String kejim) {
+		this.kejim = kejim;
+	}
+	public String getRenzm() {
+		return renzm;
+	}
+	public void setRenzm(String renzm) {
+		this.renzm = renzm;
+	}
+	public String getKejiy() {
+		return kejiy;
+	}
+	public void setKejiy(String kejiy) {
+		this.kejiy = kejiy;
+	}
+	public String getRenzy() {
+		return renzy;
+	}
+	public void setRenzy(String renzy) {
+		this.renzy = renzy;
+	}
 	
 }

+ 46 - 0
src/main/java/com/goafanti/order/bo/TOrderBonusBo.java

@@ -55,6 +55,12 @@ public class TOrderBonusBo extends TOrderBonus{
 	
 	private Integer orderStatus; //订单状态
 	private Float proofCount; //校对量
+	private Integer proofStatus; //校对状态
+	
+	private String kejim;
+	private String renzm;
+	private String kejiy;
+	private String renzy;
 	
 	private Integer main;
 
@@ -305,5 +311,45 @@ public class TOrderBonusBo extends TOrderBonus{
 	public void setDepartmentName(String departmentName) {
 		this.departmentName = departmentName;
 	}
+
+	public String getKejim() {
+		return kejim;
+	}
+
+	public void setKejim(String kejim) {
+		this.kejim = kejim;
+	}
+
+	public String getRenzm() {
+		return renzm;
+	}
+
+	public void setRenzm(String renzm) {
+		this.renzm = renzm;
+	}
+
+	public String getKejiy() {
+		return kejiy;
+	}
+
+	public void setKejiy(String kejiy) {
+		this.kejiy = kejiy;
+	}
+
+	public String getRenzy() {
+		return renzy;
+	}
+
+	public void setRenzy(String renzy) {
+		this.renzy = renzy;
+	}
+
+	public Integer getProofStatus() {
+		return proofStatus;
+	}
+
+	public void setProofStatus(Integer proofStatus) {
+		this.proofStatus = proofStatus;
+	}
 	
 }

+ 19 - 11
src/main/java/com/goafanti/order/controller/FundManagerOrderApiController.java

@@ -22,6 +22,7 @@ import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.model.TOrderBack;
 import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderRefund;
+import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.order.bo.OrderListBo;
 import com.goafanti.order.bo.OrderRefundBo;
@@ -130,12 +131,14 @@ public class FundManagerOrderApiController extends CertifyApiController {
 			return res;
 		}
 		//流水时间处理
-		try {
-			billNew.setFinancialPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(billNew.getFinancialPayTimes()));
-		} catch (ParseException e) {
-			e.printStackTrace();
-			res.getError().add(buildError("", "财务流水时间有误!"));
-			return res;
+		if(StringUtils.isNotEmpty(billNew.getFinancialPayTimes())){
+			try {
+				billNew.setFinancialPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(billNew.getFinancialPayTimes()));
+			} catch (ParseException e) {
+				e.printStackTrace();
+				res.getError().add(buildError("", "财务流水时间有误!"));
+				return res;
+			}
 		}
 		Integer i = fundManageOrderServiceImpl.addReceiptsFlow(billNew);
 		if(i>0){
@@ -157,6 +160,9 @@ public class FundManagerOrderApiController extends CertifyApiController {
 	public Result getRefundList(OrderRefundBo refund, Integer pageNo, Integer pageSize){
 		Result res = new Result();
 		refund.setAccept(TokenManager.getAdminId());
+		if(null != refund.getRefundStatus()){
+			refund.setRefundStatus(refund.getRefundStatus() + 1);
+		}
 		res.setData(orderRefundServiceImpl.getRefundList(refund, pageNo, pageSize));
 		return res;
 	}
@@ -194,12 +200,14 @@ public class FundManagerOrderApiController extends CertifyApiController {
 			res.getError().add(buildError("", "备注长度不能大于255"));
 			return res;
 		}
-		try {
+		if(StringUtils.isNotEmpty(orderRefund.getFinancialPayTimes())){
+			try {
 			orderRefund.setFinancialPayTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(orderRefund.getFinancialPayTimes()));
-		} catch (ParseException e) {
-			e.printStackTrace();
-			res.getError().add(buildError("", "财务流水时间有误!"));
-			return res;
+			} catch (ParseException e) {
+				e.printStackTrace();
+				res.getError().add(buildError("", "财务流水时间有误!"));
+				return res;
+			}
 		}
 		int r = fundManageOrderServiceImpl.addRefundFlow(orderRefund);
 		if(r>0){

+ 34 - 8
src/main/java/com/goafanti/order/controller/OrderBonusStatisticsApiController.java

@@ -11,10 +11,6 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -70,6 +66,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 	 @RequestMapping(value="/saleBonusStatistics", method = RequestMethod.GET)
 	 public Result saleBonusStatistics(TOrderBonusBo bonusBo, Integer pageNo, Integer pageSize){
 		 Result res = new Result();
+		 bonusBo.setGrantBy(TokenManager.getAdminId());
 		 res.setData(orderBonusServiceImpl.saleBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	 }
@@ -101,7 +98,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 	 @RequestMapping(value="/technicianBonusStatistics", method = RequestMethod.GET)
 	 public Result technicianBonusStatistics(TOrderBonusBo bonusBo,Integer pageNo, Integer pageSize){
 		 Result res = new Result();
-		 bonusBo.setSalesName(TokenManager.getAdminId());
+		 bonusBo.setGrantBy(TokenManager.getAdminId());
 		 res.setData(orderBonusServiceImpl.technicianBonusStatistics(bonusBo, pageNo, pageSize));
 		 return res;
 	 }
@@ -118,10 +115,40 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		 return res;
 	 }
 	 
+	 
+	 /**
+	  * 
+	  * @param bonusBo
+	  * @param response
+	  * @return
+	  * @throws IOException
+	  */
 	 @RequestMapping(value="/exportSaleBonusData", method = RequestMethod.GET)
 	 public Result exportSaleBonusData(TOrderBonusBo bonusBo,HttpServletResponse response) throws IOException{
-		Result res = new Result();
-		return res;
+		 OutputStream out = response.getOutputStream();
+		 Result res = new Result();
+		 bonusBo.setGrantBy(TokenManager.getAdminId());
+		 XSSFWorkbook wb = orderBonusServiceImpl.exportSaleBonusData(bonusBo);
+		 if(null == wb){
+			 wb = new XSSFWorkbook();
+			 XSSFSheet sheet = wb.createSheet("没有营销员奖金记录");
+			 XSSFRow row = sheet.createRow(0);
+			 XSSFCell cell = row.createCell(0);
+			 cell.setCellValue("没有营销员奖金记录");
+		 }
+		 String fileName = "营销员奖金统计" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
+		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
+		 response.setContentType("application/octet-stream;charset=utf-8");  
+		 try {
+			 // 返回数据流
+			 wb.write(out); 
+			 out.flush();
+			 out.close();
+		 } finally {
+			 out.flush(); 
+			 out.close(); 
+		 }
+		 return res;
 	 }
 	 
 	/**
@@ -282,5 +309,4 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		return res;
 	}
 	 
-	 
 }

+ 5 - 6
src/main/java/com/goafanti/order/enums/BonusSubject.java

@@ -9,13 +9,12 @@ import java.util.Map;
  *
  */
 public enum BonusSubject {
-	SF(11,"首款付清"),
-	WK(12,"尾款结清"),
+	SF(11,"首付奖"),
+	WK(12,"结算奖"),
 	TK(16,"退款"),
-	// TODO
-	YTJ(1,"申报奖"),
-	PS(2,"认证奖"),
-	DGS(3,"结算奖"),
+	SB(21,"申报奖"),
+	RZ(23,"认证奖"),
+	RZQ(24,"认证奖"),
 	
 	/** 无效 **/
 	INVALID(10, "INVALID");

+ 8 - 1
src/main/java/com/goafanti/order/service/OrderBonusService.java

@@ -34,7 +34,7 @@ public interface OrderBonusService {
 	 * @param newBo
 	 * @return
 	 */
-	Pagination<OrderListBo> saleBonusStatistics(TOrderBonusBo bonusBo, Integer pageNo, Integer pageSize);
+	Pagination<TOrderBonusBo> saleBonusStatistics(TOrderBonusBo bonusBo, Integer pageNo, Integer pageSize);
 	/**
 	 * 财务专员更改技术员(咨询师)奖金发放状态
 	 * @param id
@@ -48,4 +48,11 @@ public interface OrderBonusService {
 	 * @return
 	 */
 	XSSFWorkbook exportTechnicianBonusData(TOrderBonusBo bonusBo);
+	
+	/**
+	 * 财务专员导出营销员奖金数据
+	 * @param bonusBo
+	 * @return
+	 */
+	XSSFWorkbook exportSaleBonusData(TOrderBonusBo bonusBo);
 }

+ 9 - 1
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -320,7 +320,15 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 		orderNew.setProofStatus(1);
 		//校对时间
 		orderNew.setProofTime(new Date());
-		return tOrderNewMapper.updateByPrimaryKeySelective(orderNew);
+		tOrderNewMapper.updateByPrimaryKeySelective(orderNew);
+		//获得订单数据
+		TOrderNew new1 = tOrderNewMapper.selectByPrimaryKey(orderNew.getOrderNo());
+		//new simpl
+		//如果签单的月份小于校对的月份需要重新校对
+		
+		
+		
+		return 0;
 	}
 	
 }

+ 78 - 2
src/main/java/com/goafanti/order/service/impl/OrderBonusServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.dao.TOrderBonusMapper;
+import com.goafanti.common.dao.TOrderMonthReportMapper;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.model.TOrderBonus;
 import com.goafanti.common.model.TOrderNew;
@@ -18,6 +19,7 @@ import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.order.bo.OrderListBo;
+import com.goafanti.order.bo.OrderReportBo;
 import com.goafanti.order.bo.TOrderBonusBo;
 import com.goafanti.order.service.OrderBonusService;
 
@@ -28,6 +30,8 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 	private TOrderBonusMapper bonusMapper;
 	@Autowired
 	private TOrderNewMapper orderNewMapper;
+	@Autowired
+	private TOrderMonthReportMapper orderMonthReportMapper;
 	
 	@Override
 	public Integer addOrderBouns(TOrderBonus bonus) {
@@ -61,12 +65,50 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<OrderListBo> saleBonusStatistics(TOrderBonusBo newBo, Integer pageNo, Integer pageSize) {
+	public Pagination<TOrderBonusBo> saleBonusStatistics(TOrderBonusBo newBo, Integer pageNo, Integer pageSize) {
 		Map<String, Object> params = new HashMap<String, Object>();
 		params.put("b", newBo);
-		Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("saleBonusList", "saleBonusCount", params, pageNo, pageSize);
+		Pagination<TOrderBonusBo> data = (Pagination<TOrderBonusBo>)findPage("saleBonusList", "saleBonusCount", params, pageNo, pageSize);
+		
+		innerData((List<TOrderBonusBo>) data.getList(), newBo);
 		return data;
 	}
+	
+	private void innerData(List<TOrderBonusBo> list, TOrderBonusBo newBo){
+		Integer m = null;
+		Integer m1 = null;
+		Integer y = null;
+		Integer y1 = null;
+		if(StringUtils.isNotEmpty(newBo.getStartTime()) && StringUtils.isNotEmpty(newBo.getEndTime())){
+			m = Integer.valueOf(newBo.getStartTime().replaceAll("-", ""));
+			m1 = Integer.valueOf(newBo.getEndTime().replaceAll("-", ""));
+			y = Integer.valueOf(newBo.getStartTime().substring(0, newBo.getStartTime().indexOf("-")));
+			y1 = Integer.valueOf(newBo.getEndTime().substring(0, newBo.getEndTime().indexOf("-")));
+		}
+		for (TOrderBonusBo orderListBo : list) {
+			//处理月度数据
+			OrderReportBo r = new OrderReportBo();
+			r.setSalemansId(orderListBo.getGrantTarget());
+			r.setMonth(m);
+			r.setMonth1(m1);
+			List<OrderReportBo> l = orderMonthReportMapper.getMonthReportByMonth(r);
+			if(l.size() == 1){
+				OrderReportBo o = l.get(0);
+				orderListBo.setKejim(o.getKejim());
+				orderListBo.setRenzm(o.getRenzm());
+			}
+			
+			r.setMonth(y);
+			r.setMonth1(y1);
+			//处理年度数据
+			List<OrderReportBo> ll = orderMonthReportMapper.getYearReportByYear(r);
+			if(l.size() == 1){
+				OrderReportBo o = ll.get(0);
+				orderListBo.setKejiy(o.getKejiy());
+				orderListBo.setRenzy(o.getRenzy());
+			}
+		}
+	}
 
 	@Override
 	public Integer updateChangeBonus(String id) {
@@ -84,6 +126,7 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 		String[] deptnames = null; 
 		if(StringUtils.isBlank(deptid)){
 			//获得所有有数据的部门
+			bonusBo.setGrantType(1);
 			List<TOrderBonusBo> dlist = bonusMapper.getDeptBySome(bonusBo);
 			if(null == dlist || dlist.size() == 0){
 				return null;
@@ -97,10 +140,43 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 			}
 		}else{
 			deptnames = new String[1];
+			deptnames[0] = bonusBo.getDepartmentName();
 			map.put(bonusBo.getDepartmentName(), bonusMapper.getBonusData(bonusBo));
 		}
 		String[] comment = {"任务编号","订单编号","任务负责人","任务状态","任务数量","项目状态","受理日期","评审日期","下证日期","订单结算状态","发放类型","发放状态"};
 		XSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoT(map, deptnames, comment);
 		return wb;
 	}
+
+	@Override
+	public XSSFWorkbook exportSaleBonusData(TOrderBonusBo bonusBo) {
+		String deptid = bonusBo.getDepartmentId();
+		Map<String, List<TOrderBonusBo>> map = new HashMap<String, List<TOrderBonusBo>>();
+		String[] deptnames = null; 
+		if(StringUtils.isBlank(deptid)){
+			//获得所有有数据的部门
+			bonusBo.setGrantType(0);
+			List<TOrderBonusBo> dlist = bonusMapper.getDeptBySome(bonusBo);
+			if(null == dlist || dlist.size() == 0){
+				return null;
+			}
+			deptnames = new String[dlist.size()];
+			for (int i = 0; i < dlist.size(); i++) {
+				TOrderBonusBo ob = dlist.get(i);
+				deptnames[i] = ob.getDepartmentName();
+				bonusBo.setDepartmentId(ob.getDepartmentId());
+				List<TOrderBonusBo> l =  bonusMapper.getSaleBounsList(bonusBo);
+				innerData(l, bonusBo);
+				map.put(ob.getDepartmentName(), l);
+			}
+		}else{
+			List<TOrderBonusBo> l =  bonusMapper.getSaleBounsList(bonusBo);
+			innerData(l, bonusBo);
+			deptnames = new String[1];
+			deptnames[0] = bonusBo.getDepartmentName();
+			map.put(bonusBo.getDepartmentName(), l);
+		}
+		XSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoS(map, deptnames);
+		return wb;
+	}
 }