BaseController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Http\Controllers\QuickApp;
  3. use App\Modules\User\Models\User;
  4. use App\Modules\User\Services\QappUserService;
  5. use Illuminate\Routing\Controller;
  6. /**
  7. * @property User $user_info 用户基本信息
  8. * @property int $uid
  9. * @property string $phone 手机号
  10. * @property int $distribution_channel_id 渠道号ID
  11. * @property int $send_order_id 派单ID
  12. * @property int $app_pay_merchat_id 微信app支付通道ID
  13. * @property int $h5_pay_merchat_id 微信h5支付通道ID
  14. * @property int $ali_pay_merchat_id 支付宝支付通道ID
  15. */
  16. class BaseController extends Controller
  17. {
  18. private $field = [];
  19. public function __get($name)
  20. {
  21. if (!isset($this->field[$name])) {
  22. $qapp_user = (new QappUserService)->getGolableUser();
  23. if ($name == 'user_info') {
  24. $user = User::find($qapp_user->uid);
  25. $this->field[$name] = $user;
  26. }
  27. if ($name == 'uid') {
  28. $this->field[$name] = $qapp_user->uid;
  29. }
  30. if ($name == 'phone') {
  31. $this->field[$name] = $qapp_user->phone;
  32. }
  33. if ($name == 'distribution_channel_id') {
  34. $this->field[$name] = $qapp_user->user->distribution_channel_id;
  35. }
  36. if ($name == 'send_order_id') {
  37. $this->field[$name] = $qapp_user->send_order_id;
  38. }
  39. if ($name == 'app_pay_merchat_id') {
  40. $this->field[$name] = $qapp_user->app_pay_merchat_id;
  41. }
  42. if ($name == 'h5_pay_merchat_id') {
  43. $this->field[$name] = $qapp_user->h5_pay_merchat_id;
  44. }
  45. if ($name == 'ali_pay_merchat_id') {
  46. $this->field[$name] = $qapp_user->ali_pay_merchat_id;
  47. }
  48. }
  49. return $this->field[$name];
  50. }
  51. }