Commit fb22380f by Huang Linyu

取消分享券的作用流

parent e1206855
......@@ -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;
......
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();
}
}
......@@ -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){
......
/**
* 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;
}
}
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment