Преглед изворни кода

bug修改,校对单量的时候检查是不是要更新统计表

limin пре 7 година
родитељ
комит
a5c189f365

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

@@ -113,4 +113,5 @@ public interface TOrderBonusMapper {
 	List<TOrderBonusBo> getBonusData(TOrderBonusBo bonusBo);
 	List<TOrderBonusBo> getSaleBounsList(TOrderBonusBo bonusBo);
 	
+	int checkByOnoAndSub(TOrderBonus bonus);
 }

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

@@ -584,4 +584,8 @@
 	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>
 </mapper>

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

@@ -124,7 +124,8 @@
     total_amount, settlement_amount, refund_amount, order_status, liquidation_status, 
     process_status, project_status, approval, order_remarks, delete_sign, salesman_id, 
     finance_id, technician_id, sign_time, settlement_time, contract_no, contract_type, 
-    contacts, contact_mobile, legal_person, legal_person_tel, proof_count, proof_aid
+    contacts, contact_mobile, legal_person, legal_person_tel, proof_count, proof_aid,
+    proof_time, proof_status
   </sql>
   <sql id="Blob_Column_List">
     <!--
@@ -1060,7 +1061,6 @@
   	where a.delete_sign = 0 
   	<if test="specially == 0">
   	and a.order_status not in(3,5,6) and a.approval !=3
-  	and a.salesman_id = #{aid,jdbcType=VARCHAR}
   	</if>
   	<if test="specially == 1">
   	and a.process_status =1  and a.order_status=1
@@ -1074,15 +1074,16 @@
   	<if test="specially == 4">
   	and a.process_status in (4,5,6)
   	</if>
-  	<if test="specially == 4">
-  	and c.department_id=(select department_id from admin where  id= #{aid,jdbcType=VARCHAR})
-  	</if>
   	<if test="distribution == 1">
   	and a.process_status = 5
   	</if>
   	<if test="distribution == 2">
   	and a.process_status = 6
   	</if>
+  	
+  	<if test="aid != null">
+  	and a.salesman_id = #{aid,jdbcType=VARCHAR}
+  	</if>
   	<if test="name != null">
   	and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
   	</if>
@@ -1102,6 +1103,7 @@
   	select 
   		count(*)
   	from t_order_new a  left join `user` b on a.buyer_id=b.id
+  	from t_order_new a  left join `user` b on a.buyer_id=b.id 
   	left join admin c on a.salesman_id=c.id
   	left join admin d on a.finance_id=d.id
   	<if test="specially == 2">
@@ -1115,7 +1117,6 @@
   	where a.delete_sign = 0 
   	<if test="specially == 0">
   	and a.order_status not in(3,5,6) and a.approval !=3
-  	and a.salesman_id = #{aid,jdbcType=VARCHAR}
   	</if>
   	<if test="specially == 1">
   	and a.process_status =1  and a.order_status=1
@@ -1129,15 +1130,16 @@
   	<if test="specially == 4">
   	and a.process_status in (4,5,6)
   	</if>
-  	<if test="specially == 4">
-  	and c.department_id=(select department_id from admin where  id= #{aid,jdbcType=VARCHAR})
-  	</if>
   	<if test="distribution == 1">
   	and a.process_status = 5
   	</if>
   	<if test="distribution == 2">
   	and a.process_status = 6
   	</if>
+  	
+  	<if test="aid != null">
+  	and a.salesman_id = #{aid,jdbcType=VARCHAR}
+  	</if>
   	<if test="name != null">
   	and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
   	</if>
@@ -1267,4 +1269,4 @@
      left join t_order_new b  on a.order_no=b.order_no
      where a.id= #{id,jdbcType=INTEGER}
   </select>
-</mapper>
+</mapper>

+ 35 - 10
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.order.service.impl;
 
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -10,7 +11,6 @@ import java.util.UUID;
 
 import javax.mail.MessagingException;
 
-import org.apache.commons.io.input.BOMInputStream;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -20,6 +20,7 @@ import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.TOrderBackMapper;
 import com.goafanti.common.dao.TOrderBillNewMapper;
 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.model.TOrderBack;
@@ -54,6 +55,8 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 	@Autowired
 	private TOrderBonusMapper bonusMapper;
 	@Autowired
+	private TOrderMonthReportMapper monthReportMapper;
+	@Autowired
 	JDBCIdGenerator	idGenerator;
 
 	@SuppressWarnings("unchecked")
@@ -182,14 +185,23 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 			lstaus = 2;
 			bonus.setBonusSubject(12);
 			//发放给技术员
-			bonus.setGrantTarget(o.getTechnicianId());
-			bonus.setGrantType(1);
-			bonusMapper.insertSelective(bonus);
+			if(null != o.getTechnicianId()){
+				bonus.setGrantTarget(o.getTechnicianId());
+				bonus.setGrantType(1);
+				bonusMapper.insertSelective(bonus);
+			}
 			
 		}else if(bd.compareTo(o.getTotalAmount()) == -1){//如果订单流水小于总金额
-			if(bd.compareTo(o.getFirstAmount()) == 0){//首付完成
-				bonus.setBonusSubject(11);
-			}else if(bd.compareTo(o.getFirstAmount()) == 1){//大于首付 lstaus 1
+			if(bd.compareTo(o.getFirstAmount()) == 0 || bd.compareTo(o.getFirstAmount()) == 1){//首付完成
+				//查看首付奖是否存在
+				TOrderBonus b = new TOrderBonus();
+				b.setOrderNo(billNew.getOrderNo());
+				b.setBonusSubject(11);
+				int c = bonusMapper.checkByOnoAndSub(b);
+				//不存在就设置
+				if(c==0){
+					bonus.setBonusSubject(11);
+				}
 				lstaus = 1;
 			}
 		}
@@ -248,7 +260,7 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 			String content = "<div>退单编号: "+ refund.getId() +"</div><div>客户名称: " + o.getUserName() + "</div>";
 			 content += "<div>订单编号: "+ o.getOrderNo() +"</div><div>订单状态: " + OrderNewState.getValueByCode(o.getOrderStatus()) + "</div>";
 			
-			EmailBo emailBo = new EmailBo("同意退单", o.getEmail(), o.getSalesmanName(), a.getDepartmentId(), a.getName(), content);
+			EmailBo emailBo = new EmailBo("同意退单", o.getEmail(), o.getSalesmanName(), a.getDepartmentName(), a.getName(), content);
 			try {
 				SendEmailUtil.send(emailBo);
 			} catch (UnsupportedEncodingException e) {
@@ -325,8 +337,21 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 		TOrderNew new1 = tOrderNewMapper.selectByPrimaryKey(orderNew.getOrderNo());
 		//new simpl
 		//如果签单的月份小于校对的月份需要重新校对
-		
-		
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(new1.getSignTime());
+		int sy = cal.get(Calendar.YEAR);
+		int sm = cal.get(Calendar.MONTH);
+		cal.setTime(new1.getProofTime());
+		int py = cal.get(Calendar.YEAR);
+		int pm = cal.get(Calendar.MONTH);
+		if(py>sy || (py==sy && pm>sm)){
+			//重新校对信息
+			TOrderNew orderNew2 = new TOrderNew();
+			orderNew2.setSignTime(new1.getSignTime());
+			orderNew2.setOrderType(new1.getOrderType());
+			orderNew2.setSalesmanId(new1.getSalesmanId());
+			monthReportMapper.proofDataBySomeBody(orderNew2);
+		}
 		
 		return 0;
 	}