WeiboConfirmRefundAction.class.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 WeiboConfirmRefundAction extends CommonAction{
  10. public function index()
  11. {
  12. //列表过滤器,生成查询Map对象
  13. $map = $this->_search ();
  14. $condition['is_pay'] = 1;
  15. $condition['type'] = 1;
  16. //追加默认参数
  17. if($this->get("default_map"))
  18. $map = array_merge($map,$this->get("default_map"));
  19. $map = array_merge($map,$condition);
  20. if (method_exists ( $this, '_filter' )) {
  21. $this->_filter ( $map );
  22. }
  23. $model = D ('UserRefund');//print_r($map);exit();
  24. if (! empty ( $model )) {
  25. $this->_list ( $model, $map );
  26. }
  27. $this->display ();
  28. return;
  29. }
  30. /**
  31. * 提现确认记录
  32. */
  33. public function confirm_list(){
  34. //列表过滤器,生成查询Map对象
  35. $map = $this->_search ('UserRefund');
  36. $map['_string'] = 'is_pay = 1 or is_pay = 3 ';
  37. //追加默认参数
  38. if($this->get("default_map"))
  39. $map = array_merge($map,$this->get("default_map"));
  40. if (method_exists ( $this, '_filter' )) {
  41. $this->_filter ( $map );
  42. }
  43. //$name=$this->getActionName();
  44. $model = M ('UserRefund');
  45. if (! empty ( $model )) {
  46. $this->_list ( $model, $map );
  47. }
  48. $this->display ();
  49. return;
  50. }
  51. /**
  52. * 确认提现
  53. */
  54. public function refund_confirm()
  55. {
  56. $id = intval($_REQUEST['id']);
  57. $refund_data = M("UserRefund")->getById($id);
  58. if (intval($refund_data['withdrawals_type']) == 1){
  59. $alipay_info = M("User")->where("id = ".$refund_data['user_id'])->field('alipay_name,alipay_account')->select();
  60. $this->assign("alipay_info",$alipay_info);
  61. }
  62. $this->assign("refund_data",$refund_data);
  63. $this->display();
  64. }
  65. /**
  66. * 确认提现执行
  67. */
  68. public function confirm()
  69. {
  70. $id = intval($_REQUEST['id']);
  71. $refund_data = M("UserRefund")->getById($id);
  72. $user_id = $refund_data['user_id'];
  73. if($refund_data['is_pay']==3)
  74. {
  75. $this->error("已经提现过");
  76. }
  77. //已审核才可以提现
  78. if($refund_data&&$refund_data['is_pay']==1)
  79. {
  80. $m_config = load_auto_cache("m_config");//初始化手机端配置
  81. //微信提现
  82. //if (wx_withdraw_cash($id)||1){
  83. //管理员的SESSION
  84. $adm_session = es_session::get(md5(conf("AUTH_KEY")));
  85. $adm_id = intval($adm_session['adm_id']);
  86. if($refund_data['withdrawals_type'] == 0){
  87. define('OPEN_TEST_WX',0);//开启微信调试 只用于微信提现调试使用
  88. if (wx_withdraw_cash($id)){
  89. $refund_data['confirm_cash_ip'] = get_client_ip();
  90. M("UserRefund")->save($refund_data);
  91. //写入用户日志
  92. $data = array();
  93. $data['weibo_money'] = floatval($refund_data['weibo_money']);
  94. $data['log_admin_id'] = intval($adm_id);
  95. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  96. $ticket_name = '动态红包';
  97. $log_msg = '提现'.$data['weibo_money'].$ticket_name.'成功';
  98. account_log_com($data,$refund_data['user_id'],$log_msg,$param);
  99. $info = $refund_data['user_id'].$log_msg;
  100. save_log($info,1);
  101. $this->success("提现成功!");
  102. }else{
  103. //付款失败解冻用户提现印票
  104. $sql = "update ".DB_PREFIX."user set weibo_refund_money=weibo_refund_money-".$refund_data['weibo_money']." where id=".$refund_data['user_id'];
  105. $GLOBALS['db']->query($sql);
  106. if($GLOBALS['db']->affected_rows()){
  107. user_deal_to_reids(array($user_id));
  108. $refund_data['is_pay'] = 4;
  109. $refund_data['confirm_cash_ip'] = get_client_ip();
  110. M("UserRefund")->save($refund_data);
  111. //写入用户日志
  112. $data = array();
  113. $data['weibo_money'] = floatval($refund_data['weibo_money']);
  114. $data['log_admin_id'] = intval($adm_id);
  115. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  116. $ticket_name = '动态红包';
  117. $log_msg ='提现失败,解冻提现'.$data['weibo_money'].$ticket_name;
  118. save_log($refund_data['user_id'].$log_msg,0);
  119. account_log_com($data,$user_id,$log_msg,$param);
  120. }
  121. //写入日志
  122. $this->success("提现失败,请重试");
  123. }
  124. }elseif ($refund_data['withdrawals_type'] == 1){
  125. //支付宝提现
  126. //支付成功
  127. if (intval($_REQUEST['status']) == 1){
  128. $GLOBALS['db']->query("update ".DB_PREFIX."user_refund set pay_log='已付款',is_pay = 3,pay_time = ".get_gmtime().",confirm_cash_ip='".get_client_ip()."' where id = ".$id);
  129. $data = array();
  130. $data['weibo_money'] = floatval($refund_data['weibo_money']);
  131. $data['log_admin_id'] = intval($adm_id);
  132. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  133. $ticket_name = '动态红包';
  134. $log_msg = '提现'.$data['weibo_money'].$ticket_name.'成功';
  135. account_log_com($data,$refund_data['user_id'],$log_msg,$param);
  136. $info = $refund_data['user_id'].$log_msg;
  137. save_log($info,1);
  138. $this->success("提现成功!");
  139. }else{
  140. //付款失败解冻用户提现印票
  141. $sql = "update ".DB_PREFIX."user set weibo_refund_money=weibo_refund_money-".$refund_data['weibo_money']." where id=".$refund_data['user_id'];
  142. $GLOBALS['db']->query($sql);
  143. if($GLOBALS['db']->affected_rows()){
  144. user_deal_to_reids(array($user_id));
  145. $refund_data['is_pay'] = 4;
  146. $refund_data['confirm_cash_ip'] = get_client_ip();
  147. M("UserRefund")->save($refund_data);
  148. //写入用户日志
  149. $data = array();
  150. $data['weibo_money'] = floatval($refund_data['weibo_money']);
  151. $data['log_admin_id'] = intval($adm_id);
  152. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  153. $ticket_name = '动态红包';
  154. $log_msg ='提现失败,解冻提现'.$data['weibo_money'].$m_config['ticket_name'];
  155. save_log($refund_data['user_id'].$log_msg,0);
  156. account_log_com($data,$user_id,$log_msg,$param);
  157. }
  158. //写入日志
  159. $this->success("提现失败,请重试");
  160. }
  161. }elseif ($refund_data['withdrawals_type'] == 2){//公会提现
  162. $GLOBALS['db']->query("update ".DB_PREFIX."user_refund set pay_log='已付款',is_pay = 3,pay_time = ".get_gmtime().",confirm_cash_ip='".get_client_ip()."' where id = ".$id);
  163. $data = array();
  164. $data['weibo_money'] = floatval($refund_data['weibo_money']);
  165. $data['log_admin_id'] = intval($adm_id);
  166. $param['type'] = 1;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  167. $ticket_name = '动态红包';
  168. $log_msg = '提现'.$data['weibo_money'].$m_config['ticket_name'].'成功';
  169. account_log_com($data,$refund_data['user_id'],$log_msg,$param);
  170. $info = $refund_data['user_id'].$log_msg;
  171. save_log($info,1);
  172. $this->success("提现成功!");
  173. }
  174. //}
  175. }else{
  176. $this->error("没有提现数据");
  177. }
  178. }
  179. /**
  180. * 彻底删除
  181. */
  182. public function delete() {
  183. //彻底删除指定记录
  184. $ajax = intval($_REQUEST['ajax']);
  185. $id = $_REQUEST ['id'];
  186. if (isset ( $id )) {
  187. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  188. $rel_data = M("UserRefund")->where($condition)->findAll();
  189. $list = M("UserRefund")->where ( $condition )->delete();
  190. foreach($rel_data as $data)
  191. {
  192. $info[] = "[id:".$data['id'].",money:".$data['money']."]";
  193. }
  194. if($info) $info = implode(",",$info);
  195. if ($list!==false) {
  196. save_log($info."成功删除",1);
  197. $this->success ("成功删除",$ajax);
  198. } else {
  199. save_log($info."删除出错",0);
  200. $this->error ("删除出错",$ajax);
  201. }
  202. } else {
  203. $this->error (l("INVALID_OPERATION"),$ajax);
  204. }
  205. }
  206. /**
  207. * 导出电子表
  208. */
  209. public function export_csv($page = 1)
  210. {
  211. $pagesize = 10;
  212. set_time_limit(0);
  213. $limit = (($page - 1)*intval($pagesize)).",".(intval($pagesize));
  214. $where = " 1=1 ";
  215. //定义条件
  216. if(trim($_REQUEST['user_id'])!='')
  217. {
  218. $where.= " and ur.user_id = ".intval($_REQUEST['user_id']);
  219. }
  220. if(trim($_REQUEST['is_pay'])!='')
  221. {
  222. $where.= " and ur.is_pay = ".intval($_REQUEST['is_pay']);
  223. }
  224. $sql ="select u.user_name as user_name,u.id as user_id,u.email as email,u.ex_real_name as ex_real_name,u.ex_account_bank as ex_account_bank,u.ex_account_info as ex_account_info,u.ex_contact as ex_contact,u.mobile as mobile, ur.money as money,ur.user_bank_id from ".DB_PREFIX."user as u LEFT JOIN ".DB_PREFIX."user_refund as ur on ur.user_id = u.id where ".$where." limit ".$limit;
  225. $list=$GLOBALS['db']->getAll($sql);
  226. //var_dump($_REQUEST);exit;
  227. if($list)
  228. {
  229. register_shutdown_function(array(&$this, 'export_csv'), $page+1);
  230. $refund_value = array( 'user_name'=>'""', 'email'=>'""', 'bank_info'=>'""','mobile'=>'""','money'=>'""');
  231. if($page == 1)
  232. {
  233. $content = iconv("utf-8","gbk","会员名,邮箱,银行账户,手机,提现金额");
  234. $content = $content . "\n";
  235. }
  236. foreach($list as $k=>$v)
  237. {
  238. $refund_value['user_name'] = '"' . iconv('utf-8','gbk',$list[$k]['user_name']) . '"';
  239. $refundr_value['email'] = '"' . iconv('utf-8','gbk',$list[$k]['email']) . '"';
  240. // $refund_value['ex_real_name'] = '"' . iconv('utf-8','gbk',$list[$k]['ex_real_name']) . '"';
  241. // $refund_value['ex_account_bank'] = '"' . iconv('utf-8','gbk',$list[$k]['ex_account_bank']) . '"';
  242. // $refund_value['ex_account_info'] = '"' . iconv('utf-8','gbk',$list[$k]['ex_account_info']) . '"';
  243. // $refund_value['ex_contact'] = '"' . iconv('utf-8','gbk',$list[$k]['ex_contact']) . '"';
  244. $refund_value['bank_info'] = '"' . iconv('utf-8','gbk',get_carray_info($list[$k]['user_bank_id'],$list[$k]['user_id'])) . '"';
  245. $refund_value['mobile'] = '"' . iconv('utf-8','gbk',$list[$k]['mobile']) . '"';
  246. $refund_value['money'] = '"' . iconv('utf-8','gbk',$list[$k]['money']) . '"';
  247. $content .= implode(",", $refund_value) . "\n";
  248. }
  249. //
  250. header("Content-Disposition: attachment; filename=refund_list.csv");
  251. echo $content ;
  252. }
  253. else
  254. {
  255. if($page==1)
  256. $this->error(L("NO_RESULT"));
  257. }
  258. }
  259. }
  260. ?>