opensns商城中的微店模块下载使用后,发现一些小bug及可以优化的部分,并且根据需求制作了店铺营业总额按设定时间区间查询功能。
1.审核商铺,商品权限给出后,非超级管理员依然无法审核。
修复:
修改文件:Application/Store/Controller/StoreController.class.php
修改内容:
分别将goodlist 以及shoplist方法中的setSelectPostUrl(参数传递地址)改为对应的SetsGoodStatus 以及SetsShopStatus 即可解决
2.审核商品时需要浏览商品的详细信息,但是点商品链接提示没有内容。
其实是应为商品状态为待审核无法进入商品详情页。我的解决思路是判定商品状态后判定用户权限,有权限的用户可以访问待审核商品的详情页。
解决:
修改文件:Application/Store/Controller/IndexController.class.php
修改内容:
在进入商品详情页的判定中加入判定,当商品状态为待审核,判定登入用户权限,有权限则可以浏览商品详情。代码如下:
//管理者可以查看商品
if (!$goods || $goods['status'] != 1) {
if(!check_auth("Admin/Index/index")){ //检查用户是否有后台权限
$this->error('商品不存在。');
}
}
3.商品商铺信息通过审核后,店家修改信息资料后,对于商品或商铺状态需变更为待审核。防止店家随意修改店铺,商品信息。
解决:
修改文件:Application/Store/Controller/CenterController.class.php
修改内容:
提交修改后,将对于商品,商铺的状态信息改为待审核:
商铺在createShop方法中将$shop['status'] = 2;;
商品在doAddInfo方法中将$info['status'] = 2;
4.微店模块添加商铺营业总额限定时间区间查看
思路:取出所有店铺信息,查找每个店铺在时间段里所有订单,对所有订单统计总营业额文件:模板创建Application/Admin/View/default/Store 文件夹并在其中创建total.html文件
控制器:club/Application/Store/Controller/StoreController.class.php中添加total方法
步骤:
1. 在后台用户--后台菜单管理--微店--新增子菜单营业总额表。
2.在club/Application/Store/Controller/StoreController.class.php中编写total方法代码如下:
public function total($r = 15){
$orderModel = D('Store/Order');
$shopModel = D('Store/StoreShop');
if(IS_POST){ //设置查询时间区间
$stime = strtotime($_POST['sTime']);
$etime = strtotime($_POST['eTime']);
}
$total_count = $shopModel->where(array('status' => 1))->count();// 查询满足要求的总记录数
$Page = new \Think\Page($total_count,10);// 实例化分页类 传入总记录数和每页显示的记录数(10// 查询满足要求的总记录数)
$Page->setConfig('header','个商铺信息');
$show = $Page->show();// 分页显示输出
$shop = $shopModel->where(array('status' => 1))->limit($Page->firstRow.','.$Page->listRows)->select(); //取出所有店铺信息
foreach ($shop as $k => &$v) {
$total=0;
$v['shop_name'] = $this->getShopLink($shop[$k]); //获得店铺名链接
$map['condition'] = 3;
$map['s_uid'] = $v['uid'];
$map['pay_time'] = array("BETWEEN",array($stime,$etime)); //根据时间区间查询有效订单
$order = M("store_order")->where($map)->select(); //根据店主ID取出所有已完成的订单
/*取用户信息*/
$user =query_user(array('nickname'),$v['uid']);
$v['nickname'] = $user['nickname'];
foreach ($order as $ky => $s) {
$amount = $s['total_cny'] + $s['adj_cny'];
$total += $amount; //统计所有订单的营业额
}
$v['total'] = number_format($total,2);
}
$this->assign('page',$show);// 赋值分页输出
$this->assign('shop',$shop);
$this->meta_title = "营业总额表";
$this->display();
}
3.在Application/Admin/View/default/Store 文件夹total.html文件编写代码如下:
<extend name="Public/base"/>
<block name="body">
<!-- 标题栏 -->
<div class="main-title">
<h2>{:L('_USER_LIST_')}</h2>
</div>
<div class="clearfix">
<!-- 高级搜索 -->
<div class="search-form col-xs-2 text-right">
<div class="input-group">
<div class="form-group has-feedback">
<form class="form-horizontal ajax-form" role="form" action="{:U('total')}" method="post">
<div class="col-xs-5">
<input type="text" id="sTime" name="sTime" class="time_d form-control form_check" readonly check-type="Time" value="" placeholder="{:L('_TIME_START_')}" required/>
</div>
<div class="col-xs-5">
<input type="text" id="eTime" name="eTime" class="time_d form-control form_check" readonly check-type="Time" value="" placeholder="{:L('_TIME_OVER_')}" required/>
</div>
<div class="col-xs-5">
<input type="submit" value="查找" class="form-control form_check" />
</div>
</form>
</div>
<!--<span class="input-group-btn"> <a class="btn btn-default" href="javascript:;" id="search" url="{:U('total')}"><i class="icon-search"></i></a></span>-->
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data-table with-padding">
<table class="table table-bordered table-striped ">
<thead>
<tr>
<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
<th class="">店铺ID</th>
<th class="">店主</th>
<th class="">店铺</th>
<th class="">营业总额</th>
<th class="">销售量</th>
</tr>
</thead>
<tbody>
<notempty name="shop">
<volist name="shop" id="vo">
<tr>
<td><input class="ids" type="checkbox" name="id" value="{$vo.id}"/></td>
<td>{$vo.id}</td>
<td><a href="{:U('Admin/User/expandinfo_details',array('uid'=>$vo['uid']))}" >{$vo.nickname|op_t}</a></td>
<td>{$vo.shop_name}</td>
<td>{$vo.total}</td>
<td>{$vo.sell}</td>
</tr>
</volist>
<else/>
<td colspan="9" class="text-center">时间段内没有营业额产生</td>
</notempty>
</tbody>
</table>
</div>
<div class="with-padding">
{$page}
</div>
</block>
<block name="script">
<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
<link href="__ZUI__/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__ZUI__/lib/datetimepicker/datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript">
//搜索功能
$("#search").click(function () {
var url = $(this).attr('url');
var query = $('.search-form').find('input').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
window.location.href = url;
});
//回车搜索
$(".search-input").keyup(function (e) {
if (e.keyCode === 13) {
$("#search").click();
return false;
}
});
//导航高亮
highlight_subnav("{:U('Store/total')}");
//时间
$('.time_d').datetimepicker({
language:'zh-CN',
weekStart:1,
todayBtn:1,
autoclose:1,
todayHighlight:1,
startView:2,
minView:2,
forceParse:0,
format: 'yyyy-mm-dd'
});
</script>
</block>
完成