Csc.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <?php
  2. /** 客服中心 -- 控制器
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/10/24
  6. * Time: 10:47
  7. */
  8. namespace app\mobile\controller;
  9. use think\Config;
  10. use think\Db;
  11. class Csc extends Mobile {
  12. private $_type
  13. = [
  14. '1' => '账号问题' ,
  15. '2' => '充值问题' ,
  16. '3' => '申诉问题' ,
  17. '4' => '人工服务' ,
  18. '5' => '其他' ,
  19. ];
  20. private $_appealMsgCode = 'SMS_192715035'; //'【麻花网络游戏】您正在申诉账号,验证码:[%s],有效期10分钟。请勿向任何人提供您收到的验证码。';
  21. /**
  22. * 初始化操作
  23. */
  24. protected function _initialize() {
  25. parent::_initialize();
  26. $this->cscModel = model('CpsProblem');
  27. }
  28. /**
  29. * 客服中心
  30. */
  31. public function index(){
  32. // 获取在线客服时间
  33. $kf_time = model('Setting')->getSetting('CUSTOMER_SERVICE_TIME');
  34. // 客服QQ列表
  35. $kefuList = model('Kefu')->getKefuList();
  36. $this->assign('kf_time',$kf_time);
  37. $this->assign('kefuList',$kefuList);
  38. return $this->fetch();
  39. }
  40. /**
  41. * 常见问题
  42. */
  43. public function question() {
  44. $type = $this->request->param('type' , 0 , 'intval');
  45. $typeArr = $this->_type;
  46. foreach ($typeArr as $k => $v) {
  47. $num = $this->judgeHasByType($k);
  48. if ( !$num) unset($typeArr[$k]);
  49. }
  50. $runable = true;
  51. if ( !$type || !isset($typeArr[$type])) {
  52. reset($typeArr);
  53. $type = key($typeArr);
  54. }
  55. if (( !count($typeArr) || !isset($typeArr[$type])) && $type != 0) {
  56. $runable = false;
  57. }
  58. $page_num = 10;
  59. if ($runable) {
  60. $list = Db::connect(config('database_slave'))->table('cy_csc_problem')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))
  61. ->field('id,title,answer')
  62. ->where('type' , $type)
  63. ->order('order asc, create_time asc, id asc')
  64. ->paginate($page_num , false , array('query' => input('get.')));
  65. }
  66. if ($this->request->isAjax()) $this->jsonResult($runable ? $list : [],1);
  67. $this->assign('runable' , $runable);
  68. $this->assign('typeList' , $runable ? $typeArr : []);
  69. $this->assign('type' , $runable ? $type : 0);
  70. $this->assign('list' , $runable ? $list : []);
  71. $this->assign('current_num' , $runable ? count($list) ? ($list->toArray()['current_page'] - 1) * $page_num : 0 : 0);
  72. $this->assign('page' , $runable ? $list->render() : null);
  73. return $this->fetch();
  74. }
  75. /**
  76. * 判断 某个类型下 是否有问题
  77. */
  78. public function judgeHasByType($type) {
  79. $num = Db::connect(config('database_slave'))->table('cy_csc_problem')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->where('type' , $type)->count('id');
  80. return $num;
  81. }
  82. /**
  83. * w微信申诉页面
  84. */
  85. public function wechatAppeal() {
  86. return $this->fetch();
  87. }
  88. /**
  89. * 关注公众号页面
  90. */
  91. public function subscription() {
  92. return $this->fetch();
  93. }
  94. /**
  95. * 申诉查询
  96. */
  97. public function appealResult() {
  98. if ($this->request->isAjax()) {
  99. $code = $this->request->param('code');
  100. if ( !$code) $this->jsonResult([] , 0 , '请输入申诉编号');
  101. $Ticket = $this->request->param('ticket' , '' );
  102. $Randstr = $this->request->param('randstr' , '' );
  103. $slider = (new \app\home\controller\Member)->sliderVelidate($Ticket,$Randstr);
  104. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  105. $res = model('CscAppeal')
  106. ->field('id,userid,username,mobile,mail,status,code,certificate')
  107. ->where('code' , $code)->find();
  108. if (empty($res)) $this->jsonResult([] , 0 , '不存在该申诉编号');
  109. // 0:未审核 1:成功 2:失败 3:成功改完密码状态 4驳回',
  110. if ($res['status'] == 4) $res['status'] = 2;
  111. session('appeal_rest_pwd_info' , $res);
  112. if ( !empty($res['mobile'])) $res['mobile'] = stringObfuscation($res['mobile']);
  113. if ( !empty($res['mail'])) $res['mail'] = mailObfuscation($res['mail']);
  114. $this->success('',getMobileServiceUrl(3.1));
  115. }
  116. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  117. $this->assign('appid',$appid);
  118. return $this->fetch();
  119. }
  120. /**
  121. * 申诉查询--结果页面
  122. */
  123. public function appealResultPage(){
  124. if (!session('appeal_rest_pwd_info')) $this->redirect(getServiceUrl(3,url('appealResult')));
  125. if ($this->request->isAjax()){
  126. $certificate = $this->request->param('certificate');
  127. if ( !$certificate) $this->jsonResult([] , 0 , '请输入成功凭证');
  128. $appealInfo = session('appeal_rest_pwd_info');
  129. if (empty($appealInfo) || $certificate != $appealInfo['certificate']) {
  130. $this->jsonResult([] , 0 , '成功凭证不正确');
  131. }
  132. $this->success('',getMobileServiceUrl(3.2));
  133. }
  134. $info = session('appeal_rest_pwd_info');
  135. /*$info['status'] = 1;*/
  136. $this->assign('info',$info);
  137. return $this->fetch();
  138. }
  139. /**
  140. * 通过申诉凭证 -- 充值密码页面
  141. */
  142. public function resetPwdPage() {
  143. if (!session('appeal_rest_pwd_info')) $this->redirect(getServiceUrl(3,url('appealResult')));
  144. return $this->fetch();
  145. }
  146. /**
  147. * 重置密码
  148. */
  149. public function resetPwd() {
  150. $appealInfo = session('appeal_rest_pwd_info');
  151. if (empty($appealInfo)) $this->jsonResult([] , 0 , '系统繁忙,请稍后再试');
  152. $password1 = input('post.password1' , '' );
  153. $password2 = input('post.password2' , '' );
  154. if (empty($password1)) $this->jsonResult([] , -1 , '请输入密码');
  155. if (empty($password2)) $this->jsonResult([] , -2 , '请再次输入密码');
  156. if ($password1 != $password2) $this->jsonResult([] , -2 , '两次输入的密码不一致');
  157. $userid = model('Members')->where(['username'=>$appealInfo['username']])->value('id');
  158. $memberCTR = new Member();
  159. $res = $memberCTR->resetPassword($userid , $password1,1);
  160. if ($res == 0) $this->jsonResult([] , -2 , '新密码不能与旧密码相同');
  161. if ($res == 3) $this->jsonResult([] , -1 , '请输入正确的密码,6-15位字符');
  162. if ($res == 2) $this->jsonResult([] , -2 , '密码重置失败,请稍后在试!');
  163. $result = model('CscAppeal')->save(['status' => 3] , ['id' => $appealInfo['id']]);
  164. session('appeal_rest_pwd_info' , null);
  165. if ($result || $appealInfo['status'] == 3) {
  166. $this->success('重置成功',getMobileCscUrl());
  167. }
  168. $this->error('重置失败');
  169. }
  170. /**
  171. * 账号申诉---确认申诉账号
  172. */
  173. public function appeal() {
  174. if (session('appeal')) {
  175. session('appeal' , null);
  176. }
  177. if ($this->request->isAjax()) {
  178. $username = input('post.username' , '' );
  179. $type = input('post.type' , '' );
  180. $number = input('post.number' , '' );
  181. $reason = input('post.reason' , '' , 'intval');
  182. $agreexy = input('post.reason' );
  183. $userid = session('front_userid'); //登录帐号id(不是申诉号码id)
  184. $typeArr = ['mobile' , 'email'];
  185. $data = [];
  186. if (empty($username)) $this->error('请输入申诉账号');
  187. if ( !in_array($type , $typeArr)) $this->error('请选择申诉接收方式');
  188. if ($type == $typeArr[0]) {
  189. $data['mobile'] = $number;
  190. if (empty($number)) $this->error('请输入手机号');
  191. if ( !$this->isMobile($number)) $this->error('请输入正确的手机号');
  192. }
  193. if ($type == $typeArr[1]) {
  194. $data['mail'] = $number;
  195. if (empty($number)) $this->error('请输入邮箱');
  196. if ( !$this->isEmail($number)) $this->error('请输入正确的邮箱');
  197. }
  198. if (empty($reason)) $this->error('请选择申诉原因');
  199. if (!$agreexy) $this->error('请先同意麻花网络服务使用协议');
  200. $condition['username'] = $username;
  201. $id = model('Members')->where($condition)->value('id');
  202. if (empty($id)) $this->error('帐号不存在');
  203. $data['userid'] = $userid;
  204. $result = Db::table('cy_csc_appeal')->where($condition)->select();
  205. if (!empty($result)){
  206. foreach ($result as $v){
  207. if ($v['status'] == 0) $this->error('该账号还有申诉处理中,请勿重复申诉');
  208. if ($v['status'] == 1) {
  209. $url = getMobileServiceUrl(3);
  210. $this->error('该账号有申诉已通过,但未重置密码,请前往<a href="' . $url . '" style="color:blue">"申诉查询"</a> 进行操作');
  211. }
  212. if (NOW_TIMESTAMP - $v['create_time'] <= 3600) $this->error('该账号距离上一次申诉未到1小时,请稍后再试,或联系麻花网络客服');
  213. }
  214. }
  215. if ($reason == 2) {
  216. $condition['status'] = ['in',['3',4]];
  217. $condition['reason'] = 2;
  218. $condition['create_time'] = ['egt' , NOW_TIMESTAMP - 180 * 24 * 60 * 60];
  219. $result = model('CscAppeal')->where($condition)->order('id desc')->find();
  220. if ($result['status'] == 3 || $result['status'] == 4) $this->error('该账号在近期已有账号被盗受理完成,不可再申诉,请联系麻花网络客服咨询');
  221. }
  222. $data['reason'] = $reason;
  223. $data['username'] = $username;
  224. session('appeal',$data);
  225. $this->success('',getMobileAppealUrl('check'));
  226. }
  227. return $this->fetch();
  228. }
  229. /**
  230. * 账号申诉---手机/邮箱验证
  231. */
  232. public function check(){
  233. if (!session('appeal')){
  234. $this->redirect(getMobileAppealUrl('zhss'));
  235. }
  236. $appid = Config::get('SLIDER_VERIFICATION.APPID');
  237. $this->assign('appid',$appid);
  238. $this->assign('info',session('appeal'));
  239. return $this->fetch();
  240. }
  241. /**
  242. * 账号申诉---发送验证码
  243. */
  244. public function sendCode(){
  245. $type = input('post.type' , '' );
  246. $info = session('appeal');
  247. $typeArr = ['mobile' , 'email'];
  248. if (!$info) $this->redirect(getMobileAppealUrl('zhss'));
  249. if (!in_array($type,$typeArr) || empty($info)) $this->error('非法请求');
  250. $Ticket = $this->request->param('ticket' , '' );
  251. $Randstr = $this->request->param('randstr' , '' );
  252. $slider = (new \app\home\controller\Member)->sliderVelidate($Ticket,$Randstr);
  253. if (!$slider['code']) $this->jsonResult([],0,$slider['msg']);
  254. if ($type == $typeArr[0]){
  255. $result = (new \app\common\library\Sms)->sendCode($info['mobile'],$this->_appealMsgCode);
  256. }else{
  257. $result = (new \app\common\library\Mail)->sendCodeMailByType($info['username'], $info['mail'],'appeal');
  258. }
  259. if(isset($result) && $result['status']){
  260. $this->jsonResult([],1,'发送成功');
  261. }else{
  262. $this->jsonResult([],0,$result['msg']);
  263. }
  264. }
  265. /**
  266. * 账号申诉---验证码验证
  267. */
  268. public function appealCheckCode(){
  269. $info = session('appeal');
  270. $code = input('post.code' , 0 , 'intval');
  271. $type = input('post.type' , '' );
  272. $typeArr = ['mobile' , 'email'];
  273. if ( !in_array($type , $typeArr) || empty($info)) $this->jsonResult([],0,'非法请求');
  274. if (empty($code)) $this->jsonResult([],0,'验证不能为空');
  275. if ($type == $typeArr[0]) {
  276. $result = (new \app\common\library\Sms)->checkCode($info['mobile'] , $code);
  277. } else {
  278. $result = (new \app\common\library\Mail)->checkCode($info['username'] , $info['mail'] , $code);
  279. }
  280. if ( isset($result) && $result['status']) {
  281. session('apeealHasCheck',true);
  282. $this->success('验证成功',getMobileAppealUrl('user'));
  283. }
  284. $this->jsonResult([],0,$result['msg']);
  285. }
  286. /**
  287. * 账号申诉---账号信息
  288. */
  289. public function appealAccount(){
  290. if(!session('apeealHasCheck')){
  291. $this->redirect(getMobileAppealUrl('check'));
  292. }
  293. if(session('apeealUserinfo')){
  294. session('apeealUserinfo',null);
  295. }
  296. /*$data = session('appeal');*/
  297. /*$province = Db::table('cy_city')->where('parent_id=1')->select();*/
  298. $gameWhere = [
  299. 'cooperation_status' => ['neq',0],
  300. 'nickname' => ['neq',''],
  301. ];
  302. $gamelist = model('Game')->field('id,nickname')->where($gameWhere)->group('nickname')->order('id desc')->select();
  303. /*$province = Db::table('cy_city')->where(['type'=>['in',[1,2]]])->select();*/
  304. /*dump($province);*/
  305. $province = $this->getAddr();
  306. $this->assign('province',json_encode($province));
  307. $this->assign('gamelist',$gamelist);
  308. return $this->fetch('appeal_account');
  309. }
  310. /**
  311. * 获取省份市
  312. */
  313. public function getAddr(){
  314. $province = Db::table('cy_city')->where(['type'=>['in',[1,2]]])->select();
  315. $provinceArr = array_filter($province,function ($v){
  316. if ($v['type'] == 1) return $v;
  317. });
  318. $cityArr = array_filter($province,function ($v){
  319. if ($v['type'] == 2) return $v;
  320. });
  321. $list = [];
  322. foreach ($provinceArr as $k => $value){
  323. $list[$k] = ['id'=>$value['id'], 'name'=>$value['name'], 'sub'=>[]];
  324. foreach ($cityArr as $item){
  325. if ($item['parent_id'] == $value['id']){
  326. $list[$k]['sub'][] = ['id'=>$item['id'], 'name'=>$item['name']];
  327. }
  328. }
  329. }
  330. return $list;
  331. }
  332. /**
  333. * 账号申诉---账号信息---提交
  334. */
  335. public function appealAccountTij(){
  336. $regtime = strtotime(input('post.regtime', ''));
  337. $imei = input('post.imei', '');
  338. $addr = input('post.addr', '');
  339. $reggameid = input('post.reggameid', '');
  340. $regmobile = input('post.regmobile', '');
  341. $totalrecharge = input('post.totalrecharge', '', 'intval');
  342. $firstrechargegameid = input('post.firstrechargegameid', '');
  343. if (empty($regtime)) $this->jsonResult('',-1,'请选择注册时间');
  344. /*if (!empty($imei)) {
  345. if (strlen($imei) != 15) {
  346. $this->jsonResult('',-2,'imei格式错误');
  347. }
  348. }*/
  349. if (empty($addr)) $this->jsonResult('',-3,'请选择注册地址');
  350. if (is_numeric($addr)) $this->jsonResult('',-3,'地址格式不能为数字');
  351. if ($reggameid == '') $this->jsonResult('',-4,'请选择注册游戏');
  352. if ( $firstrechargegameid == '') $this->jsonResult('',-5,'请选择首次充值游戏');
  353. if (!empty($regmobile)) {
  354. if ($regmobile == '无') {
  355. } else {
  356. if (!$this->isMobile($regmobile)) $this->jsonResult('',-6,'请输入正确的手机号');
  357. }
  358. }else{
  359. $this->jsonResult('',-6,'请输入注册时手机号');
  360. }
  361. if ($totalrecharge != 0 && empty($totalrecharge)) $this->jsonResult('',-7,'请输入累积充值金额');
  362. if (!is_numeric($totalrecharge)) $this->jsonResult('',-7,'请输入正确的金额');
  363. $data = session('appeal');
  364. $data['regtime'] = $regtime;
  365. $data['imei'] = $imei;
  366. $data['addr'] = $addr;
  367. $data['reggameid'] = $reggameid;
  368. if ($regmobile != '无') {
  369. $data['regmobile'] = $regmobile;
  370. }else{
  371. $data['regmobile'] = '';
  372. }
  373. $data['totalrecharge'] = $totalrecharge;
  374. $data['firstrechargegameid'] = $firstrechargegameid;
  375. if(session('apeealUserinfo')){
  376. session('apeealUserinfo',null);
  377. }
  378. session('apeealUserinfo',$data);
  379. $this->success('',getMobileAppealUrl('history'));
  380. }
  381. /**
  382. * 账号申诉---账号历史信息
  383. */
  384. public function appealHistory(){
  385. if (!session('apeealUserinfo')){
  386. $this->redirect(getMobileAppealUrl('user'));
  387. }
  388. $gameWhere = [
  389. 'cooperation_status' => ['neq',0],
  390. 'nickname' => ['neq',''],
  391. ];
  392. $gamelist = model('Game')->field('id,nickname')->where($gameWhere)->group('nickname')->order('id desc')->select();
  393. $this->assign('gamelist',$gamelist);
  394. return $this->fetch('appeal_history');
  395. }
  396. /**
  397. * 账号申诉---账号历史信息--提交
  398. */
  399. public function appealHistoryTij(){
  400. $regchannelname = $this->request->param('regchannelname', '');
  401. $oldmail = !empty($this->request->param('oldmail/a')) ? array_flip(array_flip(array_filter($this->request->param('oldmail/a')))) : [];
  402. $oldmobile = !empty($this->request->param('oldmobile/a')) ? array_flip(array_flip(array_filter($this->request->param('oldmobile/a')))) : [];
  403. $boundgameid = !is_null($this->request->param('boundgameid/a')) ? array_flip(array_flip(array_filter($this->request->param('boundgameid/a')))) : '';
  404. // 旧密码 充值时间 和 充值金额可能重复,不能用array_flip进行数组翻转(会过滤掉值一样的key)
  405. $rechargetime = !empty($this->request->param('rechargetime/a')) ? array_filter($this->request->param('rechargetime/a')) : [];
  406. $rechargeamount = !is_null($this->request->param('rechargeamount/a')) ? array_filter($this->request->param('rechargeamount/a')) : [];
  407. $oldpwd = !empty($this->request->param('oldpwd/a')) ? array_filter($this->request->param('oldpwd/a')) : [];
  408. if (empty($oldpwd)) {
  409. $this->jsonResult(0,-1,'密码不能为空');
  410. }else{
  411. $pwdpreg = '/^[a-zA-Z0-9]{6,15}$/';
  412. foreach ($oldpwd as $k => $oldpwdinfo) {
  413. if (0 == preg_match($pwdpreg, $oldpwdinfo)) {
  414. $this->jsonResult($k,-1,'密码长度为6-15位字符!');
  415. }
  416. }
  417. }
  418. if ( !empty($oldmail)) {
  419. foreach ($oldmail as $k => $oldmailinfo) {
  420. if (!empty($oldmailinfo) && !$this->isEmail($oldmailinfo)) $this->jsonResult($k,-2,'请输入正确的邮箱');
  421. }
  422. }
  423. if (!empty($oldmobile)) {
  424. foreach ($oldmobile as $k => $oldmobileinfo) {
  425. if (!empty($oldmobileinfo) && !$this->isMobile($oldmobileinfo)) $this->jsonResult($k,-3,'请输入正确的手机号');
  426. }
  427. }
  428. if (empty($rechargetime) && !empty($rechargeamount)) $this->jsonResult(0,-5,'请输入充值时间');
  429. if (!empty($rechargetime) && empty($rechargeamount)) $this->jsonResult(0,-6,'请输入累积充值金额');
  430. if (!empty($rechargeamount)) {
  431. foreach ($rechargeamount as $k => $rechargeamountinfo) {
  432. if (!isset($rechargetime[$k]) || empty($rechargetime[$k])) $this->jsonResult($k,-5,'请输入充值时间');
  433. if (!is_numeric($rechargeamountinfo)) $this->jsonResult($k,-6,'请输入正确的充值金额');
  434. }
  435. }
  436. if (!empty($rechargetime)) {
  437. foreach ($rechargetime as $k => $rechargetimeinfo) {
  438. if (!isset($rechargeamount[$k]) || !is_numeric($rechargeamount[$k])) $this->jsonResult($k,-6,'请输入正确的充值金额');
  439. if (empty($rechargetimeinfo)) $this->jsonResult($k,-5,'请输入充值时间');
  440. }
  441. }
  442. if ($boundgameid == '') $this->jsonResult(0,-7,'请选择登录过的游戏');
  443. if (!empty($boundgameid)) {
  444. foreach ($boundgameid as $k => $boundgameidinfo) {
  445. if (!is_numeric($boundgameidinfo)) $this->jsonResult($k,-7,'登录过的游戏数据出错');
  446. }
  447. }
  448. $regchannelid = model('Channel')->where(['name'=>$regchannelname])->value('id');
  449. $arr['oldpwd'] = serialize($oldpwd);
  450. $arr['oldmail'] = serialize($oldmail);
  451. $arr['oldmobile'] = serialize($oldmobile);
  452. $arr['boundgameid'] = serialize($boundgameid);
  453. $arr['rechargetime'] = serialize($rechargetime);
  454. $arr['rechargeamount'] = serialize($rechargeamount);
  455. $arr['regchannelid'] = $regchannelid;
  456. $arr['create_time'] = date('Y-m-d H:i:s',NOW_TIMESTAMP); // model('CscAppeal')->getAppealScore($data) 里面时间是日期格式
  457. $data = session('apeealUserinfo');
  458. $data = array_merge($data, $arr);
  459. // 判断是否已经申诉了,防止同时申诉
  460. $result = Db::table('cy_csc_appeal')->where(['username'=>$data['username'],'status'=>['in',[0,1,2]]])->select();
  461. $re_arr = [];
  462. if (!empty($result)){
  463. foreach ($result as $v){
  464. if ($v['status'] ==2 && (NOW_TIMESTAMP - $v['create_time'] <= 3600)) $this->error('该账号距离上一次申诉未到1小时,请稍后再试,或联系麻花网络客服');
  465. if ($v['status'] !=2 ) $re_arr[] = $v;
  466. }
  467. if (!empty($re_arr)) $this->error('该账号还有申诉处理中,请勿重复申诉');
  468. }
  469. $showtime = date("YmdHis", time());
  470. $data['code'] = $showtime . rand(0, 9); //申述编码
  471. $data['score'] = model('CscAppeal')->getAppealScore($data);
  472. $scoreLow = model('CscSetting')->where('name="MARK_APPEAL"')->value('value');
  473. $appealInfo = session('appeal');
  474. $data['reason'] = $appealInfo['reason']; //申述原因
  475. $data['userid'] = $appealInfo['userid'];
  476. $data['create_time'] = strtotime($data['create_time']); // 申诉时间
  477. $is_suc = true;
  478. if ($data['score'] < $scoreLow){
  479. $data['status'] = 2;
  480. $data['operate_time'] = NOW_TIMESTAMP;
  481. $data['operate_id'] = 1;
  482. $data['notice_time'] = $data['create_time'];
  483. $is_suc = false;
  484. if (isset($appealInfo['mobile']) && !empty($appealInfo['mobile'])){
  485. $result = (new \app\common\library\Sms)->sendAppealCode($appealInfo['username'],$data['code'],$appealInfo['mobile'],'','',4);
  486. }elseif(isset($appealInfo['mail']) && !empty($appealInfo['mail'])){
  487. $result = (new \app\common\library\Mail)->sendAppealCodeMail($appealInfo['username'], $data['code'],$appealInfo['mail'],'','',4);
  488. }
  489. if(isset($result) && $result['status']){
  490. $data['is_finish'] = 1;
  491. }else{
  492. $data['remark'] = '短信发送失败:'.$result['msg'];
  493. }
  494. }else{
  495. if ($data['reason'] == 2) {
  496. // 清空手机和邮箱
  497. $update = [
  498. 'flag' => 1 ,
  499. 'email' => '' ,
  500. 'mobile' => '' ,
  501. ];
  502. model('Members')->save($update,['username' => $appealInfo['username']]);
  503. // 记录用户冻结历史记录
  504. $userid = model('Members')->where(['username' => $appealInfo['username']])->value('id');
  505. model('FrozenHistory')->addData($userid,1,0);
  506. }
  507. if (isset($appealInfo['mobile']) && !empty($appealInfo['mobile'])){
  508. $data['notice_time'] = $data['create_time'] + 86400 * 3;
  509. $result = (new \app\common\library\Sms)->sendAppealCode($appealInfo['username'],$data['code'],$appealInfo['mobile'],'三','',0);
  510. }elseif(isset($appealInfo['mail']) && !empty($appealInfo['mail'])){
  511. $data['notice_time'] = $data['create_time'] + 3600 * 6;
  512. $result = (new \app\common\library\Mail)->sendAppealCodeMail($appealInfo['username'], $data['code'],$appealInfo['mail'],'一','',0);
  513. }
  514. }
  515. $appealId = model('CscAppeal')->insertGetId($data);
  516. if ($appealId) {
  517. session('appealResult',['username'=>$appealInfo['username'],'code'=>$data['code'],'status'=>$is_suc]);
  518. $this->success('',getMobileAppealUrl('result'));
  519. }
  520. $this->error('系统繁忙,请稍后再试!');
  521. }
  522. /**
  523. * 申诉结果
  524. */
  525. public function appealEnding(){
  526. $info = session('appealResult');
  527. session('apeealUserinfo',null);
  528. session('apeeal',null);
  529. session('apeealHasCheck',null);
  530. $this->assign('info',$info);
  531. return $this->fetch();
  532. }
  533. public function ajaxGameList($keyword='')
  534. {
  535. $gameWhere = [
  536. 'cooperation_status' => ['neq',0],
  537. 'nickname' => ['neq',''],
  538. ];
  539. if ( !empty($keyword)) {
  540. $gameWhere['nickname'] = ['like',"%".$keyword."%"];
  541. }
  542. $list = model('Game')->field('id,nickname')->where($gameWhere)->group('nickname')->order('id desc')
  543. ->select();
  544. $type = $this->request->param('type', '');
  545. if (empty($type)){
  546. if($keyword == '' || strpos('麻花网络官网注册',$keyword) !== false){
  547. $arr = [['id'=>0,'nickname'=>'麻花网络官网注册']];
  548. $list = array_merge($arr,$list);
  549. }
  550. }elseif ($type == 'pay'){
  551. $list = array_merge([['id'=>0,'nickname'=>'无']],$list);
  552. }
  553. return ['list'=>$list];
  554. }
  555. }