新增邮件发送接口
This commit is contained in:
@@ -15,6 +15,7 @@ import com.gxwebsoft.common.core.web.PageParam;
|
|||||||
import com.gxwebsoft.common.core.web.BatchParam;
|
import com.gxwebsoft.common.core.web.BatchParam;
|
||||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
|
import com.gxwebsoft.common.system.service.EmailRecordService;
|
||||||
import com.gxwebsoft.shop.entity.Order;
|
import com.gxwebsoft.shop.entity.Order;
|
||||||
import com.gxwebsoft.shop.service.OrderService;
|
import com.gxwebsoft.shop.service.OrderService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -22,10 +23,15 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
import nuonuo.open.sdk.NNOpenSDK;
|
import nuonuo.open.sdk.NNOpenSDK;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -46,6 +52,8 @@ public class UserInvoiceController extends BaseController {
|
|||||||
private UserInvoiceService userInvoiceService;
|
private UserInvoiceService userInvoiceService;
|
||||||
@Resource
|
@Resource
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
@Resource
|
||||||
|
private EmailRecordService emailRecordService;
|
||||||
|
|
||||||
@ApiOperation("分页查询发票")
|
@ApiOperation("分页查询发票")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@@ -197,6 +205,8 @@ public class UserInvoiceController extends BaseController {
|
|||||||
orderInfo.setInvoiceNo(invoiceSerialNum);
|
orderInfo.setInvoiceNo(invoiceSerialNum);
|
||||||
System.out.println("invoiceSerialNum = " + invoiceSerialNum);
|
System.out.println("invoiceSerialNum = " + invoiceSerialNum);
|
||||||
orderService.updateById(orderInfo);
|
orderService.updateById(orderInfo);
|
||||||
|
invoice.setInvoiceNo(invoiceSerialNum);
|
||||||
|
userInvoiceService.updateById(invoice);
|
||||||
return success("发票开具成功", json);
|
return success("发票开具成功", json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,6 +240,16 @@ public class UserInvoiceController extends BaseController {
|
|||||||
return success("查询成功", result);
|
return success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ApiOperation("发送到邮箱")
|
||||||
|
// @GetMapping("/showInvoice/send/{pdfUrl}")
|
||||||
|
// public ApiResult<?> sendInvoice(@PathVariable("pdfUrl") String pdfUrl) {
|
||||||
|
// // 发送邮件通知
|
||||||
|
// String title = "发票凭证";
|
||||||
|
// // 发送邮件通知
|
||||||
|
// emailRecordService.sendEmail(title, pdfUrl, "ip170@163.com");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
// @ApiOperation("开具发票")
|
// @ApiOperation("开具发票")
|
||||||
// @GetMapping("/doInvoice/{id}")
|
// @GetMapping("/doInvoice/{id}")
|
||||||
// public ApiResult<?> doInvoice(@PathVariable("id") Integer id) {
|
// public ApiResult<?> doInvoice(@PathVariable("id") Integer id) {
|
||||||
|
|||||||
@@ -61,6 +61,15 @@ public class UserInvoice implements Serializable {
|
|||||||
@ApiModelProperty(value = "电子邮箱")
|
@ApiModelProperty(value = "电子邮箱")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发票流水号")
|
||||||
|
private String invoiceNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发票预览图片")
|
||||||
|
private String invoiceImg;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发票pdf地址")
|
||||||
|
private String invoicePdf;
|
||||||
|
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
|
|||||||
@@ -47,4 +47,5 @@ public interface EmailRecordService extends IService<EmailRecord> {
|
|||||||
void sendHtmlEmail(String title, String path, Map<String, Object> map, String[] toEmails)
|
void sendHtmlEmail(String title, String path, Map<String, Object> map, String[] toEmails)
|
||||||
throws MessagingException, IOException;
|
throws MessagingException, IOException;
|
||||||
|
|
||||||
|
void sendEmail(String title, String content, String receiver);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.mail.SimpleMailMessage;
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -69,4 +70,17 @@ public class EmailRecordServiceImpl extends ServiceImpl<EmailRecordMapper, Email
|
|||||||
sendFullTextEmail(title, html, toEmails); // 发送邮件
|
sendFullTextEmail(title, html, toEmails); // 发送邮件
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Override
|
||||||
|
public void sendEmail(String title, String content, String receiver) {
|
||||||
|
// 发送邮件通知
|
||||||
|
EmailRecord emailRecord = new EmailRecord();
|
||||||
|
emailRecord.setTitle(title);
|
||||||
|
emailRecord.setContent(content);
|
||||||
|
emailRecord.setReceiver(receiver);
|
||||||
|
emailRecord.setCreateUserId(42);
|
||||||
|
sendTextEmail(title,content,receiver.split(","));
|
||||||
|
save(emailRecord);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user