IosRechargeRuleAction.class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class IosRechargeRuleAction extends CommonAction{
  10. public function index()
  11. {
  12. parent::index();
  13. }
  14. public function add()
  15. {
  16. $this->display();
  17. }
  18. public function edit() {
  19. $id = intval($_REQUEST ['id']);
  20. $condition['id'] = $id;
  21. $vo = M(MODULE_NAME)->where($condition)->find();
  22. $this->assign ( 'vo', $vo );
  23. $this->display ();
  24. }
  25. public function foreverdelete() {
  26. //彻底删除指定记录
  27. $ajax = intval($_REQUEST['ajax']);
  28. $id = $_REQUEST ['id'];
  29. if (isset ( $id )) {
  30. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  31. $list = M(MODULE_NAME)->where ( $condition )->delete();
  32. if ($list!==false) {
  33. save_log(l("FOREVER_DELETE_SUCCESS"),1);
  34. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  35. } else {
  36. save_log(l("FOREVER_DELETE_FAILED"),0);
  37. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  38. }
  39. } else {
  40. $this->error (l("INVALID_OPERATION"),$ajax);
  41. }
  42. }
  43. public function insert() {
  44. B('FilterString');
  45. $ajax = intval($_REQUEST['ajax']);
  46. $data = M(MODULE_NAME)->create ();
  47. //开始验证有效性
  48. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  49. if(!check_empty($data['diamonds']))
  50. {
  51. $this->error("请输入钻石数量");
  52. }
  53. if(!(intval($data['diamonds'])>0))
  54. {
  55. $this->error("钻石数量必须大于0");
  56. }
  57. if(!check_empty($data['money']))
  58. {
  59. $this->error("请输入价格");
  60. }
  61. if(!(intval($data['money']*100)>0))
  62. {
  63. $this->error("价格必须大于0");
  64. }
  65. if(check_empty($data['gift_diamonds'])&&intval($data['gift_diamonds'])!=0&&!(intval($data['gift_diamonds'])>0))
  66. {
  67. $this->error("价格必须大于0");
  68. }
  69. // 更新数据
  70. $list=M(MODULE_NAME)->add($data);
  71. if (false !== $list) {
  72. //成功提示
  73. save_log(L("INSERT_SUCCESS"),1);
  74. $this->success(L("INSERT_SUCCESS"));
  75. } else {
  76. //错误提示
  77. save_log(L("INSERT_FAILED"),0);
  78. $this->error(L("INSERT_FAILED"));
  79. }
  80. }
  81. public function update() {
  82. B('FilterString');
  83. $data = M(MODULE_NAME)->create ();
  84. //开始验证有效性
  85. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  86. if(!check_empty($data['diamonds']))
  87. {
  88. $this->error("请输入钻石数量");
  89. }
  90. if(!(intval($data['diamonds'])>0))
  91. {
  92. $this->error("钻石数量必须大于0");
  93. }
  94. if(!check_empty($data['money']))
  95. {
  96. $this->error("请输入价格");
  97. }
  98. if(!(intval($data['money']*100)>0))
  99. {
  100. $this->error("价格必须大于0");
  101. }
  102. if(check_empty($data['gift_diamonds'])&&intval($data['gift_diamonds'])!=0&&!(intval($data['gift_diamonds'])>0))
  103. {
  104. $this->error("赠送钻石必须大于0");
  105. }
  106. $list=M(MODULE_NAME)->save ($data);
  107. if (false !== $list) {
  108. //成功提示
  109. save_log(L("UPDATE_SUCCESS"),1);
  110. $this->success(L("UPDATE_SUCCESS"));
  111. } else {
  112. //错误提示
  113. save_log(L("UPDATE_FAILED"),0);
  114. $this->error(L("UPDATE_FAILED"),0,L("UPDATE_FAILED"));
  115. }
  116. }
  117. public function set_sort()
  118. {
  119. $id = intval($_REQUEST['id']);
  120. $sort = intval($_REQUEST['sort']);
  121. if(!check_sort($sort))
  122. {
  123. $this->error(l("SORT_FAILED"),1);
  124. }
  125. M(MODULE_NAME)->where("id=".$id)->setField("sort",$sort);
  126. save_log(l("SORT_SUCCESS"),1);
  127. $this->success(l("SORT_SUCCESS"),1);
  128. }
  129. public function set_effect()
  130. {
  131. $id = intval($_REQUEST['id']);
  132. $ajax = intval($_REQUEST['ajax']);
  133. $info = M(MODULE_NAME)->where("id=".$id)->getField("name");
  134. $c_is_effect = M(MODULE_NAME)->where("id=".$id)->getField("is_effect"); //当前状态
  135. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  136. M(MODULE_NAME)->where("id=".$id)->setField("is_effect",$n_is_effect);
  137. save_log($info.l("SET_EFFECT_".$n_is_effect),1);
  138. clear_auto_cache("get_help_cache");
  139. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ;
  140. }
  141. }
  142. ?>