Commit 7cda846e by chongli

买券活动统计功能

parent ada64ab4
package com.ctrip.fun.admin.controller.basic;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,10 +19,15 @@ import org.springframework.web.bind.annotation.RequestMethod;
import com.ctrip.fun.admin.form.PaginationForm;
import com.ctrip.fun.admin.service.basic.BuyVoucherActivityService;
import com.ctrip.fun.admin.service.basic.BuyVoucherCommExcelService;
import com.ctrip.fun.common.core.util.DateUtil;
import com.ctrip.fun.common.vo.PagedResponseBean;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityBean;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityQuery;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityStatisticsBean;
import com.ctrip.fun.common.vo.basic.VoucherItemDTO;
import com.ctrip.fun.common.vo.basic.VoucherQueryFormDTO;
import com.ctrip.fun.common.vo.user.CommuneExtBean;
......@@ -26,7 +38,9 @@ public class BuyVoucherActivityController {
@Autowired
private BuyVoucherActivityService buyVoucherActivityService;
@Autowired
private BuyVoucherCommExcelService buyVoucherCommExcelService;
@RequestMapping(value = "queryList", method = RequestMethod.GET)
public String queryList(HttpServletRequest request,
@ModelAttribute("dto") BuyVoucherActivityQuery query, ModelMap model) {
......@@ -55,6 +69,64 @@ public class BuyVoucherActivityController {
return "basic/buyVoucherActivity/list";
}
@RequestMapping(value = "statistics", method = RequestMethod.GET)
public String statistics(HttpServletRequest request,@ModelAttribute("dto") BuyVoucherActivityQuery query, ModelMap model) {
int currentPage = 0;
int pageSize=0;
int total=0;
int pageCount=0;
if (null != request.getParameter("page")) {
try {
currentPage = Integer.parseInt(request.getParameter("page"));
} catch (Exception e) {
}
}
query.setPagerOffset(currentPage * query.getPagerPerPage());
pageSize = query.getPagerPerPage();
BuyVoucherActivityStatisticsBean buyVoucherActivityStatisticsBean = buyVoucherActivityService.getStatistics(query);
if(buyVoucherActivityStatisticsBean!=null){
total = (int) buyVoucherActivityStatisticsBean.getCommuneExtCounts();
}
pageCount = (0 == total % pageSize) ? (total / pageSize) : (total / pageSize + 1);
model.put("statisticsBean", buyVoucherActivityStatisticsBean);
model.put("buyAndUsed", query.getBuyAndUsed());
model.put("buyVoucherCommExcelPath", "buyVoucherActivity/buyVoucherCommExcel?id="+query.getId()+"&buyAndUsed="+query.getBuyAndUsed());
model.put("paginationData", new PaginationForm(currentPage, pageSize, pageCount, total));
return "basic/buyVoucherActivity/statistics";
}
@RequestMapping(value = "buyVoucherCommExcel", method = RequestMethod.GET)
public String buyVoucherCommExcel(HttpServletRequest request,HttpServletResponse response,@ModelAttribute("dto") BuyVoucherActivityQuery query, ModelMap model) {
List<CommuneExtBean> communeList = buyVoucherCommExcelService.list("", query);
response.setContentType("application/binary;charset=ISO8859-1");
StringBuilder excelName = new StringBuilder();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
excelName.append(format.format(new Date()));
if(query.getBuyAndUsed()==0){
excelName.append("购买尚未使用");
}else{
excelName.append("购买并使用");
}
try {
response.setHeader("Content-disposition", "attachment;filename=" + new String(excelName.toString().getBytes("gb2312"), "ISO8859-1") + ".xlsx");
ServletOutputStream outputStream = response.getOutputStream();
buyVoucherCommExcelService.exportExcel("aaa", communeList, outputStream);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@RequestMapping(value = "create", method = RequestMethod.GET)
public String toCreateBuyVoucherActivity(@ModelAttribute("dto") BuyVoucherActivityBean dto, ModelMap model) {
model.put("action", "/buyVoucherActivity/create");
......@@ -87,5 +159,6 @@ public class BuyVoucherActivityController {
buyVoucherActivityService.updateBuyVoucherActivity("", dto);
return "redirect:queryList";
}
}
package com.ctrip.fun.admin.service.basic;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestClientException;
import com.ctrip.fun.admin.service.BaseService;
import com.ctrip.fun.common.vo.PagedResponseBean;
import com.ctrip.fun.common.vo.Request;
......@@ -13,6 +18,9 @@ import com.ctrip.fun.common.vo.Response;
import com.ctrip.fun.common.vo.ResponseStatusEnum;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityBean;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityQuery;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityStatisticsBean;
import com.ctrip.fun.common.vo.basic.VoucherRuleBean;
import com.ctrip.fun.common.vo.user.CommuneExtBean;
public class BuyVoucherActivityService extends BaseService {
......@@ -71,23 +79,35 @@ public class BuyVoucherActivityService extends BaseService {
return success;
}
/**
* 获取指定的买券活动
*/
public BuyVoucherActivityBean getById(Integer id) {
String uri = super.getServiceUri("uri.buyVoucherActivity.get");
BuyVoucherActivityBean bean = new BuyVoucherActivityBean();
Request<Integer> request = new Request<Integer>("", id);
HttpEntity<Request<Integer>> entity = new HttpEntity<Request<Integer>>(request);
Response<BuyVoucherActivityBean> response = super.exchange(uri, HttpMethod.POST, entity,
new ParameterizedTypeReference<Response<BuyVoucherActivityBean>>() {
}).getBody();
if (response != null && response.getStatus() == ResponseStatusEnum.SUCCESS.getValue()) {
bean = response.getBody();
public BuyVoucherActivityStatisticsBean getStatistics(BuyVoucherActivityQuery query) {
BuyVoucherActivityStatisticsBean responseBean = null;
String uri = super.getServiceUri("uri.buyVoucherActivity.statistics");
Request<BuyVoucherActivityQuery> request = new Request<BuyVoucherActivityQuery>("", query);
HttpEntity<Request<BuyVoucherActivityQuery>> entity = new HttpEntity<Request<BuyVoucherActivityQuery>>(request);
Response<BuyVoucherActivityStatisticsBean> response = null;
try {
response = super.exchange(uri, HttpMethod.POST, entity,
new ParameterizedTypeReference<Response<BuyVoucherActivityStatisticsBean>>() {
}).getBody();
} catch (RestClientException e) {
logger.error(e.getMessage());
}
if (null != response && response.getStatus() == ResponseStatusEnum.SUCCESS.getValue()) {
responseBean = response.getBody();
} else {
logger.error("获取买券活动详细失败");
logger.error("{} status: {}, msg: {}", "获取现金券规则列表异常", response.getStatus(),
response.getMessage());
}
return bean;
return responseBean;
}
/**
......@@ -108,4 +128,25 @@ public class BuyVoucherActivityService extends BaseService {
}
return success;
}
/**
* 获取指定的买券活动
*/
public BuyVoucherActivityBean getById(Integer id) {
String uri = super.getServiceUri("uri.buyVoucherActivity.get");
BuyVoucherActivityBean bean = new BuyVoucherActivityBean();
Request<Integer> request = new Request<Integer>("", id);
HttpEntity<Request<Integer>> entity = new HttpEntity<Request<Integer>>(request);
Response<BuyVoucherActivityBean> response = super.exchange(uri, HttpMethod.POST, entity,
new ParameterizedTypeReference<Response<BuyVoucherActivityBean>>() {
}).getBody();
if (response != null && response.getStatus() == ResponseStatusEnum.SUCCESS.getValue()) {
bean = response.getBody();
} else {
logger.error("获取买券活动详细失败");
}
return bean;
}
}
package com.ctrip.fun.admin.service.basic;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestClientException;
import com.ctrip.fun.admin.utility.AbstractExcelExportService;
import com.ctrip.fun.common.vo.Request;
import com.ctrip.fun.common.vo.Response;
import com.ctrip.fun.common.vo.ResponseStatusEnum;
import com.ctrip.fun.common.vo.basic.BuyVoucherActivityQuery;
import com.ctrip.fun.common.vo.user.CommuneExtBean;
import com.ctrip.fun.mall.vo.ExcelTitleBean;
public class BuyVoucherCommExcelService extends AbstractExcelExportService<BuyVoucherActivityQuery, CommuneExtBean> {
private static Logger logger = LoggerFactory.getLogger(BuyVoucherCommExcelService.class);
@Override
public Class<CommuneExtBean> getTClass() {
return CommuneExtBean.class;
}
public List<CommuneExtBean> list(String userId, BuyVoucherActivityQuery query) {
List<CommuneExtBean> responseBean = null;
String uri = super.getServiceUri("uri.buyVoucherActivity.buyVoucherCommList");
Request<BuyVoucherActivityQuery> request = new Request<BuyVoucherActivityQuery>("", query);
HttpEntity<Request<BuyVoucherActivityQuery>> entity = new HttpEntity<Request<BuyVoucherActivityQuery>>(request);
Response<List<CommuneExtBean>> response = null;
try {
response = super.exchange(uri, HttpMethod.POST, entity,new ParameterizedTypeReference<Response<List<CommuneExtBean>>>() {}).getBody();
} catch (RestClientException e) {
logger.error(e.getMessage());
}
if (null != response && response.getStatus() == ResponseStatusEnum.SUCCESS.getValue()) {
responseBean = response.getBody();
} else {
logger.error("{} status: {}, msg: {}", "获取现金券规则列表异常", response.getStatus(),
response.getMessage());
}
return responseBean;
}
@Override
public void createExcelTitle() {
titleList = new ArrayList<ExcelTitleBean>();
Class<CommuneExtBean> cla = this.getTClass();
Method[] methods = cla.getMethods();
for (Method m : methods) {
String methodName = m.getName();
if("getUserName".equals(methodName) ||"getUid".equals(methodName)||"getMobilePhone".equals(methodName)){
ExcelTitleBean excelTitle = new ExcelTitleBean();
switch (methodName) {
case "getUid":
excelTitle.setTitle("UID");
excelTitle.setNumber(1);
break;
case "getUserName":
excelTitle.setTitle("用户名");
excelTitle.setNumber(2);
break;
case "getMobilePhone":
excelTitle.setTitle("手机号");
excelTitle.setNumber(3);
break;
default:
break;
}
excelTitle.setMethod(m);
titleList.add(excelTitle);
}
}
Collections.sort(titleList);
}
}
......@@ -259,6 +259,10 @@
<bean name="buyVoucherActivityService" class="com.ctrip.fun.admin.service.basic.BuyVoucherActivityService"
parent="baseService" />
<!-- 买券活动-->
<bean name="buyVoucherCommExcelService" class="com.ctrip.fun.admin.service.basic.BuyVoucherCommExcelService"
parent="baseService" />
<!-- 现金券分享记录 -->
<bean name="voucherShareLogService" class="com.ctrip.fun.admin.service.basic.VoucherShareLogService" parent="baseService" />
<!-- Finance -->
......
......@@ -444,6 +444,9 @@ uri.buyVoucherActivity.list=/fun-golf-service/buyVoucherActivity/list
uri.buyVoucherActivity.add=/fun-golf-service/buyVoucherActivity/add
uri.buyVoucherActivity.get=/fun-golf-service/buyVoucherActivity/get
uri.buyVoucherActivity.update=/fun-golf-service/buyVoucherActivity/update
uri.buyVoucherActivity.statistics=/fun-golf-service/buyVoucherActivity/statistics
uri.buyVoucherActivity.buyVoucherCommList=/fun-golf-service/buyVoucherActivity/buyVoucherCommList
#voucherShareLog
uri.vouchershareLog.queryList=/fun-golf-service/voucherShareLog/queryList
......
......@@ -23,15 +23,16 @@
<thead>
<tr>
<th style="width:5%">ID</th>
<th style="width:16%">活动名称</th>
<th style="width:18%">活动名称</th>
<th style="width:6%">社员价</th>
<th style="width:6%">嘉宾价</th>
<th style="width:7%">购买限制</th>
<th style="width:14%">活动开始时间</th>
<th style="width:14%">活动结束时间</th>
<th style="width:10%">活动开始时间</th>
<th style="width:10%">活动结束时间</th>
<th style="width:9%">限制购买次数</th>
<th style="width:14%">创建日期</th>
<th style="width:10%">创建日期</th>
<th style="width:5%">操作</th>
<th style="width:10%">活动统计</th>
</tr>
</thead>
<tbody>
......@@ -54,11 +55,12 @@
<#default>
未知
</#switch>
<td>${item.activityStart?string("yyyy-MM-dd HH:mm:ss")}</td>
<td>${item.activityEnd?string("yyyy-MM-dd HH:mm:ss")}</td>
<td>${item.activityStart?string("yyyy-MM-dd")}</td>
<td>${item.activityEnd?string("yyyy-MM-dd")}</td>
<td>${item.buyLimitTimes!}</td>
<td>${item.createdTime?string("yyyy-MM-dd HH:mm:ss")}</td>
<td>${item.createdTime?string("yyyy-MM-dd")}</td>
<td><a href="/buyVoucherActivity/update?id=${item.id!}&page=${paginationData.pageNumber!}">编辑</a></td>
<td style="width:10%"> <a href="/buyVoucherActivity/statistics?id=${item.id!}&buyAndUsed=0">查看</a> </td>
</tr>
</#list>
</tbody>
......
<#assign pageJsContent>
<script type="text/javascript" src="${staticServer}/js/lib/ui.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/dropZone.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/main.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/qiniu.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/bootstrap.min.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/plupload.full.min.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/zh_CN.js"></script>
<script type="text/javascript" src="${staticServer}/js/lib/highlight.js"></script>
<script>
function checkQueryAndSubmit(){
var id = $("#id").val();
if(id==""){
alert("请输入要查询的活动id");
return;
}
$("#statisticsQuery").submit();
}
var $J_exportForCourse = $("#J_exportForCourse");
$J_exportForCourse.click(function(){
var form = $('.search-box')[0];
form.action = '/buyVoucherActivity/buyVoucherCommExcel';
form.submit();
//导出之后修改回来
form.action = '/buyVoucherActivity/statistics';
})
</script>
</#assign>
<@com.layout title="买券活动统计" module="marketing" current="buyVoucherActivity_statistics" pageJs=pageJsContent pageCss=pageCssContent>
<form class="form-inline search-box widthShow" id="statisticsQuery" action="/buyVoucherActivity/statistics" method="get" autocomplete="off" >
<@com.textInput "dto.id" "style=\"margin-left: 5px;\"" "活动ID"/>
<div class="short_content_div">
<label class="control-label" for="category" style="margin-left: 5px;">购买并使用</label>
<select id="buyAndUsed" name="buyAndUsed" >
<option value="0" <#if buyAndUsed==0> selected </#if> >否</option>
<option value="1" <#if buyAndUsed==1> selected </#if> >是</option>
</select>
</div>
<button id="submitStatis" type="button" class="btn btn-primary" onclick="checkQueryAndSubmit()" >查询</button>
<input type="button" id="J_exportForCourse" class="btn btn-warning" value="导出">
</form>
<table class="table table-bordered table-striped widthShow">
<thead>
<tr>
<th >线上售出套数</th>
<th >线上总购买人数</th>
<th >线上购买并使用人数</th>
<th >线上购买尚未使用人数</th>
</tr>
</thead>
<tbody>
<tr>
<td>${statisticsBean.totalSaleOnline!}</td>
<td>${statisticsBean.buyPersonsOnline!}</td>
<td>${statisticsBean.buyAndUsePersonsOnline!}</td>
<td>${statisticsBean.buyAndNotUsePersonsOnline!}</td>
</tr>
</tbody>
</table>
<table class="table table-bordered table-striped widthShow">
<thead>
<tr>
<th >优惠券id</th>
<th >优惠券名称</th>
<th >发放总数</th>
<th >已使用</th>
<th >使用率</th>
</tr>
</thead>
<tbody>
<#list statisticsBean.voucherRules as item>
<tr>
<td>${item.id!}</td>
<td>${item.description!}</td>
<td>${item.sendAmount!}</td>
<td>${item.usedAmount!}</td>
<td>${item.percent!}</td>
</tr>
</#list>
</tbody>
</table>
<table class="table table-bordered table-striped widthShow" >
<thead>
<tr>
<th >会员UID</th>
<th >姓名</th>
<th >会员手机号</th>
</tr>
</thead>
<tbody>
<#list statisticsBean.communeExts as item>
<tr>
<td>${item.uid!}</td>
<td>${item.userName!}</td>
<td>${item.mobilePhone!}</td>
</tr>
</#list>
</tbody>
</table>
<div class="pagination pagination-right widthShow">
<ul>
<@paginator.first />
<@paginator.previous />
<@paginator.numbers separator=""/>
<@paginator.next />
<@paginator.last />
</ul>
<@paginator.statistics />
</div>
</@com.layout>
......@@ -258,7 +258,9 @@ ${pageCss}
<li <#if current == "buyVoucherActivity_list">class="active"</#if>>
<a href="/buyVoucherActivity/queryList">列表</a>
</li>
<li <#if current == "buyVoucherActivity_statistics">class="active"</#if>>
<a href="/buyVoucherActivity/statistics?id=0&buyAndUsed=0">活动统计</a>
</li>
<li class="nav-header">签到</li>
<li <#if current == "sign_get">class="active"</#if>>
......
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