VoucherController.class.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * 播播资源
  4. *
  5. * ==========================================================================
  6. * @link https://www.ttbobo.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.ttbobo.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Admin\Model\VoucherModel;
  16. class VoucherController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='优惠券中心';
  20. $this->breadcrumb2='优惠券管理';
  21. }
  22. public function index(){
  23. $model=new VoucherModel();
  24. $data=$model->show_voucher_class_page(SELLERUID);
  25. $this->assign('empty',$data['empty']);// 赋值数据集
  26. $this->assign('list',$data['list']);// 赋值数据集
  27. $this->assign('page',$data['page']);// 赋值分页输出
  28. $this->display();
  29. }
  30. function get_goods_voucher_all()
  31. {
  32. $html = $this->fetch('Voucher:fetch_goods_ajax');
  33. echo json_encode( array('code' => 0 , 'html' => $html) );
  34. die();
  35. }
  36. function add(){
  37. if(IS_POST){
  38. $model=new VoucherModel();
  39. $data=I('post.');
  40. $data['store_id'] = SELLERUID;
  41. if( empty($data['voucher_title']) ) {
  42. $status = array('status'=>'back','message'=>'优惠券名称不能为空');
  43. $this->osc_alert($status);
  44. }
  45. if( empty($data['credit']) ) {
  46. $status = array('status'=>'back','message'=>'优惠券金额不能为空');
  47. $this->osc_alert($status);
  48. }
  49. if( empty($data['total_count']) ) {
  50. $status = array('status'=>'back','message'=>'可领取人数不能为空');
  51. $this->osc_alert($status);
  52. }
  53. $return=$model->add_voucher($data);
  54. $this->osc_alert($return);
  55. die();
  56. }
  57. $this->crumbs='新增';
  58. $this->action=U('Voucher/add');
  59. $this->display('edit');
  60. }
  61. public function voucherlist()
  62. {
  63. $id = I('get.id');
  64. $model=new VoucherModel();
  65. $data=$model->show_voucher_list_page($id);
  66. $voucher_info = M('voucher')->where( array('id' => $id) )->find();
  67. $this->voucher_info = $voucher_info;
  68. $this->assign('empty',$data['empty']);// 赋值数据集
  69. $this->assign('list',$data['list']);// 赋值数据集
  70. $this->assign('page',$data['page']);// 赋值分页输出
  71. $this->display();
  72. }
  73. public function del(){
  74. $id = I('get.id');
  75. $model=new VoucherModel();
  76. $return=$model->del_voucher($id);
  77. $this->osc_alert($return);
  78. }
  79. }
  80. ?>