VipRuleAction.class.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 VipRuleAction extends CommonAction{
  10. public function index()
  11. {
  12. parent::index();
  13. }
  14. public function add()
  15. {
  16. $this->assign("new_sort", M(MODULE_NAME)->max("sort")+1);
  17. $this->display();
  18. }
  19. public function edit() {
  20. $id = intval($_REQUEST ['id']);
  21. $condition['id'] = $id;
  22. $vo = M(MODULE_NAME)->where($condition)->find();
  23. $this->assign ( 'vo', $vo );
  24. $this->display ();
  25. }
  26. public function foreverdelete() {
  27. //彻底删除指定记录
  28. $ajax = intval($_REQUEST['ajax']);
  29. $id = $_REQUEST ['id'];
  30. if (isset ( $id )) {
  31. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  32. $list = M(MODULE_NAME)->where ( $condition )->delete();
  33. //更新缓存
  34. clear_auto_cache("vip_rule_list");
  35. load_auto_cache("vip_rule_list");
  36. if ($list!==false) {
  37. save_log(l("FOREVER_DELETE_SUCCESS"),1);
  38. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  39. } else {
  40. save_log(l("FOREVER_DELETE_FAILED"),0);
  41. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  42. }
  43. } else {
  44. $this->error (l("INVALID_OPERATION"),$ajax);
  45. }
  46. }
  47. public function insert() {
  48. B('FilterString');
  49. $ajax = intval($_REQUEST['ajax']);
  50. $data = M(MODULE_NAME)->create ();
  51. //开始验证有效性
  52. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  53. if(!check_empty($data['name']))
  54. {
  55. $this->error("请输入名称");
  56. }
  57. if(!check_empty($data['day_num']))
  58. {
  59. $this->error("请输入天数");
  60. }
  61. if(!(intval($data['day_num'])>0))
  62. {
  63. $this->error("天数必须大于0");
  64. }
  65. if(!check_empty($data['money']))
  66. {
  67. $this->error("请输入价格");
  68. }
  69. if(!(intval($data['money']*100)>0))
  70. {
  71. $this->error("价格必须大于0");
  72. }
  73. if(!check_empty($data['iap_money']))
  74. {
  75. $this->error("请输入苹果支付价格");
  76. }
  77. if(!(intval($data['iap_money']*100)>0))
  78. {
  79. $this->error("苹果支付价格必须大于0");
  80. }
  81. if(!check_empty($data['product_id'])){
  82. $this->error("苹果应用内支付项目ID不能为空");
  83. }
  84. if(M(MODULE_NAME)->where("product_id = '".$data['product_id']."'")->count()>0){
  85. $this->error("苹果应用内支付项目ID已存在");
  86. }
  87. // 更新数据
  88. $list=M(MODULE_NAME)->add($data);
  89. if (false !== $list) {
  90. //更新缓存
  91. clear_auto_cache("vip_rule_list");
  92. load_auto_cache("vip_rule_list");
  93. //成功提示
  94. save_log(L("INSERT_SUCCESS"),1);
  95. $this->success(L("INSERT_SUCCESS"));
  96. } else {
  97. //错误提示
  98. save_log(L("INSERT_FAILED"),0);
  99. $this->error(L("INSERT_FAILED"));
  100. }
  101. }
  102. public function update() {
  103. B('FilterString');
  104. $data = M(MODULE_NAME)->create ();
  105. //开始验证有效性
  106. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  107. if(!check_empty($data['name']))
  108. {
  109. $this->error("请输入名称");
  110. }
  111. if(!check_empty($data['day_num']))
  112. {
  113. $this->error("请输入天数");
  114. }
  115. if(!(intval($data['day_num'])>0))
  116. {
  117. $this->error("天数必须大于0");
  118. }
  119. if(!check_empty($data['money']))
  120. {
  121. $this->error("请输入价格");
  122. }
  123. if(!(intval($data['money']*100)>0))
  124. {
  125. $this->error("价格必须大于0");
  126. }
  127. if(!check_empty($data['iap_money']))
  128. {
  129. $this->error("请输入苹果支付价格");
  130. }
  131. if(!(intval($data['iap_money']*100)>0))
  132. {
  133. $this->error("苹果支付价格必须大于0");
  134. }
  135. if(!check_empty($data['product_id'])){
  136. $this->error("苹果应用内支付项目ID不能为空");
  137. }
  138. $rule_id =$GLOBALS['db']->getOne("select id from ".DB_PREFIX."recharge_rule where product_id = '".$data['product_id']."'");
  139. if($rule_id && $rule_id!=$data['id']){
  140. $this->error("苹果应用内支付项目ID已存在");
  141. }
  142. $list=M(MODULE_NAME)->save ($data);
  143. if (false !== $list) {
  144. //更新缓存
  145. clear_auto_cache("vip_rule_list");
  146. load_auto_cache("vip_rule_list");
  147. //成功提示
  148. save_log(L("UPDATE_SUCCESS"),1);
  149. $this->success(L("UPDATE_SUCCESS"));
  150. } else {
  151. //错误提示
  152. save_log(L("UPDATE_FAILED"),0);
  153. $this->error(L("UPDATE_FAILED"),0,L("UPDATE_FAILED"));
  154. }
  155. }
  156. public function set_sort()
  157. {
  158. $id = intval($_REQUEST['id']);
  159. $sort = intval($_REQUEST['sort']);
  160. if(!check_sort($sort))
  161. {
  162. $this->error(l("SORT_FAILED"),1);
  163. }
  164. M(MODULE_NAME)->where("id=".$id)->setField("sort",$sort);
  165. //更新缓存
  166. clear_auto_cache("vip_rule_list");
  167. load_auto_cache("vip_rule_list");
  168. save_log(l("SORT_SUCCESS"),1);
  169. $this->success(l("SORT_SUCCESS"),1);
  170. }
  171. public function set_effect()
  172. {
  173. $id = intval($_REQUEST['id']);
  174. $ajax = intval($_REQUEST['ajax']);
  175. $info = M(MODULE_NAME)->where("id=".$id)->getField("title");
  176. $c_is_effect = M(MODULE_NAME)->where("id=".$id)->getField("is_effect"); //当前状态
  177. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  178. M(MODULE_NAME)->where("id=".$id)->setField("is_effect",$n_is_effect);
  179. //更新缓存
  180. clear_auto_cache("vip_rule_list");
  181. load_auto_cache("vip_rule_list");
  182. save_log($info.l("SET_EFFECT_".$n_is_effect),1);
  183. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ;
  184. }
  185. }
  186. ?>