Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
huhu-partner
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanchen
huhu-partner
Commits
bc1dac47
Commit
bc1dac47
authored
Apr 07, 2020
by
guanchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新发邮件端口
parent
45b5a8e5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
45 deletions
+63
-45
pom.xml
pom.xml
+2
-2
ReportPartnerApplication.java
...ava/com/lanren/huhu/partner/ReportPartnerApplication.java
+1
-1
AgentDailyMailTask.java
.../com/lanren/huhu/partner/schedule/AgentDailyMailTask.java
+18
-4
IMailServiceImpl.java
...om/lanren/huhu/partner/service/impl/IMailServiceImpl.java
+34
-26
application.yml
src/main/resources/application.yml
+2
-6
AgentExpandDailyMapper.xml
src/main/resources/mapper/AgentExpandDailyMapper.xml
+6
-6
No files found.
pom.xml
View file @
bc1dac47
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
</parent>
</parent>
<groupId>
com.lanren.huhu
</groupId>
<groupId>
com.lanren.huhu
</groupId>
<
artifactId>
report_expand
</artifactId
>
<
!--<artifactId>report_expand</artifactId>--
>
<
!--<artifactId>report_mail</artifactId>--
>
<
artifactId>
report_mail
</artifactId
>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
partner
</name>
<name>
partner
</name>
<description>
呼呼省钱合伙人相关服务
</description>
<description>
呼呼省钱合伙人相关服务
</description>
...
...
src/main/java/com/lanren/huhu/partner/ReportPartnerApplication.java
View file @
bc1dac47
...
@@ -41,6 +41,6 @@ public class ReportPartnerApplication implements ApplicationRunner {
...
@@ -41,6 +41,6 @@ public class ReportPartnerApplication implements ApplicationRunner {
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
logger
.
info
(
"profile active is {}"
,
profilesActive
);
logger
.
info
(
"profile active is {}"
,
profilesActive
);
// agentDailyExpandTask.runExpandPartner();
// agentDailyExpandTask.runExpandPartner();
//
agentDailyMailTask.runExpandCity2ndAgentMail();
agentDailyMailTask
.
runExpandCity2ndAgentMail
();
}
}
}
}
src/main/java/com/lanren/huhu/partner/schedule/AgentDailyMailTask.java
View file @
bc1dac47
...
@@ -12,9 +12,11 @@ import com.lanren.huhu.partner.util.DateUtils;
...
@@ -12,9 +12,11 @@ import com.lanren.huhu.partner.util.DateUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.mail.MailSendException
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
javax.mail.SendFailedException
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -58,13 +60,11 @@ public class AgentDailyMailTask {
...
@@ -58,13 +60,11 @@ public class AgentDailyMailTask {
private
String
buildMailContent
(
Integer
agentId
)
{
private
String
buildMailContent
(
Integer
agentId
)
{
Date
yesterday
=
DateUtils
.
getDateBefore
(
new
Date
(),
1
);
Date
yesterday
=
DateUtils
.
getDateBefore
(
new
Date
(),
1
);
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
Date
yesterdayBegin
=
new
Date
(
yesterday
.
getTime
()
-
yesterday
.
getTime
()
%
(
24
*
60
*
60
*
1000L
));
Date
yesterdayEnd
=
new
Date
(
yesterdayBegin
.
getTime
()
+
(
24
*
60
*
60
-
1
)
*
1000L
);
Date
monthBegin
=
new
Date
(
DateUtils
.
getMonth1stTimestamp
(
now
));
Date
monthBegin
=
new
Date
(
DateUtils
.
getMonth1stTimestamp
(
now
));
Date
monthEnd
=
new
Date
(
DateUtils
.
getMonthLastTimestamp
(
now
));
Date
monthEnd
=
new
Date
(
DateUtils
.
getMonthLastTimestamp
(
now
));
String
yesterdayStr
=
DateUtils
.
format
(
yesterday
,
DateUtils
.
FORMAT_SHORT
);
String
yesterdayStr
=
DateUtils
.
format
(
yesterday
,
DateUtils
.
FORMAT_SHORT
);
String
yesterdayBeginStr
=
DateUtils
.
format
(
yesterday
Begin
,
DateUtils
.
FORMAT_LONG
)
;
String
yesterdayBeginStr
=
DateUtils
.
format
(
yesterday
,
DateUtils
.
FORMAT_SHORT
)
+
" 00:00:00"
;
String
yesterdayEndStr
=
DateUtils
.
format
(
yesterday
End
,
DateUtils
.
FORMAT_LONG
)
;
String
yesterdayEndStr
=
DateUtils
.
format
(
yesterday
,
DateUtils
.
FORMAT_SHORT
)
+
" 23:59:59"
;
String
monthBeginStr
=
DateUtils
.
format
(
monthBegin
,
DateUtils
.
FORMAT_LONG
);
String
monthBeginStr
=
DateUtils
.
format
(
monthBegin
,
DateUtils
.
FORMAT_LONG
);
String
monthEndStr
=
DateUtils
.
format
(
monthEnd
,
DateUtils
.
FORMAT_LONG
);
String
monthEndStr
=
DateUtils
.
format
(
monthEnd
,
DateUtils
.
FORMAT_LONG
);
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
@@ -240,6 +240,20 @@ public class AgentDailyMailTask {
...
@@ -240,6 +240,20 @@ public class AgentDailyMailTask {
}
}
break
;
break
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
if
(
e
instanceof
MailSendException
)
{
Exception
[]
messageExceptions
=
((
MailSendException
)
e
).
getMessageExceptions
();
SendFailedException
sendFail
;
try
{
sendFail
=
(
SendFailedException
)
messageExceptions
[
0
];
}
catch
(
ClassCastException
ee
)
{
logger
.
error
(
"class cast exception:[{}]"
,
ee
.
getMessage
());
return
;
}
logger
.
error
(
"send mail eerror,the invalid mail address:{}"
,
sendFail
.
getInvalidAddresses
());
}
logger
.
error
(
"发送邮件失败, 第{}次"
,
i
);
logger
.
error
(
"发送邮件失败, 第{}次"
,
i
);
}
}
}
}
...
...
src/main/java/com/lanren/huhu/partner/service/impl/IMailServiceImpl.java
View file @
bc1dac47
...
@@ -3,7 +3,6 @@ package com.lanren.huhu.partner.service.impl;
...
@@ -3,7 +3,6 @@ package com.lanren.huhu.partner.service.impl;
import
com.lanren.huhu.partner.service.IMailService
;
import
com.lanren.huhu.partner.service.IMailService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.mail.javamail.JavaMailSenderImpl
;
import
org.springframework.mail.javamail.JavaMailSenderImpl
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
...
@@ -28,55 +27,64 @@ public class IMailServiceImpl implements IMailService {
...
@@ -28,55 +27,64 @@ public class IMailServiceImpl implements IMailService {
/**
/**
* Spring Boot 提供了一个发送邮件的简单抽象,使用的是下面这个接口,这里直接注入即可使用
* Spring Boot 提供了一个发送邮件的简单抽象,使用的是下面这个接口,这里直接注入即可使用
*/
*/
@Autowired
//
@Autowired
private
JavaMailSenderImpl
mailSender
;
//
private JavaMailSenderImpl mailSender;
/**
/**
* 配置
* 配置
*/
*/
@Value
(
"${spring.mail.host}"
)
private
String
host
;
@Value
(
"${spring.mail.username}"
)
@Value
(
"${spring.mail.username}"
)
private
String
username
;
private
String
username
;
@Value
(
"${spring.mail.password}"
)
@Value
(
"${spring.mail.password}"
)
private
String
password
;
private
String
password
;
@Value
(
"${spring.mail.port}"
)
private
String
port
;
@Value
(
"${spring.mail.from}"
)
@Value
(
"${spring.mail.from}"
)
private
String
from
;
private
String
from
;
@Value
(
"${spring.mail.smtp.host}"
)
private
String
host
;
@Override
@Override
public
void
sendMail
(
String
subject
,
String
text
,
File
attachment
,
String
[]
tos
)
throws
MessagingException
{
public
void
sendMail
(
String
subject
,
String
text
,
File
attachment
,
String
[]
tos
)
throws
MessagingException
{
MimeMessage
mailMessage
=
configMailMessage
();
JavaMailSenderImpl
mailSender
=
new
JavaMailSenderImpl
();
configMessageHelper
(
mailMessage
,
subject
,
text
,
attachment
,
tos
,
new
String
[]{});
mailSender
.
setHost
(
host
);
mailSender
.
setUsername
(
username
);
mailSender
.
setPassword
(
password
);
mailSender
.
setPort
(
465
);
mailSender
.
setDefaultEncoding
(
"UTF-8"
);
Properties
javaMailProperties
=
new
Properties
();
javaMailProperties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
javaMailProperties
.
setProperty
(
"mail.smtp.timeout"
,
"25000"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.class"
,
"javax.net.ssl.SSLSocketFactory"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.fallback"
,
"false"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.port"
,
"465"
);
mailSender
.
setJavaMailProperties
(
javaMailProperties
);
MimeMessage
mailMessage
=
mailSender
.
createMimeMessage
();
MimeMessageHelper
mimeMessageHelper
=
new
MimeMessageHelper
(
mailMessage
,
true
,
"UTF-8"
);
mimeMessageHelper
.
setFrom
(
from
);
mimeMessageHelper
.
setSubject
(
subject
);
mimeMessageHelper
.
setText
(
text
,
true
);
if
(
attachment
!=
null
)
{
mimeMessageHelper
.
addAttachment
(
attachment
.
getName
(),
attachment
);
}
mimeMessageHelper
.
setTo
(
tos
);
mailSender
.
send
(
mailMessage
);
mailSender
.
send
(
mailMessage
);
}
}
@Override
@Override
public
void
sendMailWithCc
(
String
subject
,
String
text
,
File
attachment
,
String
[]
tos
,
String
[]
cc
)
throws
MessagingException
{
public
void
sendMailWithCc
(
String
subject
,
String
text
,
File
attachment
,
String
[]
tos
,
String
[]
cc
)
throws
MessagingException
{
MimeMessage
mailMessage
=
configMailMessage
();
JavaMailSenderImpl
mailSender
=
new
JavaMailSenderImpl
();
MimeMessageHelper
mimeMessageHelper
=
configMessageHelper
(
mailMessage
,
subject
,
text
,
attachment
,
tos
,
new
String
[]{});
mimeMessageHelper
.
setCc
(
cc
);
mailSender
.
send
(
mailMessage
);
}
private
MimeMessage
configMailMessage
()
{
mailSender
.
setHost
(
host
);
mailSender
.
setHost
(
host
);
mailSender
.
setPort
(
Integer
.
parseInt
(
port
));
mailSender
.
setUsername
(
username
);
mailSender
.
setUsername
(
username
);
mailSender
.
setPassword
(
password
);
mailSender
.
setPassword
(
password
);
mailSender
.
setPort
(
465
);
mailSender
.
setDefaultEncoding
(
"UTF-8"
);
mailSender
.
setDefaultEncoding
(
"UTF-8"
);
Properties
javaMailProperties
=
new
Properties
();
Properties
javaMailProperties
=
new
Properties
();
javaMailProperties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
javaMailProperties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
javaMailProperties
.
setProperty
(
"mail.smtp.timeout"
,
"25000"
);
javaMailProperties
.
setProperty
(
"mail.smtp.timeout"
,
"25000"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.class"
,
"javax.net.ssl.SSLSocketFactory"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.fallback"
,
"false"
);
javaMailProperties
.
setProperty
(
"mail.smtp.socketFactory.port"
,
"465"
);
mailSender
.
setJavaMailProperties
(
javaMailProperties
);
mailSender
.
setJavaMailProperties
(
javaMailProperties
);
MimeMessage
mailMessage
=
mailSender
.
createMimeMessage
();
return
mailSender
.
createMimeMessage
();
}
private
MimeMessageHelper
configMessageHelper
(
MimeMessage
mailMessage
,
String
subject
,
String
text
,
File
attachment
,
String
[]
tos
,
String
[]
cc
)
throws
MessagingException
{
MimeMessageHelper
mimeMessageHelper
=
new
MimeMessageHelper
(
mailMessage
,
true
,
"UTF-8"
);
MimeMessageHelper
mimeMessageHelper
=
new
MimeMessageHelper
(
mailMessage
,
true
,
"UTF-8"
);
mimeMessageHelper
.
setFrom
(
from
);
mimeMessageHelper
.
setFrom
(
from
);
mimeMessageHelper
.
setSubject
(
subject
);
mimeMessageHelper
.
setSubject
(
subject
);
...
@@ -85,7 +93,7 @@ public class IMailServiceImpl implements IMailService {
...
@@ -85,7 +93,7 @@ public class IMailServiceImpl implements IMailService {
mimeMessageHelper
.
addAttachment
(
attachment
.
getName
(),
attachment
);
mimeMessageHelper
.
addAttachment
(
attachment
.
getName
(),
attachment
);
}
}
mimeMessageHelper
.
setTo
(
tos
);
mimeMessageHelper
.
setTo
(
tos
);
return
mimeMessageHelper
;
mimeMessageHelper
.
setCc
(
cc
);
mailSender
.
send
(
mailMessage
);
}
}
}
}
src/main/resources/application.yml
View file @
bc1dac47
...
@@ -60,15 +60,11 @@ spring:
...
@@ -60,15 +60,11 @@ spring:
preferred-json-mapper
:
fastjson
preferred-json-mapper
:
fastjson
#邮箱配置
#邮箱配置
mail
:
mail
:
host
:
smtp.exmail.qq.com
#发送邮件服务器
username
:
report@wasair.com
#发送邮件的邮箱地址
username
:
report@wasair.com
#发送邮件的邮箱地址
password
:
Wasai123
#客户端授权码,不是邮箱密码,这个在qq邮箱设置里面自动生成的
password
:
Wasai123
#客户端授权码,不是邮箱密码,这个在qq邮箱设置里面自动生成的
port
:
25
#端口号465或587
from
:
report@wasair.com
# 发送邮件的地址,和上面username一致
from
:
report@wasair.com
# 发送邮件的地址,和上面username一致
properties
:
smtp
:
mail
:
host
:
smtp.exmail.qq.com
smtp
:
auth
:
true
# properties.mail.smtp.starttls.enable: true
# properties.mail.smtp.starttls.enable: true
# properties.mail.smtp.starttls.required: true
# properties.mail.smtp.starttls.required: true
# properties.mail.smtp.ssl.enable: true
# properties.mail.smtp.ssl.enable: true
...
...
src/main/resources/mapper/AgentExpandDailyMapper.xml
View file @
bc1dac47
...
@@ -200,14 +200,14 @@
...
@@ -200,14 +200,14 @@
SELECT
SELECT
'Vip会员' c1,
'Vip会员' c1,
case when b.invite_user_id = a.user_id then '直接' else '间接' end c2,
case when b.invite_user_id = a.user_id then '直接' else '间接' end c2,
COUNT(
a.recharge
_time between #{yesterdayBegin} and #{yesterdayEnd} or NULL) c3,
COUNT(
c.become_high
_time between #{yesterdayBegin} and #{yesterdayEnd} or NULL) c3,
COUNT(
a.recharge
_time >= '2019-08-16 23:59:59' or NULL) c4,
COUNT(
c.become_high
_time >= '2019-08-16 23:59:59' or NULL) c4,
COUNT(
a.recharge
_time between #{monthBegin} and #{monthEnd} or NULL) c5,
COUNT(
c.become_high
_time between #{monthBegin} and #{monthEnd} or NULL) c5,
COUNT(*) c6
COUNT(*) c6
FROM agent_reward a
FROM agent_expand_detail a
LEFT JOIN partner_invite_relation b on a.source_user_id=b.user_id
JOIN partner_invite_relation b on a.expand_user_id=b.user_id
JOIN partner_account c on a.expand_user_id=c.user_id and c.is_super_partner=0 and c.partner_level=20
WHERE a.agent_id = #{agentId}
WHERE a.agent_id = #{agentId}
AND a.reward_type in (30,20,710,720,730)
GROUP BY 1,2
GROUP BY 1,2
</select>
</select>
<insert
id=
"insertByDetail"
>
<insert
id=
"insertByDetail"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment