XyPromoterTwoSubmitAction.class.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 XyPromoterTwoSubmitAction extends CommonAction
  10. {
  11. public function index()
  12. {
  13. $map['pid']=array('gt',0);
  14. $map['status']=array('in','0,2');
  15. if (trim($_REQUEST['name']) != '') {
  16. $map['name'] = array('like', '%' . trim($_REQUEST['name']) . '%');
  17. }
  18. $create_time_2=empty($_REQUEST['create_time_2'])?to_date(get_gmtime(),'Y-m-d'):strim($_REQUEST['create_time_2']);
  19. $create_time_2=to_timespan($create_time_2)+24*3600;
  20. if(trim($_REQUEST['create_time_1'])!='')
  21. {
  22. $map["create_time"] = array('between',array(to_timespan($_REQUEST['create_time_1']),$create_time_2));
  23. }
  24. $user_id = intval($_REQUEST['user_id']);
  25. if($user_id){
  26. $map['user_id'] = array('eq', $user_id);
  27. }
  28. $status = intval($_REQUEST['status']);
  29. if(isset($_REQUEST['status']) && $status >=0){
  30. $map['status'] = array('eq', $status);
  31. }
  32. $parent_name = strim($_REQUEST['parent_name']);
  33. if($parent_name){
  34. $parents=$GLOBALS['db']->getALL("select user_id from ".DB_PREFIX."bm_promoter where name like '%".$parent_name."%' and pid=0");
  35. if($parents){
  36. $parent_ids=array_map('array_shift',$parents);
  37. $map['pid'] = array('in', $parent_ids);
  38. }else{
  39. $map['pid'] = -1;
  40. }
  41. }
  42. if (method_exists($this, '_filter')) {
  43. $this->_filter($map);
  44. }
  45. $name = 'BmPromoter';
  46. $model = M($name);
  47. if (!empty ($model)) {
  48. $this->_list($model, $map);
  49. }
  50. $this->display();
  51. }
  52. public function edit()
  53. {
  54. $id = intval($_REQUEST ['id']);
  55. $condition['id'] = $id;
  56. $vo = M("BmPromoter")->where($condition)->find();
  57. $vo['parent_name'] = M("BmPromoter")->where("user_id=".intval($vo['pid'])."")->getField("name");
  58. $vo['user'] = M("User")->where("id=".intval($vo['user_id'])."")->find();
  59. $this->assign('vo', $vo);
  60. $this->display();
  61. }
  62. public function update()
  63. {
  64. B('FilterString');
  65. $data = M("BmPromoter")->create();
  66. $data_info = M("BmPromoter")->where("id=" . intval($data['id']))->find();
  67. $log_info = $data_info['name'];
  68. if (!$data_info) {
  69. $this->error("请选择审核的推广商");
  70. }
  71. if($data['status'] ==1){
  72. if (!check_empty($data_info['mobile'])) {
  73. $this->error("登录手机号不能为空");
  74. }
  75. if (!check_mobile($data_info['mobile'])) {
  76. $this->error("登录手机号不正确");
  77. }
  78. if (!check_empty(登录手机号['name'])) {
  79. $this->error("推广商名称不能为空");
  80. }
  81. $check_user_info=$this->check_user($data_info['user_id']);
  82. if($check_user_info['status'] ==0){
  83. $this->error($check_user_info['info']);
  84. }
  85. $data['is_effect']=1;
  86. }
  87. if($data['status'] ==2 && $data['memo']==''){
  88. $this->error("请输入备注");
  89. }
  90. // 更新数据
  91. $list = M("BmPromoter")->save($data);
  92. if (false !== $list) {
  93. if($data['status'] ==1){
  94. $GLOBALS['db']->query("update ".DB_PREFIX."bm_promoter set child_count=child_count+1 where id= ".intval($data_info['pid'])."");
  95. }
  96. $this->assign("jumpUrl", u(MODULE_NAME . "/index", array("id" => $data['id'])));
  97. //成功提示
  98. save_log($log_info . L("UPDATE_SUCCESS"), 1);
  99. $this->success(L("UPDATE_SUCCESS"));
  100. } else {
  101. //错误提示
  102. save_log($log_info . L("UPDATE_FAILED"), 0);
  103. $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
  104. }
  105. }
  106. public function foreverdelete() {
  107. //彻底删除指定记录
  108. $ajax = intval($_REQUEST['ajax']);
  109. $id = $_REQUEST ['id'];
  110. if (isset ( $id )) {
  111. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  112. $rel_data = M("BmPromoter")->where($condition)->findAll();
  113. foreach($rel_data as $data)
  114. {
  115. $info[] = $data['adm_name'];
  116. if($data["status"]==1 || $data["pid"]==0)
  117. {
  118. $this->error($data['name']."(ID:".$data["id"].")不能删除",$ajax);
  119. }
  120. }
  121. if($info) $info = implode(",",$info);
  122. $list = M("BmPromoter")->where ( $condition )->delete();
  123. if ($list!==false) {
  124. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  125. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  126. } else {
  127. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  128. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  129. }
  130. } else {
  131. $this->error (l("INVALID_OPERATION"),$ajax);
  132. }
  133. }
  134. //检查绑定会员
  135. public function check_user($user_id)
  136. {
  137. $return=array("status"=>0,"info"=>"");
  138. $user_id=intval($user_id);
  139. //是否有会员
  140. $user_info=$GLOBALS['db']->getRow("select id,bm_pid,is_effect,nick_name,society_id from ".DB_PREFIX."user where id= ".$user_id." ");
  141. if(!$user_info){
  142. $return["status"]=0;
  143. $return["info"]="绑定会员未注册,请注册后再绑定";
  144. return $return;
  145. }
  146. //会员是否有效
  147. if($user_info['is_effect'] ==0){
  148. $return["status"]=0;
  149. $return["info"]="无效的会员";
  150. return $return;
  151. }
  152. //是否是三级推广会员
  153. if($user_info['bm_pid'] >0){
  154. $return["status"]=0;
  155. $return["info"]="该会员已是公会,不能绑定";
  156. return $return;
  157. }
  158. //是否是公会成员
  159. if($user_info['society_id'] >0){
  160. $return["status"]=0;
  161. $return["info"]="该会员已是公会成员,不能绑定";
  162. return $return;
  163. }
  164. //是否已是绑定推广商
  165. $count_promoter=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."bm_promoter where user_id=".intval($user_info['id'])." and status=1");
  166. if($count_promoter >0){
  167. $return["status"]=0;
  168. $return["info"]="该会员被绑定了";
  169. return $return;
  170. }
  171. $return["status"]=1;
  172. return $return;
  173. }
  174. }
  175. ?>