|
@@ -72,6 +72,47 @@ public class SaleLogUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 插入运输订单的操作日志
|
|
|
+ * @param descriptoin
|
|
|
+ * @param oprationType 操作类型
|
|
|
+ * @param map 必传
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int logOrder(Map<String,Object> map,String descriptoin,int oprationType){
|
|
|
+ try{
|
|
|
+ SaleLog saleLog=new SaleLog();
|
|
|
+ saleLog.setResultId(saleLogMapper.selectMaxId());
|
|
|
+ saleLog.setOrderId(getOrderId(map));
|
|
|
+ saleLog.setDescription(descriptoin);
|
|
|
+ saleLog.setInsertTime(new Date());
|
|
|
+ saleLog.setInsertUsername(getUserName(map));
|
|
|
+ switch (oprationType){
|
|
|
+ case INSERT:
|
|
|
+ saleLog.setOprationType("新增");
|
|
|
+ break;
|
|
|
+ case UPDATE:
|
|
|
+ saleLog.setOprationType("修改");
|
|
|
+ break;
|
|
|
+ case DELETE:
|
|
|
+ saleLog.setOprationType("删除");
|
|
|
+ break;
|
|
|
+ case OPEN:
|
|
|
+ saleLog.setOprationType("启用");
|
|
|
+ break;
|
|
|
+ case CLOSE:
|
|
|
+ saleLog.setOprationType("关闭");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ saleLog.setOprationType("未知操作");
|
|
|
+ }
|
|
|
+ return saleLogMapper.insertSelective(saleLog);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处理插入用户名
|
|
|
* @param map
|
|
@@ -94,60 +135,19 @@ public class SaleLogUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //public static void main(String[] args) throws Exception {
|
|
|
- // testMail();
|
|
|
- //}
|
|
|
- //
|
|
|
- //private static void testMail () throws Exception {
|
|
|
- // // 给用户发送邮件的邮箱
|
|
|
- // final String from = "2361742724@qq.com";
|
|
|
- // // 邮箱的用户名
|
|
|
- // final String username = "2361742724@qq.com";
|
|
|
- // // 邮箱授权码,刚刚保存的授权码,不是qq密码
|
|
|
- // final String password = "rfhbbmbqssykebaf";
|
|
|
- // // 发送邮件的服务器地址,QQ服务器
|
|
|
- // final String host = "smtp.qq.com";
|
|
|
- // // 接收人邮箱
|
|
|
- // final String to = "987666087@qq.com";
|
|
|
- // // 邮件主题
|
|
|
- // final String title = "测试用例";
|
|
|
- //
|
|
|
- // // 使用QQ邮箱时配置
|
|
|
- // Properties prop = new Properties();
|
|
|
- // prop.setProperty("mail.host", "smtp.qq.com"); // 设置QQ邮件服务器
|
|
|
- // prop.setProperty("mail.transport.protocol", "smtp"); // 邮件发送协议
|
|
|
- // prop.setProperty("mail.smtp.auth", "true"); // 需要验证用户名和密码
|
|
|
- // // 关于QQ邮箱,还要设置SSL加密,其他邮箱不需要
|
|
|
- // MailSSLSocketFactory sf = new MailSSLSocketFactory();
|
|
|
- // sf.setTrustAllHosts(true);
|
|
|
- // prop.put("mail.smtp.ssl.enable", "true");
|
|
|
- // prop.put("mail.smtp.ssl.socketFactory", sf);
|
|
|
- //
|
|
|
- // // 创建定义整个邮件程序所需的环境信息的 Session 对象,QQ才有,其他邮箱就不用了
|
|
|
- // Session session = Session.getDefaultInstance(prop, new Authenticator() {
|
|
|
- // @Override
|
|
|
- // protected PasswordAuthentication getPasswordAuthentication() {
|
|
|
- // // 发件人邮箱用户名,授权码
|
|
|
- // return new PasswordAuthentication(username, password);
|
|
|
- // }
|
|
|
- // });
|
|
|
- // // 开启 Session 的 debug 模式,这样就可以查看程序发送 Email 的运行状态
|
|
|
- // session.setDebug(true);
|
|
|
- // // 通过 session 得到 transport 对象
|
|
|
- // Transport ts = session.getTransport();
|
|
|
- // // 使用邮箱的用户名和授权码连上邮箱服务器
|
|
|
- // ts.connect(host, username, password);
|
|
|
- // // 创建邮件,写邮件
|
|
|
- // MimeMessage message = new MimeMessage(session);
|
|
|
- // message.setFrom(new InternetAddress(from)); // 指明邮件的发件人
|
|
|
- // message.setRecipient(Message.RecipientType.TO, new InternetAddress(to)); // 指明邮件的收件人
|
|
|
- // message.setSubject(title); // 邮件主题
|
|
|
- // message.setContent("验证码为:8824", "text/html;charset=utf-8"); // 邮件内容
|
|
|
- // message
|
|
|
- // // 发送邮件
|
|
|
- // ts.sendMessage(message, message.getAllRecipients());
|
|
|
- // System.out.println("验证码发送成功");
|
|
|
- // // 释放资源
|
|
|
- // ts.close();
|
|
|
- //}
|
|
|
+ /**
|
|
|
+ * 获取OrderId
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private BigDecimal getOrderId(Map<String,Object> map) throws Exception {
|
|
|
+ if(map.get("orderId")!=null){
|
|
|
+ return DataChange.dataToBigDecimal(map.get("orderId"));
|
|
|
+ }else if(map.get("resultTotalId")!=null){
|
|
|
+ return saleLogMapper.getOrderIdByTotal(map);
|
|
|
+ }else{
|
|
|
+ throw new Exception("没有订单Id,保存日志失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|