Browse Source

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

anderx 7 years ago
parent
commit
ea9a059b62

+ 3 - 0
src/main/java/com/goafanti/common/dao/TOrderDunMapper.java

@@ -2,6 +2,7 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.TOrderDun;
 import com.goafanti.common.model.TOrderDunExample;
+import com.goafanti.order.bo.OrderDunTaskBo;
 import com.goafanti.order.bo.TOrderNewBo;
 
 import java.util.List;
@@ -102,4 +103,6 @@ public interface TOrderDunMapper {
 	List<TOrderDun> selectByOrderNoDunSubject(String orderNo);
 
 	List<TOrderNewBo> getOrderDunData(@Param("name")String name,@Param("orderNo") String orderNo, @Param("starTime")String starTime, @Param("endTime")String endTime);
+
+	List<OrderDunTaskBo> getTaskAllOrderDun();
 }

+ 7 - 0
src/main/java/com/goafanti/common/mapper/TOrderDunMapper.xml

@@ -389,4 +389,11 @@
   	</if>
   	order by b.sign_time desc
   </select>
+  
+  <select id="getTaskAllOrderDun" resultType="com.goafanti.order.bo.OrderDunTaskBo">
+    select a.id,a.order_no as orderNo,a.dun_subject as dunSubject,a.money,settlement_amount as settlementAmount,
+ 	b.project_status as projectStatus,b.order_status as orderStatus from t_order_dun a
+ 	left join t_order_new b on a.order_no=b.order_no
+ 	where dun_status=0 and start_time is null  
+    </select>
 </mapper>

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

@@ -1101,10 +1101,21 @@
    <select id="selectOrderNewListCount" resultType="java.lang.Integer">
   	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 
-  	where a.delete_sign = 0  
- 	<if test="specially == 0">
-  	and a.order_status not in(3,5) and a.approval !=3
+  	left join admin c on a.salesman_id=c.id
+  	left join admin d on a.finance_id=d.id
+  	<if test="specially == 2">
+	left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
+  	left join admin f on e.initiate=f.id
+  	</if>
+  	<if test="specially == 4">
+  	left join (select * from t_order_task where main=1) e on e.order_no=a.order_no
+  	left join admin f on e.task_receiver=f.id
+  	</if>
+  	where a.delete_sign = 0 
+  	<if test="specially == 0">
+  	and a.order_status not in(3,5,6) and a.approval !=3
   	</if>
   	<if test="specially == 1">
   	and a.process_status =1  and a.order_status=1
@@ -1115,9 +1126,16 @@
   	<if test="specially == 3">
   	and a.approval = 1 and  a.order_status=2
   	</if>
-	<if test="specially == 4">
+  	<if test="specially == 4">
   	and a.process_status in (4,5,6)
   	</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>
@@ -1193,7 +1211,7 @@
   </select>
   
    <select id="selectOrderRefundListByPage" resultType="com.goafanti.order.bo.TOrderRefundBo">
-  	select a.id, date_format(a.create_time,'%Y-%m_%d') as createDate,a.order_no as orderNo,
+  	select a.id, date_format(a.create_time,'%Y-%m-%d') as createDate,a.order_no as orderNo,
     c.nickname as userName,b.order_status as orderStatus,a.refund_status as refundStatus,
     a.reason,b.liquidation_status as liquidationStatus
     from t_order_refund a left join t_order_new b on a.order_no=b.order_no

+ 60 - 0
src/main/java/com/goafanti/common/task/OrderDunTask.java

@@ -0,0 +1,60 @@
+package com.goafanti.common.task;
+
+
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.goafanti.common.model.TOrderDun;
+
+import com.goafanti.order.bo.OrderDunTaskBo;
+import com.goafanti.order.service.OrderNewService;
+//@Component
+@Controller
+public class OrderDunTask {
+	@Autowired
+	private OrderNewService orderNewService;
+	
+	
+	
+	/**
+	 * 每天凌晨2点轮询处理需要催款的信息
+	 */
+	
+//	@Scheduled(cron = "0 0 2  * * ?") 
+  	@RequestMapping(value = "/open/updateorderDun", method = RequestMethod.GET)
+	public void updateorderDun(){
+  		List<OrderDunTaskBo> list=orderNewService.selectAllOrderDun();
+  		for (OrderDunTaskBo t : list) {
+			if (t.getDunSubject()/10==1) {
+				if (t.getDunSubject()%10==t.getOrderStatus()&&t.getSettlementAmount().compareTo(t.getMoney()) == -1) {
+					 updateOrderDun(t);
+				}
+			}else {
+				if (t.getDunSubject()%10==t.getProjectStatus()&&t.getSettlementAmount().compareTo(t.getMoney()) == -1) {
+					 updateOrderDun(t);
+				}
+			}
+		}
+  		
+  	}
+
+
+	private void updateOrderDun(OrderDunTaskBo t) {
+		TOrderDun tDun=new TOrderDun();
+		 tDun.setId(t.getId());
+		 tDun.setStartTime(new Date());
+		 orderNewService.updateOrderDun(tDun);
+		 orderNewService.SendEmail(t.getOrderNo(),t.getId());
+	}
+  	
+}

+ 0 - 17
src/main/java/com/goafanti/common/task/OrderTaskDun.java

@@ -1,17 +0,0 @@
-package com.goafanti.common.task;
-
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-@Component
-//@Controller
-public class OrderTaskDun {
-
-	
-	
-	
-	@Scheduled(cron = "0 0 2  * * ?") 
-	public void updatrTaskDun(){
-		
-	}
-}

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

@@ -89,7 +89,10 @@ public class SendEmailUtil {
 		BigDecimal b = new BigDecimal("1.2");
 		System.out.println(b.add(new BigDecimal(0.0000)).toString());
 		System.out.println(b.add(new BigDecimal("0")).toString());
-//		String content = "<div>客户名称: 张雯</div><div>订单编号: 0001</div>";
+		String content = "<div>客户名称: 旺旺</div><div>订单编号: 0001</div>";
+//		content +="<div>催收时间: " + 123456 +"</div><div>催收科目: " + "??" +"</div><div>催收情况: " + "???" +"</div>";
+		EmailBo bo =new EmailBo("催收通知","2304089483@qq.com","管理员","平台超管中心","管理员","<div>客户名称: 国防湖南</div><div>订单编号: 273822676366036992</div><div>催收时间: 273822676366036992</div><div>催收科目: 273822676366036992</div><div>催收情况: 273822676366036992</div>");
+		send(bo);
 //		EmailBo bo = new EmailBo("奖金信息", "13077305639@163.com,3298921364@qq.com", "limim,李敏", "财务部", "财务专员彭晓丽", content);
 //		send(bo);
 	}

+ 56 - 0
src/main/java/com/goafanti/order/bo/OrderDunTaskBo.java

@@ -0,0 +1,56 @@
+package com.goafanti.order.bo;
+
+import java.math.BigDecimal;
+
+public class OrderDunTaskBo {
+	private String id;
+	private String orderNo;
+	private Integer dunSubject;
+	private BigDecimal money;
+	private BigDecimal settlementAmount;
+	private Integer projectStatus;
+	private Integer orderStatus ;
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getOrderNo() {
+		return orderNo;
+	}
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+	public Integer getDunSubject() {
+		return dunSubject;
+	}
+	public void setDunSubject(Integer dunSubject) {
+		this.dunSubject = dunSubject;
+	}
+	public BigDecimal getMoney() {
+		return money;
+	}
+	public void setMoney(BigDecimal money) {
+		this.money = money;
+	}
+	public BigDecimal getSettlementAmount() {
+		return settlementAmount;
+	}
+	public void setSettlementAmount(BigDecimal settlementAmount) {
+		this.settlementAmount = settlementAmount;
+	}
+	public Integer getProjectStatus() {
+		return projectStatus;
+	}
+	public void setProjectStatus(Integer projectStatus) {
+		this.projectStatus = projectStatus;
+	}
+	public Integer getOrderStatus() {
+		return orderStatus;
+	}
+	public void setOrderStatus(Integer orderStatus) {
+		this.orderStatus = orderStatus;
+	}
+	
+}

+ 76 - 0
src/main/java/com/goafanti/order/enums/OrderDunSubject.java

@@ -0,0 +1,76 @@
+package com.goafanti.order.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum OrderDunSubject {
+	/** 订单审核通过 **/
+	DDSHTG(12,"订单审核通过"),
+	/** 项目待提交 **/
+	XMDTJ(20,"项目待提交"),
+	/** 项目已提交 **/
+	XMYTJ(21,"项目已提交"),
+	/** 项目评审 **/
+	XMPS(22,"项目评审"),
+	/** 项目立项 **/
+	XMLS(23,"项目立项"),
+	/** 项目公示 **/
+	XMGS(24,"项目公示"),
+	/** 项目抽查 **/
+	XMCC(25,"项目抽查"),
+	/** 项目备案 **/
+	XMBA(26,"项目备案"),
+	/** 项目下证 **/
+	XMXZ(27,"项目下证"),
+	/** 项目验收 **/
+	XMYS(28,"项目验收"),
+	/** 项目拨款 **/
+	XMBK(29,"项目拨款"),
+	/** 无效 **/
+	INVALID(10, "INVALID");
+	
+	private OrderDunSubject(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, OrderDunSubject> status = new HashMap<Integer, OrderDunSubject>();
+
+	static {
+		for (OrderDunSubject value : OrderDunSubject.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+	
+	public static String getValueByCode(Integer code){
+        for(OrderDunSubject orderDunSubject:OrderDunSubject.values()){
+            if(code.equals(orderDunSubject.getCode())){
+                return orderDunSubject.getDesc();
+            }
+        }
+        return  null;
+    }
+	public static OrderDunSubject getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return INVALID;
+	}
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+	private Integer	code;
+	private String	desc;
+	public Integer getCode() {
+		return code;
+	}
+	public void setCode(Integer code) {
+		this.code = code;
+	}
+	public String getDesc() {
+		return desc;
+	}
+	public void setDesc(String desc) {
+		this.desc = desc;
+	}
+}

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

@@ -13,6 +13,7 @@ import com.goafanti.common.model.TOrderTask;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.order.bo.BackOrderListBo;
 import com.goafanti.order.bo.BillListBo;
+import com.goafanti.order.bo.OrderDunTaskBo;
 import com.goafanti.order.bo.OrderRefundBo;
 import com.goafanti.order.bo.OrderRefundDetailBo;
 import com.goafanti.order.bo.TDunLogListBo;
@@ -158,6 +159,10 @@ public interface OrderNewService {
 	OrderRefundDetailBo orderRefundDetail(String id);
 	int updateOrderRefund(TOrderRefundWithBLOBs t);
 	int technicianBackOrder(String orderNo);
+	List<OrderDunTaskBo> selectAllOrderDun();
+	void updateOrderDun(TOrderDun tDun);
+	void SendEmail(String orderNo,String dunId);
+	
 	
 
 	

+ 67 - 4
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -1,6 +1,7 @@
 package com.goafanti.order.service.impl;
 
 
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -10,15 +11,22 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import javax.mail.MessagingException;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import com.alibaba.fastjson.JSON;
+import com.goafanti.admin.bo.AdminListBo;
+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.OrganizationContactBookMapper;
 import com.goafanti.common.dao.TDunLogMapper;
 import com.goafanti.common.dao.TOrderBackMapper;
@@ -35,13 +43,16 @@ import com.goafanti.common.model.TOrderDun;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.common.model.TOrderRefundWithBLOBs;
 import com.goafanti.common.model.TOrderTask;
+import com.goafanti.common.task.OrderReportTask;
 import com.goafanti.common.utils.ExportExcelUtil;
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.common.utils.SendEmailUtil;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.customer.bo.LockingReleaseBo;
-import com.goafanti.order.bo.OrderRefundBo;
+import com.goafanti.order.bo.OrderDunTaskBo;
 import com.goafanti.order.bo.OrderRefundDetailBo;
 import com.goafanti.order.bo.TDunLogListBo;
 import com.goafanti.order.bo.TOrderNewBo;
@@ -50,6 +61,7 @@ import com.goafanti.order.bo.TOrderTaskBo;
 import com.goafanti.order.enums.ActiveState;
 import com.goafanti.order.enums.ApprovalNewState;
 import com.goafanti.order.enums.LiquidationNewState;
+import com.goafanti.order.enums.OrderDunSubject;
 import com.goafanti.order.enums.OrderNewState;
 import com.goafanti.order.enums.ProcessStatus;
 import com.goafanti.order.enums.ProjectNewStage;
@@ -76,6 +88,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Autowired
 	private JDBCIdGenerator	idGenerator;
 	@Autowired
+	private AdminMapper	adminMapper;
+	@Autowired
 	private UserLockReleaseMapper	userLockReleaseMapper;
 	@Value(value = "${mobileRemindCodeTemplate}")
 	private String					mobileRemindCodeTemplate	= null;
@@ -88,7 +102,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Value(value = "${accessSecret}")
 	private String					accessSecret		= null;
 	
-	
+	Logger							logger	= LoggerFactory.getLogger(OrderNewServiceImpl.class);
 
 	
 	@Override
@@ -283,6 +297,7 @@ 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);
 		tOrderBackMapper.insertSelective(ob);
 	}
 
@@ -332,11 +347,12 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 	@Override
 	public int addOrderRefund(TOrderRefundWithBLOBs t) {
+		TOrderNew order =tOrderNewMapper.selectByPrimaryKey(t.getOrderNo());
 		t.setRefundStatus(refundState.DSH.getCode());
 		t.setCreateTime(new Date());
 		t.setInitiate(TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
-		t.setAccept("1");
-		//t.setAccept(tOrder.getFinanceId());
+		//t.setAccept("1");
+		t.setAccept(order.getFinanceId());
 		t.setResult("");
 		TOrderNew tOrder=new TOrderNew(); 
 		tOrder.setOrderNo(t.getOrderNo());
@@ -526,8 +542,55 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			return -1;
 		}
 		t.setOrderStatus(OrderNewState.YBH.getCode());
+		SendEmail(orderNo,null);
 		return tOrderNewMapper.updateByPrimaryKey(t);
 	}
+
+
+
+	@Override
+	public List<OrderDunTaskBo> selectAllOrderDun() {
+		return tOrderDunMapper.getTaskAllOrderDun();
+	}
+
+
+
+	@Override
+	public void updateOrderDun(TOrderDun tDun) {
+		 tOrderDunMapper.updateByPrimaryKeySelective(tDun);
+	}
+
+
+
+	@Override
+	public void  SendEmail(String orderNo,String dunId){
+		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()) +
+						"</div><div>催收科目: " + OrderDunSubject.getValueByCode(tDun.getDunSubject()) +
+						"</div><div>催收情况: " + (tDun.getDunStatus()==1?"已完成":"未完成") +"</div>";
+				tite="催收通知";
+			}
+			//发送驳回邮件
+			EmailBo bo = new EmailBo(tite, b.getEmail(), b.getSalesmanName(), a.getDepartmentName(), a.getName(), content);
+			SendEmailUtil.send(bo);
+			LoggerUtils.debug(logger, "=========================================发送邮件成功");
+		} catch (UnsupportedEncodingException e) {
+			LoggerUtils.error(getClass(), "发送邮件失败", e);
+		} catch (MessagingException e) {
+			LoggerUtils.error(getClass(), "发送邮件失败", e);
+		}
+	}
+
+
+
+