UserCommonAction.class.php 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  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. //相同操作
  10. class UserCommon extends CommonAction{
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. require_once APP_ROOT_PATH."/system/libs/user.php";
  15. }
  16. public function index($date)
  17. {
  18. if(trim($date['nick_name'])!='')
  19. {
  20. $parameter.= "nick_name like " . urlencode ( '%'.trim($date['nick_name']).'%' ) . "&";
  21. $sql_w .= "nick_name like '%".trim($date['nick_name'])."%' and ";
  22. }
  23. if(trim($date['mobile'])!='')
  24. {
  25. $parameter.= "mobile like " . urlencode ( '%'.trim($date['mobile']).'%' ) . "&";
  26. $sql_w .= "mobile like '%".trim($date['mobile'])."%' and ";
  27. }
  28. $create_time_2=empty($_REQUEST['create_time_2'])?to_date(get_gmtime(),'Y-m-d'):strim($date['create_time_2']);
  29. $create_time_2=to_timespan($create_time_2)+24*3600;
  30. if(trim($date['create_time_1'])!='' )
  31. {
  32. $parameter.="create_time between '". to_timespan($date['create_time_1']) . "' and '". $create_time_2 ."'&";
  33. $sql_w .=" (create_time between '". to_timespan($date['create_time_1']). "' and '". $create_time_2 ."' ) and ";
  34. }
  35. if(intval($date['id'])>0)
  36. {
  37. $parameter.= "id=" . intval($date['id']). "&";
  38. $sql_w .= "id=".intval($date['id'])." and ";
  39. }
  40. if($date['is_effect']!=NULL){
  41. $parameter.= "is_effect=" . intval($date['is_effect']). "&";
  42. $sql_w .= "is_effect=".intval($date['is_effect'])." and ";
  43. }else{
  44. $parameter.= "is_effect=1&";
  45. $sql_w .= "is_effect=1 and ";
  46. }
  47. if($_REQUEST['is_admin']!='')
  48. {
  49. $parameter.= "is_admin=" . intval($date['is_admin']). "&";
  50. $sql_w .= "is_admin=".intval($date['is_admin'])." and ";
  51. }
  52. if (!isset($_REQUEST['is_authentication'])) {
  53. $_REQUEST['is_authentication'] = -1;
  54. }
  55. if($_REQUEST['is_authentication']!=-1) {
  56. if (isset($date['is_authentication'])) {
  57. $parameter .= "is_authentication in (" . $date['is_authentication'] . ")&";
  58. $sql_w .= "is_authentication in (" . $date['is_authentication'] . ") and ";
  59. }
  60. }
  61. if(isset($date['is_robot'])){
  62. $parameter.= "is_robot=" . intval($date['is_robot']). "&";
  63. $sql_w .= "is_robot=".intval($date['is_robot'])." and ";
  64. }else{
  65. $parameter.= "is_robot=0&";
  66. $sql_w .= "is_robot=0 and ";
  67. }
  68. $m_config = load_auto_cache("m_config");//初始化手机端配置
  69. if(defined('OPEN_VIP')&&OPEN_VIP==1){
  70. if($_REQUEST['is_vip']!='')
  71. {
  72. $parameter.= "is_vip=" . intval($date['is_vip']). "&";
  73. $sql_w .= "is_vip=".intval($date['is_vip'])." and ";
  74. }
  75. $this->assign ( 'open_vip', 1 );
  76. }
  77. $model = D ();
  78. $m_config = load_auto_cache("m_config");
  79. $ote = floatval($m_config['onlinetime_to_experience']);
  80. $sql_str = "SELECT *," .
  81. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  82. " FROM ".DB_PREFIX."user WHERE 1=1 ";
  83. $count_sql = "SELECT count(*) as tpcount" .
  84. " FROM ".DB_PREFIX."user WHERE (1=1 ";
  85. if(intval($date['id']) == 0){
  86. $sql_str .= " and ".$sql_w." 1=1 ";
  87. $count_sql .= " and ".$sql_w." 1=1) ";
  88. }else{
  89. $sql_str .= " and ".$sql_w." 1=1 union SELECT *," .
  90. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  91. " FROM ".DB_PREFIX."user WHERE luck_num=".$date['id'];
  92. $count_sql .= " and ".$sql_w." 1=1 ) or (luck_num=".$date['id'].")";
  93. }
  94. $distribution_log = 0;
  95. if(defined('OPEN_DISTRIBUTION') && OPEN_DISTRIBUTION==1){
  96. $distribution_log = 1;
  97. }
  98. $coins = 0;
  99. if(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE==1){
  100. $coins = 1;
  101. }
  102. $goods = 0;
  103. if((defined('SHOPPING_GOODS') && SHOPPING_GOODS==1) || (defined('PAI_REAL_BTN') && PAI_REAL_BTN==1)){
  104. $goods = 1;
  105. }
  106. $voList = $this->_Sql_list($model, $sql_str, "&".$parameter,'id',0,$count_sql);
  107. foreach($voList as $k=>$v){
  108. $voList[$k]['nick_name'] = emoji_decode($v['nick_name']);
  109. $voList[$k]['head_image'] = get_spec_image($v['head_image']);
  110. $voList[$k]['distribution_log'] = $distribution_log;
  111. $voList[$k]['coins'] = $coins;
  112. $voList[$k]['goods'] = $goods;
  113. $voList[$k]['ticket'] = $v['ticket']+$v['no_ticket'];
  114. }
  115. $this->assign ( 'list', $voList );
  116. $this->display ();
  117. }
  118. public function add(){
  119. $region_lv2 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where region_level = 2 order by py asc"); //二级地址
  120. $this->assign("region_lv2",$region_lv2);
  121. //会员等级信息
  122. $user_level = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_level order by level ASC");
  123. $this->assign("user_level",$user_level);
  124. //认证类型
  125. $authent_list = M("AuthentList")->findAll();
  126. $this->assign("authent_list",$authent_list);
  127. //分类
  128. $classifi_list = M("VideoClassified")->findAll();
  129. $this->assign("classifi_list",$classifi_list);
  130. $this->display ();
  131. }
  132. public function insert(){
  133. B('FilterString');
  134. $ajax = intval($_REQUEST['ajax']);
  135. $data = M(MODULE_NAME)->create ();
  136. //开始验证有效性
  137. $this->assign("jumpUrl",u(MODULE_NAME."/add"));
  138. if($_REQUEST['v_explain']==''){
  139. $_REQUEST['v_explain'] = $_REQUEST['authentication_type'];
  140. }
  141. $_REQUEST['v_icon'] = get_spec_image(M('AuthentList')->where("name='".trim($_REQUEST['authentication_type']."'"))->getField("icon"));
  142. $_REQUEST['score'] = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where `level`=".$_REQUEST['user_level'],true,true);
  143. $res = save_user($_REQUEST,'INSERT',$update_status=1);
  144. if($res['status']==0)
  145. {
  146. $error_field = $res['data'];
  147. if($error_field['error'] == EMPTY_ERROR)
  148. {
  149. if($error_field['field_name'] == 'user_name')
  150. {
  151. $this->error(L("USER_NAME_EMPTY_TIP"));
  152. }
  153. elseif($error_field['field_name'] == 'email')
  154. {
  155. $this->error(L("USER_EMAIL_EMPTY_TIP"));
  156. }
  157. else
  158. {
  159. $this->error(sprintf(L("USER_EMPTY_ERROR"),$error_field['field_show_name']));
  160. }
  161. }
  162. if($error_field['error'] == FORMAT_ERROR)
  163. {
  164. if($error_field['field_name'] == 'email')
  165. {
  166. $this->error(L("USER_EMAIL_FORMAT_TIP"));
  167. }
  168. elseif($error_field['field_name'] == 'mobile')
  169. {
  170. $this->error(L("USER_MOBILE_FORMAT_TIP"));
  171. }
  172. }
  173. if($error_field['error'] == EXIST_ERROR)
  174. {
  175. if($error_field['field_name'] == 'user_name')
  176. {
  177. $this->error(L("USER_NAME_EXIST_TIP"));
  178. }
  179. elseif($error_field['field_name'] == 'email')
  180. {
  181. $this->error(L("USER_EMAIL_EXIST_TIP"));
  182. }
  183. elseif($error_field['field_name'] == 'mobile')
  184. {
  185. $this->error(L("USER_MOBILE_EXIST_TIP"));
  186. }
  187. }
  188. }
  189. $user_id = intval($res['user_id']);
  190. // 更新数据
  191. $log_info = $_REQUEST['nick_name'];
  192. save_log($log_info.L("INSERT_SUCCESS"),1);
  193. $this->success(L("INSERT_SUCCESS"));
  194. }
  195. public function edit($date) {
  196. $id = intval($date['id']);
  197. $condition['id'] = $id;
  198. $vo = M('User')->where($condition)->find();
  199. $vo['ban_time'] = $vo['ban_time']>0?to_date($vo['ban_time']):'';
  200. $vo['create_time'] = $vo['create_time']>0?to_date($vo['create_time']):'';
  201. $vo['nick_name'] = emoji_decode($vo['nick_name']);
  202. $vo['signature'] = emoji_decode($vo['signature']);
  203. $m_config = load_auto_cache("m_config");//初始化手机端配置
  204. if(defined('OPEN_VIP')&&OPEN_VIP==1){
  205. $this->assign ( 'open_vip', 1 );
  206. $vip_expire_time = $vo['vip_expire_time'];
  207. $vo['vip_expire_time'] = '';
  208. if(intval($vo['is_vip'])==1){
  209. $vo['vip_expire_time'] = $vip_expire_time>0?to_date($vip_expire_time):'';
  210. if($vip_expire_time>0 && $vip_expire_time<NOW_TIME){
  211. $vo['is_vip'] = 0;
  212. $vo['vip_expire_time'] = '';
  213. $sql = "update ".DB_PREFIX."user set is_vip = 0 where id = ".$id;
  214. $GLOBALS['db']->query($sql);
  215. user_deal_to_reids(array($id));
  216. }
  217. }
  218. }
  219. if(defined('OPEN_DISTRIBUTION') && OPEN_DISTRIBUTION == 1){
  220. $this->assign('open_distribution',1);
  221. }
  222. $user_level = $GLOBALS['db']->getOne("select user_level from ".DB_PREFIX."user where id = ".$id); //二级地址
  223. $vo['user_level'] = $user_level>0?$user_level:1;
  224. //过滤头像是本地连接的问题
  225. $vo['head_image'] = get_spec_image($vo['head_image'],50,50);
  226. $this->assign ( 'vo', $vo );
  227. $region_pid = 0;
  228. $region_lv2 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where region_level = 2 order by py asc"); //二级地址
  229. foreach($region_lv2 as $k=>$v)
  230. {
  231. if($v['name'] == $vo['province'])
  232. {
  233. $region_lv2[$k]['selected'] = 1;
  234. $region_pid = $region_lv2[$k]['id'];
  235. break;
  236. }
  237. }
  238. $this->assign("region_lv2",$region_lv2);
  239. if($region_pid>0)
  240. {
  241. $region_lv3 = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."region_conf where pid = ".$region_pid." order by py asc"); //三级地址
  242. foreach($region_lv3 as $k=>$v)
  243. {
  244. if($v['name'] == $vo['city'])
  245. {
  246. $region_lv3[$k]['selected'] = 1;
  247. break;
  248. }
  249. }
  250. $this->assign("region_lv3",$region_lv3);
  251. }
  252. //会员等级信息
  253. $user_level = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_level where `level`>=".$user_level." order by level ASC");
  254. $this->assign("user_level",$user_level);
  255. //认证类型
  256. $authent_list = M("AuthentList")->findAll();
  257. $this->assign("authent_list",$authent_list);
  258. //分类
  259. $classifi_list = M("VideoClassified")->findAll();
  260. $this->assign("classified_id",$classifi_list);
  261. if (defined('OPEN_EDU_MODULE') && OPEN_EDU_MODULE == 1) {
  262. if ($vo['authentication_type'] == '教师') {
  263. $teacher = M('EduTeacher')->where(array('user_id' => $vo['id']))->find();
  264. $this->assign('teaching_certificate', get_spec_image($teacher['teaching_certificate']));
  265. $this->assign('education_certificate', get_spec_image($teacher['education_certificate']));
  266. } elseif ($vo['authentication_type'] == '机构') {
  267. $org = M('EduOrg')->where(array('user_id' => $vo['id']))->find();
  268. $this->assign('business_license', get_spec_image($org['business_license']));
  269. }
  270. }
  271. //是否显示身份证号码
  272. $show_identify_number = intval($m_config['is_show_identify_number']);
  273. //①用户认证状态为非默认状态(未认证) AND 身份证号码为空, 则不显示身份证号码
  274. if(intval($vo['is_authentication'])!=0 && trim($vo['identify_number'])==''){
  275. $show_identify_number = 0;
  276. }
  277. // //②用户认证状态为未通过(3)状态 AND 需要身份验证, 则显示身份验证
  278. // if(intval($vo['is_authentication'])==3 && intval($m_config['is_show_identify_number'])==1){
  279. // $show_identify_number = 1;
  280. // }
  281. $this->assign('show_identify_number',$show_identify_number);
  282. //家族列表 ljz
  283. if((defined('OPEN_FAMILY_JOIN')&&OPEN_FAMILY_JOIN==1)){
  284. $family = $GLOBALS['db']->getAll("select name,id,user_id from " . DB_PREFIX . "family");
  285. $family_bj = 0;//标记位,记录是否是族长
  286. //判断该成员是否是族长
  287. foreach ($family as $key => $val){
  288. if($id == $val['user_id']){
  289. $family = array();
  290. $family[] = array('id' => $val['id'],'name' => $val['name']);
  291. $family_bj = 1;
  292. }
  293. }
  294. if($family_bj == 0){
  295. $family = $GLOBALS['db']->getAll("select name,id,user_id,status from " . DB_PREFIX . "family where status=1");
  296. }
  297. $this->assign('family',$family);
  298. }else{
  299. $family = 0;
  300. $this->assign('family',$family);
  301. }
  302. //是否显示公会邀请码ljz
  303. if(defined('OPEN_SOCIETY_MODULE') && OPEN_SOCIETY_MODULE && $m_config['society_pattern'] != 0 && $m_config['open_society_code'] == 1 && $vo['society_id'] == 0){
  304. $this->assign('open_society_code',1);
  305. }else{
  306. $this->assign('open_society_code',0);
  307. }
  308. $this->display ();
  309. }
  310. //删除
  311. public function delete($data) {
  312. //彻底删除指定记录
  313. $ajax = intval($data['ajax']);
  314. $id = $data ['id'];
  315. if (isset ( $id )) {
  316. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  317. $rel_data = M('User')->where($condition)->findAll();
  318. foreach($rel_data as $data)
  319. {
  320. $info[] = $data['user_name'];
  321. }
  322. if($info) $info = implode(",",$info);
  323. $ids = explode ( ',', $id );
  324. foreach($ids as $uid)
  325. {
  326. delete_user($uid);
  327. }
  328. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  329. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  330. } else {
  331. $this->error (l("INVALID_OPERATION"),$ajax);
  332. }
  333. }
  334. public function update() {
  335. B('FilterString');
  336. $data = M('User')->create ();
  337. //开始验证有效性
  338. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  339. $old_user_info = M('User')->where("id=".$data['id'])->find();
  340. //app和admin共用user.php的save_user方法,后台update是没有验证码的,所以save_user设置标示字段$update_status
  341. $user_info=$GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".intval($data['id']));
  342. /*if($user_info['user_level'] != $data['user_level']){
  343. //require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  344. //require_once(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  345. //$user_redis = new UserRedisService();
  346. $score = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where `level` = ".$data['user_level']);
  347. //$online_time = $user_redis->getOne_db($data['id'],'online_time');
  348. //$online_time = intval($online_time)>0?intval($online_time):0;
  349. //$score = $score - floor($online_time/app_conf('ONLINETIME_TO_EXPERIENCE'));
  350. $user_info['score'] = $score;
  351. }*/
  352. if($user_info['login_type'] == 2 && empty($data['mobile'])){
  353. $this->error('手机注册用户,手机号不能为空');
  354. }else{
  355. if($data['mobile']!=''){
  356. if($GLOBALS['db']->getOne("select id from ".DB_PREFIX."user where id<>".$data['id']." and mobile=".$data['mobile'])){
  357. $this->error('该手机号已经被使用过');
  358. }else{
  359. $user_info['mobile'] = $data['mobile'];
  360. }
  361. }
  362. }
  363. $user_info['user_level'] = $data['user_level'];
  364. if($data['v_explain']==''){
  365. $data['v_explain'] = $data['authentication_type'];
  366. }
  367. $data['v_icon'] = get_spec_image(M('AuthentList')->where("name='".trim($data['authentication_type']."'"))->getField("icon"));
  368. $data['authent_list_id'] = get_spec_image(M('AuthentList')->where("name='".trim($data['authentication_type']."'"))->getField("id"));
  369. $data['nick_name'] = emoji_encode($data['nick_name'] );
  370. if($data['nick_name']&&$GLOBALS['db']->getOne("SELECT nick_name FROM ".DB_PREFIX."user WHERE id<>".$data['id']." and nick_name ='".$data['nick_name']."'"))
  371. {
  372. $this->error('昵称被占用,请重新输入');
  373. }
  374. $data['signature'] = emoji_encode($data['signature'] );
  375. $user_info = array_merge($user_info,$data);
  376. if (defined('GAME_DISTRIBUTION') && GAME_DISTRIBUTION == 1) {
  377. if($user_info['id'] == $user_info['game_distribution_id']){
  378. $this->error('推荐人不能为自己');
  379. }
  380. if ($user_info['game_distribution_id']) {
  381. $distribution = M('User')->where(['id'=>$user_info['game_distribution_id']])->find();
  382. if (!$distribution) {
  383. $this->error('推荐人ID不存在');
  384. }
  385. }
  386. }
  387. //2.5版本 将禁播信息加入禁播表
  388. if(intval($data['is_ban'])==1){
  389. $ban_data['user_id'] = $data['id'];
  390. $ban_data['ban_type'] = $data['ban_type'];
  391. $ban_data['ban_ip'] = $user_info['login_ip'];
  392. $ban_data['apns_code'] = $user_info['apns_code'];
  393. $ban_data['ban_time'] = NOW_TIME;
  394. $GLOBALS['db']->query("delete from ".DB_PREFIX."ban_list where user_id=".$data['id']);
  395. $GLOBALS['db']->autoExecute(DB_PREFIX."ban_list", $ban_data,'INSERT');
  396. }else {
  397. $GLOBALS['db']->query("delete from ".DB_PREFIX."ban_list where user_id=".$data['id']);
  398. $user_info['ban_type'] = 0;
  399. }
  400. if ($data['is_authentication'] == 3) {
  401. $m_config = load_auto_cache("m_config");
  402. $user_info['v_explain'] = '';
  403. $user_info['v_icon'] = '';
  404. $user_info['investor_time'] = get_gmtime() + $m_config['attestation_time'];
  405. }
  406. $res = save_user($user_info,'UPDATE',$update_status=0);
  407. if($res['status']==0)
  408. {
  409. $error_field = $res['data'];
  410. if($error_field['error'] == EMPTY_ERROR)
  411. {
  412. if($error_field['field_name'] == 'user_name')
  413. {
  414. $this->error(L("USER_NAME_EMPTY_TIP"));
  415. }
  416. elseif($error_field['field_name'] == 'email')
  417. {
  418. $this->error(L("USER_EMAIL_EMPTY_TIP"));
  419. }
  420. else
  421. {
  422. $this->error(sprintf(L("USER_EMPTY_ERROR"),$error_field['field_show_name']));
  423. }
  424. }elseif($error_field['error'] == FORMAT_ERROR)
  425. {
  426. if($error_field['field_name'] == 'email')
  427. {
  428. $this->error(L("USER_EMAIL_FORMAT_TIP"));
  429. }
  430. if($error_field['field_name'] == 'mobile')
  431. {
  432. $this->error(L("USER_MOBILE_FORMAT_TIP"));
  433. }
  434. }elseif($error_field['error'] == EXIST_ERROR)
  435. {
  436. if($error_field['field_name'] == 'user_name')
  437. {
  438. $this->error(L("USER_NAME_EXIST_TIP"));
  439. }
  440. if($error_field['field_name'] == 'email')
  441. {
  442. $this->error(L("USER_EMAIL_EXIST_TIP"));
  443. }
  444. if($error_field['field_name'] == 'mobile')
  445. {
  446. $this->error(L("USER_MOBILE_EXIST_TIP"));
  447. }
  448. }else{
  449. $this->error($res['error']);
  450. }
  451. }
  452. //开始更新is_effect状态
  453. M("User")->where("id=".intval($data['id']))->setField("is_effect",intval($data['is_effect']));
  454. $user_id = intval($data['id']);
  455. $log_info = '';
  456. if($data['user_level']!=$old_user_info['user_level']){
  457. $log_info .=" 等级从".$old_user_info['user_level']."级变为".$data['user_level']."级";
  458. }
  459. if($data['is_authentication']!=$old_user_info['is_authentication']){
  460. $log_info .=" 认证状态从".$this->get_authentication($old_user_info['is_authentication'])."变为".$this->get_authentication($data['is_authentication']);
  461. }
  462. //工会邀请码,认证通过自动添加公会ljz
  463. if(defined('OPEN_SOCIETY_MODULE') && OPEN_SOCIETY_MODULE){
  464. $m_config = load_auto_cache("m_config");
  465. if($m_config['society_pattern'] != 0 && $m_config['open_society_code'] == 1 && strlen($data['society_code']) > 0){
  466. if($data['is_authentication'] == 2){
  467. //查询用户是否已经有公会
  468. if($old_user_info['society_id'] > 0){
  469. $GLOBALS['db']->query("update ".DB_PREFIX."user set society_code=null where id=".$old_user_info['id']);
  470. $this->error('抱歉你已有公会,公会邀请码失效');
  471. }else{
  472. //查询邀请码对应的公会
  473. $society_id = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."society where status=1 and society_code='".$data['society_code']."'");
  474. if(!empty($society_id)){
  475. $oTime = time();//获取当前时间戳
  476. //$GLOBALS['db']->query("update ".DB_PREFIX."user set society_id=".$society_id." where id=".$old_user_info['id']);
  477. //$GLOBALS['db']->query("delete from " . DB_PREFIX . "society_apply where society_id=".$society_id." and apply_type=0 and user_id=".$old_user_info['id']);
  478. //$GLOBALS['db']->autoExecute(DB_PREFIX . 'society_apply',array('society_id'=>$society_id,'user_id'=>$old_user_info['id'],'create_time'=>$oTime,'apply_type'=>0,'status'=>0));
  479. $res1 = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."society_apply where user_id=".$old_user_info['id']." and society_id=".$society_id);
  480. if(empty($res1)){
  481. $GLOBALS['db']->autoExecute(DB_PREFIX . 'society_apply',array('society_id'=>$society_id,'user_id'=>$old_user_info['id'],'create_time'=>$oTime,'apply_type'=>0,'status'=>0));
  482. }
  483. }else{
  484. $GLOBALS['db']->query("update ".DB_PREFIX."user set society_code=null where id=".$old_user_info['id']);
  485. $this->error('公会邀请码不存在');
  486. }
  487. }
  488. }elseif($data['is_authentication'] == 3 || $data['is_authentication'] == 0){
  489. $GLOBALS['db']->query("update ".DB_PREFIX."user set society_code=null where id=".$old_user_info['id']);
  490. }
  491. }else{
  492. $GLOBALS['db']->query("update ".DB_PREFIX."user set society_code=null where id=".$old_user_info['id']);
  493. }
  494. }
  495. //家族指定ljz
  496. if((defined('OPEN_FAMILY_JOIN')&&OPEN_FAMILY_JOIN==1)){
  497. $family_id = intval($_REQUEST['family']);//家族ID 用户ID $data['id']
  498. //判断是否是族长
  499. $res = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "family where user_id=".$data['id']);
  500. if(empty($res)){//不是族长
  501. $GLOBALS['db']->autoExecute(DB_PREFIX . "user", array('family_id' => $family_id,'family_chieftain' => 0), 'UPDATE', "id=".$user_id);
  502. }else{
  503. $GLOBALS['db']->autoExecute(DB_PREFIX . "user", array('family_id' => $family_id,'family_chieftain' => 1), 'UPDATE', "id=".$user_id);
  504. }
  505. }
  506. if (defined('OPEN_EDU_MODULE') && OPEN_EDU_MODULE == 1) {
  507. if ($data['authentication_type'] == '教师') {
  508. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", array('is_effect' => 0), "UPDATE",
  509. "user_id=" . $data['id']);
  510. $teacher = M('EduTeacher')->create();
  511. $teacher_info = array_merge(array(
  512. 'user_id' => $data['id'],
  513. 'title' => $data['authentication_name'],
  514. 'teaching_certificate' => $teacher['teaching_certificate'],
  515. 'education_certificate' => $teacher['education_certificate'],
  516. 'is_effect' => $data['is_authentication'] == 2 ? 1: 0,
  517. ));
  518. if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "edu_teacher where user_id=" . $data['id']) > 0) {
  519. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", $teacher_info, "UPDATE",
  520. "user_id=" . $data['id']);
  521. } else {
  522. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", $teacher_info);
  523. }
  524. } elseif ($data['authentication_type'] == '机构') {
  525. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", array('is_effect' => 0), "UPDATE",
  526. "user_id=" . $data['id']);
  527. $org = M('EduOrg')->create();
  528. $org_info = array_merge(array(
  529. 'user_id' => $data['id'],
  530. 'title' => $data['authentication_name'],
  531. 'business_license' => $org['business_license'],
  532. 'is_effect' => $data['is_authentication'] == 2 ? 1 : 0,
  533. ));
  534. if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "edu_org where user_id=" . $data['id']) > 0) {
  535. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", $org_info, "UPDATE", "user_id=" . $data['id']);
  536. } else {
  537. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", $org_info);
  538. }
  539. } else {
  540. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_teacher", array('is_effect' => 0), "UPDATE",
  541. "user_id=" . $data['id']);
  542. $GLOBALS['db']->autoExecute(DB_PREFIX . "edu_org", array('is_effect' => 0), "UPDATE",
  543. "user_id=" . $data['id']);
  544. }
  545. }
  546. user_deal_to_reids(array(intval($data['id'])));
  547. save_log($user_id.L("UPDATE_SUCCESS").$log_info,1);
  548. $this->success(L("UPDATE_SUCCESS"));
  549. }
  550. public function get_authentication($is_authentication){
  551. switch($is_authentication){
  552. case 1:
  553. return "待审核";
  554. break;
  555. case 2:
  556. return "已认证";
  557. break;
  558. case 3:
  559. return "认证不通过";
  560. break;
  561. default:
  562. return "未认证";
  563. }
  564. }
  565. //设置状态
  566. public function set_effect($data)
  567. {
  568. $id = intval($data['id']);
  569. $ajax = intval($data['ajax']);
  570. $user_info = M("User")->getById($id);
  571. $c_is_effect = M("User")->where("id=".$id)->getField("is_effect"); //当前状态
  572. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  573. $result=M("User")->where("id=".$id)->setField("is_effect",$n_is_effect);
  574. $user_data = array();
  575. if($result){
  576. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  577. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  578. $user_redis = new UserRedisService();
  579. $user_data['is_effect'] = $n_is_effect;
  580. $user_redis->update_db($id, $user_data);
  581. }
  582. save_log($user_info['nick_name'].l("SET_EFFECT_".$n_is_effect),1);
  583. clear_auto_cache('charm_podcast');
  584. clear_auto_cache('newstar_rank');
  585. clear_auto_cache('rich_list');
  586. clear_auto_cache('rank_consumption');
  587. clear_auto_cache('rank_contribution');
  588. return $n_is_effect;
  589. }
  590. //设置永久禁播状态
  591. public function set_ban($data)
  592. {
  593. $id = intval($data['id']);
  594. $ajax = intval($data['ajax']);
  595. $user_info = M("User")->getById($id);
  596. $c_is_effect = M("User")->where("id=".$id)->getField("is_ban"); //当前状态
  597. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  598. $result=M("User")->where("id=".$id)->setField("is_ban",$n_is_effect);
  599. $user_data = array();
  600. if($result){
  601. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  602. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  603. $user_redis = new UserRedisService();
  604. $user_data['is_ban'] = $n_is_effect;
  605. $user_redis->update_db($id, $user_data);
  606. if($n_is_effect==0){
  607. $GLOBALS['db']->query("delete from ".DB_PREFIX."ban_list where user_id=".$id);
  608. $GLOBALS['db']->query("update ".DB_PREFIX."user set ban_type=0 where id=".$id);
  609. }
  610. }
  611. save_log($user_info['nick_name'].l("SET_BAN_".$n_is_effect),1);
  612. return $n_is_effect;
  613. }
  614. //设置禁热门状态
  615. public function set_hot_on($data){
  616. $id = intval($data['id']);
  617. $ajax = intval($data['ajax']);
  618. $user_info = M("User")->getById($id);
  619. $c_is_effect = M("User")->where("id=".$id)->getField("is_hot_on"); //当前状态
  620. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  621. $result=M("User")->where("id=".$id)->setField("is_hot_on",$n_is_effect);
  622. $user_data = array();
  623. if($result){
  624. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  625. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  626. $user_redis = new UserRedisService();
  627. $user_data['is_hot_on'] = $n_is_effect;
  628. $user_redis->update_db($id, $user_data);
  629. }
  630. save_log($user_info['nick_name'].l("SET_HOT_ON_".$n_is_effect),1);
  631. return $n_is_effect;
  632. }
  633. //新增关注
  634. public function add_focus($data){
  635. $user_id = intval($data['user_id']);
  636. $user = M('User')->where("id=".$user_id)->find();
  637. $user['nick_name'] = emoji_decode($user['nick_name']);
  638. $this->assign("user",$user);
  639. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  640. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  641. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  642. $now=get_gmtime();
  643. if(trim($data['nick_name'])!='')
  644. {
  645. $map[DB_PREFIX.'user.nick_name'] = array('like','%'.trim($data['nick_name']).'%');
  646. }
  647. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  648. $create_time_2=to_timespan($create_time_2)+24*3600;
  649. if(trim($data['create_time_1'])!='' )
  650. {
  651. $map[DB_PREFIX.'user.create_time'] = array('between',array(to_timespan($data['create_time_1']),$create_time_2));
  652. }
  653. if(intval($data['id'])>0)
  654. {
  655. $map[DB_PREFIX.'user.id'] = intval($data['id']);
  656. }else{
  657. $users = array();
  658. $user_redis = new UserFollwRedisService($user_id);
  659. $fans = $user_redis->get_follonging_user($user_id,1,100);
  660. foreach($fans as $k=>$v){
  661. $users[] = $v['user_id'];
  662. }
  663. $users[] = $user_id;
  664. if($users){
  665. $map[DB_PREFIX.'user.id'] = array('not in',$users);
  666. }
  667. }
  668. $map[DB_PREFIX.'user.is_effect'] = 1;
  669. if (method_exists ( $this, '_filter' )) {
  670. $this->_filter ( $map );
  671. }
  672. $model = D ('User');
  673. if (! empty ( $model )) {
  674. $this->_list ( $model, $map );
  675. }
  676. $list = $this->get("list");
  677. foreach($list as $k=>$v){
  678. $user_id = intval($v['id']);
  679. $user_redis = new UserRedisService();
  680. $user_info = $user_redis->getRow_db($user_id,array('diamonds','use_diamonds','ticket','score','user_level'));
  681. $list[$k]['diamonds'] = $user_info['diamonds']>0?$user_info['diamonds']:0;
  682. $list[$k]['use_diamonds'] = $user_info['use_diamonds']>0?$user_info['use_diamonds']:0;
  683. $list[$k]['ticket'] = $user_info['ticket']>0?$user_info['ticket']:0;
  684. $list[$k]['score'] = $user_info['score']>0?$user_info['score']:0;
  685. $list[$k]['user_level'] = $user_info['user_level']>0?$user_info['user_level']:1;
  686. $userfollw_redis = new UserFollwRedisService($user_id);
  687. $fans_count = $userfollw_redis->follower_count();
  688. $focus_count = $userfollw_redis->follow_count();
  689. $list[$k]['focus_count'] = $focus_count>0?$focus_count:0;
  690. $list[$k]['fans_count'] = $fans_count>0?$fans_count:0;
  691. }
  692. $this->assign ( 'list', $list );
  693. $this->assign ( 'module_name', MODULE_NAME );
  694. $this->display("UserCommon:add_focus");
  695. }
  696. //新增关注
  697. public function set_follow($data){
  698. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  699. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  700. $id = $data ['id'];
  701. $user_id = $data['user_id'];
  702. if (isset ( $id )) {
  703. $info_success = array();
  704. $focus_user = explode(',',$id);
  705. foreach($focus_user as $v)
  706. {
  707. $deal_id = $user_id;
  708. if($user_id!=$v){
  709. $root = redis_set_follow($user_id,$v);
  710. if($root['status']==1){
  711. $info_success[] = $v;
  712. }else{
  713. $info[] = $v;
  714. }
  715. }
  716. }
  717. if($info) $info = implode(",",$info);
  718. $info = "用户ID".$deal_id."新增关注:".$info;
  719. if($info_success) $success_str = implode(",",$info_success);
  720. $success_str = "用户ID".$deal_id."新增关注:".$success_str;
  721. if (sizeof($info_success)) {
  722. save_log($success_str.l("INSERT_SUCCESS"),1);
  723. $root['status'] = 1;
  724. $root['info'] = '新增成功!';
  725. admin_ajax_return($root);
  726. } else {
  727. save_log($info.l("INSERT_FAILED"),0);
  728. $root['status'] = 0;
  729. $root['info'] = '新增失败!';
  730. admin_ajax_return($root);
  731. }
  732. } else {
  733. return false;
  734. }
  735. }
  736. //关注列表
  737. public function focus_list($data,$page=0){
  738. $user_id = intval($data['id']);
  739. $user = M("User")->getById($user_id);
  740. $user['nick_name'] = emoji_decode($user['nick_name']);
  741. $this->assign("user",$user);
  742. if($user)
  743. {
  744. $page = intval($_REQUEST['p']);
  745. if($page<=0)
  746. $page = 1;
  747. $map['user_id'] = $user['id'];
  748. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  749. $redisCommon = new Ridescommon();
  750. $redis = $redisCommon->video_follw_list($map['user_id'],0,$page);
  751. $model = D ("Focus");
  752. if (! empty ( $model )) {
  753. $this->_list ( $model, $map,'','',1,$redis);
  754. }
  755. }
  756. $this->display("UserCommon:focus_list");
  757. }
  758. //新增粉丝
  759. public function add_fans($data){
  760. $user_id = intval($data['user_id']);
  761. $user = M('User')->where("id=".$user_id)->find();
  762. $user['nick_name'] = emoji_decode($user['nick_name']);
  763. $this->assign("user",$user);
  764. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  765. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  766. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  767. $now=get_gmtime();
  768. if(trim($data['nick_name'])!='')
  769. {
  770. $map[DB_PREFIX.'user.nick_name'] = array('like','%'.trim($data['nick_name']).'%');
  771. }
  772. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  773. $create_time_2=to_timespan($create_time_2)+24*3600;
  774. if(trim($data['create_time_1'])!='' )
  775. {
  776. $map[DB_PREFIX.'user.create_time'] = array('between',array(to_timespan($data['create_time_1']),$create_time_2));
  777. }
  778. if(intval($data['id'])>0)
  779. {
  780. $map[DB_PREFIX.'user.id'] = intval($data['id']);
  781. }else{
  782. $users = array();
  783. $user_redis = new UserFollwRedisService($user_id);
  784. $fans = $user_redis->get_follonging_by_user($user_id,1,100);
  785. foreach($fans as $k=>$v){
  786. $users[] = $v['user_id'];
  787. }
  788. $users[] = $user_id;
  789. if($users){
  790. $map[DB_PREFIX.'user.id'] = array('not in',$users);
  791. }
  792. }
  793. $map[DB_PREFIX.'user.is_effect'] = 1;
  794. if (method_exists ( $this, '_filter' )) {
  795. $this->_filter ( $map );
  796. }
  797. $model = D ('User');
  798. if (! empty ( $model )) {
  799. $this->_list ( $model, $map );
  800. }
  801. $list = $this->get("list");
  802. foreach($list as $k=>$v){
  803. $user_id = intval($v['id']);
  804. $user_redis = new UserRedisService();
  805. $user_info = $user_redis->getRow_db($user_id,array('diamonds','use_diamonds','ticket','score','user_level'));
  806. $list[$k]['diamonds'] = $user_info['diamonds']>0?$user_info['diamonds']:0;
  807. $list[$k]['use_diamonds'] = $user_info['use_diamonds']>0?$user_info['use_diamonds']:0;
  808. $list[$k]['ticket'] = $user_info['ticket']>0?$user_info['ticket']:0;
  809. $list[$k]['score'] = $user_info['score']>0?$user_info['score']:0;
  810. $list[$k]['user_level'] = $user_info['user_level']>0?$user_info['user_level']:1;
  811. $userfollw_redis = new UserFollwRedisService($user_id);
  812. $fans_count = $userfollw_redis->follower_count();
  813. $focus_count = $userfollw_redis->follow_count();
  814. $list[$k]['focus_count'] = $focus_count>0?$focus_count:0;
  815. $list[$k]['fans_count'] = $fans_count>0?$fans_count:0;
  816. }
  817. $this->assign ( 'list', $list );
  818. $this->assign ( 'module_name', MODULE_NAME );
  819. $this->display("UserCommon:add_fans");
  820. }
  821. //新增粉丝
  822. public function set_follower($data){
  823. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  824. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  825. $id = $data ['id'];
  826. $user_id = $data['user_id'];
  827. if (isset ( $id )) {
  828. $info_success = array();
  829. $focus_user = explode(',',$id);
  830. foreach($focus_user as $v)
  831. {
  832. $deal_id = $user_id;
  833. if($user_id!=$v){
  834. $root = redis_set_follow($v,$user_id);
  835. if($root['status']==1){
  836. $info_success[] = $v;
  837. }else{
  838. $info[] = $v;
  839. }
  840. }
  841. }
  842. if($info) $info = implode(",",$info);
  843. $info = "用户ID".$deal_id."新增粉丝:".$info;
  844. if($info_success) $success_str = implode(",",$info_success);
  845. $success_str = "用户ID".$deal_id."新增粉丝:".$success_str;
  846. if (sizeof($info_success)) {
  847. save_log($success_str.l("INSERT_SUCCESS"),1);
  848. $root['status'] = 1;
  849. $root['info'] = '新增成功!';
  850. admin_ajax_return($root);
  851. } else {
  852. save_log($info.l("INSERT_FAILED"),0);
  853. $root['status'] = 0;
  854. $root['info'] = '新增失败!';
  855. admin_ajax_return($root);
  856. }
  857. } else {
  858. return false;
  859. }
  860. }
  861. //粉丝列表
  862. public function fans_list($data,$page=0){
  863. $user_id = intval($data['id']);
  864. $user = M("User")->getById($user_id);
  865. $user['nick_name'] = emoji_decode($user['nick_name']);
  866. $this->assign("user",$user);
  867. if($user)
  868. {
  869. $page = intval($_REQUEST['p']);
  870. if($page<=0)
  871. $page = 1;
  872. $map['user_id'] = $user['id'];
  873. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  874. $redisCommon = new Ridescommon();
  875. $redis = $redisCommon->video_follw_list($map['user_id'],1,$page);
  876. $model = D ("Focus");
  877. if (! empty ( $model )) {
  878. $this->_list ( $model, $map,'','',1,$redis);
  879. }
  880. }
  881. $this->display("UserCommon:fans_list");
  882. }
  883. //删除关注
  884. public function del_focus_list($data){
  885. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  886. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  887. $id = $data ['id'];
  888. $user_id = $data['user_id'];
  889. if (isset ( $id )) {
  890. $info_success = array();
  891. $focus_user = explode(',',$id);
  892. foreach($focus_user as $v)
  893. {
  894. $deal_id = $user_id;
  895. $info[] = $v;
  896. if($user_id!=$v){
  897. $root = redis_set_follow($user_id,$v);
  898. if($root['status']==1){
  899. $info_success[] = $v;
  900. }
  901. }
  902. }
  903. if($info) $info = implode(",",$info);
  904. $info = "用户ID".$deal_id."删除关注:".$info;
  905. if($info_success) $success_str = implode(",",$info_success);
  906. $success_str = "用户ID".$deal_id."删除关注:".$success_str;
  907. if (sizeof($info_success)) {
  908. save_log($info_success.l("FOREVER_DELETE_SUCCESS"),1);
  909. $root['status'] = 1;
  910. $root['info'] = '删除成功!';
  911. admin_ajax_return($root);
  912. } else {
  913. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  914. $root['status'] = 0;
  915. $root['info'] = '删除失败!';
  916. admin_ajax_return($root);
  917. }
  918. } else {
  919. $root['status'] = 0;
  920. $root['info'] = '删除失败!';
  921. admin_ajax_return($root);
  922. }
  923. }
  924. //删除粉丝
  925. public function del_fans_list($data){
  926. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  927. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  928. $id = $data ['id'];
  929. $user_id = $data['user_id'];
  930. if (isset ( $id )) {
  931. $info_success = array();
  932. $focus_user = explode(',',$id);
  933. foreach($focus_user as $v)
  934. {
  935. $deal_id = $user_id;
  936. $info[] = $v;
  937. if($user_id!=$v){
  938. $root = redis_set_follow($v,$user_id);
  939. if($root['status']==1){
  940. $info_success[] = $v;
  941. }
  942. }
  943. }
  944. if($info) $info = implode(",",$info);
  945. $info = "用户ID".$deal_id."删除粉丝:".$info;
  946. if($info_success) $success_str = implode(",",$info_success);
  947. $success_str = "用户ID".$deal_id."删除粉丝:".$success_str;
  948. if (sizeof($info_success)) {
  949. save_log($info_success.l("FOREVER_DELETE_SUCCESS"),1);
  950. $root['status'] = 1;
  951. $root['info'] = '删除成功!';
  952. admin_ajax_return($root);
  953. } else {
  954. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  955. $root['status'] = 0;
  956. $root['info'] = '删除失败!';
  957. admin_ajax_return($root);
  958. }
  959. } else {
  960. $root['status'] = 0;
  961. $root['info'] = '删除失败!';
  962. admin_ajax_return($root);
  963. }
  964. }
  965. //印票贡献榜
  966. public function contribution_list($data){
  967. $user_id = intval($data['id']);
  968. $user = M("User")->getById($user_id);
  969. $user['nick_name'] = emoji_decode($user['nick_name']);
  970. $this->assign("user",$user);
  971. if($user)
  972. {
  973. $page = intval($_REQUEST['p']);
  974. if($page<=0)
  975. $page = 1;
  976. $map['podcast_id'] = $user['id'];
  977. require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  978. $redisCommon = new Ridescommon();
  979. $redis = $redisCommon->video_contribute_list($map['podcast_id'],0,$map['podcast_id'],$page);
  980. foreach ($redis['list'] as $k => $v) {
  981. $redis['list'][$k]['nick_name'] = emoji_decode($v['nick_name']);
  982. }
  983. $model = D ("UserContribution");
  984. if (! empty ( $model )) {
  985. $this->_list ( $model, $map,'','',1,$redis);
  986. }
  987. }
  988. $this->display();
  989. }
  990. /**
  991. * 删除印票贡献榜
  992. */
  993. /* public function del_contribution_list($data)
  994. {
  995. $id = $data['id'];
  996. if (isset ( $id )) {
  997. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  998. $rel_data = M("UserContribution")->where($condition)->findAll();
  999. foreach($rel_data as $data)
  1000. {
  1001. $deal_id = $data['podcast_id'];
  1002. $info[] = $data['user_id'];
  1003. }
  1004. if($info) $info = implode(",",$info);
  1005. $info = "用户ID".$deal_id."的印票贡献榜:".$info;
  1006. $list = M("UserContribution")->where ( $condition )->delete();
  1007. if ($list!==false) {
  1008. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1009. return true;
  1010. } else {
  1011. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1012. return false;
  1013. }
  1014. } else {
  1015. return false;
  1016. }
  1017. }*/
  1018. //消息推送
  1019. public function push($data){
  1020. $user_id = intval($data['id']);
  1021. $user = M("User")->getById($user_id);
  1022. $this->assign("user",$user);
  1023. if($user)
  1024. {
  1025. $map['user_id'] = $user['id'];
  1026. $model = D ("PushAnchor");
  1027. if (! empty ( $model )) {
  1028. $this->_list ( $model, $map );
  1029. }
  1030. }
  1031. $this->display();
  1032. }
  1033. /**
  1034. * 删除推送消息
  1035. */
  1036. public function del_push($data)
  1037. {
  1038. $id = $data['id'];
  1039. if (isset ( $id )) {
  1040. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  1041. $rel_data = M("PushAnchor")->where($condition)->findAll();
  1042. foreach($rel_data as $data)
  1043. {
  1044. $deal_id = $data['user_id'];
  1045. $info[] = $data['room_id'];
  1046. }
  1047. if($info) $info = implode(",",$info);
  1048. $info = "用户ID".$deal_id."的直播推送消息:".$info;
  1049. $list = M("PushAnchor")->where ( $condition )->delete();
  1050. if ($list!==false) {
  1051. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1052. return true;
  1053. } else {
  1054. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1055. return false;
  1056. }
  1057. } else {
  1058. return false;
  1059. }
  1060. }
  1061. public function account($data)
  1062. {
  1063. $user_id = intval($data['id']);
  1064. $model = D ();
  1065. $user_info = array();
  1066. if($user_id){
  1067. $sql_str = "select id,nick_name,diamonds,score,ticket from ".DB_PREFIX."user where id = ".$user_id;
  1068. $user_info = $GLOBALS['db']->getRow($sql_str); //
  1069. }
  1070. $user_info['nick_name'] = emoji_decode($user_info['nick_name']);
  1071. $this->assign("user_info",$user_info);
  1072. $this->display();
  1073. }
  1074. public function modify_account($data)
  1075. {
  1076. $data_arr = array();
  1077. $user_id = intval($data['id']);
  1078. $data_arr['diamonds'] = floatval($data['diamonds']);
  1079. $sql_str = "select id,diamonds from ".DB_PREFIX."user where id = ".$user_id;
  1080. $user_info = $GLOBALS['db']->getRow($sql_str); //
  1081. if($data_arr['diamonds']+$user_info['diamonds']>2147483647||$data_arr['diamonds']+$user_info['diamonds']<0){
  1082. return false;
  1083. }
  1084. //$data_arr['ticket'] = intval($data['ticket']);
  1085. $msg = trim($data['msg'])==''?l("ADMIN_MODIFY_ACCOUNT"):trim($data['msg']);
  1086. modify_account($data_arr,$user_id,$msg);
  1087. if ($data_arr['diamonds'] >= 0)
  1088. save_log("用户".$user_id."钻石增加".$data_arr['diamonds']."成功",1);
  1089. elseif ($data_arr['diamonds'] < 0){
  1090. save_log("用户".$user_id."钻石减少".(-$data_arr['diamonds'])."成功",1);
  1091. }
  1092. return true;
  1093. }
  1094. public function account_detail($data)
  1095. {
  1096. $user_id = intval($data['id']);
  1097. $user_info = M("User")->getById($user_id);
  1098. $user_info['nick_name'] = emoji_decode($user_info['nick_name']);
  1099. $this->assign("user_info",$user_info);
  1100. $map['user_id'] = $user_id;
  1101. if($data['type']!=''){
  1102. $map['type'] = intval($data['type']);
  1103. }
  1104. if (method_exists ( $this, '_filter' )) {
  1105. $this->_filter ( $map );
  1106. }
  1107. $types = array('0'=>'充值记录','1'=>'提现记录','3'=>'兑换记录');
  1108. if(defined('OPEN_SHARE_EXPERIENCE')&&OPEN_SHARE_EXPERIENCE==1){
  1109. $types[4] = '分享';
  1110. }
  1111. if(defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1){
  1112. $types[4] = '家族收益';
  1113. }
  1114. if((defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1) && (defined('OPEN_SHARE_EXPERIENCE')&&OPEN_SHARE_EXPERIENCE==1)){
  1115. $types[4] = '分享或家族收益';
  1116. }
  1117. if(defined('OPEN_LOGIN_SEND_SCORE')&&OPEN_LOGIN_SEND_SCORE==1){
  1118. $types[5] = '每日首次登录送积分';
  1119. }
  1120. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  1121. $types[6] = '付费直播消费记录';
  1122. }
  1123. if(defined('PAI_REAL_BTN')&&PAI_REAL_BTN==1 || defined('PAI_VIRTUAL_BTN')&&PAI_VIRTUAL_BTN==1){
  1124. $types[8] = '竞拍记录';
  1125. }
  1126. if ((defined('DISTRIBUTION_SCAN')&&DISTRIBUTION_SCAN==1)){
  1127. $types[9] = '分销抽成记录';
  1128. }
  1129. if ((defined('OPEN_REWARD_GIFT')&&OPEN_REWARD_GIFT==1)){
  1130. $types[12] = '中奖记录';
  1131. }
  1132. if ((defined('QK_TREE')&&QK_TREE==1)){
  1133. $types[21] = '购买树苗记录';
  1134. }
  1135. if(defined('OPEN_SOCIETY_MODULE') && OPEN_SOCIETY_MODULE){
  1136. $m_config = load_auto_cache("m_config");
  1137. if($m_config['society_pattern'] != 0){
  1138. $types[12] = '公会操作';
  1139. $types[8] = '有抽成公会收益';
  1140. $types[10] = '无抽成公会收益';
  1141. }
  1142. }
  1143. $model = M ("UserLog");
  1144. if (! empty ( $model )) {
  1145. $this->_list ( $model, $map );
  1146. }
  1147. $this->assign ( 'module_name', MODULE_NAME );
  1148. $this->assign("types",$types);
  1149. $this->display ();
  1150. return;
  1151. }
  1152. public function foreverdelete_account_detail()
  1153. {
  1154. //彻底删除指定记录
  1155. $ajax = intval($_REQUEST['ajax']);
  1156. $id = $_REQUEST ['id'];
  1157. if (isset ( $id )) {
  1158. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  1159. $rel_data = M("UserLog")->where($condition)->findAll();
  1160. foreach($rel_data as $data)
  1161. {
  1162. $info[] = $data['id'];
  1163. }
  1164. if($info) $info = implode(",",$info);
  1165. $list = M("UserLog")->where ( $condition )->delete();
  1166. if ($list!==false) {
  1167. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1168. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  1169. } else {
  1170. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1171. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  1172. }
  1173. } else {
  1174. $this->error (l("INVALID_OPERATION"),$ajax);
  1175. }
  1176. }
  1177. public function check_user($user_id){
  1178. if(intval($user_id)>0)
  1179. {
  1180. $uinfo = M("User")->getById(intval($user_id));
  1181. if($uinfo)
  1182. {
  1183. $result['status'] = true;
  1184. $result['user_info'] = $uinfo;
  1185. admin_ajax_return($result);
  1186. }
  1187. else
  1188. {
  1189. $result['status'] = false;
  1190. admin_ajax_return($result);
  1191. }
  1192. }
  1193. $result['status'] = false;
  1194. return($result);
  1195. }
  1196. //礼物日志
  1197. public function prop($data)
  1198. {
  1199. $now=get_gmtime();
  1200. $user_id = intval($_REQUEST['id']);
  1201. $user_info = M("User")->getById($user_id);
  1202. $user_info['nick_name'] = emoji_decode($user_info['nick_name']);
  1203. $prop_list = M("prop")->where("is_effect <>0")->findAll();
  1204. $where = "l.from_user_id=".$user_id ;
  1205. $model = D ("video_prop");
  1206. //赠送时间
  1207. $current_Year = date('Y');
  1208. $current_YM = date('Ym');
  1209. for ($i=0; $i<5; $i++)
  1210. {
  1211. $years[$i] = $current_Year - $i;
  1212. }
  1213. for ($i=01; $i<13; $i++)
  1214. {
  1215. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  1216. }
  1217. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  1218. $time=$data['years'].''.$data['month'];
  1219. }else{
  1220. $time=$current_YM;
  1221. }
  1222. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  1223. $this->error("请选择月份");
  1224. }
  1225. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  1226. $this->error("请选择年份");
  1227. }
  1228. //查询ID
  1229. if(strim($data['to_user_id'])!=''){
  1230. $parameter.= "l.to_user_id=".intval($data['to_user_id']). "&";
  1231. $sql_w .= "l.to_user_id=".intval($data['to_user_id'])." and ";
  1232. }
  1233. //查询昵称
  1234. if(trim($data['nick_name'])!='')
  1235. {
  1236. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  1237. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  1238. }
  1239. if (!isset($_REQUEST['prop_id'])) {
  1240. $_REQUEST['prop_id'] = -1;
  1241. }
  1242. //查询礼物
  1243. if($_REQUEST['prop_id']!=-1) {
  1244. if (isset($data['prop_id'])) {
  1245. $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
  1246. $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
  1247. }
  1248. }
  1249. // //查询时间
  1250. // $create_time_2=empty($data['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  1251. // $create_time_1=to_timespan($data['create_time_1'])+24*3600;
  1252. // $create_time_2=to_timespan($create_time_2)+24*3600;
  1253. //
  1254. //
  1255. // if(trim($data['create_time_1'])!='')
  1256. // {
  1257. // $parameter.="l.create_time between '".strtotime($data['create_time_1']) . "' and '". $create_time_2 ."'&";
  1258. // $sql_w .="l.create_time between '". strtotime($data['create_time_1']). "' and '". $create_time_2 ."' and ";
  1259. //
  1260. // }
  1261. // if(trim($data['create_time_2']))
  1262. // {
  1263. //
  1264. // $parameter.="l.create_time<=".$create_time_2. "&";
  1265. // $sql_w .="l.create_time<=". $create_time_2." and ";
  1266. //
  1267. //
  1268. // }
  1269. //
  1270. // //比较两个时间段的月份是否一致,如不一致,提示
  1271. // $create_time_1_m =date('m', $create_time_1);
  1272. // $create_time_2_m =date('m', $create_time_2);
  1273. // if(trim($data['create_time_1'])!=''&& trim($data['create_time_2'])!=''){
  1274. // if($create_time_2_m!=$create_time_1_m){
  1275. // $this->error("查询时间只能在当月内");
  1276. // }
  1277. // }
  1278. //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
  1279. if($data['years']!=''&&$data['month']!=''){
  1280. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name,l.from_ip,l.is_coin
  1281. FROM ".DB_PREFIX."video_prop_".$time." as l
  1282. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1283. WHERE $where "." and ".$sql_w." 1=1 ";
  1284. $count_sql = "SELECT count(l.id) as tpcount
  1285. FROM ".DB_PREFIX."video_prop_".$time." as l
  1286. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1287. WHERE $where "." and ".$sql_w." 1=1 ";
  1288. }else{
  1289. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name,l.from_ip,l.is_coin
  1290. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  1291. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1292. WHERE $where "." and ".$sql_w." 1=1 ";
  1293. $count_sql = "SELECT count(l.id) as tpcount
  1294. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  1295. LEFT JOIN ".DB_PREFIX."user AS u ON l.to_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  1296. WHERE $where "." and ".$sql_w." 1=1 ";
  1297. }
  1298. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  1299. foreach($volist as $k=>$v){
  1300. if($volist[$k]['prop_id']==12){
  1301. $volist[$k]['total_ticket']='';
  1302. }
  1303. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  1304. $volist[$k]['nick_name'] = emoji_decode($volist[$k]['nick_name']);
  1305. }
  1306. $this->assign("user_info",$user_info);
  1307. $this->assign("prop",$prop_list);
  1308. $this->assign("years",$years);
  1309. $this->assign("month",$month);
  1310. $this->assign("list", $volist);
  1311. $this->display ();
  1312. return;
  1313. }
  1314. /**
  1315. * 删除礼物日志
  1316. */
  1317. public function del_prop()
  1318. {
  1319. //彻底删除指定记录
  1320. $ajax = intval($_REQUEST['ajax']);
  1321. $id = intval($_REQUEST ['id']);
  1322. $create_ym = intval($_REQUEST ['create_ym']);
  1323. if (isset ( $id )) {
  1324. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  1325. //默认删除本月记录,如果用户进行时间搜索,通过ajax获取起始时间的年月用REQUEST获取,
  1326. //再与表名连接进行查询删除。
  1327. $rel_data = M("video_prop_".date('Ym',NOW_TIME))->where($condition)->findAll();
  1328. foreach($rel_data as $data)
  1329. {
  1330. $info[] = $data['id'];
  1331. }
  1332. if($info) $info = implode(",",$info);
  1333. $list = M("video_prop_".date('Ym',NOW_TIME))->where ( $condition )->delete();
  1334. if($create_ym!='NaNNaN' &&date('Ym',NOW_TIME)!=$create_ym) {
  1335. $rel_data = M("video_prop_".$create_ym)->where($condition)->findAll();
  1336. foreach($rel_data as $data)
  1337. {
  1338. $info[] = $data['id'];
  1339. }
  1340. if($info) $info = implode(",",$info);
  1341. $list = M("video_prop_".$create_ym)->where ( $condition )->delete();
  1342. }
  1343. if ($list!==false) {
  1344. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  1345. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  1346. } else {
  1347. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  1348. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  1349. }
  1350. } else {
  1351. $this->error (l("INVALID_OPERATION"),$ajax);
  1352. }
  1353. }
  1354. //分享奖励
  1355. public function distribution_log($data)
  1356. {
  1357. $now=get_gmtime();
  1358. $user_id = intval($_REQUEST['id']);
  1359. $user_info = M("User")->getById($user_id);
  1360. $where = "l.to_user_id=".$user_id ;
  1361. $model = D ("distribution_log");
  1362. //查询ID
  1363. if(strim($data['from_user_id'])!=''){
  1364. $parameter.= "l.from_user_id=".intval($data['from_user_id']). "&";
  1365. $sql_w .= "l.from_user_id=".intval($data['from_user_id'])." and ";
  1366. }
  1367. //查询昵称
  1368. if(trim($data['nick_name'])!='')
  1369. {
  1370. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  1371. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  1372. }
  1373. //查询时间
  1374. $create_time_2=empty($data['create_time_2'])?to_date($now,'Y-m-d'):strim($data['create_time_2']);
  1375. $create_time_1=to_timespan($data['create_time_1'])+24*3600;
  1376. $create_time_2=to_timespan($create_time_2)+24*3600;
  1377. if(trim($data['create_time_1'])!='')
  1378. {
  1379. $parameter.="l.create_time between '".strtotime($data['create_time_1']) . "' and '". $create_time_2 ."'&";
  1380. $sql_w .="l.create_time between '". strtotime($data['create_time_1']). "' and '". $create_time_2 ."' and ";
  1381. }
  1382. if(trim($data['create_time_2']))
  1383. {
  1384. $parameter.="l.create_time<=".$create_time_2. "&";
  1385. $sql_w .="l.create_time<=". $create_time_2." and ";
  1386. }
  1387. //比较两个时间段的月份是否一致,如不一致,提示
  1388. $create_time_1_m =date('m', $create_time_1);
  1389. $create_time_2_m =date('m', $create_time_2);
  1390. if(trim($data['create_time_1'])!=''&& trim($data['create_time_2'])!=''){
  1391. if($create_time_2_m!=$create_time_1_m){
  1392. $this->error("查询时间只能在当月内");
  1393. }
  1394. }
  1395. $sql_str = "SELECT l.id,l.from_user_id,l.ticket, l.create_time,u.nick_name
  1396. FROM ".DB_PREFIX."distribution_log as l
  1397. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id
  1398. WHERE $where "." and ".$sql_w." 1=1 ";
  1399. $count_sql = "SELECT count(l.id) as tpcount
  1400. FROM ".DB_PREFIX."distribution_log as l
  1401. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id
  1402. WHERE $where "." and ".$sql_w." 1=1 ";
  1403. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,'id',0,$count_sql);
  1404. foreach($volist as $k=>$v){
  1405. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  1406. }
  1407. $this->assign("user_info",$user_info);
  1408. $this->assign("list", $volist);
  1409. $this->display ();
  1410. return;
  1411. }
  1412. //查询分销子成员
  1413. public function distribution_user($data)
  1414. {
  1415. $user_id = intval($data['id']);
  1416. $model = D("user");
  1417. $user_info = M("User")->getById($user_id);
  1418. $parameter = '';
  1419. $sql_w = '1=1';
  1420. //赠送时间
  1421. $current_Year = date('Y');
  1422. for ($i=0; $i<5; $i++)
  1423. {
  1424. $years[$i] = $current_Year - $i;
  1425. }
  1426. for ($i=01; $i<13; $i++)
  1427. {
  1428. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  1429. }
  1430. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  1431. $time=$data['years'].'-'.$data['month']."-01 00:00:00";
  1432. $s_month=to_timespan($time);
  1433. $e_month=to_timespan(date('Y-m-d', mktime(23, 59, 59, date('m', strtotime($time))+1, 00)));
  1434. $is_seslect = 1;
  1435. }
  1436. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  1437. $this->error("请选择月份");
  1438. }
  1439. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  1440. $this->error("请选择年份");
  1441. }
  1442. //查询注册时间
  1443. if ($is_seslect) {
  1444. $parameter .= "u.create_time>" . intval($s_month) . "&";
  1445. $parameter .= "u.create_time<" . intval($e_month) . "&";
  1446. $sql_w .= " and u.create_time>" . intval($s_month);
  1447. $sql_w .= " and u.create_time<" . intval($e_month);
  1448. }
  1449. //查询ID
  1450. if (strim($data['from_user_id']) != '') {
  1451. $parameter .= "u.id=" . intval($data['from_user_id']) . "&";
  1452. $sql_w .= " and u.id=" . intval($data['from_user_id']);
  1453. }
  1454. //查询昵称
  1455. if (trim($data['nick_name']) != '') {
  1456. $parameter .= "u.nick_name like " . urlencode('%' . trim($data['nick_name']) . '%') . "&";
  1457. $sql_w .= " and u.nick_name like '%" . trim($data['nick_name']) . "%'";
  1458. }
  1459. $field = "u.id,u.nick_name ";
  1460. $left_join_1 = ",(select sum(pn.money) from ".DB_PREFIX."payment_notice as pn where pn.user_id = u.id and pn.is_paid=1 ) as sum_money";
  1461. $left_join_2 = ", u.use_diamonds as sum_diamonds";
  1462. $where = " u.p_user_id=".$user_id." and ".$sql_w;
  1463. $sql_str = "select ".$field.$left_join_1.$left_join_2." from fanwe_user as u where ".$where." group by u.id";
  1464. $count_sql = "select count(u.id) as tpcount from ".DB_PREFIX."user as u where $where";
  1465. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,'id',0,$count_sql);
  1466. foreach($volist as $k=>$v){
  1467. if($v['sum_money']==''){
  1468. $volist[$k]['sum_money'] = 0;
  1469. }
  1470. if($v['sum_diamonds']==''){
  1471. $volist[$k]['sum_diamonds'] = 0;
  1472. }
  1473. }
  1474. $this->assign("user_info",$user_info);
  1475. $this->assign("list", $volist);
  1476. $this->assign("years",$years);
  1477. $this->assign("month",$month);
  1478. $this->display ();
  1479. }
  1480. /**
  1481. * @param $data
  1482. * @param bool $get_result 如果为true则函数return $result,如果为false则admin_ajax_return($result);
  1483. * @return mixed
  1484. */
  1485. public function forbid_msg($data,$get_result=false){
  1486. fanwe_require(APP_ROOT_PATH.'mapi/lib/core/common.php');
  1487. $id = intval($data['user_id']);
  1488. $is_nospeaking = M("User")->where("id=".$id)->getField("is_nospeaking");
  1489. if($get_result && $is_nospeaking){
  1490. $result['status'] = 1;
  1491. $result['info'] = "已经全局禁言";
  1492. return $result;
  1493. }
  1494. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  1495. $api = createTimAPI();
  1496. $time = 4294967295;
  1497. $info = "im全局禁言";
  1498. $set_nospeaking = 1;
  1499. if($is_nospeaking){
  1500. $time = 0;
  1501. $set_nospeaking =0;
  1502. $info = "解除im全局禁言";
  1503. }
  1504. $ret = $api->set_no_speaking($id,$time);
  1505. if($ret['ErrorCode']){
  1506. $ret = $api->set_no_speaking($id,$time);
  1507. }
  1508. if($ret['ErrorCode']){
  1509. $result['status'] = 0;
  1510. $result['info'] = $info."失败";
  1511. save_log($id.$info."失败",0);
  1512. }else{
  1513. $result['status'] = 1;
  1514. $result['info'] = $info."成功";
  1515. M("User")->where("id=".$id)->setField("is_nospeaking",$set_nospeaking);
  1516. user_deal_to_reids(array($id));
  1517. save_log($id.$info."成功",1);
  1518. }
  1519. if($get_result){
  1520. return $result;
  1521. }
  1522. admin_ajax_return($result);
  1523. }
  1524. }