EventService.php 918 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace addons\WechatVideoShop\common\service;
  3. use addons\WechatVideoShop\common\models\WechatVideoShopEvents;
  4. class EventService
  5. {
  6. /**
  7. * @param array $params
  8. * @param string $org_post
  9. * @param array $post
  10. * @param \Exception|null $e
  11. * @return WechatVideoShopEvents
  12. */
  13. public function create(array $params, string $org_post, array $post = [], \Exception $e = null)
  14. {
  15. $model = new WechatVideoShopEvents();
  16. $model->req = $params;
  17. $model->org_post = $org_post;
  18. $model->post = $post;
  19. if (!empty($e)) {
  20. $model->exception = [
  21. 'file' => $e->getFile(),
  22. 'code' => $e->getCode(),
  23. 'line' => $e->getLine(),
  24. 'msg' => $e->getMessage(),
  25. 'trace' => $e->getTrace()
  26. ];
  27. }
  28. $model->save();
  29. return $model;
  30. }
  31. }