XyPromoterUserAction.class.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  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 XyPromoterUserAction extends CommonAction{
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. require_once APP_ROOT_PATH."/admin/Lib/Action/UserCommonAction.class.php";
  14. require_once APP_ROOT_PATH."/system/libs/user.php";
  15. }
  16. public function index()
  17. {
  18. //$common = new UserCommon();
  19. $data = $_REQUEST;
  20. // $data['is_authentication'] = array('in',array(0,1,3));
  21. $data['is_robot'] = 0;
  22. $sql_w = "society_chieftain=1 and ";
  23. $pid=intval($data['bm_pid']);
  24. if($pid >0){
  25. $parameter.= "bm_pid=" . $pid. "&";
  26. $sql_w .= "bm_pid=".$pid." and ";
  27. }else{
  28. $sql_w .= "bm_pid >0 and ";
  29. }
  30. if(trim($data['nick_name'])!='')
  31. {
  32. $parameter.= "nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  33. $sql_w .= "nick_name like '%".trim($data['nick_name'])."%' and ";
  34. }
  35. if(trim($data['mobile'])!='')
  36. {
  37. $parameter.= "mobile like " . urlencode ( '%'.trim($data['mobile']).'%' ) . "&";
  38. $sql_w .= "mobile like '%".trim($data['mobile'])."%' and ";
  39. }
  40. $create_time_2=empty($_REQUEST['create_time_2'])?to_date(get_gmtime(),'Y-m-d'):strim($data['create_time_2']);
  41. $create_time_2=to_timespan($create_time_2)+24*3600;
  42. if(trim($data['create_time_1'])!='' )
  43. {
  44. $parameter.="create_time between '". to_timespan($data['create_time_1']) . "' and '". $create_time_2 ."'&";
  45. $sql_w .=" (create_time between '". to_timespan($data['create_time_1']). "' and '". $create_time_2 ."' ) and ";
  46. }
  47. if(intval($data['id'])>0)
  48. {
  49. $parameter.= "id=" . intval($data['id']). "&";
  50. $sql_w .= "id=".intval($data['id'])." and ";
  51. }
  52. if($data['is_effect']!=NULL){
  53. $parameter.= "is_effect=" . intval($data['is_effect']). "&";
  54. $sql_w .= "is_effect=".intval($data['is_effect'])." and ";
  55. }else{
  56. $parameter.= "is_effect=1&";
  57. $sql_w .= "is_effect=1 and ";
  58. }
  59. if($_REQUEST['is_admin']!='')
  60. {
  61. $parameter.= "is_admin=" . intval($data['is_admin']). "&";
  62. $sql_w .= "is_admin=".intval($data['is_admin'])." and ";
  63. }
  64. if (!isset($_REQUEST['is_authentication'])) {
  65. $_REQUEST['is_authentication'] = -1;
  66. }
  67. if($_REQUEST['is_authentication']!=-1) {
  68. if (isset($data['is_authentication'])) {
  69. $parameter .= "is_authentication in (" . $data['is_authentication'] . ")&";
  70. $sql_w .= "is_authentication in (" . $data['is_authentication'] . ") and ";
  71. }
  72. }
  73. if(isset($data['is_robot'])){
  74. $parameter.= "is_robot=" . intval($data['is_robot']). "&";
  75. $sql_w .= "is_robot=".intval($data['is_robot'])." and ";
  76. }else{
  77. $parameter.= "is_robot=0&";
  78. $sql_w .= "is_robot=0 and ";
  79. }
  80. $m_config = load_auto_cache("m_config");//初始化手机端配置
  81. if(defined('OPEN_VIP')&&OPEN_VIP==1){
  82. if($_REQUEST['is_vip']!='')
  83. {
  84. $parameter.= "is_vip=" . intval($data['is_vip']). "&";
  85. $sql_w .= "is_vip=".intval($data['is_vip'])." and ";
  86. }
  87. $this->assign ( 'open_vip', 1 );
  88. }
  89. $model = D ();
  90. $m_config = load_auto_cache("m_config");
  91. $ote = floatval($m_config['onlinetime_to_experience']);
  92. $sql_str = "SELECT *," .
  93. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  94. " FROM ".DB_PREFIX."user WHERE 1=1 ";
  95. $count_sql = "SELECT count(*) as tpcount" .
  96. " FROM ".DB_PREFIX."user WHERE (1=1 ";
  97. if(intval($data['id']) == 0){
  98. $sql_str .= " and ".$sql_w." 1=1 ";
  99. $count_sql .= " and ".$sql_w." 1=1) ";
  100. }else{
  101. $sql_str .= " and ".$sql_w." 1=1 union SELECT *," .
  102. " ticket-refund_ticket as useable_ticket ,floor(score + online_time*".$ote.") as u_score" .
  103. " FROM ".DB_PREFIX."user WHERE luck_num=".$data['id'];
  104. $count_sql .= " and ".$sql_w." 1=1 ) or (luck_num=".$data['id'].")";
  105. }
  106. $distribution_log = 0;
  107. if(defined('OPEN_DISTRIBUTION') && OPEN_DISTRIBUTION==1){
  108. $distribution_log = 1;
  109. }
  110. $coins = 0;
  111. if(defined('OPEN_GAME_MODULE') && OPEN_GAME_MODULE==1){
  112. $coins = 1;
  113. }
  114. $goods = 0;
  115. if((defined('SHOPPING_GOODS') && SHOPPING_GOODS==1) || (defined('PAI_REAL_BTN') && PAI_REAL_BTN==1)){
  116. $goods = 1;
  117. }
  118. $voList = $this->_Sql_list($model, $sql_str, "&".$parameter,'id',0,$count_sql);
  119. foreach($voList as $k=>$v){
  120. $voList[$k]['head_image'] = get_spec_image($v['head_image']);
  121. $voList[$k]['distribution_log'] = $distribution_log;
  122. $voList[$k]['coins'] = $coins;
  123. $voList[$k]['goods'] = $goods;
  124. $voList[$k]['ticket'] = $v['ticket']+$v['no_ticket'];
  125. }
  126. $this->assign ( 'list', $voList );
  127. $this->display ();
  128. }
  129. public function edit() {
  130. $common = new UserCommon();
  131. $data = $_REQUEST;
  132. $common->edit($data);
  133. }
  134. public function delete() {
  135. //彻底删除指定记录
  136. $common = new UserCommon();
  137. $data = $_REQUEST;
  138. $common->delete($data);
  139. }
  140. public function update() {
  141. $common = new UserCommon();
  142. $data = $_REQUEST;
  143. $common->update($data);
  144. }
  145. public function set_effect()
  146. {
  147. $common = new UserCommon();
  148. $data = $_REQUEST;
  149. $n_is_effect = $common->set_effect($data);
  150. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1);
  151. }
  152. public function set_ban()
  153. {
  154. $common = new UserCommon();
  155. $data = $_REQUEST;
  156. $n_is_effect = $common->set_ban($data);
  157. $this->ajaxReturn($n_is_effect,l("SET_BAN_".$n_is_effect),1);
  158. }
  159. //禁热门
  160. public function set_hot_on()
  161. {
  162. $common = new UserCommon();
  163. $data = $_REQUEST;
  164. $n_is_effect = $common->set_hot_on($data);
  165. $this->ajaxReturn($n_is_effect,l("SET_HOT_ON_".$n_is_effect),1);
  166. }
  167. //新增关注
  168. public function add_focus(){
  169. $common = new UserCommon();
  170. $data = $_REQUEST;
  171. $common->add_focus($data);
  172. }
  173. //新增关注
  174. public function set_follow(){
  175. $common = new UserCommon();
  176. $data = $_REQUEST;
  177. $common->set_follow($data);
  178. }
  179. //关注列表
  180. public function focus_list(){
  181. $common = new UserCommon();
  182. $data = $_REQUEST;
  183. $common->focus_list($data);
  184. }
  185. //新增粉丝
  186. public function add_fans(){
  187. $common = new UserCommon();
  188. $data = $_REQUEST;
  189. $common->add_fans($data);
  190. }
  191. //新增粉丝
  192. public function set_follower(){
  193. $common = new UserCommon();
  194. $data = $_REQUEST;
  195. $common->set_follower($data);
  196. }
  197. //粉丝列表
  198. public function fans_list(){
  199. $common = new UserCommon();
  200. $data = $_REQUEST;
  201. $common->fans_list($data);
  202. }
  203. //删除关注
  204. public function del_focus_list(){
  205. $common = new UserCommon();
  206. $data = $_REQUEST;
  207. $common->del_focus_list($data);
  208. }
  209. //删除粉丝
  210. public function del_fans_list(){
  211. $common = new UserCommon();
  212. $data = $_REQUEST;
  213. $common->del_fans_list($data);
  214. }
  215. //印票贡献榜
  216. public function contribution_list(){
  217. $common = new UserCommon();
  218. $data = $_REQUEST;
  219. $common->contribution_list($data);
  220. }
  221. /**
  222. * 删除印票贡献榜
  223. */
  224. /*public function del_contribution_list()
  225. {
  226. $ajax = intval($_REQUEST['ajax']);
  227. $id = $_REQUEST ['id'];
  228. if (isset ( $id )) {
  229. $common = new UserCommon();
  230. $data = $_REQUEST;
  231. $status = $common->del_contribution_list($data);
  232. if ($status!==false) {
  233. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  234. } else {
  235. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  236. }
  237. } else {
  238. $this->error (l("INVALID_OPERATION"),$ajax);
  239. }
  240. }*/
  241. //消息推送
  242. public function push(){
  243. $common = new UserCommon();
  244. $data = $_REQUEST;
  245. $common->push($data);
  246. }
  247. //删除推送消息
  248. public function del_push(){
  249. $ajax = intval($_REQUEST['ajax']);
  250. $id = $_REQUEST ['id'];
  251. if (isset ( $id )) {
  252. $common = new UserCommon();
  253. $data = $_REQUEST;
  254. $status = $common->del_push($data);
  255. if ($status!==false) {
  256. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  257. } else {
  258. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  259. }
  260. } else {
  261. $this->error (l("INVALID_OPERATION"),$ajax);
  262. }
  263. }
  264. //账户管理
  265. public function account()
  266. {
  267. $common = new UserCommon();
  268. $data = $_REQUEST;
  269. $status = $common->account($data);
  270. }
  271. //账户修改
  272. public function modify_account()
  273. {
  274. $common = new UserCommon();
  275. $data = $_REQUEST;
  276. $status = $common->modify_account($data);
  277. if($status){
  278. $this->success(L("UPDATE_SUCCESS"));
  279. }else{
  280. $this->error("累计充值数据有误!");
  281. }
  282. }
  283. //账户日志
  284. public function account_detail()
  285. {
  286. $common = new UserCommon();
  287. $data = $_REQUEST;
  288. $common->account_detail($data);
  289. }
  290. //兑换日志
  291. public function exchange_log()
  292. {
  293. $common = new UserCommon();
  294. $data = $_REQUEST;
  295. $common->exchange_log($data);
  296. }
  297. //删除账户日志
  298. public function foreverdelete_account_detail()
  299. {
  300. //彻底删除指定记录
  301. $ajax = intval($_REQUEST['ajax']);
  302. $id = $_REQUEST ['id'];
  303. $data = $_REQUEST;
  304. if (isset ( $id )) {
  305. $common = new UserCommon();
  306. $status = $common->foreverdelete_account_detail($data);
  307. if ($status!==false) {
  308. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  309. } else {
  310. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  311. }
  312. } else {
  313. $this->error (l("INVALID_OPERATION"),$ajax);
  314. }
  315. }
  316. //删除兑换日志
  317. public function foreverdelete_exchange_log()
  318. {
  319. //彻底删除指定记录
  320. $ajax = intval($_REQUEST['ajax']);
  321. $id = $_REQUEST ['id'];
  322. $data = $_REQUEST;
  323. if (isset ( $id )) {
  324. $common = new UserCommon();
  325. $status = $common->foreverdelete_exchange_log($data);
  326. if ($status!==false) {
  327. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  328. } else {
  329. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  330. }
  331. } else {
  332. $this->error (l("INVALID_OPERATION"),$ajax);
  333. }
  334. }
  335. //检查用户
  336. public function check_user(){
  337. $common = new UserCommon();
  338. $user_id = $_REQUEST['id'];
  339. admin_ajax_return($common->check_user($user_id));
  340. }
  341. //礼物日志
  342. public function prop()
  343. {
  344. $common = new UserCommon();
  345. $data = $_REQUEST;
  346. $common->prop($data);
  347. }
  348. //收礼物日志
  349. public function closed_prop(){
  350. $data = $_REQUEST;
  351. $now=get_gmtime();
  352. $user_id = intval($_REQUEST['id']);
  353. $user_info = M("User")->getById($user_id);
  354. $prop_list = M("prop")->where("is_effect <>0")->findAll();
  355. $where = "l.to_user_id=".$user_id ;
  356. $model = D ("video_prop");
  357. //赠送时间
  358. $current_Year = date('Y');
  359. $current_YM = date('Ym');
  360. for ($i=0; $i<5; $i++)
  361. {
  362. $years[$i] = $current_Year - $i;
  363. }
  364. for ($i=01; $i<13; $i++)
  365. {
  366. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  367. }
  368. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  369. $time=$data['years'].''.$data['month'];
  370. }else{
  371. $time=$current_YM;
  372. }
  373. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  374. $this->error("请选择月份");
  375. }
  376. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  377. $this->error("请选择年份");
  378. }
  379. //查询ID
  380. if(strim($data['from_user_id'])!=''){
  381. $parameter.= "l.from_user_id=".intval($data['from_user_id']). "&";
  382. $sql_w .= "l.from_user_id=".intval($data['from_user_id'])." and ";
  383. }
  384. //查询昵称
  385. if(trim($data['nick_name'])!='')
  386. {
  387. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  388. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  389. }
  390. if (!isset($_REQUEST['prop_id'])) {
  391. $_REQUEST['prop_id'] = -1;
  392. }
  393. //查询礼物
  394. if($_REQUEST['prop_id']!=-1) {
  395. if (isset($data['prop_id'])) {
  396. $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
  397. $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
  398. }
  399. }
  400. //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
  401. if($data['years']!=''&&$data['month']!=''){
  402. $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
  403. FROM ".DB_PREFIX."video_prop_".$time." as l
  404. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  405. WHERE $where "." and ".$sql_w." 1=1 ";
  406. $count_sql = "SELECT count(l.id) as tpcount
  407. FROM ".DB_PREFIX."video_prop_".$time." as l
  408. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  409. WHERE $where "." and ".$sql_w." 1=1 ";
  410. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  411. FROM ".DB_PREFIX."video_prop_".$time." as l
  412. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  413. WHERE $where "." and ".$sql_w." 1=1 ";
  414. }else{
  415. $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
  416. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  417. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  418. WHERE $where "." and ".$sql_w." 1=1 ";
  419. $count_sql = "SELECT count(l.id) as tpcount
  420. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  421. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  422. WHERE $where "." and ".$sql_w." 1=1 ";
  423. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  424. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  425. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  426. WHERE $where "." and ".$sql_w." 1=1 ";
  427. }
  428. $count = $GLOBALS['db']->getOne($count_sql);
  429. $total_ticket = $GLOBALS['db']->getOne($total_ticket_sql);
  430. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  431. foreach($volist as $k=>$v){
  432. if($volist[$k]['prop_id']==12){
  433. $volist[$k]['total_ticket']='';
  434. }
  435. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  436. }
  437. $this->assign("user_info",$user_info);
  438. $this->assign("prop",$prop_list);
  439. $this->assign("years",$years);
  440. $this->assign("month",$month);
  441. $this->assign("list", $volist);
  442. $this->assign("count",intval($count));
  443. $this->assign('total_ticket',intval($total_ticket));
  444. $this->display ();
  445. }
  446. //分享奖励
  447. public function distribution_log(){
  448. $common = new UserCommon();
  449. $data = $_REQUEST;
  450. $common->distribution_log($data);
  451. }
  452. //分销子成员奖励
  453. public function distribution_user(){
  454. $common = new UserCommon();
  455. $data = $_REQUEST;
  456. $common->distribution_user($data);
  457. }
  458. //删除礼物日志
  459. public function delete_prop()
  460. {
  461. //彻底删除指定记录
  462. $ajax = intval($_REQUEST['ajax']);
  463. $id = intval($_REQUEST ['id']);
  464. $data = $_REQUEST;
  465. if (isset ( $id )) {
  466. $common = new UserCommon();
  467. $status = $common->del_prop($data);
  468. if ($status!==false) {
  469. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  470. } else {
  471. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  472. }
  473. } else {
  474. $this->error (l("INVALID_OPERATION"),$ajax);
  475. }
  476. }
  477. public function forbid_msg(){
  478. $common = new UserCommon();
  479. $data = $_REQUEST;
  480. $common->forbid_msg($data);
  481. }
  482. //商品管理
  483. public function goods(){
  484. $user_id = intval($_REQUEST['user_id']);
  485. if(strim($_REQUEST['name'])!=''){
  486. $map['name'] = array('like','%'.strim($_REQUEST['name']).'%');
  487. }
  488. $map['is_effect'] = 1;
  489. $model = D ('goods');
  490. if (! empty ( $model )) {
  491. $this->_list ( $model, $map );
  492. }
  493. $list = $this->get('list');
  494. $user_list = $GLOBALS['db']->getAll("select goods_id from ".DB_PREFIX."user_goods where is_effect=1 and user_id=".$user_id);
  495. foreach($list as $k => $v){
  496. $imgs=array();
  497. $imgs_details=array();
  498. $imgs=json_decode($v['imgs'],1);
  499. $imgs_details=json_decode($v['imgs_details'],1);
  500. $list[$k]['imgs'] = $imgs[0];
  501. $list[$k]['imgs_details'] = $imgs_details[0];
  502. $list[$k]['has']= '否';
  503. foreach($user_list as $value1){
  504. if($v['id'] == $value1['goods_id']){
  505. $list[$k]['has'] = '是';
  506. break;
  507. }
  508. }
  509. }
  510. $sort = array_column($list, 'has');
  511. array_multisort($sort, SORT_DESC, $list);
  512. $this->assign("list",$list);
  513. $this->display();
  514. }
  515. //上架商品
  516. public function shelves(){
  517. $ajax = intval($_REQUEST['ajax']);
  518. $goods_id = intval($_REQUEST ['id']);
  519. $user_id = intval($_REQUEST ['user_id']);
  520. if (isset($goods_id)) {
  521. $where['goods_id'] = $goods_id;
  522. $where['user_id'] = $user_id;
  523. $user_goods = M('user_goods')->where($where)->select();
  524. $goods_info = $GLOBALS['db']->getRow("select name,imgs,imgs_details,price,pai_diamonds,kd_cost,score,is_effect from ".DB_PREFIX."goods where is_effect=1 and id=".$goods_id);
  525. if($user_goods){
  526. $list = M('user_goods')->where($where)->save($goods_info);
  527. }else{
  528. $data = array_merge($where,$goods_info);
  529. $list = M('user_goods')->add($data);
  530. }
  531. if ($list!==false) {
  532. $result['info'] = "上架成功!";
  533. $result['status'] = 1;
  534. } else {
  535. $result['info'] = "上架失败!";
  536. $result['status'] = 0;
  537. }
  538. $this->ajax_return($result);
  539. } else {
  540. $this->error (l("INVALID_OPERATION"),$ajax);
  541. }
  542. }
  543. //下架商品
  544. public function sold(){
  545. $ajax = intval($_REQUEST['ajax']);
  546. $goods_id = intval($_REQUEST ['id']);
  547. $user_id = intval($_REQUEST ['user_id']);
  548. if (isset($goods_id)) {
  549. $condition['goods_id'] = $goods_id;
  550. $condition['user_id'] = $user_id;
  551. $user_goods = M('user_goods')->where($condition)->select();
  552. if($user_goods){
  553. $list = M('user_goods')->where($condition)->delete();
  554. }
  555. if ($list!==false) {
  556. $result['info'] = "下架成功!";
  557. $result['status'] = 1;
  558. } else {
  559. $result['info'] = "下架失败!";
  560. $result['status'] = 0;
  561. }
  562. $this->ajax_return($result);
  563. } else {
  564. $this->error (l("INVALID_OPERATION"),$ajax);
  565. }
  566. }
  567. public function clear_view_count(){
  568. $sql = "update ".DB_PREFIX."user set view_count = 0";
  569. $res = $GLOBALS['db']->query($sql);
  570. if($res){
  571. $result['info'] = "清除成功!";
  572. $result['status'] = 1;
  573. }else{
  574. $result['info'] = "清除失败!";
  575. $result['status'] = 0;
  576. }
  577. admin_ajax_return($result);
  578. }
  579. public function weibo_index()
  580. {
  581. $common = new UserCommon();
  582. $data = $_REQUEST;
  583. // $data['is_authentication'] = array('in',array(0,1,3));
  584. $data['is_robot'] = 0;
  585. $common->index($data);
  586. }
  587. public function set_sort()
  588. {
  589. $id = intval($_REQUEST['id']);
  590. $sort = intval($_REQUEST['sort']);
  591. $log_info = M("User")->where("id=".$id)->getField("nick_name");
  592. if(!check_sort($sort))
  593. {
  594. $this->error(l("SORT_FAILED"),1);
  595. }
  596. M("User")->where("id=".$id)->setField("weibo_recommend_weight",$sort);
  597. save_log($log_info.l("SORT_SUCCESS"),1);
  598. $this->success(l("SORT_SUCCESS"),1);
  599. }
  600. public function game_rate()
  601. {
  602. if ($_POST) {
  603. $user_id = intval($_REQUEST['user_id']);
  604. $rate = intval($_REQUEST['rate']);
  605. if (!$user_id) {
  606. $this->ajax_return(array(
  607. 'status' => 0,
  608. 'error' => '参数错误',
  609. ));
  610. }
  611. if ($rate > 100 || $rate < 0) {
  612. $this->ajax_return(array(
  613. 'status' => 0,
  614. 'error' => '参数错误',
  615. ));
  616. }
  617. $where = array('id' => $user_id);
  618. $user_model = M('user');
  619. $res = $user_model->setField('rate', $rate, $where);
  620. if ($res) {
  621. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  622. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  623. $user_redis = new UserRedisService();
  624. $user_redis->update_db($user_id, ['rate' => $rate]);
  625. $this->ajax_return(array(
  626. 'status' => 1,
  627. 'error' => '更新成功',
  628. ));
  629. }
  630. $this->ajax_return(array(
  631. 'status' => 0,
  632. 'error' => '更新失败',
  633. ));
  634. } else {
  635. $user_id = intval($_REQUEST['user_id']);
  636. $user_model = M('user');
  637. $user_info = $user_model->field(array('id', 'rate'))->find($user_id);
  638. $user_info['rate'] = +$user_info['rate'];
  639. $this->assign("user_info", $user_info);
  640. $this->display();
  641. }
  642. }
  643. protected function ajax_return($data)
  644. {
  645. header("Content-Type:text/html; charset=utf-8");
  646. echo (json_encode($data));
  647. exit;
  648. }
  649. public function game_distribution()
  650. {
  651. if ($_POST) {
  652. $user_id = intval($_REQUEST['user_id']);
  653. $game_distribution1 = intval($_REQUEST['game_distribution1']);
  654. $game_distribution2 = intval($_REQUEST['game_distribution2']);
  655. if (!$user_id) {
  656. $this->ajax_return(array(
  657. 'status' => 0,
  658. 'error' => '参数错误',
  659. ));
  660. }
  661. $where = array('id' => $user_id);
  662. $user_model = M('user');
  663. $res = $user_model->where($where)->save(['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2]);
  664. if ($res) {
  665. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  666. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  667. $user_redis = new UserRedisService();
  668. $user_redis->update_db($user_id, ['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2]);
  669. $this->ajax_return(array(
  670. 'status' => 1,
  671. 'error' => '更新成功',
  672. ));
  673. }
  674. $this->ajax_return(array(
  675. 'status' => 0,
  676. 'error' => '更新失败',
  677. ));
  678. } else {
  679. $user_id = intval($_REQUEST['user_id']);
  680. $user_model = M('user');
  681. $user_info = $user_model->field(array('id', 'game_distribution1', 'game_distribution2'))->find($user_id);
  682. $user_info['game_distribution1'] = +$user_info['game_distribution1'];
  683. $user_info['game_distribution2'] = +$user_info['game_distribution2'];
  684. $this->assign("user_info", $user_info);
  685. $this->display();
  686. }
  687. }
  688. public function invitation_code()
  689. {
  690. $user_id = intval($_REQUEST['user_id']);
  691. $user_model = M('user');
  692. $user_info = $user_model->field(['invitation_code','create_time'])->find($user_id);
  693. if ($user_info['invitation_code']) {
  694. exit($user_info['invitation_code']);
  695. }
  696. $users = $user_model->field(['id','create_time'])->where(['invitation_code' => ''])->findAll();
  697. foreach ($users as $v) {
  698. $res = $user_model->save(['invitation_code' => substr(md5($v['id'] . ':' . $v['create_time']), -16),'id' => $v['id']]);
  699. }
  700. exit(substr(md5($user_id . ':' . $user_info['create_time']), -16));
  701. }
  702. public function game_distribution_detail()
  703. {
  704. $user_id = intval($_REQUEST['user_id']);
  705. if ($_REQUEST['type']) {
  706. $model = M('game_distribution');
  707. $table = DB_PREFIX . 'user u,' . DB_PREFIX . 'game_distribution gd';
  708. $field = "u.id,u.nick_name,u.head_image,sum(gd.first_distreibution_money * (gd.first_distreibution_id = {$user_id}) + gd.second_distreibution_money * (gd.second_distreibution_id = {$user_id})) as `sum`,gd.is_ticket";
  709. $where = "(gd.first_distreibution_id = $user_id or gd.second_distreibution_id = $user_id) and u.id = gd.user_id";
  710. $group = 'u.id,gd.is_ticket';
  711. $list = $model->table($table)->field($field)->where($where)->group($group)->findAll();
  712. $this->assign("list", $list);
  713. } else {
  714. $map = [
  715. 'user_id' => $user_id,
  716. ];
  717. $model = M('game_distribution');
  718. if (!empty($model)) {
  719. $this->_list($model, $map);
  720. }
  721. }
  722. $this->assign("user_id", $user_id);
  723. $this->display();
  724. }
  725. //禁游戏
  726. public function forbid_game(){
  727. $id= intval($_REQUEST['user_id']);
  728. $open_game =$GLOBALS['db']->getRow("select open_game from ".DB_PREFIX."user where id =".$id);
  729. $where = 'id='.$id;
  730. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  731. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  732. $user_redis = new UserRedisService();
  733. $data['open_game'] = 1;
  734. $info = '';
  735. if($open_game['open_game']==1) {
  736. $data['open_game'] = 0;
  737. $info = '取消';
  738. }
  739. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  740. if ($list!==false) {
  741. $user_redis->update_db($id, $data);
  742. $this->success ($info.'禁游戏成功',1);
  743. }else{
  744. $this->error ($info.'禁游戏成功',1);
  745. }
  746. }
  747. //禁付费
  748. public function forbid_pay(){
  749. $id= intval($_REQUEST['user_id']);
  750. $open_game =$GLOBALS['db']->getRow("select open_pay from ".DB_PREFIX."user where id =".$id);
  751. $where = 'id='.$id;
  752. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  753. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  754. $user_redis = new UserRedisService();
  755. $data['open_pay'] = 1;
  756. $info = '';
  757. if($open_game['open_pay']==1) {
  758. $data['open_pay'] = 0;
  759. $info = '取消';
  760. }
  761. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  762. if ($list!==false) {
  763. $user_redis->update_db($id, $data);
  764. $this->success ($info.'禁付费成功',1);
  765. }else{
  766. $this->error ($info.'禁付费成功',1);
  767. }
  768. }
  769. //禁竞拍
  770. public function forbid_auction(){
  771. $id= intval($_REQUEST['user_id']);
  772. $open_game =$GLOBALS['db']->getRow("select open_auction from ".DB_PREFIX."user where id =".$id);
  773. $where = 'id='.$id;
  774. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  775. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  776. $user_redis = new UserRedisService();
  777. $data['open_auction'] = 1;
  778. $info = '';
  779. if($open_game['open_auction']==1) {
  780. $data['open_auction'] = 0;
  781. $info = '取消';
  782. }
  783. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  784. if ($list!==false) {
  785. $user_redis->update_db($id, $data);
  786. $this->success ($info.'禁竞拍成功',1);
  787. }else{
  788. $this->error ($info.'禁竞拍成功',1);
  789. }
  790. }
  791. }
  792. ?>