Log.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace addons\shopro\controller\commission;
  3. use app\admin\model\shopro\commission\Log as LogModel;
  4. use addons\shopro\library\Operator;
  5. use app\admin\model\shopro\user\User as UserModel;
  6. use app\admin\model\Admin as AdminModel;
  7. class Log extends Commission
  8. {
  9. protected $noNeedLogin = [];
  10. protected $noNeedRight = ['*'];
  11. // 分销动态
  12. public function index()
  13. {
  14. $agentId = $this->service->user->id;
  15. $logs = LogModel::where([
  16. 'agent_id' => $agentId
  17. ])->order('id desc')->paginate(request()->param('list_rows', 10));
  18. $morphs = [
  19. 'user' => UserModel::class,
  20. 'admin' => AdminModel::class,
  21. 'system' => AdminModel::class
  22. ];
  23. $logs = morph_to($logs, $morphs, ['oper_type', 'oper_id']);
  24. $logs = $logs->toArray();
  25. // 解析操作人信息
  26. foreach ($logs['data'] as &$log) {
  27. $log['oper'] = Operator::info($log['oper_type'], $log['oper'] ?? null);
  28. }
  29. $this->success("", $logs);
  30. }
  31. }