user_center.action.php 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  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 user_centerCModule extends baseCModule
  10. {
  11. //我的等级
  12. public function grade(){
  13. $root = array();
  14. $user_id = intval($_REQUEST['user_id']);
  15. if($user_id == 0){
  16. $user_id = $GLOBALS['user_info']['id'];
  17. }
  18. if($user_id == 0){
  19. $root['error'] = "用户未登陆,请先登陆.";
  20. $root['status'] = 0;
  21. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  22. }else{
  23. //chack_grade(intval($GLOBALS['user_info']['id']));
  24. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  25. $user_redis = new UserRedisService();
  26. $user_data = $user_redis->getRow_db($user_id,array('id','score','online_time','user_level'));
  27. user_leverl_syn($user_data);
  28. $level=$GLOBALS['db']->getRow("select ul.name as leve_name,ul.score as l_score from ".DB_PREFIX."user_level as ul where ul.level=".intval($user_data['user_level']));
  29. $m_config = load_auto_cache("m_config");
  30. $level['u_score'] = $user_data['score']+floor($user_data['online_time']*floatval($m_config['onlinetime_to_experience']));
  31. $level['up_score'] = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where level=".intval($user_data['user_level']+1));
  32. if(intval($level['up_score'])<=0){
  33. $l_up_score = $GLOBALS['db']->getOne("select score from ".DB_PREFIX."user_level where level>".intval($user_data['user_level']+1));
  34. if($l_up_score['score']>0){
  35. $level['up_score'] =$l_up_score['score'];
  36. }else{
  37. $level['up_score'] ='满级';
  38. }
  39. }
  40. $user_data['user_level'] = $level['name'];
  41. $root = $level;
  42. $root['status'] = 1;
  43. $root['error'] = '';
  44. }
  45. $root['page_title'] = '等级';
  46. api_ajax_return($root);
  47. }
  48. //我的收益
  49. public function profit(){
  50. $root = array();
  51. if(!$GLOBALS['user_info']){
  52. $root['error'] = "用户未登陆,请先登陆.";
  53. $root['status'] = 0;
  54. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  55. }else{
  56. $user_id = intval($GLOBALS['user_info']['id']);
  57. //$profit= $GLOBALS['db']->getRow("select ticket,money,subscribe,wx_openid,mobile from ".DB_PREFIX."user where id=".$user_id);
  58. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  59. $user_redis = new UserRedisService();
  60. //$profit = $user_redis->getRow_db($user_id,array('ticket','money','subscribe','wx_openid','mobile','refund_ticket','binding_alipay'));
  61. $profit = $GLOBALS['db']->getRow("select ticket,money,refund_ticket,subscribe,wx_openid,binding_alipay,weibo_refund_money,weibo_money from ".DB_PREFIX."user where id = ".$user_id);
  62. //$root = $profit;
  63. $root['status'] = 1;
  64. $root['error'] = '';
  65. $m_config = load_auto_cache("m_config");//初始化手机端配置
  66. $root['ticket_catty_ratio'] = floatval($m_config['ticket_catty_ratio']);//提现比例
  67. //公会长提现比例特殊
  68. if (OPEN_SOCIETY_MODULE){
  69. $society_info = $GLOBALS['db']->getRow("select society_id,society_chieftain from ".DB_PREFIX."user where id=".$user_id);
  70. if (intval($society_info['society_chieftain'])){//判断是否是公会长
  71. $refund_rate = $GLOBALS['db']->getOne("select refund_rate from ".DB_PREFIX."society where id=".$society_info['society_id']);
  72. $root['ticket_catty_ratio'] = floatval($refund_rate);
  73. if ($root['ticket_catty_ratio'] > 1 || $root['ticket_catty_ratio'] <= 0){
  74. $root['ticket_catty_ratio'] = $m_config['society_public_rate'];
  75. }
  76. }
  77. }
  78. $root['ticket'] =intval($profit['ticket']);
  79. $root['money'] = number_format(intval($profit['ticket']-$profit['refund_ticket'])*floatval($root['ticket_catty_ratio']),2);
  80. $root['useable_ticket'] =intval($profit['ticket']-$profit['refund_ticket']);
  81. $root['subscribe'] =intval($profit['subscribe']);
  82. $root['weibo_money'] = number_format($profit['weibo_money']-$profit['weibo_refund_money'],2);
  83. //$root['weibo_refund_money'] = number_format($profit['weibo_refund_money'],2);
  84. $root['weibo_total_money'] = number_format($profit['weibo_money'],2);
  85. //最小提现印票
  86. $root['ticket_catty_min'] = intval(intval($m_config['ticket_catty_min'])/floatval($root['ticket_catty_ratio']));
  87. //添加微信公众号名称
  88. $root['subscription'] =mb_strlen($m_config['subscription'])?$m_config['subscription']:'';
  89. //每日可提现印票
  90. if (floatval($root['ticket_catty_ratio']) > 0){
  91. $root['day_ticket_max'] = intval(intval($m_config['day_cash_max'])/floatval($root['ticket_catty_ratio']));
  92. }
  93. //是否有未处理的提现
  94. if($GLOBALS['db']->getOne("select count(*) FROM ".DB_PREFIX."user_refund WHERE user_id = ".$user_id." and (is_pay =0 or is_pay=1)") > 0){
  95. $root['refund_exist'] = 1;
  96. }else{
  97. $root['refund_exist'] = 0;
  98. }
  99. if($profit['wx_openid']!='')
  100. $root['binding_wx'] = 1;
  101. else
  102. $root['binding_wx'] = 0;
  103. if($profit['mobile']!='')
  104. $root['mobile_exist'] = 1;
  105. else
  106. $root['mobile_exist'] = 0;
  107. if(OPEN_PAI_MODULE==1){
  108. $rs = FanweServiceCall("user_center","profit",array("user_id"=>$user_id));
  109. }
  110. //$rs = FanweServiceCall("user_center","profit",array("user_id"=>$user_id));
  111. //$rs['pai_income_done'] = 0;
  112. //$rs['pai_income_undone'] = 0;
  113. $root['show_pai_ticket'] = 0;
  114. $root['pai_ticket'] = intval($rs['pai_income_done']);
  115. $root['pai_wait_ticket'] = intval($rs['pai_income_undone']);
  116. $root['show_goods_ticket'] = 0;
  117. $root['goods_ticket'] = intval($rs['goods_income_done']);
  118. $root['goods_wait_ticket'] = intval($rs['goods_income_undone']);
  119. //是否绑定支付宝 0指未绑定, 1指已绑定
  120. $root['binding_alipay'] = intval($profit['binding_alipay']);
  121. //提现开启或关闭 1:开启 0:关闭
  122. $root['is_refund'] = $m_config['is_refund'];
  123. if (intval($m_config['is_refund']) == 1){//提现是开启的
  124. //开启微信还是支付宝提现
  125. $withdrawals_type = intval($m_config['withdrawals_type']);
  126. if($withdrawals_type == 0){
  127. $root['withdrawals_wx'] = 1;
  128. $root['withdrawals_alipay'] = 0;
  129. }else{
  130. $root['withdrawals_wx'] = 0;
  131. $root['withdrawals_alipay'] = 1;
  132. }
  133. }else{//提现是关闭的,微信支付宝均设为0
  134. $root['withdrawals_wx'] = 0;
  135. $root['withdrawals_alipay'] = 0;
  136. }
  137. }
  138. ajax_return($root);
  139. }
  140. //我的收益-兑换规则列表
  141. public function exchange()
  142. {
  143. $root = array('status'=>1,'error'=>'');
  144. $m_config = load_auto_cache("m_config");//初始化手机端配置
  145. if(!$GLOBALS['user_info']){
  146. $root['error'] = "用户未登陆,请先登陆.";
  147. $root['status'] = 0;
  148. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  149. }else{
  150. $exchange_rules = $video_new = $GLOBALS['db']->getAll("select er.id,er.diamonds,er.ticket from ".DB_PREFIX."exchange_rule as er where is_effect=1 and is_delete=0 order by er.diamonds");
  151. $root['exchange_rules'] = $exchange_rules;
  152. //$user = $GLOBALS['db']->getRow("select ticket,diamonds from ".DB_PREFIX."user where id=".$GLOBALS['user_info']['id'],true,true);
  153. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  154. $user_redis = new UserRedisService();
  155. $user = $user_redis->getRow_db($GLOBALS['user_info']['id'],array('ticket','diamonds','refund_ticket'));
  156. $GLOBALS['user_info']['ticket'] = intval($user['ticket']);
  157. $root['ticket'] = intval($user['ticket']);
  158. $GLOBALS['user_info']['refund_ticket'] = intval($user['refund_ticket']);
  159. $root['refund_ticket'] = intval($user['refund_ticket']);//已使用的印票
  160. $GLOBALS['user_info']['diamonds'] = intval($user['diamonds']);
  161. $root['diamonds'] = intval($user['diamonds']);
  162. $root['useable_ticket'] =intval($user['ticket']-$user['refund_ticket']);
  163. //兑换规则
  164. //$ratio = floatval(app_conf('TICKET_CATTY_RATIO'));
  165. $ratio = $m_config['exchange_rate'];
  166. $root['ratio'] = $ratio;
  167. $m_config = load_auto_cache("m_config");
  168. $exchange_rate = floatval($m_config['exchange_rate']);
  169. //兑换最低票数
  170. if($exchange_rate>0){
  171. $min_ticket = floatval(1/$exchange_rate);
  172. $root['min_ticket'] = $min_ticket;
  173. }else{
  174. $root['min_ticket'] = 0;
  175. }
  176. }
  177. ajax_return($root);
  178. }
  179. //我的收益-兑换功能
  180. public function do_exchange(){
  181. $root = array();
  182. if(!$GLOBALS['user_info']){
  183. $root['error'] = "用户未登陆,请先登陆.";
  184. $root['status'] = 0;
  185. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  186. }else{
  187. $user_id = intval($GLOBALS['user_info']['id']);//登录用户
  188. $rule_id = intval($_REQUEST['rule_id']);//100
  189. $ticket = intval($_REQUEST['ticket']);//250000
  190. //$user = $GLOBALS['db']->getRow("select ticket,diamonds from ".DB_PREFIX."user where id=".$user_id);
  191. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  192. $user_redis = new UserRedisService();
  193. $user = $user_redis->getRow_db($user_id,array('ticket','diamonds','refund_ticket'));
  194. $m_config = load_auto_cache("m_config");//初始化手机端配置
  195. if($user['ticket']-$user['refund_ticket']<$ticket){
  196. $root['status'] = 0;
  197. $root['error'] = $m_config['ticket_name'].'不足';
  198. $root['ticket'] = $user['ticket'];
  199. $root['refund_ticket'] = $user['refund_ticket'];
  200. $root['diamonds'] = $user['diamonds'];
  201. ajax_return($root);
  202. }
  203. if($rule_id>0){
  204. //兑换规则
  205. $exchange_rule = $video_new = $GLOBALS['db']->getRow("select er.* from ".DB_PREFIX."exchange_rule as er where is_effect=1 and is_delete=0 and id = ".$rule_id." and ticket=".$ticket);
  206. if($exchange_rule){
  207. $diamonds = intval($exchange_rule['diamonds']);
  208. $ticket = intval($exchange_rule['ticket']);
  209. }else{
  210. $root['status'] = 0;
  211. $root['error'] = '兑换出错';
  212. $root['ticket'] = $user['ticket'];
  213. $root['refund_ticket'] = $user['refund_ticket'];
  214. $root['diamonds'] = $user['diamonds'];
  215. ajax_return($root);
  216. }
  217. }else{
  218. //自定义兑换
  219. //$ratio = app_conf('TICKET_CATTY_RATIO');
  220. $ratio = $m_config['exchange_rate'];
  221. $diamonds = intval($ticket*$ratio);
  222. }
  223. if($diamonds>0){
  224. //使用兑换列表的值
  225. $sql = "update ".DB_PREFIX."user set refund_ticket=refund_ticket+".$ticket.",diamonds=diamonds+".$diamonds." where ticket >= refund_ticket + ".$ticket." and id=".$user_id;
  226. $GLOBALS['db']->query($sql);
  227. if($GLOBALS['db']->affected_rows()){
  228. //redis 更新信息
  229. user_deal_to_reids(array($user_id));
  230. $exchange_log = array();
  231. $exchange_log['user_id'] = $user_id;
  232. $exchange_log['rule_id'] = $rule_id;
  233. $exchange_log['diamonds'] = $diamonds;
  234. $exchange_log['ticket'] = $ticket;
  235. $exchange_log['create_time'] = get_gmtime();
  236. $exchange_log['is_success'] = 1;
  237. $GLOBALS['db']->autoExecute(DB_PREFIX."exchange_log",$exchange_log,"INSERT","","SILENT");
  238. //写入用户日志
  239. $data = array();
  240. $data['diamonds'] = intval($diamonds);
  241. $data['ticket'] = intval($ticket);
  242. $param['type'] = 3;//类型 0表示充值 1表示提现 2赠送道具 3 兑换印票
  243. $ticket_name = $m_config['ticket_name']!=''?$m_config['ticket_name']:'印票';
  244. $log_msg = $ticket.$ticket_name.'兑换成'.$diamonds.'钻石';
  245. account_log_com($data,$user_id,$log_msg,$param);
  246. $root['error'] = '兑换成功';
  247. $root['status'] = 1;
  248. }else{
  249. $exchange_log['is_success'] = 0;
  250. $GLOBALS['db']->autoExecute(DB_PREFIX."exchange_log",$exchange_log,"INSERT","","SILENT");
  251. $root['status'] = 0;
  252. $root['error'] = '兑换失败';
  253. }
  254. }
  255. }
  256. //获取新的印票
  257. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  258. $user_redis = new UserRedisService();
  259. $user_new_info = $user_redis->getRow_db($user_id,array('ticket','diamonds','refund_ticket'));
  260. $GLOBALS['user_info']['ticket'] = $user_new_info['ticket'];
  261. $GLOBALS['user_info']['refund_ticket'] = $user_new_info['refund_ticket'];
  262. $GLOBALS['user_info']['diamonds'] = $user_new_info['diamonds'];
  263. $root['ticket'] = $user_new_info['ticket'];
  264. $root['refund_ticket'] = $user_new_info['refund_ticket'];
  265. $root['diamonds'] = $user_new_info['diamonds'];
  266. $root['useable_ticket'] =intval($user_new_info['ticket']-$user_new_info['refund_ticket']);
  267. ajax_return($root);
  268. }
  269. //微信提现
  270. public function money_carry_wx()
  271. {
  272. $root = array();
  273. if(!$GLOBALS['user_info']){
  274. $root['error'] = "用户未登陆,请先登陆.";
  275. $root['status'] = 0;
  276. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  277. }else{
  278. $m_config = load_auto_cache("m_config");//初始化手机端配置
  279. if(intval($m_config['is_refund']) != 1 || intval($m_config['withdrawals_type']) != 0)
  280. {
  281. $root['status'] =0;
  282. $root['error'] ='微信提现已经关闭!';
  283. ajax_return($root);
  284. }
  285. //$ticket_info =floatval($GLOBALS['db']->getRow("select ticket,refund_ticket from ".DB_PREFIX."user where id = '".intval($GLOBALS['user_info']['id'])."'"));
  286. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  287. $user_redis = new UserRedisService();
  288. $ticket_info = $user_redis->getRow_db($GLOBALS['user_info']['id'],array('ticket','refund_ticket'));
  289. $ready_refund_ticket =floatval($GLOBALS['db']->getOne("select sum(ticket) from ".DB_PREFIX."user_refund where user_id = ".intval($GLOBALS['user_info']['id'])." and is_pay in (0,1,3)"));
  290. $bank_info['ratio']= floatval($m_config['ticket_catty_ratio']);
  291. $bank_info['can_use_ticket']=$ticket_info['ticket']-$ticket_info['refund_ticket']-$ready_refund_ticket;
  292. $bank_info['ready_refund_ticket']=$ready_refund_ticket;
  293. $root = $bank_info;
  294. $root['status'] = 1;
  295. $root['error'] ='';
  296. }
  297. ajax_return($root);
  298. }
  299. //微信提现
  300. public function submitrefundwx()
  301. {
  302. $root = array();
  303. $id = intval($_REQUEST['id']);
  304. $m_config = load_auto_cache("m_config");//初始化手机端配置
  305. $user_info_wx = es_session::get("user_info_wx");
  306. $user_info =$user_info_wx[$id];
  307. $refresh = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind';
  308. //$user_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".intval($id));
  309. $tips = '<!DOCTYPE html>
  310. <html>
  311. <head>
  312. <meta charset="utf-8">
  313. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  314. <title>微信提现</title>
  315. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=0,minimum-scale=0.5">
  316. <meta http-equiv="refresh" content="1; url='.$refresh.'"><link rel="shortcut icon" href="/favicon.ico">
  317. <meta name="apple-mobile-web-app-capable" content="yes">
  318. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  319. </head>
  320. <body style="background:#f0f7f6;">
  321. xxxx
  322. </body>
  323. </html>';
  324. if(!$user_info){
  325. $error = "用户未登陆,请先登陆.";
  326. echo str_replace('xxxx',$error,$tips);return;
  327. }else{
  328. // 进入每月提现一次流程
  329. $month_carry_one = intval($m_config['month_carry_one'])?1:0;
  330. if($month_carry_one){
  331. $ready_refund_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user_refund where user_id = ".intval($user_info['id'])." and is_pay = 3");
  332. $pay_time = $ready_refund_info['pay_time'];
  333. //本月是否有提现
  334. if($pay_time!=''&&(to_date($pay_time,"Ym")==to_date(get_gmtime(),'Ym'))){
  335. $error ='每月只能提现一次,本月已经提现过了';
  336. echo str_replace('xxxx',$error,$tips);return;
  337. }else{
  338. //查看本月允许提现时间
  339. if(to_date(get_gmtime(),'d')<intval($m_config['month_carry_min'])||to_date(get_gmtime(),'d')>intval($m_config['month_carry_max'])){
  340. $error ='每月'.intval($m_config['month_carry_min']).'日到'.intval($m_config['month_carry_max']).'日才能提现';
  341. echo str_replace('xxxx',$error,$tips);return;
  342. }
  343. }
  344. }
  345. $ready_refund_id =intval($GLOBALS['db']->getOne("select id from ".DB_PREFIX."user_refund where user_id = ".intval($user_info['id'])." and (is_pay =0 or is_pay=1)"));
  346. if($ready_refund_id)
  347. {
  348. $error ='您还有未处理的提现!';
  349. echo str_replace('xxxx',$error,$tips);return;
  350. }
  351. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  352. $user_redis = new UserRedisService();
  353. $user_ticket_info = $user_redis->getRow_db($user_info['id'],array('ticket','refund_ticket'));
  354. $memo = "微信提现";
  355. //可用印票
  356. $use_ticket =$user_ticket_info['ticket']-$user_ticket_info['refund_ticket'];
  357. //今日可提现金额
  358. $s_now_time = to_timespan(to_date(NOW_TIME,"Y-m-d 00:00:00"));
  359. $e_now_time = to_timespan(to_date(NOW_TIME,"Y-m-d 23:59:59"));
  360. $ready_refund_info = $GLOBALS['db']->getOne("select sum(money) from " . DB_PREFIX . "user_refund where user_id = " . intval($user_info['id']) . " and is_pay = 3 and pay_time>=".$s_now_time." and pay_time<=".$e_now_time);
  361. $use_cash_money = floatval(floatval($m_config['day_cash_max']) - $ready_refund_info);
  362. $rate = $m_config['ticket_catty_ratio'];
  363. if (OPEN_SOCIETY_MODULE == 1){
  364. $society_info = $GLOBALS['db']->getRow("select society_id,society_chieftain from ".DB_PREFIX."user where id=".$user_info['id']);
  365. if (intval($society_info['society_chieftain']) == 1){
  366. $error ='会长提现,请联系客服!';
  367. echo str_replace('xxxx',$error,$tips);return;
  368. $refund_rate = $GLOBALS['db']->getOne("select refund_rate from ".DB_PREFIX."society where id=".$society_info['society_id']);
  369. $rate = floatval($refund_rate);
  370. }elseif(intval($society_info['society_id'])){
  371. $error ='公会成员不允许提现!';
  372. echo str_replace('xxxx',$error,$tips);return;
  373. $refund_rate = $GLOBALS['db']->getOne("select refund_rate from ".DB_PREFIX."society where id=".$society_info['society_id']);
  374. $rate = floatval($refund_rate);
  375. }
  376. }
  377. //总金额
  378. $use_money = floatval($use_ticket*$rate);
  379. $ticket_catty_min = $m_config['ticket_catty_min']?$m_config['ticket_catty_min']:1;
  380. if($use_money<$ticket_catty_min){
  381. $error = "可领取金额小于提现最低额度".$ticket_catty_min."元!";
  382. echo str_replace('xxxx',$error,$tips);return;
  383. }
  384. $cash_money = strim($_REQUEST['cash_money']);
  385. $num_cash_money = floatval($cash_money);
  386. if(!isset($_REQUEST['cash_money'])){
  387. $error_tip = "";
  388. $cash_money='';
  389. }elseif($cash_money==''){
  390. $error_tip = "请输入领取金额";
  391. $cash_money='';
  392. }elseif(!preg_match('/^[0-9]+(.[0-9]{0,2})?$/', $cash_money)){
  393. $error_tip = "领取金额最多两位小数";
  394. }elseif($num_cash_money<$ticket_catty_min){
  395. $error_tip = "领取金额最低额度为".$ticket_catty_min."元";
  396. }elseif($num_cash_money>$use_money){
  397. $error_tip = "领取金额超过总金额";
  398. }elseif($num_cash_money>$use_cash_money){
  399. $error_tip = "领取金额超过今日可领取金额";
  400. }else{
  401. $ticket = $num_cash_money/$rate;
  402. if($ticket>0&&$num_cash_money>0){
  403. $refund_data['money'] = $num_cash_money;
  404. $refund_data['user_bank_id'] = -1;
  405. $refund_data['ticket'] = $ticket;
  406. $refund_data['user_id'] = $user_info['id'];
  407. $refund_data['create_time'] = NOW_TIME;
  408. $refund_data['memo'] = $memo;
  409. $refund_data['withdrawals_type'] = 0;
  410. $GLOBALS['db']->autoExecute(DB_PREFIX."user_refund",$refund_data);
  411. $error ='提现申请提交成功!';
  412. echo str_replace('xxxx',$error,$tips);return;
  413. }else{
  414. $error ='提现申请提交失败!';
  415. echo str_replace('xxxx',$error,$tips);return;
  416. }
  417. }
  418. $action = SITE_DOMAIN.'/mapi/index.php?ctl=user_center&act=submitrefundwx&id='.$id;
  419. $html = '<div class="content">
  420. <div class="m-top">
  421. <div class="m-user">
  422. <div class="user-img">
  423. <img src="'.$user_info['head_image'].'"/>
  424. </div>
  425. <div class="user-name">
  426. <p class="name">'.$user_info['nick_name'].'</p>
  427. <p class="id">'.$user_info['id'].'</p>
  428. </div>
  429. <div class="clear"></div>
  430. </div>
  431. <div class="m-money">
  432. <div class="money-all">
  433. <p class="money">'.number_format($use_money,2).'</p><p class="title">总金额(元)</p>
  434. </div>
  435. <div class="money-today">
  436. <p class="money">'.number_format($use_cash_money,2).'</p><p class="title">今日可领取金额(元)</p>
  437. </div>
  438. <div class="clear"></div>
  439. </div>
  440. <div class="clear"></div>
  441. </div>
  442. <form method="post" action="'.$action.'">
  443. <div class="m-input">
  444. <span>领取金额</span>
  445. <div class="input-content">
  446. <input type="text" name="cash_money" value="'.$cash_money.'" placeholder="请输入要领取的金额" />
  447. <span>(元)</span>
  448. </div>
  449. </div>';
  450. if($error_tip){
  451. $html.='<div class="m-input">
  452. <span style="padding-left:60px;text-align:right;">&nbsp;</span>
  453. <div class="input-content">
  454. <span style="color:red">'.$error_tip.'</span>
  455. </div>
  456. </div>';
  457. }
  458. $html.='<div class="button">
  459. <input type="submit" value="确定"/>
  460. </div></form>
  461. </div>';
  462. echo '<!DOCTYPE html><html><head>
  463. <meta charset="UTF-8">
  464. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  465. <title>微信提现</title>
  466. <meta name="viewport" content="initial-scale=1, maximum-scale=1">
  467. <meta name="apple-mobile-web-app-capable" content="yes">
  468. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  469. <style type="text/css">
  470. *{margin: 0;padding: 0;}
  471. body{background: #eef7f4;font-size: 16px;}
  472. .clear {clear: both;visibility: hidden;font-size: 0;height: 0;line-height: 0;}
  473. .content{padding: 20px;background: #fff;}
  474. .m-user{display: -webkit-flex;display: flex;-webkit-align-items: center;align-items: center;margin-bottom: 15px;}
  475. .user-img{width: 40px;height: 40px;overflow: hidden;border-radius: 50%;float: left;margin-right: 5px;}
  476. .user-img img{width: 100%;}
  477. .user-name{float: left;}
  478. .user-name .name{font-size: 18px;line-height: 18px;margin-bottom: 5px;}
  479. .m-money{text-align: center;display: -webkit-flex;display: flex;-webkit-justify-content: center;justify-content: center;}
  480. .money-all{width: 50%;padding-right: 10px;box-sizing: border-box;text-align: left;}
  481. .money{font-size: 24px;color: #FF0000;font-family: arial;}
  482. .money-today{width: 50%;padding-left: 10px;box-sizing: border-box;text-align: left;}
  483. .title{color: #666;line-height: 20px;font-size: 14px;}
  484. .button{text-align: center;display: -webkit-flex;display: flex;margin: 15px 0 0 66px;}
  485. .button input{border:none;text-align: center;background: #ff5500;height: 40px;line-height: 40px;color: #fff;padding: 0 30px;display: block;text-decoration: none;border-radius: 3px;}
  486. .m-input{display: -webkit-flex;display: flex;-webkit-align-items: center;align-items: center;margin-top: 15px;display:-webkit-box;-webkit-box-orient:horizontal;}
  487. .m-input .input-content{display:flex;-webkit-box-flex:1;-moz-box-flex:1;-webkit-box-align:center;}
  488. .m-input input{height: 36px;line-height: 36px;border: 1px solid #dedede;padding: 0 10px;margin: 0 10px;display: flex;font-size:14px;}
  489. .m-input span{font-size: 14px;line-height: 30px;color: #666;}
  490. </style></head><body>
  491. '.$html.'
  492. </body></html>';
  493. }
  494. }
  495. //编辑账户信息初始化
  496. public function user_edit(){
  497. $root = array();
  498. if(!$GLOBALS['user_info']){
  499. $root['error'] = "用户未登陆,请先登陆.";
  500. $root['status'] = 0;
  501. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  502. }else{
  503. $root['status'] = 1;
  504. $root['error'] = "";
  505. $user_id = intval($GLOBALS['user_info']['id']);
  506. $sql = "select id as user_id,head_image,nick_name,sex,signature,is_authentication,birthday,emotional_state,province,city,job,is_edit_sex,luck_num from ".DB_PREFIX."user where id=".$user_id;
  507. $user= $GLOBALS['db']->getRow($sql,true,true);
  508. foreach($user as $k=>$v){
  509. $user[$k]= htmlspecialchars_decode($v);
  510. }
  511. $user['head_image'] = get_spec_image($user['head_image']);
  512. $user['birthday'] = date('Y-m-d',$user['birthday']);
  513. $root['user'] = $user;
  514. }
  515. ajax_return($root);
  516. }
  517. //保存账户信息
  518. public function user_save(){
  519. $root = array();
  520. if(!$GLOBALS['user_info']){
  521. $root['error'] = "用户未登陆,请先登陆.";
  522. $root['status'] = 0;
  523. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  524. }else{
  525. $user_id = intval($GLOBALS['user_info']['id']);
  526. $user_info_req = $_REQUEST;
  527. foreach($user_info_req as $k=>$v){
  528. if($v!='user_center'||$v!='user_save'){
  529. $user_info[$k] = trim($v);
  530. }
  531. }
  532. //判断性别是否可修改
  533. if(isset($user_info['sex'])){
  534. $user_info['is_edit_sex'] = 0;
  535. }
  536. $user_info['id'] =$user_id;
  537. $user_info['birthday'] = strtotime($user_info['birthday']);
  538. $GLOBALS['db']->query("set names 'utf8mb4'");
  539. if($user_info['birthday']=='')unset($user_info['birthday']);
  540. if($user_info['signature']=='')unset($user_info['signature']);
  541. if($user_info['nick_name']=='')unset($user_info['nick_name']);
  542. $m_config = load_auto_cache("m_config");//初始化手机端配置
  543. //昵称如果等于铭感词,则提示,如果包含 则用*代替
  544. if($m_config['name_limit']==1){
  545. $nick_name=$user_info['nick_name'];
  546. $limit_sql =$GLOBALS['db']->getCol("SELECT name FROM ".DB_PREFIX."limit_name");
  547. $in=in_array($nick_name,$limit_sql);
  548. if($in){
  549. ajax_return(array("sqtatus"=>0,"error"=>'昵称包含敏感词汇'));
  550. }elseif($GLOBALS['db']->getCol("SELECT name FROM ".DB_PREFIX."limit_name WHERE '$nick_name' like concat('%',name,'%')")){
  551. $user_info['nick_name']=str_replace($limit_sql,'*',$nick_name);
  552. }
  553. }
  554. if($GLOBALS['db']->getOne("SELECT nick_name FROM ".DB_PREFIX."user WHERE nick_name ='$nick_name' and id!= $user_id" ))
  555. {
  556. ajax_return(array("status"=>0,"error"=>'昵称被占用,请重新输入'));
  557. }
  558. fanwe_require(APP_ROOT_PATH."system/libs/user.php");
  559. //提交空字段不操作
  560. if($user_info){
  561. $status = save_user($user_info,'UPDATE');
  562. }else{
  563. $root['status'] = 1;
  564. $root['error'] = '';
  565. ajax_return($root);
  566. }
  567. if($status){
  568. //更新session
  569. $user_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id =".$status['data']);
  570. es_session::set("user_info", $user_info);
  571. $user_id= $status['data'];
  572. $sql = "select id as user_id,head_image,nick_name,sex,signature,is_authentication,birthday,emotional_state,province,city,job,is_edit_sex from ".DB_PREFIX."user where id=".$user_id;
  573. $user= $GLOBALS['db']->getRow($sql);
  574. $user['head_image'] = get_spec_image($user['head_image']);
  575. $user['birthday'] = date('Y-m-d',$user['birthday']);
  576. $root['status'] = 1;
  577. $root['error'] = '编辑成功';
  578. $root['user'] = $user;
  579. }else{
  580. $root['status'] = 0;
  581. $root['error'] = '编辑失败';
  582. }
  583. }
  584. ajax_return($root);//返回信息缺少认证信息
  585. }
  586. //地区接口
  587. public function region_list(){
  588. $root = array();
  589. $root['status'] = 1;
  590. $root['error'] = '';
  591. $region_list = load_auto_cache("region_list");
  592. $root['region_list'] = $region_list;
  593. $m_config = load_auto_cache("m_config");
  594. $root['region_versions'] =$m_config['region_versions'];
  595. ajax_return($root);
  596. }
  597. //认证初始化
  598. public function authent(){
  599. $root = array();
  600. if(!$GLOBALS['user_info']){
  601. $root['error'] = "用户未登陆,请先登陆.";
  602. $root['status'] = 0;
  603. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  604. }else{
  605. $m_config = load_auto_cache("m_config");
  606. $root['status'] = 1;
  607. $root['error'] = "";
  608. $root['title'] = $m_config['short_name']."认证";
  609. $user_id = intval($GLOBALS['user_info']['id']);
  610. $user_sql = "select id,id as user_id,investor_send_info,authentication_type,authentication_name,identify_number, contact,from_platform,wiki,identify_positive_image,identify_nagative_image,identify_hold_image,is_authentication from ".DB_PREFIX."user where is_effect =1 and id=".$user_id;
  611. $user = $GLOBALS['db']->getRow($user_sql,true,true);
  612. foreach($user as $k=>$v){
  613. $user[$k] = htmlspecialchars_decode($v);
  614. }
  615. $user['identify_number'] = !empty($user['identify_number'])?$user['identify_number']:'';
  616. $authent_list_sql = "select id,`name` from ".DB_PREFIX."authent_list order by sort desc";
  617. $authent_list = $GLOBALS['db']->getAll($authent_list_sql,true,true);
  618. $root['user'] = $user;
  619. $root['authent_list'] = $authent_list;
  620. $root['investor_send_info'] = $user['investor_send_info'];
  621. }
  622. ajax_return($root);
  623. }
  624. //提交认证
  625. public function attestation(){
  626. $root = array();
  627. if(!$GLOBALS['user_info']){
  628. $root['error'] = "用户未登陆,请先登陆.";
  629. $root['status'] = 0;
  630. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  631. }else{
  632. $root['status'] = 1;
  633. $root['error'] = "";
  634. fanwe_require(APP_ROOT_PATH.'system/libs/user.php');
  635. $authentication_type = strim($_REQUEST['authentication_type']);//认证类型
  636. $authentication_name = trim($_REQUEST['authentication_name']) ;//真实姓名
  637. $identify_number = strim($_REQUEST['identify_number']) ;//身份证号码
  638. $contact = trim($_REQUEST['contact']);//联系方式
  639. //$from_platform = '';//来自平台
  640. $wiki =trim($_REQUEST['wiki']); //百度百科
  641. $identify_hold_image=strim($_REQUEST['identify_hold_image']);//手持身份证正面
  642. $identify_positive_image=strim($_REQUEST['identify_positive_image']);//身份证正面
  643. $identify_nagative_image=strim($_REQUEST['identify_nagative_image']);//身份证反面
  644. //=============================
  645. if($authentication_type==''){
  646. $root['status'] = 0;
  647. $root['error'] = '请选择认证类型!';
  648. ajax_return($root);
  649. }
  650. if($authentication_name==''){
  651. $root['status'] = 0;
  652. $root['error'] = '请填写真实姓名!';
  653. ajax_return($root);
  654. }
  655. if($identify_number==''){
  656. $root['status'] = 0;
  657. $root['error'] = '请输入真实身份证号码!';
  658. ajax_return($root);
  659. }
  660. if($contact==''){
  661. $root['status'] = 0;
  662. $root['error'] = '请填写联系方式!';
  663. ajax_return($root);
  664. }
  665. /*if($from_platform==''){
  666. $root['status'] = 0;
  667. $root['error'] = '请填写来自平台!';
  668. ajax_return($root);
  669. }*/
  670. if($identify_positive_image==''){
  671. $root['status'] = 0;
  672. $root['error'] = '请上传身份证正面照片!';
  673. ajax_return($root);
  674. }
  675. if($identify_nagative_image==''){
  676. $root['status'] = 0;
  677. $root['error'] = '请上传身份证背面照片!';
  678. ajax_return($root);
  679. }
  680. if($identify_hold_image==''){
  681. $root['status'] = 0;
  682. $root['error'] = '请上传手持身份证正面!';
  683. ajax_return($root);
  684. }
  685. if (!preg_match('/^([\xe4-\xe9][\x80-\xbf]{2}){2,4}$/', $authentication_name)) {
  686. $root['status'] = 0;
  687. $root['error'] = '请填写2-4位中文姓名!';
  688. ajax_return($root);
  689. }
  690. if (!check_mobile($contact)) {
  691. $root['status'] = 0;
  692. $root['error'] = '请填写11位手机号!';
  693. ajax_return($root);
  694. }
  695. //判断该实名是否存在
  696. $user_info=$GLOBALS['db']->getRow("select id from ".DB_PREFIX."user where id=".$GLOBALS['user_info']['id']);
  697. if($user_info){
  698. $user_info['is_authentication'] = 1;//认证状态 0指未认证 1指待审核 2指认证 3指审核不通过
  699. $user_info['user_type'] = 0;//用户类型
  700. $user_info['authentication_type'] = $authentication_type;//认证类型
  701. $user_info['authentication_name'] = $authentication_name;//真实姓名
  702. $user_info['identify_number'] = $identify_number;//身份证号码
  703. $user_info['contact'] = $contact;//联系方式
  704. //$user_info['from_platform'] = $from_platform;//来自平台
  705. $user_info['wiki'] =$wiki; //百度百科
  706. $user_info['identify_hold_image']=get_spec_image($identify_hold_image);//手持身份证正面
  707. $user_info['identify_positive_image']=get_spec_image($identify_positive_image);//身份证正面
  708. $user_info['identify_nagative_image']=get_spec_image($identify_nagative_image);//身份证反面
  709. $res = save_user($user_info,"UPDATE");
  710. if($res['status']==1){
  711. //更新session
  712. $user_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id =".$res['data']);
  713. es_session::set("user_info", $user_info);
  714. $root['status'] = 1;
  715. $root['error'] = '已提交,等待审核';
  716. }else{
  717. $root['status'] = 0;
  718. $root['error'] = $res['error'];
  719. }
  720. }else{
  721. $root['status'] = 0;
  722. $root['error'] = '会员信息不存在';
  723. }
  724. }
  725. ajax_return($root);
  726. }
  727. //提现领取记录
  728. public function extract_record(){
  729. $root = array();
  730. if(!$GLOBALS['user_info']){
  731. $root['error'] = "用户未登陆,请先登陆.";
  732. $root['status'] = 0;
  733. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  734. }else{
  735. $page = intval($_REQUEST['page'])?intval($_REQUEST['page']):1;
  736. $page_size= 20;
  737. $limit = (($page-1) * $page_size) . "," . $page_size;
  738. $user_id = $GLOBALS['user_info']['id'];
  739. $sql ="select money,pay_time,create_time,is_pay from ".DB_PREFIX."user_refund where is_pay in (1,3) and user_id =".$user_id ." limit $limit" ;
  740. $list = $GLOBALS['db']->getAll($sql,true,true);
  741. $totle_money = 0;
  742. if($list){
  743. foreach($list as $k=>$v){
  744. if($v['is_pay']==3){
  745. $totle_money += $v['money']*100;
  746. }
  747. $record[$k]['money'] = number_format($v['money'] ,2);
  748. if($v['pay_time']!=0){
  749. $record[$k]['pay_time'] =date("Y年m月d日",$v['pay_time']);
  750. }
  751. $record[$k]['is_pay'] =intval($v['is_pay']);
  752. $record[$k]['create_time'] =date("Y年m月d日",$v['create_time']);
  753. }
  754. }else{
  755. $record = array();
  756. }
  757. if(count($list)==$page_size){
  758. $root['has_next'] = 1;
  759. }else{
  760. $root['has_next'] = 0;
  761. }
  762. $root['page'] = $page;
  763. $root['total_money'] = number_format(intval($totle_money)/100,2);
  764. $root['status'] = 1;
  765. $root['error'] = '';//提现记录
  766. $root['list'] = $record;
  767. }
  768. ajax_return($root);
  769. }
  770. //更新微信openid
  771. public function update_wxopenid(){
  772. $root = array();
  773. if(!$GLOBALS['user_info']){
  774. $root['error'] = "用户未登陆,请先登陆.";
  775. $root['status'] = 0;
  776. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  777. }else{
  778. $user_id = intval($GLOBALS['user_info']['id']);
  779. fanwe_require(APP_ROOT_PATH."system/utils/weixin.php");
  780. $m_config = load_auto_cache("m_config");//初始化手机端配置
  781. //获取微信配置信息
  782. if($m_config['wx_appid']==''||$m_config['wx_secrit']==''){
  783. $root['status'] = 0;
  784. $root['error'] = "微信提现参数未配置,请联系客服";
  785. ajax_return($root);
  786. }else{
  787. $wx_appid = strim($m_config['wx_appid']);
  788. $wx_secrit = strim($m_config['wx_secrit']);
  789. }
  790. $jump_url = SITE_DOMAIN.url_wap("user_center#update_wxopenid");
  791. $weixin=new weixin($wx_appid,$wx_secrit,$jump_url);
  792. if($_REQUEST['code']!=""){
  793. $wx_info=$weixin->scope_get_userinfo($_REQUEST['code']);
  794. fanwe_require(APP_ROOT_PATH."system/libs/user.php");
  795. $root = wxUser_update($wx_info,$user_id);
  796. }else{
  797. $root['status'] = 0;
  798. $root['error'] = "绑定微信信息失败";
  799. }
  800. }
  801. ajax_return($root);
  802. }
  803. //支付宝提现绑定接口
  804. public function binding_alipay(){
  805. $root = array();
  806. if(!$GLOBALS['user_info']){
  807. $root['error'] = "用户未登陆,请先登陆.";
  808. $root['status'] = 0;
  809. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  810. }else{
  811. $user_id = $GLOBALS['user_info']['id'];
  812. $alipay_name = trim($_REQUEST['alipay_name']);
  813. $alipay_account = trim($_REQUEST['alipay_account']);
  814. if ($alipay_name != '' && $alipay_account != ''){
  815. $alipay = array();
  816. $alipay['alipay_name'] = strim($alipay_name);
  817. $alipay['alipay_account'] = strim($alipay_account);
  818. $alipay['binding_alipay'] = 1;
  819. $where = "id=".$user_id;
  820. $result = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$alipay,"UPDATE",$where);
  821. if (!$result){
  822. $root['error'] = "绑定失败";
  823. $root['status'] = 0;
  824. }else{
  825. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  826. $user_redis = new UserRedisService();
  827. $user_ticket_info = $user_redis->update_db($user_id,$alipay);
  828. $root['error'] = '绑定成功';
  829. $root['status'] = 1;
  830. }
  831. }else{
  832. $root['error'] = "支付宝账户与名称不能为空";
  833. $root['status'] = 0;
  834. }
  835. }
  836. ajax_return($root);
  837. }
  838. //支付宝提现界面初始化接口
  839. public function money_carry_alipay()
  840. {
  841. $root = array('status'=>1,'error'=>'初始化成功');
  842. if(!$GLOBALS['user_info']){
  843. $root['error'] = "用户未登陆,请先登陆.";
  844. $root['status'] = 0;
  845. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  846. }else{
  847. $m_config = load_auto_cache("m_config");//初始化手机端配置
  848. $user_id = intval($GLOBALS['user_info']['id']);
  849. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  850. $user_redis = new UserRedisService();
  851. $ticket = $user_redis->getRow_db($user_id,array('ticket','refund_ticket','weibo_money','weibo_refund_money','alipay_name','alipay_account'));
  852. $root['weibo_money'] = floatval($ticket['weibo_money']);
  853. $root['alipay_name'] = $ticket['alipay_name'];
  854. $root['alipay_account'] = $ticket['alipay_account'];
  855. $root['ratio'] = $m_config['weibo_catty_ratio'];//提现比例
  856. $root['can_use_money'] =intval($ticket['weibo_money']-$ticket['weibo_refund_money']);//可提现印票
  857. if (floatval($m_config['weibo_catty_ratio']) > 0){
  858. //每日可提现印票
  859. $root['day_ticket_max'] = intval(intval($m_config['day_cash_max'])/floatval($m_config['weibo_catty_ratio']));
  860. //最小提现印票
  861. $root['ticket_catty_min'] = intval(intval($m_config['ticket_catty_min'])/floatval($m_config['weibo_catty_ratio']));
  862. }
  863. //计算已提现印票
  864. $user_refund = $GLOBALS['db']->getRow("SELECT SUM(weibo_money) AS refund_sum FROM ".DB_PREFIX.
  865. "user_refund WHERE user_id=".$user_id." AND is_pay=3 AND type =1");
  866. $root['ready_refund_weibo_money'] = intval($user_refund['refund_sum']);
  867. }
  868. api_ajax_return($root);
  869. }
  870. //支付宝提现接口
  871. public function submit_refund_alipay()
  872. {
  873. $root = array('status' => 1, 'error' => '成功');
  874. if (!$GLOBALS['user_info']) {
  875. $root['error'] = "用户未登陆,请先登陆.";
  876. $root['status'] = 0;
  877. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  878. } else {
  879. $m_config = load_auto_cache("m_config");//初始化手机端配置
  880. $user_id = $GLOBALS['user_info']['id'];//会员ID
  881. $rate = $m_config['weibo_catty_ratio'];//提现比例
  882. $weibo_money = intval($_REQUEST['weibo_money']);//提现印票
  883. $memo = "支付宝提现";
  884. $money = floatval($weibo_money * $rate);
  885. //未处理提现
  886. $ready_refund_id = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_refund where user_id = " . intval($user_id) . " and (is_pay =0 or is_pay=1) and type =1"));
  887. if ($ready_refund_id) {
  888. $root['error'] = '您还有未处理的提现!';
  889. $root['status'] = 0;
  890. api_ajax_return($root);
  891. }
  892. //会员当前印票
  893. $user_weibo_money_info = $GLOBALS['db']->getRow("select weibo_refund_money ,weibo_money from ".DB_PREFIX."user where id = '".intval($user_id)."'");
  894. $user_weibo_money = $user_weibo_money_info['weibo_money'] - $user_weibo_money_info['weibo_refund_money'];//可使用的印票
  895. //超额判断
  896. if ($weibo_money > $user_weibo_money) {
  897. $root['error'] = '提现超出限制!不能大于可用提现';
  898. $root['status'] = 0;
  899. api_ajax_return($root);
  900. }
  901. // 进入每月提现一次流程
  902. $month_carry_one = intval($m_config['month_carry_one']) ? 1 : 0;//提现配置,1:每月提现1次,0:无限制
  903. if ($month_carry_one) {
  904. $ready_refund_info = $GLOBALS['db']->getRow("select pay_time from " . DB_PREFIX . "user_refund where user_id = " . intval($user_id) . " and is_pay = 3");
  905. $pay_time = $ready_refund_info['pay_time'];
  906. //本月是否有提现
  907. if ($pay_time != '' && (to_date($pay_time, "Ym") == to_date(get_gmtime(), 'Ym'))) {
  908. $root['error'] = '每月只能提现一次,本月已经提现过了';
  909. $root['status'] = 0;
  910. api_ajax_return($root);
  911. } else {
  912. //查看本月允许提现时间
  913. if ((to_date(get_gmtime(), 'm') > intval($m_config['month_carry_max']) || to_date(get_gmtime(), 'm') < intval($m_config['month_carry_min']))&&intval($m_config['month_carry_max'])!=0&&intval($m_config['month_carry_min'])!=0){
  914. $root['error'] = '每月' . intval($m_config['month_carry_min']) . '日到' . intval($m_config['month_carry_max']) . '日才能提现';
  915. $root['status'] = 0;
  916. api_ajax_return($root);
  917. }
  918. }
  919. }
  920. //如果开启了公会,公会长的提现比例需修改;禁止公会长提现
  921. if(OPEN_SOCIETY_MODULE == 1){
  922. $society_info = $GLOBALS['db']->getRow("select society_id,society_chieftain from ".DB_PREFIX."user where id=".$user_id);
  923. if(intval($society_info['society_chieftain']) == 1){
  924. $root['error'] ='会长提现,请联系客服!';
  925. $root['status'] = 0;
  926. api_ajax_return($root);
  927. }elseif(intval($society_info['society_id'])) {
  928. $root['error'] ='公会成员不允许提现!';
  929. $root['status'] = 0;
  930. api_ajax_return($root);
  931. }
  932. /*if (intval($society_info['society_chieftain'])){
  933. $refund_rate = $GLOBALS['db']->getOne("select refund_rate from ".DB_PREFIX."society where id=".$society_info['society_id']);
  934. $rate = floatval($refund_rate);
  935. if ($rate > 1 || $rate <= 0){
  936. $rate = $m_config['society_public_rate'];
  937. }
  938. }*/
  939. }
  940. //提现最小值
  941. $ticket_catty_min = $m_config['ticket_catty_min'] > 1 ? $m_config['ticket_catty_min'] : 1;
  942. //最小判断
  943. if ($money < $ticket_catty_min) {
  944. $root['error'] = '支付宝提现单笔不能少于' . $ticket_catty_min . '元';
  945. $root['status'] = 0;
  946. api_ajax_return($root);
  947. }
  948. //取用户当日提现金额之和
  949. //create_time储存的是格林威治时间。使用时需转换为北京时间
  950. $refunded_money_sql = "select sum(money) from ".DB_PREFIX."user_refund where user_id=$user_id and (is_pay=0 or is_pay=1 or is_pay=3)
  951. and DATE_FORMAT(FROM_UNIXTIME(create_time+28800),'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d')";
  952. $refunded_money = $GLOBALS['db']->getOne($refunded_money_sql);
  953. $total_money = floatval($refunded_money) + $money;
  954. //提现最大值
  955. $day_cash_max = intval($m_config['day_cash_max']);
  956. //总和判断
  957. if($total_money > $day_cash_max){
  958. $root['error'] = '支付宝每日提现总额不能多于' . $day_cash_max . '元';
  959. $root['status'] = 0;
  960. api_ajax_return($root);
  961. }
  962. $refund_data['money'] = $money;
  963. $refund_data['user_bank_id'] = -1;
  964. $refund_data['weibo_money'] = $weibo_money;
  965. $refund_data['user_id'] = $user_id;
  966. $refund_data['create_time'] = NOW_TIME;
  967. $refund_data['memo'] = $memo;
  968. $refund_data['withdrawals_type'] = 1;
  969. $refund_data['type'] = 1;
  970. $GLOBALS['db']->autoExecute(DB_PREFIX . "user_refund", $refund_data);
  971. }
  972. api_ajax_return($root);
  973. }
  974. //竞拍收入明细
  975. //$type 0 --已结算
  976. //$type 1 --待结算
  977. public function income(){
  978. // if (intval($_REQUEST['details'])==1) {
  979. // $this->goods_income_details();
  980. // }
  981. $root=array();
  982. $user_id = intval($GLOBALS['user_info']['id']);
  983. if($user_id == 0){
  984. $root['status']=10007;
  985. $root['error']="请先登录";
  986. api_ajax_return($root);
  987. }
  988. $year = intval($_REQUEST['year']);
  989. $month = intval($_REQUEST['month']);
  990. $type = intval($_REQUEST['type']);
  991. $is_pai = intval($_REQUEST['is_pai']);
  992. $time=NOW_TIME;
  993. $end_year=to_date($time,'Y');
  994. $end_month=to_date($time,'m');
  995. if ($year==0) {
  996. $year=$end_year;
  997. $month=$end_month;
  998. }
  999. $rs = FanweServiceCall("user_center","pai_income_details",array("user_id"=>$user_id,"year"=>$year,"month"=>$month,"type"=>$type,"is_pai"=>$is_pai));
  1000. if($rs['status'] == 1){
  1001. $root['type'] = $type;
  1002. $root['status'] = $rs['status'];
  1003. $root['ticket'] = $rs['cumulative'];
  1004. $root['pending'] = $rs['settlement'];
  1005. $root['now_year'] = $year;
  1006. $root['now_month'] = $month;
  1007. $root['end_year'] = intval($end_year);
  1008. $root['end_month'] = intval($end_month);
  1009. $root['list'] = $rs['details'];
  1010. $root['page'] = array('page'=>1,'has_next'=>0);
  1011. }
  1012. api_ajax_return($root);
  1013. }
  1014. //商品收入明细
  1015. //$type 1 --已结算
  1016. //$type 2 --待结算
  1017. //$tupe 3 --无效
  1018. public function goods_income_details(){
  1019. $root =array();
  1020. $user_id = intval($GLOBALS['user_info']['id']);
  1021. if($user_id == 0){
  1022. $root['status']=10007;
  1023. $root['error']="请先登录";
  1024. api_ajax_return($root);
  1025. }
  1026. $page = intval($_REQUEST['page']);
  1027. $page_size = 20;
  1028. $time = NOW_TIME;
  1029. $year = intval($_REQUEST['year']);
  1030. $month = intval($_REQUEST['month']);
  1031. $type = intval($_REQUEST['type']);
  1032. $end_year=to_date($time,'Y');
  1033. $end_month=to_date($time,'m');
  1034. if ($year==0) {
  1035. $year=$end_year;
  1036. $month=$end_month;
  1037. }
  1038. fanwe_require(APP_ROOT_PATH . 'mapi/shop/pai_podcast.action.php');
  1039. $pai_podcast = new pai_podcastCModule();
  1040. $rs = $pai_podcast->commodity_profitlist($page,$page_size,$time,$year,$month,$type);
  1041. if($rs['status'] == 1){
  1042. if($rs['OrderIncome']['totalAccount'] == ''){
  1043. $rs['OrderIncome']['totalAccount']=0;
  1044. }
  1045. if($rs['OrderIncome']['waitAccount'] == ''){
  1046. $rs['OrderIncome']['waitAccount']=0;
  1047. }
  1048. if($rs['ProfitOrder'] == ''){
  1049. $rs['ProfitOrder']=array();
  1050. }
  1051. $root['type'] = $type;
  1052. $root['status'] = $rs['status'];
  1053. $root['ticket'] = $rs['OrderIncome']['totalAccount'];
  1054. $root['pending'] = $rs['OrderIncome']['waitAccount'];
  1055. $root['now_year'] = $year;
  1056. $root['now_month'] = $month;
  1057. $root['end_year'] = intval($end_year);
  1058. $root['end_month'] = intval($end_month);
  1059. $root['list'] = $rs['ProfitOrder'];
  1060. $root['page'] = array('page'=>1,'has_next'=>0);
  1061. }
  1062. api_ajax_return($root);
  1063. }
  1064. /*
  1065. * 支付宝认证
  1066. */
  1067. public function authent_alipay(){
  1068. $m_config = load_auto_cache("m_config");//初始化手机端配置
  1069. $user_id = intval($GLOBALS['user_info']['id']);
  1070. $request = $_REQUEST;
  1071. if($user_id == 0){
  1072. $root['status']=10007;
  1073. $root['error']="请先登录";
  1074. ajax_return($root);
  1075. }else{
  1076. $m_config = load_auto_cache("m_config");//初始化手机端配置
  1077. $aliConnect = new aliConnectAPI($m_config['alipay_partner'],$m_config['alipay_key']);
  1078. if(intval($GLOBALS['db']->getOne("select id from fanwe_user where v_type=3 and id=".$user_id." and alipay_authent_token <>''")))
  1079. {
  1080. $root['status'] = 0;
  1081. $root['error']='用户支付宝已认证';
  1082. echo $aliConnect ->build_html($root['error']); die;
  1083. }
  1084. if(strim($request['is_success'])=='T'){
  1085. //支付宝用户号
  1086. $alipay_user_id = intval($request['user_id']);
  1087. //授权令牌
  1088. $token = strim($request['token']);
  1089. //真实姓名
  1090. $real_name = strim($_REQUEST['real_name']);
  1091. require_once(APP_ROOT_PATH."system/libs/user.php");
  1092. $user_data = array();
  1093. $user_data['id'] = $user_id;
  1094. $user_data['alipay_user_id'] = $alipay_user_id;
  1095. $user_data['alipay_name'] = $real_name;
  1096. $user_data['alipay_authent_token'] = $token;
  1097. $user_data['v_type'] = 3;
  1098. $root = AuthentAlipayUser($user_data);
  1099. echo $aliConnect ->buildRequestForm($root['error']); die;
  1100. }
  1101. if((!defined('OPEN_AUTHENT_ALIPAY')||OPEN_AUTHENT_ALIPAY==0)&&intval($m_config['authent_alipay'])==0){
  1102. $root['status']=0;
  1103. $root['error']="支付宝一键认证未开启";
  1104. ajax_return($root);
  1105. }else{
  1106. $aliConnect ->get_display_code();
  1107. }
  1108. }
  1109. }
  1110. /*
  1111. * 更新推荐人字段
  1112. */
  1113. public function update_p_user_id(){
  1114. $root = array('status' => 1,'error'=>'');
  1115. $user_id = intval($GLOBALS['user_info']['id']);
  1116. $request = $_REQUEST;
  1117. if($user_id == 0){
  1118. $root['status']=10007;
  1119. $root['error']="请先登录";
  1120. ajax_return($root);
  1121. }
  1122. if (intval($GLOBALS['user_info']['p_user_id'])>0) {
  1123. $root['error'] = "推荐人已存在!";
  1124. $root['status'] = 0;
  1125. ajax_return($root);
  1126. }
  1127. $p_user_id = intval($_REQUEST['p_user_id']);
  1128. $p_user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where id =" . $p_user_id);
  1129. if(intval($p_user_id)==0){
  1130. $root['error'] = "推荐人不存在!";
  1131. $root['status'] = 0;
  1132. ajax_return($root);
  1133. }
  1134. $data = array(
  1135. 'p_user_id' =>$p_user_id,
  1136. );
  1137. $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,"UPDATE", "id=".$user_id);
  1138. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  1139. $user_redis = new UserRedisService();
  1140. $user_redis->update_db($user_id,$data);
  1141. //更新session
  1142. $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id =" . $user_id);
  1143. es_session::set("user_info", $user_info);
  1144. api_ajax_return($root);
  1145. }
  1146. /*
  1147. * 获取推荐人字段
  1148. */
  1149. public function get_p_user_id(){
  1150. $root = array('status' => 1,'error'=>'');
  1151. $user_id = intval($GLOBALS['user_info']['id']);
  1152. $request = $_REQUEST;
  1153. if($user_id == 0){
  1154. $root['status']=10007;
  1155. $root['error']="请先登录";
  1156. ajax_return($root);
  1157. }
  1158. $root['p_user_id'] = intval($GLOBALS['user_info']['p_user_id']);
  1159. api_ajax_return($root);
  1160. }
  1161. public function cont(){
  1162. $root = array();
  1163. $user_id = intval($_REQUEST['to_user_id']);
  1164. if(!$user_id){
  1165. if(!$GLOBALS['user_info']){
  1166. $root['error'] = "用户未登陆,请先登陆.";
  1167. $root['status'] = 0;
  1168. $root['user_login_status'] = 0;//有这个参数: user_login_status = 0 时,表示服务端未登陆、要求登陆,操作
  1169. api_ajax_return($root);
  1170. }
  1171. $user_id = intval($GLOBALS['user_info']['id']);//被查看的用户id
  1172. }
  1173. $user = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$user_id);
  1174. if(!$user){
  1175. $root['error'] = "用户不存在.";
  1176. $root['status'] = 0;
  1177. api_ajax_return($root);
  1178. }
  1179. $page = intval($_REQUEST['p']);//取第几页数据
  1180. if($page==0){
  1181. $page_size = "50";
  1182. }else{
  1183. $page_size=30;
  1184. //$limit = (($page-1)*$page_size).",".$page_size;
  1185. }
  1186. fanwe_require(APP_ROOT_PATH.'mapi/xr/redis/WeiboContributionRedisService.php');
  1187. $weiboCont_redis = new WeiboContributionRedisService();
  1188. $root = $weiboCont_redis->get_podcast_contribute($user_id,$page,$page_size);
  1189. $root['total_num'] = intval(floor($root['user']['ticket']));
  1190. api_ajax_return($root);
  1191. }
  1192. public function user_levels(){
  1193. $user_level = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_level order by level ASC limit 0,6");
  1194. $root['status']=1;
  1195. $root['error']="";
  1196. foreach($user_level as $k=>$v){
  1197. if($v['icon']){
  1198. $user_level[$k]['icon'] = get_spec_image($v['icon']);
  1199. }
  1200. }
  1201. $root['list'] = $user_level;
  1202. api_ajax_return($root);
  1203. }
  1204. }
  1205. ?>