bonus.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * 红包管理
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class bonusControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. }
  13. public function bonus_typeOp(){
  14. $bonus_type = Model('bonus_type');
  15. $bonus_list = $bonus_type->getAll();
  16. Tpl::output('bonus_list', $bonus_list) ;
  17. $this->show_menu('bonus','bonus_type_list');
  18. Tpl::showpage('bonus.bonus_type_list');
  19. }
  20. public function bonus_type_addOp() {
  21. $this->show_menu('bonus','bonus_type_add');
  22. $this->bonus_form();
  23. }
  24. public function bonus_type_editOp() {
  25. $id = $_GET['id'];
  26. $this->show_menu('type','bonus_type_edit');
  27. $this->bonus_form($id);
  28. }
  29. public function bonus_type_saveOp() {
  30. $type_id = $_POST['type_id'] ? $_POST['type_id'] : 0;
  31. $bonus_value = array(
  32. 'type_name' => $_POST['type_name'],
  33. 'send_type' => $_POST['send_type'],
  34. 'send_start_date' => strtotime(trim($_POST['send_start_date'])),
  35. 'send_end_date' => strtotime(trim($_POST['send_end_date'])),
  36. 'use_start_date' => strtotime(trim($_POST['use_start_date'])),
  37. 'use_end_date' => strtotime(trim($_POST['use_end_date']))
  38. );
  39. $bonus_type = Model('bonus_type');
  40. $bonus_type->save($bonus_value, $type_id);
  41. if(intval($_POST['send_type']) === 1){
  42. $bonus_file = $_FILES['bonus_file'];
  43. if($bonus_file && !empty($bonus_file['name'])){
  44. if ($bonus_file['tmp_name'] == ""){
  45. $this->setError('上传失败,请联系服务器管理员。');
  46. return false;
  47. }
  48. $bonus_file_content = file_get_contents($bonus_file['tmp_name']);
  49. $bonus = Model('user_bonus');
  50. $bonus->loadFile($bonus_file_content);
  51. }
  52. }
  53. $this->bonus_typeOp();
  54. }
  55. private function bonus_form($id = 0){
  56. Tpl::output('id', $id);
  57. if($id > 0){
  58. $bonus_type = Model('bonus_type');
  59. $bonus_type_data = $bonus_type->get($id);
  60. Tpl::output('data', $bonus_type_data[0]);
  61. }
  62. Tpl::showpage('bonus.bonus_type_form');
  63. }
  64. private function show_menu($menu_type,$menu_key=''){
  65. $menu_array = array();
  66. switch ($menu_type) {
  67. case 'bonus':
  68. $menu_array = array(
  69. 1=>array('menu_key'=>'bonus_type_list','menu_name'=>'红包类型列表', 'menu_url'=>'index.php?act=bonus&op=bonus_type'),
  70. 2=>array('menu_key'=>'bonus_type_add','menu_name'=>'添加红包类型', 'menu_url'=>'index.php?act=bonus&op=bonus_type_add'),
  71. );
  72. break;
  73. case 'type':
  74. $menu_array = array(
  75. 1=>array('menu_key'=>'bonus_type_edit','menu_name'=>'编辑红包类型', 'menu_url'=>'index.php?act=bonus&op=bonus_type_edit')
  76. );
  77. break;
  78. }
  79. Tpl::output('menu',$menu_array);
  80. Tpl::output('menu_key',$menu_key);
  81. }
  82. }