Browse Source

奖金数据重复检查bug修复

limin 7 years ago
parent
commit
8da44a16b7

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

@@ -584,9 +584,9 @@
 	and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
 	</if>
   </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} 
+  	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>
   <!-- 判断当前订单中有没有未发放的数据 -->
   <select id="checkNoPay" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="java.lang.Integer">

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

@@ -832,6 +832,7 @@
   	<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>
@@ -866,6 +867,7 @@
   	<if test="o.processStatus != null">
   	and process_status = #{o.processStatus,jdbcType=VARCHAR}
   	</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>

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

@@ -89,8 +89,10 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 		TOrderNew onew = new TOrderNew();
 		onew.setOrderNo(orderNo);
 		onew.setDeleteSign(0);//正常
-		onew.setProcessStatus(2);//已派财务管理员
 		onew.setApproval(approval);//特批状态
+		if(approval == 0){
+			onew.setProcessStatus(2);//已派财务管理员
+		}
 		onew.setOrderStatus(2);//营销管理员审核通过
 		
 		int idCount = tOrderNewMapper.getCountByIdAndStatus(onew);
@@ -198,7 +200,11 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 			if(null != o.getTechnicianId()){
 				bonus.setGrantTarget(o.getTechnicianId());
 				bonus.setGrantType(1);
-				bonusMapper.insertSelective(bonus);
+				int c = bonusMapper.checkByOnoAndSub(bonus);
+				//不存在就设置
+				if(c==0){
+					bonusMapper.insertSelective(bonus);
+				}
 				//发送邮件
 //				Admin oo = adminMapper.selectAllByid(o.getTechnicianId());
 //				AdminListBo a = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
@@ -219,6 +225,7 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 				TOrderBonus b = new TOrderBonus();
 				b.setOrderNo(billNew.getOrderNo());
 				b.setBonusSubject(11);
+				b.setGrantType(0);
 				int c = bonusMapper.checkByOnoAndSub(b);
 				//不存在就设置
 				if(c==0){

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

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