html
<include file="Public:header" />
<include file="Public:nav" />
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<include file="Public:listCrumbs" />
</ol>
</div>
</div>
<div class="alert sb-alert alert-gray margin-left-right-20 margin-top-10 margin-bottom-20">
<div class="row">
<div class="col-lg-4 search-margin">
<span class="input-group input-group-sm">
<span class="input-group-addon" id="uid"><b>支付时间:</b></span>
<input class="form-control-erbi col-lg-4" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text" id="start_time" placeholder='开始时间' value="<?php echo $start_time; ?>" />
<span style="display: block;float: left;margin-top: 5px;margin-left: 5px;margin-right: 5px;">-</span>
<input class="form-control-erbi col-lg-4" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text" id="end_time" placeholder='结束时间' value="<?php echo $end_time; ?>" />
<img onclismoothck="WdatePicker()" src="/plugin/My97DatePicker/skin/datePicker2.gif" style="display: block;float: left;margin-top: 5px;margin-left: 5px;" width="16" height="22" align="absmiddle">
</span>
</div>
<div class="col-lg-3 search-margin">
<span class="input-group input-group-sm">
<span class="input-group-addon"><b>企业名称:</b></span>
<input class="form-control-erbi col-lg-10 yh-style" type="text" id="company_name" placeholder='企业名称' value="<?php echo $company_name; ?>" />
</span>
</div>
<button type="button" class="btn btn-sm btn-primary" style="float: right; margin-right: 40px;" id="search">
<i class="fa fa-search" aria-hidden="true"></i> 查询
</button>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<!-- /.panel-heading -->
<div class="panel-body" style="padding-top: 10px;">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>ID</th>
<th>充值企业</th>
<th>充值单号</th>
<th>微信支付流水号</th>
<th>充值金额(元)</th>
<th>会员年限</th>
<th>支付时间</th>
</tr>
</thead>
<tbody id="tbody">
<volist name="result" id="vo">
<tr data-id="{$vo.id}" data-table="banner">
<td>{$vo.id}</td>
<td><span class="over-ellipsis">{$vo.company_uid}-{$vo.company_name}</span></td>
<td>{$vo.order_num}</td>
<td>{$vo.transaction_id}</td>
<td>{$vo.amount}</td>
<td>{$vo.year}</td>
<td>{$vo.pay_time|date='Y-m-d H:i',###}</td>
</tr>
</volist>
</tbody>
</table>
<include file="Public:page" />
<input type="hidden" name="page" id="page" value="{$page}" />
</div>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<include file="Public:bottomJs" />
<script>
function get_search(){
let start_time = $("#start_time").val();
let end_time = $("#end_time").val();
let company_name = $("#company_name").val();
if(start_time && !end_time)
{
alert('请选择结束时间');
return;
}
if(!start_time && end_time)
{
alert('请选择开始时间');
return;
}
if(start_time && end_time)
{
if(end_time < start_time)
{
alert('开始结束时间选择不对');
return;
}
}
let search_str = '';
if(start_time && end_time) search_str +='&start_time=' + start_time + '&end_time=' + end_time;
if(company_name) search_str +='&company_name=' + company_name;
return search_str;
}
$(function () {
// 搜索
$("#search").on('click', function () {
let search_str = get_search();
if (search_str) {
window.location.href = '__URL__/index?page=' + 1 + search_str;
}
});
})
</script>
<include file="Public:footer" />
php
<?php
namespace Admin\Action;
class RechargeOrderAction extends CommonAction
{
public function _initialize()
{
parent::_initialize();
$model_name = '企业会员充值订单';
$this->assign('model_name', $model_name);
}
public function index()
{
$page = 1;
if (!empty($_GET['page'])) {
$page = (int) $_GET['page'];
}
$this->assign('page', $page);
$step = C('PAGE_NORMAL_COUNT');
$model = D('Page');
$start = ($page - 1) * $step;
// search
$where['status'] = 2; // 正常
//搜索
if($_GET['company_name'])
{
$company_user = M('company_user');
$company_uids = $company_user->where(['name'=>['like','%'.$_GET['company_name'].'%']])->getField('id',true);
$where['company_uid'] = ['in', $company_uids];
$this->assign('company_name', $_GET['company_name']);
}
if($_GET['start_time'])
{
$this->assign('start_time', $_GET['start_time']);
$this->assign('end_time', $_GET['end_time']);
$where['pay_time'] = array(array('gt',strtotime($_GET['start_time'].' 00:00')),array('lt',strtotime($_GET['end_time'].' 23:59')),'and');
}
$recharge_order = M('recharge_order');
$result_list = $recharge_order->where($where)->limit($start . ',' . $step)->order('id desc')->select();
$company_user = M('company_user');
foreach($result_list as $k => &$v) {
$v['company_name'] = $company_user->where(['id'=>$v['company_uid']])->getField('name');
}
$this->assign('result', $result_list);
$model_flag = $model->index('recharge_order', $page, $where);
$this->assign('allPage', $model_flag);
$this->display();
}
}
tips:后台的一个重要功能,就是查询.然后是统计.