ManageController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace App\Http\Controllers\Manage\Manage;
  3. use App\Http\Controllers\Manage\BaseController;
  4. use App\Http\Controllers\Manage\Manage\Transformers\ManageTransformer1;
  5. use App\Modules\Channel\Services\ChannelService;
  6. use App\Modules\Channel\Services\ChannelUserService;
  7. use App\Modules\Manage\Services\ManageService;
  8. use Illuminate\Http\Request;
  9. use Cache;
  10. use Redis;
  11. class ManageController extends BaseController
  12. {
  13. /**
  14. * @apiVersion 1.0.0
  15. * @apiDescription 修改密码
  16. * @api {POST} auth/modifyPassword 修改密码
  17. * @apiGroup Manage
  18. * @apiName modifyPassword
  19. * @apiParam {String} account 账号.
  20. * @apiParam {String} password 密码.
  21. * @apiParam {String} new_password 新密码.
  22. * @apiParam {String} new_password_repeat 重复新密码.
  23. * @apiSuccessExample {json} Success-Response:
  24. *
  25. * {
  26. * "code": 0,
  27. * "msg": "",
  28. * "data": {}
  29. * }
  30. */
  31. function modifyPassword(Request $request)
  32. {
  33. $account = $request->has('account') ? trim($request->input('account')) : '';
  34. $password = $request->has('password') ? trim($request->input('password')) : '';
  35. $new_password = $request->has('new_password') ? trim($request->input('new_password')) : '';
  36. $new_password_repeat = $request->has('new_password_repeat') ? trim($request->input('new_password_repeat')) : '';
  37. if(!$account || !$password || !$new_password || !$new_password_repeat) return response()->error('PARAM_ERROR');
  38. if($new_password != $new_password_repeat) return response()->error('PASSWORD_NOT_SAME');
  39. $manage = ManageService::getByAccount($account);
  40. if($manage->password != md5($password."^-^zhuishuyun^_^")) return response()->error('PASSWORD_WRONG');
  41. if($manage->account)
  42. {
  43. $password = md5($new_password."^-^zhuishuyun^_^");
  44. if(ManageService::modifyPassword($manage->account, $password))
  45. {
  46. return response()->success();
  47. }
  48. }
  49. }
  50. /**
  51. * @apiVersion 1.0.0
  52. * @apiDescription 获取商务列表
  53. * @api {GET} auth/business 获取商务列表
  54. * @apiGroup Manage
  55. * @apiName auth/business
  56. * @apiSuccessExample {json} Success-Response:
  57. *
  58. * {
  59. * "code": 0,
  60. * "msg": "",
  61. * "data": {}
  62. * }
  63. */
  64. function getBusiness(Request $request) {
  65. $params = [];
  66. $data = ManageService::getBusinessManageList($params, true);
  67. return response()->collection(new ManageTransformer1(), $data);
  68. }
  69. /**
  70. * @apiVersion 1.0.0
  71. * @apiDescription 获取渠道修改账号信息短信验证码
  72. * @api {GET} channel/getChannelAccountSmsCode 获取渠道修改账号信息短信验证码
  73. * @apiGroup Manage
  74. * @apiName channel/getChannelAccountSmsCode
  75. *
  76. * @apiParam {channelId} channelId 渠道ID.
  77. *
  78. * @apiSuccessExample {json} Success-Response:
  79. *
  80. * {
  81. * "code": 0,
  82. * "msg": "",
  83. * "data": {}
  84. * }
  85. */
  86. function getChannelAccountSms(Request $request) {
  87. $channelId = $request->has('channelId') ? $request->input('channelId') : '';
  88. if(!$channelId) {
  89. //return response("渠道ID输入错误");
  90. return response()->error('PARAM_ERROR');
  91. }
  92. $channel = ChannelService::getById($channelId);
  93. if(!$channel) {
  94. return response()->error('PARAM_ERROR');
  95. }
  96. $channelUser = ChannelUserService::getById($channel->channel_user_id);
  97. if(!$channelUser) {
  98. //return response("渠道ID输入错误");
  99. return response()->error('PARAM_ERROR');
  100. }
  101. $phone = $channelUser->phone;
  102. $phoneCode = Redis::get('sms_'.$channelId."_".$phone);
  103. if(!$phoneCode) {
  104. $phoneCode = Cache::get('sms_'.$channelId."_".$phone);
  105. }
  106. if(empty($phoneCode)) {
  107. //return response("没有找到验证码!");
  108. return response()->error('PHONE_CODE_ERROR');
  109. } else {
  110. return response()->success($phoneCode);
  111. //return response("渠道【".$channelId."】的验证码为【".$phoneCode."】");
  112. }
  113. }
  114. }