user_center.action.php 66 KB

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