ThinkPHP中MVC代码范例
来源:互联网 发布:js系列减速机加油标准 编辑:程序博客网 时间:2024/05/16 16:24
Controller
public function productlist(){ $map = ['p.isdelete'=>0,'u.isdelete'=>0,'p.istrade'=>0];//没有删除//获取提交的数据 $name = I('name'); $status = I('post.status'); $begindate = I("post.begindate"); $enddate = I("post.enddate"); $audit=I('post.audit'); $istop=I('post.istop'); $show_status=I('post.show_status');//拼接where条件 if($name) $map['p.name'] = ['like','%'.$name.'%']; if($status>=0 && is_numeric($status)) $map['p.status'] = $status; if($begindate && $enddate) $map['p.addtime'] = array(array('egt',$begindate),array('elt',date('Y-m-d', strtotime("$enddate+1days"))) ); // if($begindate) $map['p.addtime'] = array("egt",$begindate); // if($enddate) $map['p.addtime'] = array('elt', date('Y-m-d', strtotime("$enddate+1days"))); if($audit>=0 && is_numeric($audit))$map['p.audit']=$audit; if($istop>=0 && is_numeric($istop))$map['p.istop']=$istop; if($show_status == 1){ $map['p.status'] = 1; $map['p.audit'] = 2; $map['p.show_start_time'] = array('elt',date('Y-m-d H:i:s',time())); $map['p.show_end_time'] = array('egt',date('Y-m-d H:i:s',time())); } //分页 $pagenum =I('param.p'); if(!$pagenum)$pagenum=1; $pagenum=!is_numeric($pagenum)?1:$pagenum; $pagesize= C('pagesize',null,10);// $pagesize=2; $count=0;// $list = D('product')->getproductlist($map,'p.*,u.user_name'); //进入Model调用方法$list = D('product')->getproductlist($pagenum,$pagesize,$count,$begindate,$enddate,$map,'p.*,u.user_name'); //echo M()->_sql();die; if($list){ foreach($list as $k=>$v){ $bt = strtotime($v['show_start_time']); $et = strtotime($v['show_end_time']); if($bt<time() && $et>time() && $v['audit'] ==2 && $v['isdelete'] == 0){ $list[$k]['show_status'] = 1;//前台展示 }else{ $list[$k]['show_status'] = 0;//前台未展示 } } } $this->assign('list',$list); $page = new \Think\Page($count,$pagesize); $show = $page->show(); $this->assign('page',$show); $this->display(); }
Model
public function getproductlist($pagenum,$pagesize,&$count,$begindate,$enddate,$map=[],$field="*"){$pre = C('DB_PREFIX');//获取表前缀// if ($begindate)$map['p.addtime']= array("egt",$begindate);// if ($enddate)$map['p.addtime']=array('elt', date('Y-m-d', strtotime("$enddate+1days")));//拼接sql 结合多表查询$list=M('product')->alias('as p')->field($field)->join($pre.'user as u on u.id=p.sponsorid','left')->where($map)->page($pagenum.','.$pagesize)->order('p.addtime desc')->select();//分页数据总数量$count=M('product')->alias('as p')->join($pre.'user as u on u.id=p.sponsorid','left')->where($map)->count();return $list;}
View
<div class="container-fluid"><ol class="breadcrumb default square rsaquo sm"><li><a href="{:U('/Manage/Index/home')}" title="首页"><i class="fa fa-home"></i></a></li><li class="text-primary">团购管理</li><li class="active">订单管理</li></ol><div class="the-box less-margin searchbox"><form method="post" action="{:U('Product/porderlist')}"><label>关键字</label><select class="form-control" id="keytype" name="keytype"><option value="1" <if condition="I('post.keytype') eq '1'">selected="selected"</if>>平台流水号</option><option value="2" <if condition="I('post.keytype') eq '2'">selected="selected"</if>>项目编号</option><option value="3" <if condition="I('post.keytype') eq '3'">selected="selected"</if>>手机</option><option value="4" <if condition="I('post.keytype') eq '4'">selected="selected"</if>>产品名称</option></select><input type="text" class="form-control input-text" id="keywords" name="keywords" value="{:I('post.keywords')}"><select name="status" id="status" class="form-control"><option value="-1" <if condition="I('post.status') eq ''">selected=selected</if>>支付状态</option><option value="0" <if condition="I('post.status') eq 0 and I('post.status') neq ''">selected=selected</if>>未支付</option><option value="1" <if condition="I('post.status') eq 1">selected=selected</if>>已支付</option><option value="2" <if condition="I('post.status') eq 2">selected=selected</if>>已关闭</option></select><select name="isprize" id="isprize" class="form-control"><option value="-1" <if condition="I('post.isprize') eq ''">selected=selected</if>>档位类型</option><option value="0" <if condition="I('post.isprize') eq 0 and I('post.isprize') neq ''">selected=selected</if>>普通档位</option><option value="1" <if condition="I('post.isprize') eq 1">selected=selected</if>>抽奖档位</option></select><select name="iswinning" id="iswinning" class="form-control"><option value="-1" <if condition="I('post.iswinning') eq ''">selected=selected</if>>中奖状态</option><option value="0" <if condition="I('post.iswinning') eq 0 and I('post.iswinning') neq ''">selected=selected</if>>未中奖</option><option value="1" <if condition="I('post.iswinning') eq 1">selected=selected</if>>已中奖</option></select><input type="text" class="form-control datepicker input-text" id="enddate" name="enddate" value="{:I('post.enddate')}"><input type="submit" class="btn btn-info margin-left" value="搜索"></form></div><div class="the-box"><div class="table-responsive"><table class="table table-condensed table-hover" id="datatable-display1"><thead class="bg-primary"><tr><th>编号</th><th>订单编码</th><th>产品名称</th><th>档位类型</th><th>手机</th> <th>实付金额</th> <th>消费积分</th><th>支付时间</th><th>支付状态</th><th>是否邮寄</th><!-- <th>收货地址</th><th>收货人姓名</th><th>联系电话</th> --><!-- <th>添加时间</th> --><th>操作</th></tr></thead><tbody><volist name="list" id="vo" key="k"><tr><td>{$k}</td><td>{$vo.code}</td><td>{$vo.name}</td><td><if condition="$vo['isprize'] eq '1'">抽奖档位<else/>普通档位</if></td><!-- <td>{$vo.user_name}</td> --><td>{$vo.phone}</td><td>{$vo.actual}</td><td>{$vo.integral}</td><td>{$vo.paytime}</td><td><if condition="$vo['status'] eq 0"><span class="badge">未付</span><elseif condition="$vo['status'] eq 1"/><span class="badge badge-success">已付</span><else/><span class="badge ">已关闭</span></if></td> <td><if condition="$vo['ispost'] eq 1"><span class="badge badge-success">需要</span><else/><span class="badge ">不需要</span></if></td><!-- <td>{$vo.areaname}{$vo.address}</td><td>{$vo.nickname}</td><td>{$vo.phone}</td> --><td class="navbar-right"><a href="{:U('Product/porderinfo',array('id'=>$vo['id']))}" >查看</a><if condition="stripos($rightslist,'productorg') nheq false"><if condition="($vo['ispost'] eq 1) and ($vo['post_status'] eq 0) and ($vo['status'] eq 1)"><a data-toggle="modal" data-target="#myModal" data-id="{$vo.id}" class="dysh" id="stick" style="cursor:pointer" >发货</a><elseif condition="($vo['ispost'] eq 1) and ($vo['status'] eq 1)"/><a data-toggle="modal" data-target="#myModal" data-id="{$vo.id}" class="dysh" id="stick" style="cursor:pointer" >修改单号</a></if></if></td></tr></volist></tbody><tfoot><tr><if condition="$list"><td colspan="9"></td><td colspan="9"><form method="post" action="{:U('Export/ExportPorderlist')}"><input type="hidden" name="keytype" value="{:I('post.keytype')}"/><input type="hidden" name="keywords" value="{:I('post.keywords')}"/><input type="hidden" name="status" value="{:I('post.status')}"/><input type="hidden" name="isprize" value="{:I('post.isprize')}"/><input type="hidden" name="iswinning" value="{:I('post.iswinning')}"/><if condition="stripos($rightslist,'productorg') nheq false"><input type="submit" class="btn btn-info margin-left" value="导出EXCEL"></if></form></td> </if></tr></tr></tfoot></table>{$page}</div></div></div><!-- 模态框(Modal) --><div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel">确认发货</h4> </div> <div class="modal-body"><form method="POST" action="{:U('Product/sendorder')}" name="form_login" ><div ><input type="hidden" value="" name="id" id="expressid">物流公司<br/><select name="expressid" id="exid" > <option value="0">选择物流公司</option> <volist name="express" id="v"> <option value="{$v.id}">{$v.name}</optio> </volist> </select> <br/> <br/> 收货地址 <span id="readr"></span> <br/> <br/> 收 货 人 <span id="rename"></span> <br/> <br/> 联系电话 <span id="rephone"></span> <br/> <br/> 物流单号<input type='text' id ="test" name="express_no" class="form-control"/></div></form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal" class="close">关闭</button> <button type="button" id="sub" class="btn btn-primary affirm">确认</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal --></div>
阅读全文
0 0
- ThinkPHP中MVC代码范例
- PHP中MVC框架ThinkPHP
- THINKPHP中RBAC代码备注
- thinkPHP中MVC模式的分析(一)
- thinkPHP中MVC模式的分析(二)
- Flex中嵌入Html代码范例
- 代码范例
- thinkphp增删改查范例
- 【代码】thinkphp 框架 中 ajax 的应用
- JAVA读取txt文件中数据代码范例
- Unity中Navigation组件的使用代码范例和注意事项
- ThinkPHP 多层MVC支持
- ThinkPHP里的MVC
- thinkPHP的MVC框架
- ThinkPHP之多层MVC
- TheBeerHouse--ASP.NET MVC范例
- 代码范例 - ArrayUtils
- JAVA代码注释范例
- 偶遇尴尬 MyBatis 问题
- 为虚拟机添加一张网卡
- Java面向对象思想
- oracle 锁表解决方法
- 字符串反转几种方法
- ThinkPHP中MVC代码范例
- 未“起飞”就倒闭?共享充电宝企业“乐电”逃之夭夭
- java 多态特性
- ADB命令抓取Android LogCat
- hdu 6031 Innumerable Ancestors lca + 二分
- ORM框架之GreenDao3.0使用详解(二)
- 矩阵计算
- padding实现居中
- Java 5种方法实现生产者消费者问题与2种方法实现读者写者问题