|
|
|
@ -9,6 +9,8 @@ import cn.hutool.core.util.ArrayUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.dxhy.base.common.constant.ConfigureConstant; |
|
|
|
|
import com.dxhy.base.common.constant.OrderInfoEnum; |
|
|
|
|
import com.dxhy.base.common.constant.OrderManagementConstant; |
|
|
|
@ -19,7 +21,12 @@ import com.dxhy.base.file.common.ExcelReadContext; |
|
|
|
|
import com.dxhy.base.file.handle.ExcelExportHandle; |
|
|
|
|
import com.dxhy.base.service.module.base.model.SalerWarning; |
|
|
|
|
import com.dxhy.base.service.module.base.service.SalerWarningService; |
|
|
|
|
import com.dxhy.base.service.module.buyer.model.BuyerEntity; |
|
|
|
|
import com.dxhy.base.service.module.buyer.service.BuyerService; |
|
|
|
|
import com.dxhy.base.service.module.thirdservice.simsback.service.SimsBackService; |
|
|
|
|
import com.dxhy.base.service.module.thirdservice.user.model.DeptEntity; |
|
|
|
|
import com.dxhy.base.service.module.thirdservice.user.service.UserInfoService; |
|
|
|
|
import com.dxhy.base.service.openapi.protocol.qd.PageGfxxReq; |
|
|
|
|
import com.dxhy.base.service.utils.DesensitizeUtil; |
|
|
|
|
import com.dxhy.base.sms.utils.MessageSenderUtil; |
|
|
|
|
import com.dxhy.base.sms.vo.AttachmentVo; |
|
|
|
@ -83,6 +90,7 @@ import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
|
import org.joda.time.DateTime; |
|
|
|
@ -195,6 +203,12 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
@Resource |
|
|
|
|
private OrderInfoQdGtgmfMapper orderInfoQdGtgmfMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private UserInfoService userInfoService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BuyerService buyerService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 作用: |
|
|
|
@ -1880,6 +1894,7 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
String pushType = fpYxTsMqData.getPushType(); |
|
|
|
|
String emailAddress = fpYxTsMqData.getEmailAddress(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发票流水号为空
|
|
|
|
|
if (StringUtils.isEmpty(fpqqlsh)) { |
|
|
|
|
log.error("发票流水号:{},流水号为空不交付邮件!", fpqqlsh); |
|
|
|
@ -1895,18 +1910,42 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
fphm = orderInvoiceInfo.getSdfphm(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//从大B获取配置信息
|
|
|
|
|
DeptEntity deptEntity = userInfoService.querySysDeptEntity(orderInvoiceInfo.getXhfNsrsbh(), orderInvoiceInfo.getEntId()); |
|
|
|
|
|
|
|
|
|
log.info("大B邮箱配置信息:{}", JSONObject.toJSONString(deptEntity)); |
|
|
|
|
if (ObjectUtils.isEmpty(deptEntity)) { |
|
|
|
|
OrderInvoiceInfo orderInvoiceInfoUpdate = new OrderInvoiceInfo(); |
|
|
|
|
orderInvoiceInfoUpdate.setFpqqlsh(orderInvoiceInfo.getFpqqlsh()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushStatus(OrderInfoEnum.EMAIL_PUSH_STATUS_3.getKey()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushSbyy("获取大B邮箱配置失败"); |
|
|
|
|
updateOrderInvoiceInfoByFpqqlsh(orderInvoiceInfoUpdate, shList); |
|
|
|
|
log.error("获取大B邮箱配置失败"); |
|
|
|
|
return R.error("获取大B邮箱配置失败"); |
|
|
|
|
} |
|
|
|
|
if (ConfigureConstant.STRING_0.equals(deptEntity.getEmailSend())) { |
|
|
|
|
OrderInvoiceInfo orderInvoiceInfoUpdate = new OrderInvoiceInfo(); |
|
|
|
|
orderInvoiceInfoUpdate.setFpqqlsh(orderInvoiceInfo.getFpqqlsh()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushStatus(OrderInfoEnum.EMAIL_PUSH_STATUS_1.getKey()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushSbyy("邮箱推送未开启"); |
|
|
|
|
updateOrderInvoiceInfoByFpqqlsh(orderInvoiceInfoUpdate, shList); |
|
|
|
|
log.info("税号-{}未开启邮箱推送", JSON.toJSONString(shList)); |
|
|
|
|
return R.error("税号-{}未开启邮箱推送", JSON.toJSONString(shList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果为自动推送,红票数据不交付邮件
|
|
|
|
|
//如果为手动,交付红票邮件
|
|
|
|
|
if (ConfigureConstant.STRING_1.equals(pushType)) { |
|
|
|
|
if (OrderInfoEnum.INVOICE_BILLING_TYPE_1.getKey().equals(orderInvoiceInfo.getKplx())) { |
|
|
|
|
log.error("发票代码:{},发票号码:{},红票数据不交付邮件!", fpdm, fphm); |
|
|
|
|
OrderInvoiceInfo orderInvoiceInfoUpdate = new OrderInvoiceInfo(); |
|
|
|
|
orderInvoiceInfoUpdate.setFpqqlsh(orderInvoiceInfo.getFpqqlsh()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushStatus(OrderInfoEnum.EMAIL_PUSH_STATUS_0.getKey()); |
|
|
|
|
orderInvoiceInfoUpdate.setEmailPushSbyy("红票数据不交付邮件"); |
|
|
|
|
updateOrderInvoiceInfoByFpqqlsh(orderInvoiceInfoUpdate, shList); |
|
|
|
|
return R.error("发票代码:" + fpdm + ",发票号码:" + fphm + ",红票数据不交付邮件!"); |
|
|
|
|
} |
|
|
|
|
// if (OrderInfoEnum.INVOICE_BILLING_TYPE_1.getKey().equals(orderInvoiceInfo.getKplx())) {
|
|
|
|
|
// log.error("发票代码:{},发票号码:{},红票数据不交付邮件!", fpdm, fphm);
|
|
|
|
|
// OrderInvoiceInfo orderInvoiceInfoUpdate = new OrderInvoiceInfo();
|
|
|
|
|
// orderInvoiceInfoUpdate.setFpqqlsh(orderInvoiceInfo.getFpqqlsh());
|
|
|
|
|
// orderInvoiceInfoUpdate.setEmailPushStatus(OrderInfoEnum.EMAIL_PUSH_STATUS_0.getKey());
|
|
|
|
|
// orderInvoiceInfoUpdate.setEmailPushSbyy("红票数据不交付邮件");
|
|
|
|
|
// updateOrderInvoiceInfoByFpqqlsh(orderInvoiceInfoUpdate, shList);
|
|
|
|
|
// return R.error("发票代码:" + fpdm + ",发票号码:" + fphm + ",红票数据不交付邮件!");
|
|
|
|
|
// }
|
|
|
|
|
//自动交付数据,需要防止并发操作,增加redis和数据库双重逻辑判断,优先判断redis状态,如果已发送,跳过处理,再判断数据库状态,如果为已发送,跳过处理
|
|
|
|
|
String pushEmailRedis = redisService.get(String.format(RedisConstant.REDIS_PUSH_EMAIL, orderInvoiceInfo.getFpqqlsh())); |
|
|
|
|
if (ConfigureConstant.STRING_1.equals(pushEmailRedis)) { |
|
|
|
@ -1934,6 +1973,18 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
|
|
|
|
|
OrderInvoiceInfo orderInvoiceInfoUpdate = new OrderInvoiceInfo(); |
|
|
|
|
orderInvoiceInfoUpdate.setFpqqlsh(orderInvoiceInfo.getFpqqlsh()); |
|
|
|
|
|
|
|
|
|
//购方信息获取邮箱
|
|
|
|
|
if (StringUtils.isBlank(emailAddress)){ |
|
|
|
|
PageGfxxReq pageGfxxReq = new PageGfxxReq(); |
|
|
|
|
pageGfxxReq.setGfmc(orderInvoiceInfo.getGhfMc()); |
|
|
|
|
pageGfxxReq.setXhfNsrsbh(orderInvoiceInfo.getXhfNsrsbh()); |
|
|
|
|
BuyerEntity buyerEntity = buyerService.queryBuyerInfo(pageGfxxReq); |
|
|
|
|
if (ObjectUtil.isNotNull(buyerEntity)){ |
|
|
|
|
emailAddress = buyerEntity.getEmail(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//存在邮箱的话用邮箱进行推送
|
|
|
|
|
if (StringUtils.isNotBlank(emailAddress)) { |
|
|
|
|
|
|
|
|
@ -1962,7 +2013,7 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
EmailContent emailContent = buildEmailContent(orderInvoiceInfo, emailAddressList, terminalCode); |
|
|
|
|
if (ObjectUtil.isNotNull(emailContent)) { |
|
|
|
|
//调用邮件服务
|
|
|
|
|
Map<String, String> sendEmail = sendEmail(emailContent); |
|
|
|
|
Map<String, String> sendEmail = sendEmail(emailContent, orderInvoiceInfo); |
|
|
|
|
|
|
|
|
|
//根据调用邮件服务的结果更新数据库
|
|
|
|
|
if (!ConfigureConstant.STRING_0000.equals(String.valueOf(sendEmail.get(OrderManagementConstant.CODE)))) { |
|
|
|
@ -2166,7 +2217,7 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
DateUtil.formatDateTime(orderInvoiceInfo.getCreateTime()), OrderCommonUtils.getFpzlDmMc(orderInvoiceInfo.getFpzlDm()), sbyy}); |
|
|
|
|
emailContent.setTo(toArr); |
|
|
|
|
// 发送邮件
|
|
|
|
|
sendEmail(emailContent); |
|
|
|
|
sendEmail(emailContent, orderInvoiceInfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2184,7 +2235,7 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
* @author <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a> |
|
|
|
|
* @date 2021-12-13 |
|
|
|
|
*/ |
|
|
|
|
private Map<String, String> sendEmail(EmailContent emailContent) { |
|
|
|
|
private Map<String, String> sendEmail(EmailContent emailContent, OrderInvoiceInfo orderInvoiceInfo) { |
|
|
|
|
String emailSendType = invoiceConfig.getEmailSendType(); |
|
|
|
|
Map<String, String> resultMap = new HashMap<>(3); |
|
|
|
|
if (SEND_TYPE_0.equals(emailSendType)) { |
|
|
|
@ -2213,14 +2264,26 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
}); |
|
|
|
|
mailContent.setAttachmentVos(attachmentVoList); |
|
|
|
|
} |
|
|
|
|
//从大B获取配置信息
|
|
|
|
|
DeptEntity deptEntity = userInfoService.querySysDeptEntity(orderInvoiceInfo.getXhfNsrsbh(), orderInvoiceInfo.getEntId()); |
|
|
|
|
|
|
|
|
|
log.info("大B邮箱配置信息:{}", JSONObject.toJSONString(deptEntity)); |
|
|
|
|
if (ObjectUtils.isEmpty(deptEntity)) { |
|
|
|
|
log.error("获取大B邮箱配置失败"); |
|
|
|
|
resultMap.put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999); |
|
|
|
|
resultMap.put(OrderManagementConstant.ALL_MESSAGE, "获取大B邮箱配置失败"); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
boolean isBlank = ObjectUtils.isEmpty(deptEntity) || StringUtils.isBlank(deptEntity.getSendAddress()); |
|
|
|
|
|
|
|
|
|
//发件方信息
|
|
|
|
|
SendMailVo sendVo = new SendMailVo(); |
|
|
|
|
//发件方邮箱
|
|
|
|
|
sendVo.setSendAddress(invoiceConfig.getSendAddress()); |
|
|
|
|
sendVo.setSendAddress(isBlank ? invoiceConfig.getSendAddress() : deptEntity.getSendAddress()); |
|
|
|
|
//发件方第三方授权码
|
|
|
|
|
sendVo.setAuthPassword(invoiceConfig.getAuthPassword()); |
|
|
|
|
sendVo.setAuthPassword(isBlank ? invoiceConfig.getAuthPassword() : deptEntity.getAuthPassword()); |
|
|
|
|
//发件方名称
|
|
|
|
|
sendVo.setSendName(invoiceConfig.getSendName()); |
|
|
|
|
sendVo.setSendName(isBlank ? invoiceConfig.getSendName() : deptEntity.getSendName()); |
|
|
|
|
//发件方邮件服务器
|
|
|
|
|
sendVo.setSmtpServer(invoiceConfig.getSmtpServer()); |
|
|
|
|
//邮件服务器端口
|
|
|
|
|