Bladeren bron

发送短信和站内消息开发

Signed-off-by: anderx <312518615@qq.com>
anderx 5 jaren geleden
bovenliggende
commit
66e2c7609c

+ 25 - 13
src/main/java/com/goafanti/common/bo/EmailBo.java

@@ -32,16 +32,16 @@ public class EmailBo {
 	 * @param sender		发起人id
 	 * @param content		内容
 	 */
-	public EmailBo(String subject, String address, String addressee,
-			String deptname, String sender,
-			String content) {
-		this.subject = subject;
-		this.address = address;
-		this.addressee = addressee;
-		this.deptname = deptname;
-		this.sender = sender;
-		this.content = content;
-	}
+//	public EmailBo(String subject, String address, String addressee,
+//			String deptname, String sender,
+//			String content) {
+//		this.subject = subject;
+//		this.address = address;
+//		this.addressee = addressee;
+//		this.deptname = deptname;
+//		this.sender = sender;
+//		this.content = content;
+//	}
 	
 	/**
 	 * 
@@ -72,14 +72,14 @@ public class EmailBo {
 	 *  
 	 * @param subject	标题
 	 * @param address	收件地址
-	 * @param deptname		部门
+	 * @param deptname		发起人部门
 	 * @param sender		发起人
 	 * @param content		内容
 	 * @param orderNo		订单编号
-	 * @param date		时间
+	 * @param date			时间
 	 * @param adminName		接收人名字
 	 * @param userName		用户名称
-	 * @param type		类型 0通用 1催款
+	 * @param type		类型 0通用 1催款 2付款催款
 	 * @param approval   null 非特批
 	 * @return 
 	 */
@@ -95,6 +95,18 @@ public class EmailBo {
 		if(type==1)this.content=setDunFormat( addressee, sender, deptname,orderNo, date , dunStatusName,adminName,userName,0);
 		if(type==2)this.content=setDunFormat( addressee, sender, deptname,orderNo, date , dunStatusName,adminName,userName,1);
 	}
+	
+	public  EmailBo(String subject, String address, String deptname, String sender,
+			 String orderNo,String adminName) {
+		this.subject = subject;
+		this.address = address;
+		this.addressee = "";
+		this.deptname = deptname;
+		this.sender = sender;
+		this.content = setGeneralFormat();
+		
+	}
+
 
 	public String setDunFormat(String addressee,String sender,String deptname,String orderNo,String date ,String dunStatusName,String adminName,
 			String userName,int i) {

+ 5 - 0
src/main/java/com/goafanti/common/dao/FinancialPaymentMapper.java

@@ -2,6 +2,7 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.FinancialPayment;
 import com.goafanti.common.model.FinancialPaymentExample;
+import com.goafanti.organization.bo.NoticeInformationBo;
 import com.goafanti.organization.bo.outFinancialPayment;
 
 import java.util.List;
@@ -77,4 +78,8 @@ public interface FinancialPaymentMapper {
 	int updateByPrimaryKey(FinancialPayment record);
 
 	List<outFinancialPayment> selectByPid(Integer id);
+
+
+
+	NoticeInformationBo selectBypidGetNotice(Integer pid);
 }

+ 4 - 0
src/main/java/com/goafanti/common/enums/NoticeStatus.java

@@ -50,6 +50,10 @@ public enum NoticeStatus {
 	TASK_PATENT_ERROR(41,"专利提醒失败"),
 	TASK_PATENT_REMIND(42,"专利缴费提醒"),
 	PAYMENT_DUN(43,"付款节点提醒"),
+	PAYMENT_NODE(44,"付款审核通知"),
+	PAYMENT_NO(45,"付款驳回通知"),
+	PAYMENT_YES(46,"付款通过通知"),
+	PAYMENT_COMPLETE(47,"财务付款通知"),
 	OTHER(0, "其他");
 
 	private NoticeStatus(Integer code, String desc) {

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

@@ -984,7 +984,7 @@
   </select>
   <!-- 获得当前登录人的名字和部门名 -->
   <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
-  	select a.name, d.name as departmentName,a.department_id departmentId from admin a
+  	select a.name, d.name as departmentName,a.department_id departmentId,a.email from admin a
   		left join department d on a.department_id = d.id
   		where a.id = #{_parameter,jdbcType=VARCHAR}
   </select>

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

@@ -287,4 +287,11 @@
   select id,pid,party_amount partyAmount,date_format(payment_time,'%Y-%m-%d') paymentTimes 
   from financial_payment where pid= #{id}
   </select>
+  <select id="selectBypidGetNotice" resultType="com.goafanti.organization.bo.NoticeInformationBo">
+	select b.id pid,d.order_no orderNo,d.salesman_id salesmanId,d.salesman_name salesmanName , d.buyer_name buyerName,
+	d.finance_id financeId,d.finance_name financeName ,sa.email salesmanEmail,fa.email financeEmail
+	from  t_order_payment b left join t_order_task c on b.tid=c.id left join t_order_mid d on c.order_no=d.order_no
+	left join admin sa on d.salesman_id=sa.id left join admin fa on d.finance_id=fa.id
+	where b.id= #{pid}
+  </select>
 </mapper>

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

@@ -1147,7 +1147,6 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			//发送驳回邮件
 			EmailBo bo = new EmailBo(tite, b.getEmail(), b.getSalesmanName(), a.getDepartmentName(), a.getName(), content);
 			if(StringUtils.isNotBlank(b.getEmail())) {
-				LoggerUtils.debug(logger, "tite:"+tite+"  Email:"+ b.getEmail()+"  收件人姓名:"+ b.getSalesmanName()+ "    部门:"+a.getDepartmentName()+ "  发件人姓名:"+a.getName()+"   内容:"+ content);
 				SendEmailUtil.getInstance().send(bo);
 			}
 			LoggerUtils.debug(logger, "=========================================发送邮件成功");

+ 70 - 0
src/main/java/com/goafanti/organization/bo/NoticeInformationBo.java

@@ -0,0 +1,70 @@
+package com.goafanti.organization.bo;
+
+public class NoticeInformationBo {
+	private Integer pid;
+	private String salesmanId;
+	private String salesmanName;
+	private String orderNo;
+	private String buyerName;
+	private String financeId;
+	private String financeName;
+	private String salesmanEmail;
+	private String financeEmail;
+	
+	public Integer getPid() {
+		return pid;
+	}
+	public void setPid(Integer pid) {
+		this.pid = pid;
+	}
+	public String getSalesmanId() {
+		return salesmanId;
+	}
+	public void setSalesmanId(String salesmanId) {
+		this.salesmanId = salesmanId;
+	}
+	public String getSalesmanName() {
+		return salesmanName;
+	}
+	public void setSalesmanName(String salesmanName) {
+		this.salesmanName = salesmanName;
+	}
+	public String getOrderNo() {
+		return orderNo;
+	}
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+	public String getBuyerName() {
+		return buyerName;
+	}
+	public void setBuyerName(String buyerName) {
+		this.buyerName = buyerName;
+	}
+	public String getFinanceId() {
+		return financeId;
+	}
+	public void setFinanceId(String financeId) {
+		this.financeId = financeId;
+	}
+	public String getFinanceName() {
+		return financeName;
+	}
+	public void setFinanceName(String financeName) {
+		this.financeName = financeName;
+	}
+	public String getSalesmanEmail() {
+		return salesmanEmail;
+	}
+	public void setSalesmanEmail(String salesmanEmail) {
+		this.salesmanEmail = salesmanEmail;
+	}
+	public String getFinanceEmail() {
+		return financeEmail;
+	}
+	public void setFinanceEmail(String financeEmail) {
+		this.financeEmail = financeEmail;
+	}
+	
+	
+}

+ 80 - 8
src/main/java/com/goafanti/organization/controller/ThirdPartyCompanyApiController.java

@@ -26,6 +26,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 	@Resource
 	private ThirdPartyCompanyService thirdPartyCompanyService;
 	
+	/**
+	 * 新增第三方机构
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/addCompany" , method = RequestMethod.POST)
 	public Result addCompany(ThirdPartyCompany t) {
 		Result res =new Result();
@@ -37,6 +42,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 修改第三方机构
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/updateCompany" , method = RequestMethod.POST)
 	public Result updateCompany(ThirdPartyCompany t) {
 		Result res =new Result();
@@ -52,6 +62,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 删除第三方机构
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/deleteCompany" , method = RequestMethod.POST)
 	public Result deleteCompany(Integer id) {
 		Result res =new Result();
@@ -62,7 +77,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.deleteCompany(id));
 		return res;
 	}
-	
+	/**
+	 * 第三方机构列表
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectCompany" , method = RequestMethod.GET)
 	public Result selectCompany(Integer tid) {
 		Result res =new Result();
@@ -75,6 +94,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 	}
 	
 	
+	/**
+	 * 模糊查询机构列表
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectVague" , method = RequestMethod.GET)
 	public Result selectVague(String  name) {
 		Result res =new Result();
@@ -86,6 +110,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 新增付款节点
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/addPaymentNode" , method = RequestMethod.POST)
 	public Result addPaymentNode(InputPaymentNode p) {
 		Result res =new Result();
@@ -97,7 +126,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
-
+	/**
+	 * 删除付款节点
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/deletePaymentNode" , method = RequestMethod.POST)
 	public Result deletePaymentNode(Integer id) {
 		Result res =new Result();
@@ -108,7 +141,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.deletePaymentNode(id));
 		return res;
 	}
-	
+	/**
+	 * 修改付款节点
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/updatePaymentNode" , method = RequestMethod.POST)
 	public Result updatePaymentNode(InputPaymentNode p) {
 		Result res =new Result();
@@ -124,6 +161,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 付款节点列表
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectPaymentNode" , method = RequestMethod.GET)
 	public Result selectPaymentNode(Integer tid) {
 		Result res =new Result();
@@ -135,7 +177,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
-	
+	/**
+	 * 新增付款
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/addOrderPayment" , method = RequestMethod.POST)
 	public Result addOrderPayment(TOrderPayment p) {
 		Result res =new Result();
@@ -146,7 +192,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.addOrderPayment(p));
 		return res;
 	}
-	
+	/**
+	 * 修改付款
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/updateOrderPayment" , method = RequestMethod.POST)
 	public Result updateOrderPayment(TOrderPayment p) {
 		Result res =new Result();
@@ -157,7 +207,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.updateOrderPayment(p));
 		return res;
 	}
-	
+	/**
+	 * 付款详情
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/OrderPaymentDetails" , method = RequestMethod.GET)
 	public Result OrderPaymentDetails(Integer id) {
 		Result res =new Result();
@@ -169,6 +223,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 付款列表
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectOrderPayment" , method = RequestMethod.GET)
 	public Result selectOrderPayment(Integer id) {
 		Result res =new Result();
@@ -180,6 +239,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		return res;
 	}
 	
+	/**
+	 * 付款日志
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectPaymentLog" , method = RequestMethod.GET)
 	public Result selectPaymentLog(Integer id) {
 		Result res =new Result();
@@ -190,7 +254,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.selectPaymentLog(id));
 		return res;
 	}
-	
+	/**
+	 * 新增财务付款
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/addfinancialPayment" , method = RequestMethod.POST)
 	public Result addfinancialPayment(InuptFinancialPayment f) {
 		Result res =new Result();
@@ -205,7 +273,11 @@ public class ThirdPartyCompanyApiController extends BaseApiController{
 		res.data(thirdPartyCompanyService.addfinancialPayment(f));
 		return res;
 	}
-	
+	/**
+	 * 财务付款列表
+	 * @param t
+	 * @return
+	 */
 	@RequestMapping(value = "/selectfinancialPayment" , method = RequestMethod.GET)
 	public Result selectfinancialPayment(Integer id) {
 		Result res =new Result();

+ 57 - 4
src/main/java/com/goafanti/organization/service/impl/ThirdPartyCompanyServiceImpl.java

@@ -1,28 +1,39 @@
 package com.goafanti.organization.service.impl;
 
+import java.io.UnsupportedEncodingException;
 import java.util.List;
+import java.util.UUID;
 
+import javax.mail.MessagingException;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.goafanti.admin.bo.AdminListBo;
+import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.CompanyLibraryMapper;
 import com.goafanti.common.dao.FinancialPaymentMapper;
+import com.goafanti.common.dao.NoticeMapper;
 import com.goafanti.common.dao.PaymentLogMapper;
 import com.goafanti.common.dao.PaymentNodeMapper;
 import com.goafanti.common.dao.TOrderPaymentMapper;
 import com.goafanti.common.dao.ThirdPartyCompanyMapper;
-import com.goafanti.common.model.Admin;
+import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.model.CompanyLibrary;
+import com.goafanti.common.model.Notice;
 import com.goafanti.common.model.PaymentLog;
 import com.goafanti.common.model.TOrderPayment;
 import com.goafanti.common.model.ThirdPartyCompany;
 import com.goafanti.common.utils.DateUtils;
+import com.goafanti.common.utils.SendEmailUtil;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.organization.bo.InputPaymentNode;
 import com.goafanti.organization.bo.InuptFinancialPayment;
+import com.goafanti.organization.bo.NoticeInformationBo;
 import com.goafanti.organization.bo.OutPaymentLog;
 import com.goafanti.organization.bo.OutPaymentNode;
 import com.goafanti.organization.bo.OutThirdPartyCompany;
@@ -46,6 +57,8 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 	@Autowired
 	private AdminMapper	adminMapper;
 	@Autowired
+	private NoticeMapper	noticeMapper;
+	@Autowired
 	private FinancialPaymentMapper	financialPaymentMapper;
 	
 
@@ -133,7 +146,10 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 	public int addOrderPayment(TOrderPayment p) {
 		p.setStatus(0);
 		tOrderPaymentMapper.insertSelectiveGetId(p);
-		Admin a=adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
+		System.out.println(p.getId());
+		NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
+		AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
+		addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_NODE.getCode());
 		PaymentLog pl=new PaymentLog(p.getId(),0,"发起付款",a.getId(),a.getName());
 		paymentLogMapper.insertSelective(pl);
 		return 1;
@@ -148,6 +164,15 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 
 	@Override
 	public int updateOrderPayment(TOrderPayment p) {
+		//状态 0审核 1驳回 2待支付 3已支付
+		Integer type=NoticeStatus.PAYMENT_NODE.getCode();
+		if (p.getStatus()==1)type= NoticeStatus.PAYMENT_NO.getCode();
+		else if(p.getStatus()==2)type= NoticeStatus.PAYMENT_YES.getCode();
+		NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(p.getId());
+		AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
+		addNoticAndSendEmail(ni,a,type);
+		PaymentLog pl=new PaymentLog(p.getId(),0,NoticeStatus.getValueByCode(type),a.getId(),a.getName());
+		paymentLogMapper.insertSelective(pl);
 		return tOrderPaymentMapper.updateByPrimaryKeySelective(p);
 	}
 
@@ -160,7 +185,6 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 
 	@Override
 	public List<outOrderPayment> selectOrderPayment(Integer id) {
-		
 		return tOrderPaymentMapper.selectByTid(id);
 	}
 
@@ -168,6 +192,9 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 	@Override
 	public int addfinancialPayment(InuptFinancialPayment f) {
 		f.setPaymentTime(DateUtils.StringToDate(f.getPaymentTimes(), AFTConstants.YYYYMMDD));
+		NoticeInformationBo ni=financialPaymentMapper.selectBypidGetNotice(f.getPid());
+		AdminListBo a =adminMapper.getDeptNameByAid(TokenManager.getAdminId());
+		addNoticAndSendEmail(ni,a,NoticeStatus.PAYMENT_COMPLETE.getCode());
 		return financialPaymentMapper.insertSelective(f);
 	}
 
@@ -178,5 +205,31 @@ public class ThirdPartyCompanyServiceImpl extends  BaseMybatisDao<ThirdPartyComp
 	}
 
 
-
+	public void addNoticAndSendEmail(NoticeInformationBo in,AdminListBo a,Integer type) {
+		String str=NoticeStatus.getValueByCode(type)+": 订单编号 -"+in.getOrderNo()+
+				",客户名称:"+in.getBuyerName()+", 操作人:"+a.getName()+"-"+a.getDepartmentName()+"。";
+		Notice n =new Notice();
+		EmailBo bo = new EmailBo(NoticeStatus.getValueByCode(type), a.getEmail(), a.getDepartmentName(), a.getName(),
+				in.getOrderNo(), in.getSalesmanName());
+		n.setId(UUID.randomUUID().toString());
+		if (type==NoticeStatus.PAYMENT_NODE.getCode()) {
+			n.setAid(in.getFinanceId());
+			bo.setAddress(in.getFinanceEmail());
+		} else {
+			n.setAid(in.getSalesmanId());
+			bo.setAddress(in.getSalesmanEmail());
+		}
+		
+		n.setNoticeType(type);
+		n.setContent(str);
+		n.setReaded(0);//未读
+		noticeMapper.insertSelective(n);
+		if(StringUtils.isNotBlank(a.getEmail())) {
+			try {
+				SendEmailUtil.getInstance().send(bo);
+			} catch (UnsupportedEncodingException | MessagingException e) {
+				e.printStackTrace();
+			}
+		}
+	}
 }