提交 f8a3c8ff authored 作者: Mangostiffy's avatar Mangostiffy

新增抽奖日志管理

上级 59b165e8
package com.mall.controller.api;
import com.jfinal.i18n.Res;
import com.mall.controller.base.BaseController;
import com.mall.service.mengbeng.lottery.LotteryManager;
import com.mall.util.PageData;
......@@ -10,10 +9,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping(value="/api/lottery",produces="application/json;charset=UTF-8")
......@@ -41,16 +39,24 @@ public class LotteryApi extends BaseController {
PageData result=list.get(resultnumber);//单次结果
resultnumberlist.add((int) result.get("c_lottery_number"));
}
PageData lotteryresult=new PageData();
lotteryresult.put("store_id",store_id);
DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
lotteryresult.put("createtime",df.format(new Date()));
if(resultnumberlist.get(0)==resultnumberlist.get(1)&&resultnumberlist.get(1)==resultnumberlist.get(2)){
pd.put("c_lottery_number",resultnumberlist.get(0));
pd=lotteryService.findByLotterynumber(pd);
//TODO:处理奖品
if(null!=pd){
//TODO:根据数字处理奖品
System.out.println("中奖");
Map resultmap=new HashMap();
resultmap.put("result",1);
resultmap.put("resultnumber",resultnumberlist);
resultmap.put("reward",pd);
//保存中奖记录
lotteryresult.put("reward",pd.get("c_lottery_reward"));
lotteryService.saveLotterylog(lotteryresult);
return ResultOutDto.ok(resultmap);
}else{
return ResultOutDto.err(null,"奖品不存在");
......@@ -61,6 +67,7 @@ public class LotteryApi extends BaseController {
resultmap.put("resultnumber",resultnumberlist);
resultmap.put("reward",null);
System.out.println("未中奖");
lotteryService.saveLotterylog(lotteryresult);
return ResultOutDto.ok(resultmap);
}
}catch (Exception e){
......
......@@ -204,4 +204,24 @@ public class LotteryController extends BaseController {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(format,true));
}
@RequestMapping("/listlotterylog")
public ModelAndView listlotterylog(Page page) throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"列表Lottery");
//if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;} //校验权限(无权查看时页面会有提示,如果不注释掉这句代码就无法进入列表页面,所以根据情况是否加入本句代码)
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
String keywords = pd.getString("keywords"); //关键词检索条件
if(null != keywords && !"".equals(keywords)){
pd.put("keywords", keywords.trim());
}
page.setPd(pd);
List<PageData> varList = lotteryService.lotteryloglistPage(page); //列出Lottery日志列表
mv.setViewName("tongmeng/lotterylog/lotterylog_list");
mv.addObject("varList", varList);
mv.addObject("pd", pd);
mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
return mv;
}
}
......@@ -60,6 +60,20 @@ public interface LotteryManager{
* @throws Exception
*/
public PageData findByLotterynumber(PageData pd) throws Exception;
/**
* 保存抽奖记录
* @param pd
* @throws Exception
*/
public void saveLotterylog(PageData pd) throws Exception;
/**
* 列表抽奖日志
* @param page
* @return
* @throws Exception
*/
public List<PageData> lotteryloglistPage(Page page) throws Exception;
}
......@@ -83,5 +83,15 @@ public class LotteryService implements LotteryManager {
return (PageData) dao.findForObject("LotteryMapper.findByLotterynumber",pd);
}
@Override
public void saveLotterylog(PageData pd) throws Exception {
dao.save("LotteryMapper.saveLotterylog",pd);
}
@Override
public List<PageData> lotteryloglistPage(Page page) throws Exception {
return (List<PageData>) dao.findForList("LotteryMapper.lotteryloglistPage",page);
}
}
......@@ -111,5 +111,40 @@
<include refid="tableName"></include>
where c_lottery_number = #{c_lottery_number}
</select>
<!--保存抽奖激励-->
<insert id="saveLotterylog" parameterType="pd">
insert into
c_lottery_log
(
store_id,
reward,
createtime
)
values
(
#{store_id},
#{reward},
#{createtime}
)
</insert>
<!--列表抽奖记录-->
<select id="lotteryloglistPage" parameterType="page" resultType="pd">
select
lottery_log_id,
c_lottery_log.store_id,
reward,
c_store.store_name,
c_store.store_logo,
createtime
from
c_lottery_log
inner join c_store on c_store.store_id=c_lottery_log.store_id
where 1=1
<if test="pd.keywords!= null and pd.keywords != ''">
and c_store.store_name LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -35,6 +35,15 @@
<include refid="tableName"></include>
inner join c_store as share on share.store_id=<include refid="tableName"></include>.share_store
inner join c_store as shared on shared.store_id=<include refid="tableName"></include>.shareed_store
where 1=1
<if test="pd.keywords!= null and pd.keywords != ''">
and
(
share.store_name LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
or
shared.store_name LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
)
</if>
order by share_time desc
</select>
......
......@@ -96,7 +96,7 @@
<div class="col-xs-12">
<!-- 检索 -->
<form action="list.do" method="post" name="Form" id="Form">
<form action="${pageContext.request.contextPath}/list.do" method="post" name="Form" id="Form">
<table style="margin-top:5px;">
......
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 下拉框 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/ace/css/chosen.css" />
<!-- jsp文件头和头部 -->
<%@ include file="../../system/index/top.jsp"%>
<!-- 日期框 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/ace/css/datepicker.css" />
</head>
<body class="no-skin">
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
<!-- /section:basics/sidebar -->
<div class="main-content">
<div class="main-content-inner">
<div class="page-content">
<div class="row">
<div class="col-xs-12">
<!-- 检索 -->
<form action="${pageContext.request.contextPath}/lottery/listlotterylog.do" method="post" name="Form" id="Form">
<table style="margin-top:5px;">
<tr>
<td>
<div class="nav-search">
<span class="input-icon">
<input type="text" placeholder="这里输入店铺名" class="nav-search-input" id="nav-search-input" autocomplete="off" name="keywords" value="${pd.keywords }" placeholder="这里输入关键词"/>
<i class="ace-icon fa fa-search nav-search-icon"></i>
</span>
</div>
</td>
<%--<td style="padding-left:2px;"><input class="span10 date-picker" name="lastStart" id="lastStart" value="" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:88px;" placeholder="开始日期" title="开始日期"/></td>
<td style="padding-left:2px;"><input class="span10 date-picker" name="lastEnd" name="lastEnd" value="" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:88px;" placeholder="结束日期" title="结束日期"/></td>
<td style="vertical-align:top;padding-left:2px;">
<select class="chosen-select form-control" name="name" id="id" data-placeholder="请选择" style="vertical-align:top;width: 120px;">
<option value=""></option>
<option value="">全部</option>
<option value="">1</option>
<option value="">2</option>
</select>
</td>--%>
<c:if test="${QX.cha == 1 }">
<td style="vertical-align:top;padding-left:2px"><a class="btn btn-light btn-xs" onclick="tosearch();" title="检索"><i id="nav-search-icon" class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a></td>
</c:if>
<%--<c:if test="${QX.toExcel == 1 }"><td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs" onclick="toExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="ace-icon fa fa-download bigger-110 nav-search-icon blue"></i></a></td></c:if>--%>
</tr>
</table>
<!-- 检索 -->
<table id="simple-table" class="table table-striped table-bordered table-hover" style="margin-top:5px;">
<thead>
<tr>
<th class="center" style="width:50px;">序号</th>
<th class="center">店铺名</th>
<th class="center">奖品</th>
<th class="center">抽奖时间</th>
</tr>
</thead>
<tbody>
<!-- 开始循环 -->
<c:choose>
<c:when test="${not empty varList}">
<c:if test="${QX.cha == 1 }">
<c:forEach items="${varList}" var="var" varStatus="vs">
<tr>
<td class='center' style="width: 30px;">${vs.index+1}</td>
<td class='center'>${var.store_name}</td>
<td class='center'>
<c:if test="${var.reward != null}">
${var.reward}个月
</c:if>
<c:if test="${var.reward==null}">
未中奖
</c:if>
</td>
<td class='center'>${var.createtime}</td>
</tr>
</c:forEach>
</c:if>
<c:if test="${QX.cha == 0 }">
<tr>
<td colspan="100" class="center">您无权查看</td>
</tr>
</c:if>
</c:when>
<c:otherwise>
<tr class="main_info">
<td colspan="100" class="center" >没有相关数据</td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
</table>
<div class="page-header position-relative">
<table style="width:100%;">
<tr>
<%--<td style="vertical-align:top;">
<c:if test="${QX.add == 1 }">
<a class="btn btn-mini btn-success" onclick="add();">新增</a>
</c:if>
&lt;%&ndash; <c:if test="${QX.del == 1 }">
<a class="btn btn-mini btn-danger" onclick="makeAll('确定要删除选中的数据吗?');" title="批量删除" ><i class='ace-icon fa fa-trash-o bigger-120'></i></a>
</c:if> &ndash;%&gt;
</td> --%>
<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
</tr>
</table>
</div>
</form>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.page-content -->
</div>
</div>
<!-- /.main-content -->
<!-- 返回顶部 -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
</div>
<!-- /.main-container -->
<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../../system/index/foot.jsp"%>
<!-- 删除时确认窗口 -->
<script src="${pageContext.request.contextPath}/static/ace/js/bootbox.js"></script>
<!-- ace scripts -->
<script src="${pageContext.request.contextPath}/static/ace/js/ace/ace.js"></script>
<!-- 下拉框 -->
<script src="${pageContext.request.contextPath}/static/ace/js/chosen.jquery.js"></script>
<!-- 日期框 -->
<script src="${pageContext.request.contextPath}/static/ace/js/date-time/bootstrap-datepicker.js"></script>
<!--提示框-->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery.tips.js"></script>
<script type="text/javascript">
$(top.hangge());//关闭加载状态
//检索
function tosearch(){
top.jzts();
$("#Form").submit();
}
$(function() {
//日期框
$('.date-picker').datepicker({
autoclose: true,
todayHighlight: true
});
//下拉框
if(!ace.vars['touch']) {
$('.chosen-select').chosen({allow_single_deselect:true});
$(window)
.off('resize.chosen')
.on('resize.chosen', function() {
$('.chosen-select').each(function() {
var $this = $(this);
$this.next().css({'width': $this.parent().width()});
});
}).trigger('resize.chosen');
$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
if(event_name != 'sidebar_collapsed') return;
$('.chosen-select').each(function() {
var $this = $(this);
$this.next().css({'width': $this.parent().width()});
});
});
$('#chosen-multiple-style .btn').on('click', function(e){
var target = $(this).find('input[type=radio]');
var which = parseInt(target.val());
if(which == 2) $('#form-field-select-4').addClass('tag-input-style');
else $('#form-field-select-4').removeClass('tag-input-style');
});
}
//复选框全选控制
var active_class = 'active';
$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
var th_checked = this.checked;//checkbox inside "TH" table header
$(this).closest('table').find('tbody > tr').each(function(){
var row = this;
if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
});
});
});
//新增
function add(){
top.jzts();
var diag = new top.Dialog();
diag.Drag=true;
diag.Title ="新增";
diag.URL = '${pageContext.request.contextPath}/oneclassfy/goAdd.do';
diag.Width = 900;
diag.Height = 710;
diag.Modal = true; //有无遮罩窗口
diag. ShowMaxButton = true; //最大化按钮
diag.ShowMinButton = true; //最小化按钮
diag.CancelEvent = function(){ //关闭事件
if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
nextPage(${page.totalPage});
}
diag.close();
};
diag.show();
}
//删除
function del(Id){
bootbox.confirm("确定要删除吗?", function(result) {
if(result) {
top.jzts();
var url = "${pageContext.request.contextPath}/oneclassfy/delete.do?CLASSIFY_ID="+Id+"&tm="+new Date().getTime();
$.get(url,function(data){
if(data.flag==1){
nextPage(${page.currentPage});
}else{
alert(data.errmsg);
nextPage(${page.currentPage});
}
});
}
});
}
//修改
function edit(Id){
top.jzts();
var diag = new top.Dialog();
diag.Drag=true;
diag.Title ="编辑";
diag.URL = '${pageContext.request.contextPath}/oneclassfy/goEdit.do?CLASSIFY_ID='+Id;
diag.Width = 900;
diag.Height = 710;
diag.Modal = true; //有无遮罩窗口
diag. ShowMaxButton = true; //最大化按钮
diag.ShowMinButton = true; //最小化按钮
diag.CancelEvent = function(){ //关闭事件
if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
nextPage(${page.currentPage});
}
diag.close();
};
diag.show();
}
//批量操作
function makeAll(msg){
bootbox.confirm(msg, function(result) {
if(result) {
var str = '';
for(var i=0;i < document.getElementsByName('ids').length;i++){
if(document.getElementsByName('ids')[i].checked){
if(str=='') str += document.getElementsByName('ids')[i].value;
else str += ',' + document.getElementsByName('ids')[i].value;
}
}
if(str==''){
bootbox.dialog({
message: "<span class='bigger-110'>您没有选择任何内容!</span>",
buttons:
{ "button":{ "label":"确定", "className":"btn-sm btn-success"}}
});
$("#zcheckbox").tips({
side:1,
msg:'点这里全选',
bg:'#AE81FF',
time:8
});
return;
}else{
if(msg == '确定要删除选中的数据吗?'){
top.jzts();
$.ajax({
type: "POST",
url: '${pageContext.request.contextPath}/oneclassfy/deleteAll.do?tm='+new Date().getTime(),
data: {DATA_IDS:str},
dataType:'json',
//beforeSend: validateData,
cache: false,
success: function(data){
$.each(data.list, function(i, list){
tosearch();
});
}
});
}
}
}
});
};
//导出excel
function toExcel(){
window.location.href='${pageContext.request.contextPath}/oneclassfy/excel.do';
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -31,7 +31,7 @@
<!-- 检索 -->
<form action="list.do" method="post" name="Form" id="Form">
<form action="${pageContext.request.contextPath}/list.do" method="post" name="Form" id="Form">
<!--
<table style="margin-top:5px;">
<tr>
......
......@@ -29,7 +29,7 @@
<div class="row">
<div class="col-xs-12">
<!-- 检索 -->
<form action="list.do" method="post" name="Form" id="Form">
<form action="${pageContext.request.contextPath}/share/list.do" method="post" name="Form" id="Form">
<table style="margin-top:5px;">
<tr>
......@@ -51,10 +51,11 @@
<option value="">2</option>
</select>
</td>
--%>
<c:if test="${QX.cha == 1 }">
<td style="vertical-align:top;padding-left:2px"><a class="btn btn-light btn-xs" onclick="tosearch();" title="检索"><i id="nav-search-icon" class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a></td>
</c:if>
<c:if test="${QX.toExcel == 1 }"><td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs" onclick="toExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="ace-icon fa fa-download bigger-110 nav-search-icon blue"></i></a></td></c:if>
<%--<c:if test="${QX.toExcel == 1 }"><td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs" onclick="toExcel();" title="导出到EXCEL"><i id="nav-search-icon" class="ace-icon fa fa-download bigger-110 nav-search-icon blue"></i></a></td></c:if>
--%>
</tr>
</table>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论