Browse Source

Merge branch 'test' of http://git.jishutao.com/jishutao/kede-server.git into test

limin 7 years ago
parent
commit
d3bde54615

+ 15 - 1
src/main/java/com/goafanti/common/enums/NoticeStatus.java

@@ -5,6 +5,8 @@ import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 
+import com.goafanti.order.enums.OrderDunSubject;
+
 public enum NoticeStatus {
 	PATENTINFO(1, "专利申请管理"),
 	COGNIZANCE(2, "高企认定管理"),
@@ -19,7 +21,11 @@ public enum NoticeStatus {
 	ORGANIZATIONACHIEVEMENT(11, "组织用户科技成果管理"),
 	ORDER_CHANGE_ADD(12,"订单变更信息添加"),
 	ORDER_CHANGE_UDPATE(13,"订单变更信息修改"),
-	OTHER(12, "其他");
+	ORDER_DUN(14,"订单催款信息"),
+	ORDER_BACK(15,"订单驳回信息"),
+	ORDER_REFUND(16,"订单退单信息"),
+	ORDER_BONUS(17,"奖金信息"),
+	OTHER(0, "其他");
 
 	private NoticeStatus(Integer code, String desc) {
 		this.code = code;
@@ -33,6 +39,14 @@ public enum NoticeStatus {
 			status.put(value.getCode(), value);
 		}
 	}
+	public static String getValueByCode(Integer code){
+        for(NoticeStatus oticeStatus:NoticeStatus.values()){
+            if(code.equals(oticeStatus.getCode())){
+                return oticeStatus.getDesc();
+            }
+        }
+        return  null;
+    }
 
 	public static NoticeStatus getStatus(Integer code) {
 		if (containsType(code)) {

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

@@ -1061,6 +1061,7 @@
   	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,16 +1075,15 @@
   	<if test="specially == 4">
   	and a.process_status in (4,5,6)
   	</if>
+  	<if test="specially == 5">
+  	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>
@@ -1103,7 +1103,6 @@
   	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">
@@ -1117,6 +1116,7 @@
   	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
@@ -1130,16 +1130,15 @@
   	<if test="specially == 4">
   	and a.process_status in (4,5,6)
   	</if>
+  	<if test="specially == 5">
+  	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>

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

@@ -676,6 +676,9 @@
     <if test="specially == 1">
     and a.super_id is null
     </if>
+    <if test="specially == 2">
+    and d.superior_id= (select department_id from admin where  id= #{aid,jdbcType=VARCHAR})
+    </if>
     <if test="orderNo != null">
   	and a.order_no= #{orderNo,jdbcType=VARCHAR}
   	</if>
@@ -713,6 +716,9 @@
     <if test="specially == 1">
     and a.super_id is null<!-- 不看子任务 -->
     </if>
+    <if test="specially == 2">
+    and d.superior_id= (select department_id from admin where  id= #{aid,jdbcType=VARCHAR})
+    </if>
     <if test="orderNo != null">
   	and a.order_no= #{orderNo,jdbcType=VARCHAR}
   	</if>
@@ -740,7 +746,7 @@
 	date_format(a.task_end_time,'%Y-%m-%d') as endDate,date_format(a.accept_time,'%Y-%m-%d') as acceptDate,
 	date_format(a.review_time,'%Y-%m-%d') as reviewDate,date_format(a.publicity_time,'%Y-%m-%d') as publicityDate,
 	date_format(a.licence_time,'%Y-%m-%d') as licenceDate,date_format(a.task_distribution_time,'%Y-%m-%d') as taskDate,
-	REPLACE(e.contact_mobile, SUBSTR(e.contact_mobile,4,4), '****') as contactMobile
+	e.contacts ,e.contact_mobile as contactMobile ,e.legal_person as legalPerson,e.legal_person_tel as legalPersonTel
 from t_order_task a left join business_project b on a.commodity_id=b.id
   	left join business_category c on b.cid=c.id
     left join admin d on a.task_receiver=d.id

+ 2 - 26
src/main/java/com/goafanti/common/model/Notice.java

@@ -141,32 +141,8 @@ public class Notice {
 	}
 
 	public String getNoticeTypeName(){
-		if (null == this.noticeType){
-			return null;
-		} else {
-			if (NoticeStatus.PATENTINFO.getCode() == this.noticeType){
-				return NoticeStatus.PATENTINFO.getDesc();
-			} 
-			if (NoticeStatus.COGNIZANCE.getCode() == this.noticeType){
-				return NoticeStatus.COGNIZANCE.getDesc();
-			}
-			if (NoticeStatus.COPYRIGHT.getCode() == this.noticeType){
-				return NoticeStatus.COPYRIGHT.getDesc();
-			}
-			if (NoticeStatus.TECHPROJECT.getCode() == this.noticeType){
-				return NoticeStatus.TECHPROJECT.getDesc();
-			}
-			if (NoticeStatus.PERSONALCERTIFY.getCode() == this.noticeType){
-				return NoticeStatus.PERSONALCERTIFY.getDesc();
-			}
-			if (NoticeStatus.ORGANIZATIONCERTIFY.getCode() == this.noticeType){
-				return NoticeStatus.ORGANIZATIONCERTIFY.getDesc();
-			}
-			if (NoticeStatus.CONTRACT.getCode() == this.noticeType){
-				return NoticeStatus.CONTRACT.getDesc();
-			}
-			return NoticeStatus.OTHER.getDesc();
-		}
+		if (null == this.noticeType)return null;
+		return NoticeStatus.getValueByCode(this.noticeType);
 	}
     
 	public void setNoticeTypeName(Integer noticeType){

+ 9 - 4
src/main/java/com/goafanti/common/task/OrderDunTask.java

@@ -1,9 +1,12 @@
 package com.goafanti.common.task;
 
 
+import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.List;
 
+import javax.mail.MessagingException;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -12,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
+import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.model.TOrderDun;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.order.bo.OrderDunTaskBo;
@@ -30,7 +34,7 @@ public class OrderDunTask {
 	
 //	@Scheduled(cron = "0 0 2  * * ?") 
   	@RequestMapping(value = "/open/updateorderDun", method = RequestMethod.GET)
-  	@Transactional
+  	@Transactional(rollbackFor=Exception.class)
 	public void updateorderDun(){
   		try {
   		List<OrderDunTaskBo> list=orderNewService.selectAllOrderDun();
@@ -47,7 +51,7 @@ public class OrderDunTask {
 				}
 			}
 		}
-  		} catch (InterruptedException e) {
+  		} catch (InterruptedException | UnsupportedEncodingException | MessagingException e) {
   			LoggerUtils.error(getClass(), "=============================================");
 			LoggerUtils.error(getClass(), "催款的信息处理失败", e);
 			LoggerUtils.error(getClass(), "=============================================");
@@ -56,13 +60,14 @@ public class OrderDunTask {
   	}
 
 
-	private void updateOrderDun(OrderDunTaskBo t) {
+	private void updateOrderDun(OrderDunTaskBo t) throws UnsupportedEncodingException, MessagingException {
 		TOrderDun tDun=new TOrderDun();
 		 tDun.setId(t.getId());
 		 tDun.setDunStatus(1);
 		 tDun.setStartTime(new Date());
 		 orderNewService.updateOrderDun(tDun);
-		 orderNewService.SendEmail(t.getOrderNo(),t.getId());
+		 orderNewService.addNotic(t.getOrderNo(),NoticeStatus.ORDER_DUN.getCode());
+		 orderNewService.sendEmail(t.getOrderNo(),t.getId());
 	}
   	
 }

+ 16 - 1
src/main/java/com/goafanti/order/bo/TOrderTaskDetailBo.java

@@ -11,7 +11,6 @@ public class TOrderTaskDetailBo {
 	private Integer taskStatus;
 	private String taskDate;
 	private String taskComment;
-	private String contacts;
 	private String attachmentUrl;
 	private String salesmanName;
 	private String startDate;
@@ -20,7 +19,11 @@ public class TOrderTaskDetailBo {
 	private String reviewDate;
 	private String publicityDate;
 	private String licenceDate;
+	private String contacts;
 	private String contactMobile;
+	private String legalPerson;
+	private String legalPersonTel;
+	
 	
 	public String getTaskComment() {
 		return taskComment;
@@ -143,5 +146,17 @@ public class TOrderTaskDetailBo {
 	public void setAttachmentUrl(String attachmentUrl) {
 		this.attachmentUrl = attachmentUrl;
 	}
+	public String getLegalPerson() {
+		return legalPerson;
+	}
+	public void setLegalPerson(String legalPerson) {
+		this.legalPerson = legalPerson;
+	}
+	public String getLegalPersonTel() {
+		return legalPersonTel;
+	}
+	public void setLegalPersonTel(String legalPersonTel) {
+		this.legalPersonTel = legalPersonTel;
+	}
 	
 }

+ 6 - 1
src/main/java/com/goafanti/order/controller/AdminNewOrderApiController.java

@@ -116,7 +116,12 @@ public class AdminNewOrderApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
 			return res;
 		}
-		return res.data(orderNewService.deleteOrderNew(orderNo));
+		int i=orderNewService.deleteOrderNew(orderNo);
+		if (i==-1) {
+			res.getError().add(buildError("订单未达删除条件","订单未达删除条件"));
+			return res;
+		}
+		return res.data(i);
 	}
 	
 	/**

+ 1 - 1
src/main/java/com/goafanti/order/controller/OrderProjectApiController.java

@@ -25,7 +25,7 @@ import com.goafanti.order.bo.TOrderTaskDetailBo;
 import com.goafanti.order.service.OrderProjectService;
 
 @RestController
-@RequestMapping(value = "/open/api/admin/orderProject")
+@RequestMapping(value = "/api/admin/orderProject")
 public class OrderProjectApiController extends CertifyApiController {
 	
 	@Autowired

+ 1 - 1
src/main/java/com/goafanti/order/enums/TaskState.java

@@ -11,7 +11,7 @@ public enum TaskState {
 	 /** 材料已启动 **/
 	 CLYQD(2,"材料已启动"),
 	 /** 材料已完成 **/
-	 CLYWC(2,"材料已完成"),
+	 CLYWC(3,"材料已完成"),
 	/** 无效 **/
 	INVALID(10, "无效");
 	

+ 5 - 2
src/main/java/com/goafanti/order/service/OrderNewService.java

@@ -1,7 +1,10 @@
 package com.goafanti.order.service;
 
+import java.io.UnsupportedEncodingException;
 import java.util.List;
 
+import javax.mail.MessagingException;
+
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import com.goafanti.common.model.TOrderDun;
@@ -159,7 +162,7 @@ public interface OrderNewService {
 	int technicianBackOrder(String orderNo);
 	List<OrderDunTaskBo> selectAllOrderDun();
 	void updateOrderDun(TOrderDun tDun);
-	void SendEmail(String orderNo,String dunId);
-
+	void sendEmail(String orderNo,String dunId) throws UnsupportedEncodingException, MessagingException;
+	void addNotic(String orderNo,Integer type);
 	
 }

+ 44 - 13
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -27,6 +27,7 @@ import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.dao.AdminMapper;
+import com.goafanti.common.dao.NoticeMapper;
 import com.goafanti.common.dao.OrganizationContactBookMapper;
 import com.goafanti.common.dao.TDunLogMapper;
 import com.goafanti.common.dao.TOrderBackMapper;
@@ -35,7 +36,9 @@ import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.dao.TOrderRefundMapper;
 import com.goafanti.common.dao.TOrderTaskMapper;
 import com.goafanti.common.dao.UserLockReleaseMapper;
+import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.error.BusinessException;
+import com.goafanti.common.model.Notice;
 import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.TDunLog;
 import com.goafanti.common.model.TOrderBack;
@@ -89,6 +92,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Autowired
 	private AdminMapper	adminMapper;
 	@Autowired
+	NoticeMapper	noticeMapper;
+	@Autowired
 	private UserLockReleaseMapper	userLockReleaseMapper;
 	@Value(value = "${mobileRemindCodeTemplate}")
 	private String					mobileRemindCodeTemplate	= null;
@@ -135,6 +140,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		checkOrder(order,t);
 		t.setTaskStatus(TaskState.WFP.getCode());
 		t.setProjectStatus(ProjectNewStage.DTJ.getCode());
+		if(t.getCommodityPrice()!=null)order.setTotalAmount(order.getTotalAmount());
 		return tOrderTaskMapper.insertSelective(t);
 	}
 
@@ -296,12 +302,34 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		ob.setBackStatus(0);//待处理
 		ob.setInitiate(TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
 		ob.setAccept(tOrder.getSalesmanId());
-		SendEmail(orderNo,null);
+		// 新增站内消息
+		addNotic(orderNo,NoticeStatus.ORDER_BACK.getCode());
+		// 发送邮件
+		try {
+			sendEmail(orderNo,null);
+		} catch (UnsupportedEncodingException | MessagingException e) {
+			LoggerUtils.error(getClass(), "发送邮件失败", e);
+		}
 		tOrderBackMapper.insertSelective(ob);
 	}
 
 
 
+	public void addNotic(String orderNo,Integer type) {
+		String id=TokenManager.getAdminId()==null?"1":TokenManager.getAdminId();
+		AdminListBo a = adminMapper.getDeptNameByAid(id);
+		String str=NoticeStatus.getValueByCode(type)+": 订单编号 -"+orderNo+", 操作人:"+a.getDepartmentName()+"-"+a.getName()+"。";
+		Notice n =new Notice();
+		n.setId(UUID.randomUUID().toString());
+		n.setAid(id);
+		n.setNoticeType(type);
+		n.setContent(str);
+		n.setReaded(0);//未读
+		noticeMapper.insertSelective(n);
+	}
+
+
+
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<TOrderNewBo> dunOrderNewList(String name, String orderNo, String starTime, String endTime,
@@ -433,10 +461,13 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 	@Override
 	public int deleteOrderNew(String orderNo) {
-		TOrderNew t=new TOrderNew();
-		t.setOrderNo(orderNo);
-		t.setDeleteSign(1);//作废
-		return tOrderNewMapper.updateByPrimaryKeySelective(t);
+		TOrderNew t=tOrderNewMapper.selectByPrimaryKey(orderNo);
+		if (t.getOrderStatus()==OrderNewState.YBH.getCode()||t.getOrderStatus()==OrderNewState.YTD.getCode()) {
+			t.setOrderNo(orderNo);
+			t.setDeleteSign(1);//作废
+			return tOrderNewMapper.updateByPrimaryKeySelective(t);
+		}
+		return -1;
 	}
 
 
@@ -541,7 +572,13 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			return -1;
 		}
 		t.setOrderStatus(OrderNewState.YBH.getCode());
-		SendEmail(orderNo,null);
+		//sendEmail
+		addNotic(orderNo,NoticeStatus.ORDER_BACK.getCode());
+		try {
+			sendEmail(orderNo,null);
+		} catch (UnsupportedEncodingException | MessagingException e) {
+			LoggerUtils.error(getClass(), "发送邮件失败", e);
+		}
 		return tOrderNewMapper.updateByPrimaryKey(t);
 	}
 	
@@ -560,13 +597,12 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 
 	@Override
-	public void  SendEmail(String orderNo,String dunId){
+	public void  sendEmail(String orderNo,String dunId) throws UnsupportedEncodingException, MessagingException{
 		String id=TokenManager.getAdminId()==null?"1":TokenManager.getAdminId();
 		AdminListBo a = adminMapper.getDeptNameByAid(id);
 		TOrderNewBo b  = tOrderNewMapper.getSaleIdByOno(orderNo);
 		String content = "<div>客户名称: "+ b.getUserName() +"</div><div>订单编号: " + orderNo + "</div>";
 		String tite="订单驳回";
-		try {
 			if(StringUtils.isNotBlank(dunId)) {
 				TOrderDun tDun=tOrderDunMapper.selectByPrimaryKey(dunId);
 				content +="<div>催收时间: " +  new SimpleDateFormat("yyyy-MM-dd").format(tDun.getCreateTime()) +
@@ -579,11 +615,6 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			LoggerUtils.debug(logger, "tite:"+tite+"  Email:"+ b.getEmail()+"  收件人姓名:"+ b.getSalesmanName()+ "    部门:"+a.getDepartmentName()+ "  发件人姓名:"+a.getName()+"   内容:"+ content);
 			SendEmailUtil.getInstance().send(bo);
 			LoggerUtils.debug(logger, "=========================================发送邮件成功");
-		} catch (UnsupportedEncodingException e) {
-			LoggerUtils.error(getClass(), "发送邮件失败", e);
-		} catch (MessagingException e) {
-			LoggerUtils.error(getClass(), "发送邮件失败", e);
-		}
 	}
 	
 	

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

@@ -101,8 +101,8 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		Map<String, Object> params = new HashMap<String, Object>();
 		if(pageSize==null||pageSize<0)pageSize=10;
 		if(pageNo==null||pageNo<0)pageNo=1;
-		if (specially!=null&&specially==0) {
-			params.put("aid", TokenManager.getAdminId()==null?"e82a4405-2104-481d-ba5f-72a639589efd":TokenManager.getAdminId());
+		if (specially!=null&&(specially==0||specially==2)) {
+			params.put("aid", TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
 		}
 		if (null!=specially) params.put("specially", specially);
 		if (StringUtils.isNotBlank(name)) params.put("name", name);
@@ -128,6 +128,13 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		task.setTaskStatus(t.getTaskStatus());
 		task.setProjectStatus(t.getProjectStatus());
 		task.setTaskComment(t.getTaskComment());
+		TOrderNew tn=new TOrderNew(); 
+		tn.setOrderNo(t.getOrderNo());
+		tn.setContacts(t.getContacts());
+		tn.setContactMobile(t.getContacts());
+		tn.setLegalPerson(t.getLegalPerson());
+		tn.setLegalPersonTel(t.getLegalPersonTel());
+		tOrderNewMapper.updateByPrimaryKeySelective(tn);
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 		try {
 			if(StringUtils.isNotBlank(t.getStartDate()))task.setTaskStartTime(sdf.parse(t.getStartDate()));
@@ -139,9 +146,6 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		} catch (ParseException e) {
 			e.printStackTrace();
 		}
-		if (true) {
-		//处理奖金	
-		}
 		tOrderTaskMapper.updateByPrimaryKeySelective(task);
 		TOrderTask task2=tOrderTaskMapper.selectByPrimaryKey(task.getId());//查询出项目信息
 		if (task2.getSuperId()!=null) {//是否有父项目