WeiboRefundAction.class.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 WeiboRefundAction extends CommonAction{
  10. /**
  11. * 提现审核记录
  12. */
  13. public function index()
  14. {
  15. //列表过滤器,生成查询Map对象
  16. $map = $this->_search ();
  17. $map['_string'] = 'is_pay = 0';
  18. //追加默认参数
  19. if($this->get("default_map"))
  20. $map = array_merge($map,$this->get("default_map"));
  21. $map['type'] = 1;
  22. if(strim($_REQUEST['nick_name'])!=''){//name
  23. $user=M("User")->where("nick_name like '%".strim($_REQUEST['nick_name'])."%' ")->findAll();
  24. $user_arr_id = array();
  25. foreach($user as $k=>$v){
  26. $user_arr_id[$k] =intval($v['id']);
  27. }
  28. //$user_str_id = implode(',',$user_arr_id);
  29. $map['user_id'] = array('in',$user_arr_id);
  30. }
  31. if(intval($_REQUEST['user_id'])>0)
  32. {
  33. $map['user_id'] = intval($_REQUEST['user_id']);
  34. }
  35. if (method_exists ( $this, '_filter' )) {
  36. $this->_filter ( $map );
  37. }
  38. $name=$this->getActionName();
  39. $model = D ($name);
  40. if (! empty ( $model )) {
  41. $this->_list ( $model, $map );
  42. }
  43. $this->display ();
  44. return;
  45. }
  46. public function refund_allow(){
  47. $id=intval($_REQUEST['id']);
  48. $status=intval($_REQUEST['status']);
  49. $refund_data=M("UserRefund")->getById($id);
  50. $info=array();
  51. if($status){
  52. $info['do']='允许';
  53. }else{
  54. $info['do']='不允许';
  55. }
  56. $this->assign("info",$info);
  57. $this->assign("refund_data",$refund_data);
  58. $this->assign("status",$status);
  59. $this->display ();
  60. }
  61. public function refund_go_allow(){
  62. $id=intval($_REQUEST['id']);
  63. $status=intval($_REQUEST['status']);
  64. $refund_data = M("UserRefund")->getById($id);
  65. $user_id = $refund_data['user_id'];
  66. if($refund_data)
  67. {
  68. if($refund_data['is_pay']==1)
  69. {
  70. $this->error("已经允许提现");
  71. }
  72. $reply = strim($_REQUEST['reply']);
  73. $m_config = load_auto_cache("m_config");//初始化手机端配置
  74. $ticket_name = $m_config['ticket_name']!=''?$m_config['ticket_name']:'印票';
  75. //管理员的SESSION
  76. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  77. $adm_id = intval($adm_session['adm_id']);
  78. if($status==1){
  79. //修改读取本地mysql 20170118
  80. $refund_user = $GLOBALS['db']->getRow("select weibo_money,weibo_refund_money from ".DB_PREFIX."user where id=".$user_id);
  81. if(intval($refund_user['weibo_money'])-intval($refund_user['weibo_refund_money'])<intval($refund_data['weibo_money']))
  82. {
  83. $refund_data['pay_log'] = "动态红包不足,不能提现";
  84. $refund_data['is_pay'] = 4;
  85. M("UserRefund")->save($refund_data);
  86. $info="动态红包不足不足,不能提现";
  87. }else{
  88. //冻结用户提现印票
  89. $sql = "update ".DB_PREFIX."user set weibo_refund_money=weibo_refund_money+".$refund_data['weibo_money']." where weibo_money >= weibo_refund_money + ".$refund_data['weibo_money']." and id=".$refund_data['user_id'];
  90. $GLOBALS['db']->query($sql);
  91. if($GLOBALS['db']->affected_rows()){
  92. user_deal_to_reids(array($user_id));
  93. $refund_data['is_pay'] = 1;
  94. $refund_data['pay_log']="已审核";
  95. $info="允许操作成功";
  96. //写入用户日志
  97. $data = array();
  98. $data['weibo_money'] = intval($refund_data['weibo_money']);
  99. $data['log_admin_id'] = intval($adm_id);
  100. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  101. $log_msg ='冻结提现'.$data['weibo_money'].'动态红包成功';
  102. account_log_com($data,$refund_data['user_id'],$log_msg,$param);
  103. save_log($user_id.$log_msg,1);
  104. }else{
  105. $refund_data['pay_log']="提现冻结失败";
  106. }
  107. }
  108. }else{
  109. $refund_data['is_pay'] = 2;
  110. $refund_data['pay_log']="--";
  111. $refund_data['partner_trade_no']="--";
  112. $info="拒绝提现操作成功";
  113. //写入用户日志
  114. $data = array();
  115. $data['weibo_money'] = intval($refund_data['weibo_money']);
  116. $data['log_admin_id'] = intval($adm_id);
  117. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  118. $log_msg ='提现动态红包'.$data['weibo_money'].',被拒绝';
  119. account_log_com($data,$refund_data['user_id'],$log_msg,$param);
  120. save_log($user_id.$log_msg,0);
  121. }
  122. $refund_data['reply']=$reply;
  123. M("UserRefund")->save($refund_data);
  124. $GLOBALS['msg']->manage_msg('MSG_MONEY_CARRY_RESULT',$refund_data['user_id'],$refund_data);
  125. $this->success($info);
  126. }else{
  127. $this->error("没有提现数据");
  128. }
  129. }
  130. public function delete() {
  131. //彻底删除指定记录
  132. $ajax = intval($_REQUEST['ajax']);
  133. $id = $_REQUEST ['id'];
  134. if (isset ( $id )) {
  135. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  136. $rel_data = M("UserRefund")->where($condition)->findAll();
  137. $list = M("UserRefund")->where ( $condition )->delete();
  138. foreach($rel_data as $data)
  139. {
  140. $info[] = "[id:".$data['id'].",ticket:".$data['ticket']."]";
  141. }
  142. if($info) $info = implode(",",$info);
  143. if ($list!==false) {
  144. save_log($info."成功删除",1);
  145. $this->success ("成功删除",$ajax);
  146. } else {
  147. save_log($info."删除出错",0);
  148. $this->error ("删除出错",$ajax);
  149. }
  150. } else {
  151. $this->error (l("INVALID_OPERATION"),$ajax);
  152. }
  153. }
  154. public function refund_check() {
  155. $user_id=intval($_REQUEST['user_id']);
  156. $sql = "select u.id, u.nick_name, b.`max_ticket` , u.ticket as 'actual_ticket', (u.ticket - b.`max_ticket`) as 'differ', u.refund_ticket, u.ticket - u.refund_ticket as 'surplus_ticket' from (select to_user_id, sum(total_ticket) as 'max_ticket' from (select to_user_id,sum(total_ticket) as total_ticket from ".DB_PREFIX."video_prop group by to_user_id";
  157. $table = DB_PREFIX . 'live_pay_log';
  158. $sql .= $this->refund_check_tablename_exist($table);
  159. $table = DB_PREFIX . 'live_pay_log_history';
  160. $sql .= $this->refund_check_tablename_exist($table);
  161. //家族、分享
  162. $table = DB_PREFIX . 'user_log';
  163. $sql .= $this->refund_check_tablename_exist_user_log($table);
  164. //分销
  165. $table = DB_PREFIX . 'distribution_log';
  166. $sql .= $this->refund_check_tablename_exist_distribution_log($table);
  167. $i = 0;
  168. do{
  169. $lastday=date('Ym',strtotime(date('Ym',NOW_TIME)." -".$i." month"));
  170. $sql1 = $this->refund_check_tablename_exist1($lastday);
  171. if($sql1!=''){
  172. $sql .= $sql1;
  173. }
  174. $i++;
  175. }while($sql1!=''&&$i<12);
  176. $sql .= " ) as a where a.to_user_id group by to_user_id ) b LEFT JOIN ".DB_PREFIX."user u on u.id = b.to_user_id where u.id=".$user_id." order by (u.ticket - b.`max_ticket`) desc";
  177. $list = $GLOBALS['db']->getAll($sql);
  178. $this->assign("list",$list);
  179. $this->display ();
  180. }
  181. public function refund_check_tablename_exist_distribution_log($table){
  182. $res = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  183. $sql = '';
  184. if($res){
  185. $sql = " UNION ALL select to_user_id,sum(ticket) as total_ticket from ".$table." group by to_user_id";
  186. }
  187. return $sql;
  188. }
  189. public function refund_check_tablename_exist_user_log($table){
  190. $res = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  191. $sql = '';
  192. if($res){
  193. $sql = " UNION ALL select user_id as to_user_id,sum(ticket) as total_ticket from ".$table." where type=4 and (log_info like '%收取家族收益%' or log_info like '%分享%') group by to_user_id";
  194. }
  195. return $sql;
  196. }
  197. public function refund_check_tablename_exist($table) {
  198. $res = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  199. $sql = '';
  200. if($res){
  201. $sql = " UNION ALL select to_user_id, sum(total_ticket) from ".$table." group by to_user_id";
  202. }
  203. return $sql;
  204. }
  205. public function refund_check_tablename_exist1($dayname='') {
  206. if($dayname==''){
  207. $dayname = date('Ym',NOW_TIME);
  208. }
  209. $table = DB_PREFIX . 'video_prop_' . $dayname;
  210. if($table!=''){
  211. $res = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  212. }else{
  213. $res = 0 ;
  214. }
  215. $sql = '';
  216. if($res){
  217. $sql = " UNION ALL select to_user_id, sum(total_ticket) from ".$table." where is_red_envelope=0 group by to_user_id";
  218. }
  219. return $sql;
  220. }
  221. }
  222. ?>