|
|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|