BaseController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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] = $qapp_user->user;
  26. $this->field[$name] = $user;
  27. }
  28. if ($name == 'uid') {
  29. $this->field[$name] = $qapp_user->uid;
  30. }
  31. if ($name == 'phone') {
  32. $this->field[$name] = $qapp_user->phone;
  33. }
  34. if ($name == 'distribution_channel_id') {
  35. $this->field[$name] = $qapp_user->user->distribution_channel_id;
  36. }
  37. if ($name == 'send_order_id') {
  38. $this->field[$name] = $qapp_user->send_order_id;
  39. }
  40. if ($name == 'app_pay_merchat_id') {
  41. $this->field[$name] = $qapp_user->app_pay_merchat_id;
  42. }
  43. if ($name == 'h5_pay_merchat_id') {
  44. $this->field[$name] = $qapp_user->h5_pay_merchat_id;
  45. }
  46. if ($name == 'ali_pay_merchat_id') {
  47. $this->field[$name] = $qapp_user->ali_pay_merchat_id;
  48. }
  49. }
  50. return $this->field[$name];
  51. }
  52. }