BaseController.php 2.0 KB

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