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

原创
2016-10-11 14:01:58 824浏览
WeMall微信商城源码插件Coupon代金券代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考
WeMall微信商城源码插件Coupon代金券代码是用于商业推广的比较有效的方式,分享了部分比较重要的代码,供技术员学习参考

AdminController.class.php
namespace Addons\Coupon\Controller;

class AdminController extends InitController
{
public function index()
{
$num = 25;
$p = I("get.page") ? I("get.page") : 1;

$couponModel = D(’Addons://Coupon/AddonCouponMenu’);
$coupon = $couponModel->getPageConditionOrder($p, $num, "id desc");
$this->assign("couponList", $coupon);// 赋值数据集

$count = $couponModel->getCount();// 查询满足要求的总记录数
$Page = new \Think\Page($count, $num);// 实例化分页类 传入总记录数和每页显示的记录数
$Page->setConfig(’theme’, "");
$show = $Page->show();// 分页显示输出
$this->assign(’page’, $show);// 赋值分页输出

$this->display(); // 输出模板
}

public function add()
{
if (IS_POST) {
if (!I("post.name")) {
return;
}

$data = I("post.");
$data[’last_time’] = I(’post.last_time’, ’’, ’strtotime’);
$coupon_id = D(’Addons://Coupon/AddonCouponMenu’)->addCouponMenu($data);

isset($coupon_id) ? $this->success(’添加成功’, ’Admin/Admin/index/addon/Coupon’) : $this->error(’添加失败’, u_addons("Coupon://Admin/Admin/index"));
} else {
$this->display(); // 输出模板
}
}

public function detail()
{
$cdata[’coupon_menu_id’] = I(’get.id’);
$m = M(’AddonCoupon’);
$count = $m->where($cdata)->count(); // 查询满足要求的总记录数
$Page = new \Think\Page ($count, 15); // 实例化分页类 传入总记录数和每页显示的记录数
$Page->setConfig(’theme’, "");
$show = $Page->show(); // 分页显示输出
$detail = $m->where($cdata)->limit($Page->firstRow . ’,’ . $Page->listRows)->select();

$this->assign("page", $show); // 赋值分页输出
$this->assign(’coupon’, $detail);
$this->display();
}

public function export()
{

}

public function del()
{
$cdata[’coupon_menu_id’] = $data[’id’] = I(’get.id’);
$c = M(’AddonCouponMenu’)->where($data)->delete();
$m = M(’AddonCoupon’)->where($cdata)->delete();
if ($c != false && $m != false) {
$this->success(’删除成功’, ’Admin/Admin/index/addon/Coupon’);
} else {
$this->error(’操作失败’, ’Admin/Admin/index/addon/Coupon’);
}
}

public function detail_del()
{
$cdata[’id’] = I(’get.id’);
$m = M(’AddonCoupon’)->where($cdata)->delete();
if ($m != false) {
$this->success(’删除成功’, ’Admin/Admin/index/addon/Coupon’);
} else {
$this->error(’操作失败’, ’Admin/Admin/index/addon/Coupon’);
}
}
}

AddonCouponMenuModel.class.php
namespace Addons\Coupon\Model;

use Think\Model\RelationModel;

class AddonCouponMenuModel extends RelationModel
{
protected $_link = array();

public function getCount()
{
$count = $this->count();
return $count;
}

public function getPageConditionOrder($p = 1, $num = 1, $order)
{
// 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 $_GET[p]获取
$orderList = $this->page($p . ’,’ . $num . ’’)->order($order)->select();
return $orderList;
}

public function addCouponMenu($data)
{
$data[’ctime’] = time();
$number = $data[’num’] = intval($data[’num’]);
$data[’coupon_menu_id’] = $this->add($data);

for ($i = 0; $i < $number; $i++) {
$data[’code’] = rand_code(6);
$code = M(’AddonCoupon’)->where(array(’code’ => $data[’code’]))->find();
if (!isset($code)) {
$coupon_id = M(’AddonCoupon’)->add($data);
} else {
$number = $number + 1;
}
}
return $coupon_id;
}
}
Admin_detail.html


优惠券管理











优惠券管理




































ID 优惠码 金额 状态 截止时间 操作

{$coupon.id}

{$coupon.code}

{$coupon.price}

{$coupon.status}

{:date(’Y-m-d H:i:s’,$coupon[’last_time’])}
href="//m.sbmmt.com/m/faq/{:u_addons(\’Coupon://Admin/Admin/detail_del\’,array(’id’=>$coupon[’id’]))}">删除










代码来源: www.wemallshop.com

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

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。