Rumah > php教程 > php手册 > WeMall微信商城源码插件代金券部分代码

WeMall微信商城源码插件代金券部分代码

WBOY
Lepaskan: 2016-10-11 14:01:58
asal
1259 orang telah melayarinya

WeMall微信商城源码插件Coupon代金券代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考
WeMall微信商城源码插件Coupon代金券代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考

AdminController.class.php
<?php <br /> namespace Addons\Coupon\Controller;  <br>   <br> class AdminController extends InitController  <br> {  <br>     public function index()  <br>     {  <br>         $num = 25;  <br>         $p = I("get.page") ? I("get.page") : 1;  <br>   <br>         $couponModel = D(’Addons://Coupon/AddonCouponMenu’);  <br>         $coupon = $couponModel->getPageConditionOrder($p, $num, "id desc");  <br>         $this->assign("couponList", $coupon);// 赋值数据集  <br>   <br>         $count = $couponModel->getCount();// 查询满足要求的总记录数  <br>         $Page = new \Think\Page($count, $num);// 实例化分页类 传入总记录数和每页显示的记录数  <br>         $Page->setConfig(’theme’, "<ul> <li>%FIRST%</li> <li>%UP_PAGE%</li> <li>%LINK_PAGE%</li> <li>%DOWN_PAGE%</li> <li>%END%</li> <li><a> %HEADER%  %NOW_PAGE%/%TOTAL_PAGE% 页</a></li> </ul>");  <br>         $show = $Page->show();// 分页显示输出  <br>         $this->assign(’page’, $show);// 赋值分页输出  <br>   <br>         $this->display(); // 输出模板  <br>     }  <br>   <br>     public function add()  <br>     {  <br>         if (IS_POST) {  <br>             if (!I("post.name")) {  <br>                 return;  <br>             }  <br>   <br>             $data = I("post.");  <br>             $data[’last_time’] = I(’post.last_time’, ’’, ’strtotime’);  <br>             $coupon_id = D(’Addons://Coupon/AddonCouponMenu’)->addCouponMenu($data);  <br>   <br>             isset($coupon_id) ? $this->success(’添加成功’, ’Admin/Admin/index/addon/Coupon’) : $this->error(’添加失败’, u_addons("Coupon://Admin/Admin/index"));  <br>         } else {  <br>             $this->display(); // 输出模板  <br>         }  <br>     }  <br>   <br>     public function detail()  <br>     {  <br>         $cdata[’coupon_menu_id’] = I(’get.id’);  <br>         $m = M(’AddonCoupon’);  <br>         $count = $m->where($cdata)->count(); // 查询满足要求的总记录数  <br>         $Page = new \Think\Page ($count, 15); // 实例化分页类 传入总记录数和每页显示的记录数  <br>         $Page->setConfig(’theme’, "<ul> <li>%FIRST%</li> <li>%UP_PAGE%</li> <li>%LINK_PAGE%</li> <li>%DOWN_PAGE%</li> <li>%END%</li> <li><a> %HEADER%  %NOW_PAGE%/%TOTAL_PAGE% 页</a></li> </ul>");  <br>         $show = $Page->show(); // 分页显示输出  <br>         $detail = $m->where($cdata)->limit($Page->firstRow . ’,’ . $Page->listRows)->select();  <br>   <br>         $this->assign("page", $show); // 赋值分页输出  <br>         $this->assign(’coupon’, $detail);  <br>         $this->display();  <br>     }  <br>   <br>     public function export()  <br>     {  <br>   <br>     }  <br>   <br>     public function del()  <br>     {  <br>         $cdata[’coupon_menu_id’] = $data[’id’] = I(’get.id’);  <br>         $c = M(’AddonCouponMenu’)->where($data)->delete();  <br>         $m = M(’AddonCoupon’)->where($cdata)->delete();  <br>         if ($c != false && $m != false) {  <br>             $this->success(’删除成功’, ’Admin/Admin/index/addon/Coupon’);  <br>         } else {  <br>             $this->error(’操作失败’, ’Admin/Admin/index/addon/Coupon’);  <br>         }  <br>     }  <br>   <br>     public function detail_del()  <br>     {  <br>         $cdata[’id’] = I(’get.id’);  <br>         $m = M(’AddonCoupon’)->where($cdata)->delete();  <br>         if ($m != false) {  <br>             $this->success(’删除成功’, ’Admin/Admin/index/addon/Coupon’);  <br>         } else {  <br>             $this->error(’操作失败’, ’Admin/Admin/index/addon/Coupon’);  <br>         }  <br>     }  <br> }  
AddonCouponMenuModel.class.php
<?php <br /> namespace Addons\Coupon\Model;  <br>   <br> use Think\Model\RelationModel;  <br>   <br> class AddonCouponMenuModel extends RelationModel  <br> {  <br>     protected $_link = array();  <br>   <br>     public function getCount()  <br>     {  <br>         $count = $this->count();  <br>         return $count;  <br>     }  <br>   <br>     public function getPageConditionOrder($p = 1, $num = 1, $order)  <br>     {  <br>         // 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 $_GET[p]获取  <br>         $orderList = $this->page($p . ’,’ . $num . ’’)->order($order)->select();  <br>         return $orderList;  <br>     }  <br>   <br>     public function addCouponMenu($data)  <br>     {  <br>         $data[’ctime’] = time();  <br>         $number = $data[’num’] = intval($data[’num’]);  <br>         $data[’coupon_menu_id’] = $this->add($data);  <br>   <br>         for ($i = 0; $i              $data[’code’] = rand_code(6);  <br>             $code = M(’AddonCoupon’)->where(array(’code’ => $data[’code’]))->find();  <br>             if (!isset($code)) {  <br>                 $coupon_id = M(’AddonCoupon’)->add($data);  <br>             } else {  <br>                 $number = $number + 1;  <br>             }  <br>         }  <br>         return $coupon_id;  <br>     }  <br> }   Admin_detail.html
<section>  <br>     <h1>  <br>         优惠券管理  <br>         <small></small>  <br>     </h1>  <br> </section>  <br>   <br> <!-- Main content -->  <br> <section>  <br>     <div>  <br>         <!-- /.col -->  <br>         <div>  <br>             <div>  <br>                 <div>  <br>                     <h3>优惠券管理</h3>  <br>                     <!-- /.box-tools -->  <br>                 </div>  <br>                 <!-- /.box-header -->  <br>                 <div>  <br>                     <div>  <br>                         <div>  <br>                             <a>  <br>                                 返回优惠券列表页  <br>                             </a>  <br>                         </div>  <br>                         <!-- /.btn-group -->  <br>                     </div>  <br>                     <div>  <br>                         <table>  <br>                             <tbody>  <br>                             <tr>  <br>                                 <!--<th class="hidden-xs">-->  <br>                                     <!--<label><input onchange="checkAll()" type="checkbox" value=""></label>-->  <br>                                 <!--</th>-->  <br>                                 <th>ID</th>  <br>                                 <th>优惠码</th>  <br>                                 <th>金额</th>  <br>                                 <th>状态</th>  <br>                                 <th>截止时间</th>  <br>                                 <th>操作</th>  <br>                             </tr>  <br>                             <volist>  <br>                                 <tr>  <br>                                     <!--<td class="hidden-xs">-->  <br>                                         <!--<label><input name="checkbox" class="check" type="checkbox"-->  <br>                                                       <!--value="{$coupon.id}"></label>-->  <br>                                     <!--</td>-->  <br>                                     <td>  <br>                                         {$coupon.id}  <br>                                     </td>  <br>                                     <td>  <br>                                         {$coupon.code}  <br>                                     </td>  <br>                                     <td>  <br>                                         {$coupon.price}  <br>                                     </td>  <br>                                     <td>  <br>                                         {$coupon.status}  <br>                                     </td>  <br>                                     <td>  <br>                                         {:date(’Y-m-d H:i:s’,$coupon[’last_time’])}  <br>                                     </td>  <br>                                     <td> <a></a>                                             href="{:u_addons(\’Coupon://Admin/Admin/detail_del\’,array(’id’=>$coupon[’id’]))}">删除</td>  <br>                                 </tr>  <br>                             </volist>  <br>                             </tbody>  <br>                         </table>  <br>                         <div>  <br>                             <div>  <br>                                 <!--<div class="btn-group">-->  <br>                                     <!--<button type="button" class="btn btn-danger"-->  <br>                                             <!--onclick="batchUrl(’{:U(\’Admin/coupon/delcoupon\’)}’)">全部删除-->  <br>                                     <!--</button>-->  <br>                                 <!--</div>-->  <br>                                 <div>  <br>                                     {$page}  <br>                                     <!-- /.btn-group -->  <br>                                 </div>  <br>                             </div>  <br>                         </div>  <br>                     </div>  <br>                     <!-- /.mail-box-messages -->  <br>                 </div>  <br>             </div>  <br>             <!-- /. box -->  <br>         </div>  <br>         <!-- /.col -->  <br>     </div>  <br> </section>   代码来源: www.wemallshop.com
WeMall微信商城源码插件代金券部分代码

附件 Coupon代金券.rar ( 8.65 KB 下载:2 次 )

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan