BaseController.php 2.5 KB

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