Exchange.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\UserApi;
  4. use app\common\model\Mobile;
  5. use stdClass;
  6. use think\Env;
  7. /**
  8. * 民生号码
  9. * @ApiInternal
  10. */
  11. class Exchange extends UserApi
  12. {
  13. protected $noNeedLogin='*';
  14. /**
  15. * 民生号码下架
  16. * */
  17. public function ms_no_down(){
  18. $key=Env::get('api_config.minsheng_key','aallsoJJDAG87ADAnna');
  19. $secret=Env::get('api_config.minsheng_secret','adakda2313BAALPOjjada12');
  20. $info=new stdClass;
  21. $tid=input('tid')?:session_create_id();
  22. $sign1=$this->request->post('sign');
  23. $post=$this->request->post();
  24. $no=$post['param']['msisdn']??null;
  25. $params=$post['param']??[];
  26. user_log('no_api/minsheng',$post);
  27. $base641=base64_encode($key);
  28. $base642=base64_encode($tid.$secret);
  29. ksort($params);
  30. $base643=base64_encode(json_encode($params,256));
  31. $sign2=md5($base642.$base641.$base643);
  32. if($sign1!=$sign2){
  33. $info->msg='签名有误';
  34. goto END;
  35. }
  36. if($no){
  37. $mobiles=Mobile::where('no',$no)->select();
  38. foreach ($mobiles as $mobile){
  39. $mobile['status']=$mobile::S_DOWN;
  40. $mobile->save();
  41. }
  42. }
  43. END:
  44. $this->result('success',$info,10200);
  45. }
  46. }