Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
caosy
/
fun-golf-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fb22380f
authored
Aug 04, 2018
by
Huang Linyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
取消分享券的作用流
parent
e1206855
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
0 deletions
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherDao.java
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherShareLogDao.java
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
src/main/java/com/ctrip/fun/golf/task/CancelVoucherSharingTask.java
src/main/resources/task.spring.xml
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherDao.java
View file @
fb22380f
...
...
@@ -41,6 +41,7 @@ import com.ctrip.fun.common.vo.order.VourcherStatusEnum;
import
com.ctrip.fun.golf.dao.GenericHibernateDao
;
import
com.ctrip.fun.golf.domain.basic.Voucher
;
import
com.ctrip.fun.golf.domain.basic.VoucherRule
;
import
com.ctrip.fun.golf.domain.basic.VoucherShareLog
;
import
com.ctrip.fun.golf.vo.PagedEntityBean
;
import
com.ctrip.fun.mall.vo.LabelValueBean
;
...
...
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherShareLogDao.java
View file @
fb22380f
package
com
.
ctrip
.
fun
.
golf
.
dao
.
basic
;
import
java.util.List
;
import
org.hibernate.Query
;
import
org.hibernate.Session
;
import
org.hibernate.transform.Transformers
;
import
com.ctrip.fun.common.vo.adminUser.AdminUserBean
;
import
com.ctrip.fun.golf.dao.GenericHibernateDao
;
import
com.ctrip.fun.golf.domain.basic.VoucherShareLog
;
public
class
VoucherShareLogDao
extends
GenericHibernateDao
<
VoucherShareLog
,
Integer
>
{
public
List
<
VoucherShareLog
>
findSharedLogList
()
{
String
hsql
=
"select * from bsc_voucher_share_log t where t.status=1 and t.createTime < DATE_SUB(NOW(),INTERVAL 1 DAY)"
;
Session
session
=
this
.
getSession
();
Query
query
=
session
.
createSQLQuery
(
hsql
);
List
<
VoucherShareLog
>
logList
=
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
VoucherShareLog
.
class
)).
list
();
return
logList
;
}
public
void
endSharingById
(
Integer
id
)
{
String
hsql
=
"Update VoucherShareLog set status = 2 where id = "
+
id
;
this
.
getSession
().
createQuery
(
hsql
).
executeUpdate
();
}
}
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
View file @
fb22380f
...
...
@@ -849,6 +849,28 @@ public class VoucherService {
}
}
}
/**
* 执行退还抵用券操作,将分享中的抵用券退回
*/
public
void
executeCancelSharingTask
()
{
//获取所有分享时间大于1天的活动
List
<
VoucherShareLog
>
voucherShareLogList
=
voucherShareLogDao
.
findSharedLogList
()
;
if
(
voucherShareLogList
.
size
()>
0
){
StringBuffer
voucherIdsBuf
=
new
StringBuffer
();
for
(
VoucherShareLog
voucherShare
:
voucherShareLogList
){
voucherIdsBuf
.
append
(
voucherShare
.
getVoucherIds
()+
","
);
voucherShareLogDao
.
endSharingById
(
voucherShare
.
getId
());
}
String
[]
voucherIdsArr
=
voucherIdsBuf
.
substring
(
0
,
voucherIdsBuf
.
length
()-
1
).
split
(
","
);
for
(
String
str
:
voucherIdsArr
){
voucherDao
.
updateVoucherNotIsShare
(
Integer
.
parseInt
(
str
));
}
}
}
private
void
setOnlyMe
(
VoucherItemDTO
vo
,
Integer
onlyMe
){
if
(
onlyMe
==
null
){
...
...
src/main/java/com/ctrip/fun/golf/task/CancelVoucherSharingTask.java
0 → 100644
View file @
fb22380f
/**
* Copyright 2014 CTRIP Co.,Ltd. All rights reserved.
*/
package
com
.
ctrip
.
fun
.
golf
.
task
;
import
org.quartz.Job
;
import
org.quartz.JobExecutionContext
;
import
org.quartz.JobExecutionException
;
import
org.quartz.SchedulerException
;
import
org.springframework.context.ApplicationContext
;
import
com.ctrip.fun.golf.service.basic.VoucherService
;
import
com.ctrip.fun.golf.service.user.CommuneExpireService
;
/**
* 抵用券退回任务
*
* @author lingsl
* @version 1.0.0
*/
public
class
CancelVoucherSharingTask
implements
Job
{
private
VoucherService
voucherService
;
@Override
public
void
execute
(
JobExecutionContext
context
)
throws
JobExecutionException
{
ApplicationContext
applicationContext
=
null
;
try
{
applicationContext
=
(
ApplicationContext
)
(
context
.
getScheduler
().
getContext
().
get
(
"applicationContext"
));
}
catch
(
SchedulerException
e
)
{
e
.
printStackTrace
();
}
if
(
applicationContext
!=
null
)
{
this
.
setVoucherService
((
VoucherService
)
applicationContext
.
getBean
(
"voucherService"
));
}
this
.
voucherService
.
executeCancelSharingTask
();
}
public
VoucherService
getVoucherService
()
{
return
voucherService
;
}
public
void
setVoucherService
(
VoucherService
voucherService
)
{
this
.
voucherService
=
voucherService
;
}
}
src/main/resources/task.spring.xml
View file @
fb22380f
...
...
@@ -153,6 +153,7 @@
<ref
bean=
"sendMessageForEventActivityOrderCronTriggerBean"
/>
<ref
bean=
"workPointTriggerBean"
/>
<ref
bean=
"communeExpireTriggerBean"
/>
<ref
bean=
"cancelVoucherSharingTriggerBean"
/>
</list>
</property>
</bean>
...
...
@@ -476,4 +477,17 @@
<property
name=
"misfireInstruction"
value=
"2"
></property>
</bean>
<bean
id=
"cancelVoucherSharingDetail"
class=
"org.springframework.scheduling.quartz.JobDetailFactoryBean"
>
<property
name=
"durability"
value=
"true"
></property>
<property
name=
"jobClass"
value=
"com.ctrip.fun.golf.task.CancelVoucherSharingTask"
/>
</bean>
<!-- 10:00 every day trigger -->
<bean
id=
"cancelVoucherSharingTriggerBean"
class=
"org.springframework.scheduling.quartz.CronTriggerFactoryBean"
>
<property
name=
"jobDetail"
ref=
"cancelVoucherSharingDetail"
/>
<property
name=
"cronExpression"
value=
"* 0/20 * * * ?"
/>
<property
name=
"misfireInstruction"
value=
"2"
></property>
</bean>
</beans>
\ No newline at end of file
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