Browse Source

Merge remote-tracking branch 'origin/test' into dev

anderx 7 years ago
parent
commit
2248f77d54

+ 2 - 0
src/main/java/com/goafanti/common/dao/TOrderTaskMapper.java

@@ -126,4 +126,6 @@ public interface TOrderTaskMapper {
 	TOrderTaskDetailBo getOrderTaskDetail(String id);
 
 	TOrderTask selectBySuperId(String superId);
+	
+	List<TOrderTask> getReceiverByOid(String oid);
 }

+ 4 - 3
src/main/java/com/goafanti/common/mapper/TOrderBonusMapper.xml

@@ -351,7 +351,7 @@
   <!-- 财务专员统计技术员的奖金 -->
   <select id="technicianBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
    select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,  
-  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
+  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
   		accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
   		o.liquidation_status as liquidationStatus, ga.name as byName,
   		bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
@@ -530,7 +530,7 @@
   <!-- 获得及技术员奖金数据 -->
   <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
   select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,  
-  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
+  		t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
   		accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
   		o.liquidation_status as liquidationStatus, ga.name as byName,
   		bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
@@ -599,7 +599,8 @@
   </select>
   <!-- 根据订单编号和科目和奖金发放人检查这个奖金是否存在 -->
   <select id="checkByOnoAndSub" parameterType="com.goafanti.common.model.TOrderBonus" resultType="java.lang.Integer">
-  	select count(*) from t_order_bonus where order_no = #{orderNo,jdbcType=VARCHAR} and bonus_subject = #{bonusSubject,jdbcType=INTEGER} and grant_type = #{grantType,jdbcType=INTEGER}
+  	select count(*) from t_order_bonus where order_no = #{orderNo,jdbcType=VARCHAR} and bonus_subject = #{bonusSubject,jdbcType=INTEGER} 
+  	and grant_target = #{grantTarget,jdbcType=VARCHAR} and grant_type = #{grantType,jdbcType=INTEGER}
   </select>
   <!-- 判断当前订单中有没有未发放的数据 -->
   <select id="checkNoPay" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="java.lang.Integer">

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

@@ -822,8 +822,10 @@
   
    <!-- 查看所有待财务管理员分配的订单数据 -->
   <select id="getAllUnassignedListOrder" parameterType="Map" resultType="com.goafanti.order.bo.OrderListBo">
+  	select * from (
   	select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus,
   	o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
+  	,liquidation_status
   	from t_order_new o 
   	left join `user` u on o.buyer_id = u.id
   	left join admin a on o.salesman_id = a.id
@@ -832,7 +834,6 @@
   	<if test="o.processStatus != null">
   	and process_status = #{o.processStatus,jdbcType=INTEGER}
   	</if>
-  	or (approval = 2 and finance_id is null and delete_sign = 0)
   	<if test='o.orderNo != null and o.orderNo != ""'>
   	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
   	</if>
@@ -848,30 +849,80 @@
   	<bind name="b" value="o.endTime + ' 23:59:59'"/>
   	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
   	</if>
+  	union 
+	select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus, 
+	o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
+	,liquidation_status 
+	from t_order_new o 
+	left join `user` u on o.buyer_id = u.id 
+	left join admin a on o.salesman_id = a.id 
+	where delete_sign = 0 and approval = 2 and finance_id is null 
+  	<if test='o.orderNo != null and o.orderNo != ""'>
+  	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.financeId != null and o.financeId != ""'>
+  	and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.buyerName != null and o.buyerName != ""'>
+  	<bind name="n" value="'%' + o.buyerName + '%'"/>
+  	and u.nickname  like #{n,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.startTime != null and o.startTime != "" and o.endTime != null and o.endTime != ""'>
+  	<bind name="a" value="o.startTime + ' 00:00:00'"/>
+  	<bind name="b" value="o.endTime + ' 23:59:59'"/>
+  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
+  	</if>
+)oo
   	<if test="ob == 1">
-  	order by o.sign_time desc
+  	order by oo.signTime desc
   	</if>
   	<if test="ob == 2">
-  	order by o.liquidation_status,o.sign_time desc
+  	order by oo.liquidation_status,oo.signTime desc
   	</if>
 	<if test="page_sql != null">
 		${page_sql}
 	</if>
   </select>
   <select id="getAllUnassignedCountOrder" parameterType="Map" resultType="java.lang.Integer">
-  	select count(*)  from t_order_new o 
+  select count(*) from (
+  	select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus,
+  	o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
+  	,liquidation_status
+  	from t_order_new o 
   	left join `user` u on o.buyer_id = u.id
   	left join admin a on o.salesman_id = a.id
   	where delete_sign = 0
   	and order_status = 2
   	<if test="o.processStatus != null">
-  	and process_status = #{o.processStatus,jdbcType=VARCHAR}
+  	and process_status = #{o.processStatus,jdbcType=INTEGER}
   	</if>
-  	or (approval = 2 and finance_id is null and delete_sign = 0)
   	<if test='o.orderNo != null and o.orderNo != ""'>
   	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
   	</if>
-  	<if test='financeId != null and financeId != ""'>
+  	<if test='o.financeId != null and o.financeId != ""'>
+  	and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.buyerName != null and o.buyerName != ""'>
+  	<bind name="n" value="'%' + o.buyerName + '%'"/>
+  	and u.nickname  like #{n,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.startTime != null and o.startTime != "" and o.endTime != null and o.endTime != ""'>
+  	<bind name="a" value="o.startTime + ' 00:00:00'"/>
+  	<bind name="b" value="o.endTime + ' 23:59:59'"/>
+  	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
+  	</if>
+  	union 
+	select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus, 
+	o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
+	,liquidation_status 
+	from t_order_new o 
+	left join `user` u on o.buyer_id = u.id 
+	left join admin a on o.salesman_id = a.id 
+	where delete_sign = 0 and approval = 2 and finance_id is null 
+  	<if test='o.orderNo != null and o.orderNo != ""'>
+  	and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
+  	</if>
+  	<if test='o.financeId != null and o.financeId != ""'>
   	and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
   	</if>
   	<if test='o.buyerName != null and o.buyerName != ""'>
@@ -883,6 +934,7 @@
   	<bind name="b" value="o.endTime + ' 23:59:59'"/>
   	and o.sign_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
   	</if>
+)oo
   </select>
   <!-- 查看某订单状态是否符合要求 -->
   <select id="getCountByIdAndStatus" parameterType="com.goafanti.common.model.TOrderNew" resultType="java.lang.Integer">

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

@@ -868,4 +868,9 @@ from t_order_task a left join business_project b on a.commodity_id=b.id
   	and d.name like CONCAT('%', #{adminName,jdbcType=VARCHAR},'%')
   	</if>
   </select>
-</mapper>
+  	<!-- 根据订单编号获得所有的任务负责人 -->
+  	<select id="getReceiverByOid" parameterType="java.lang.String" resultMap="BaseResultMap">
+  	select distinct task_receiver from t_order_task 
+	where order_no = #{orderNo,jdbcType=VARCHAR}
+  	</select>
+</mapper>

+ 1 - 0
src/main/java/com/goafanti/common/utils/ExportExcelUtil.java

@@ -260,6 +260,7 @@ public class ExportExcelUtil {
 					String o = "";
 					switch (comment[i]) {
 					case "任务编号": o = ob.getTid().toString(); break;
+					case "任务名称": o = ob.getCommodityName(); break;
 					case "订单编号": o = ob.getOrderNo(); break;
 					case "任务负责人": o = ob.getSalesName(); break;
 					case "任务状态": o = TaskState.getValueByCode(ob.getTaskStatus()); break;

+ 11 - 29
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -26,6 +26,7 @@ import com.goafanti.common.dao.TOrderBonusMapper;
 import com.goafanti.common.dao.TOrderMonthReportMapper;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.dao.TOrderRefundMapper;
+import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.model.Notice;
 import com.goafanti.common.model.TOrderBack;
@@ -33,7 +34,7 @@ import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderBonus;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.common.model.TOrderRefund;
-import com.goafanti.common.task.MonthReportTask;
+import com.goafanti.common.model.TOrderTask;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.SendEmailUtil;
 import com.goafanti.common.utils.StringUtils;
@@ -63,6 +64,8 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 	@Autowired
 	private TOrderMonthReportMapper monthReportMapper;
 	@Autowired
+	private TOrderTaskMapper taskMapper;
+	@Autowired
 	JDBCIdGenerator	idGenerator;
 	@Autowired
 	NoticeMapper	noticeMapper;
@@ -196,27 +199,18 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 		}else if(bd.compareTo(o.getTotalAmount()) == 0){//付完款//如果订单流水等于于总金额 lstaus 2
 			lstaus = 2;
 			bonus.setBonusSubject(12);
-			//发放给技术员
-			if(null != o.getTechnicianId()){
-				bonus.setGrantTarget(o.getTechnicianId());
+			//发放给技术员如果付完款所有参与这个项目任务的人都会有结算奖
+			//获得所有的任务负责人
+			List<TOrderTask> l = taskMapper.getReceiverByOid(billNew.getOrderNo());
+			for (TOrderTask tOrderTask : l) {
+				bonus.setGrantTarget(tOrderTask.getTaskReceiver());
 				bonus.setGrantType(1);
 				int c = bonusMapper.checkByOnoAndSub(bonus);
 				//不存在就设置
 				if(c==0){
 					bonusMapper.insertSelective(bonus);
 				}
-				//发送邮件
-//				Admin oo = adminMapper.selectAllByid(o.getTechnicianId());
-//				AdminListBo a = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
-//				String content = "<div>订单编号: "+ billNew.getOrderNo() +"</div><div>应收人: " + oo.getName() + "</div>";
-//				EmailBo emailBo = new EmailBo("奖金发放", oo.getEmail(), oo.getName(), a.getDepartmentName(), a.getName(), content);
-//				try {
-//					SendEmailUtil.send(emailBo);
-//				} catch (UnsupportedEncodingException e) {
-//					e.printStackTrace();
-//				} catch (MessagingException e) {
-//					e.printStackTrace();
-//				}
+				
 			}
 			
 		}else if(bd.compareTo(o.getTotalAmount()) == -1){//如果订单流水小于总金额
@@ -226,6 +220,7 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 				b.setOrderNo(billNew.getOrderNo());
 				b.setBonusSubject(11);
 				b.setGrantType(0);
+				b.setGrantTarget(o.getSalesmanId());
 				int c = bonusMapper.checkByOnoAndSub(b);
 				//不存在就设置
 				if(c==0){
@@ -258,19 +253,6 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 				//设置发放人类型
 				bonus.setGrantType(0);
 				bonusMapper.insertSelective(bonus);
-				
-				//发送邮件
-//				TOrderNewBo oo = tOrderNewMapper.getSaleIdByOno(billNew.getOrderNo());
-//				AdminListBo a = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
-//				String content = "<div>订单编号: "+ billNew.getOrderNo() +"</div><div>应收人: " + oo.getSalesmanName() + "</div>";
-//				EmailBo emailBo = new EmailBo("奖金发放", oo.getEmail(), oo.getSalesmanName(), a.getDepartmentName(), a.getName(), content);
-//				try {
-//					SendEmailUtil.send(emailBo);
-//				} catch (UnsupportedEncodingException e) {
-//					e.printStackTrace();
-//				} catch (MessagingException e) {
-//					e.printStackTrace();
-//				}
 			}
 		}
 		

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

@@ -151,7 +151,7 @@ public class OrderBonusServiceImpl extends BaseMybatisDao<TOrderBonusMapper> imp
 		}else{
 			map.put(bonusBo.getDepartmentName(), bonusMapper.getBonusData(bonusBo));
 		}
-		String[] comment = {"任务编号","订单编号","任务负责人","任务状态","任务数量","项目状态","受理日期","评审日期","下证日期","订单结算状态","发放类型","发放状态"};
+		String[] comment = {"任务编号","任务名称","订单编号","任务负责人","任务状态","任务数量","项目状态","受理日期","评审日期","下证日期","订单结算状态","发放类型","发放状态"};
 		XSSFWorkbook wb = ExportExcelUtil.exportDeptBonusInfoT(map, comment);
 		return wb;
 	}

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

@@ -207,9 +207,9 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 				if (task.getProjectStatus()==ProjectNewStage.GS.getCode())tb.setBonusSubject(24);//项目公示
 				tb.setGrantType(1);//技术员
 				//新增奖金之前检查这个奖金数据是否存在
+				tb.setGrantTarget(task.getTaskReceiver());
 				int c = tOrderBonusMapper.checkByOnoAndSub(tb);
 				if(c==0){
-					tb.setGrantTarget(task.getTaskReceiver());
 					tb.setGrantBy(t.getFinanceId());
 					tOrderBonusMapper.insertSelective(tb);
 				}