DeliveryKeloopErr.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. class DeliveryKeloopErr extends \yii\db\ActiveRecord
  12. {
  13. /**
  14. * @inheritdoc
  15. */
  16. public static function tableName()
  17. {
  18. return '{{%delivery_keloop_err}}';
  19. }
  20. public function behaviors()
  21. {
  22. return [
  23. [
  24. 'class' => TimestampBehavior::class,
  25. 'attributes' => [
  26. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  27. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
  28. ]
  29. ]
  30. ];
  31. }
  32. public static function saveErr($store_id, $order_id, $order_no, $err) {
  33. $model = new self();
  34. $model->store_id = $store_id;
  35. $model->order_id = $order_id;
  36. $model->order_no = $order_no;
  37. $model->err_res = is_array($err) ? json_encode($err, JSON_UNESCAPED_UNICODE) : $err;
  38. if($model->save()){
  39. return [
  40. 'code' => 0,
  41. ];
  42. }
  43. return [
  44. 'code' => 1,
  45. 'msg' => array_shift($model->getFirstErrors()),
  46. ];
  47. }
  48. }