UserOrderRelations.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace common\models\order;
  3. use common\enums\StatusEnum;
  4. use Exception;
  5. use RuntimeException;
  6. use Yii;
  7. /**
  8. * This is the model class for table "qimall_user_order_relations".
  9. *
  10. * @property int $id
  11. * @property int $mall_id
  12. * @property int $order_id 订单id
  13. * @property int $user_id 用户id
  14. * @property string $parents 下单时的上级关系链,包含等级
  15. * @property int $status 状态 -1删除 0禁用 1正常
  16. * @property int $created_at
  17. * @property int $updated_at
  18. */
  19. class UserOrderRelations extends \common\models\base\BaseActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'qimall_user_order_relations';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['mall_id', 'order_id', 'user_id', 'status', 'created_at', 'updated_at'], 'integer'],
  35. [['parents'], 'required'],
  36. [['parents'], 'safe'],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'order_id' => 'Order ID',
  48. 'user_id' => 'User ID',
  49. 'parents' => 'Parents',
  50. 'status' => 'Status',
  51. 'created_at' => 'Created At',
  52. 'updated_at' => 'Updated At',
  53. ];
  54. }
  55. /**
  56. * @param array $params
  57. *
  58. * @return bool|self
  59. */
  60. public static function setData(array $params)
  61. {
  62. try {
  63. $model = new self();
  64. $model->loadDefaultValues();
  65. if (!$model->load($params, '')) {
  66. throw new RuntimeException($model->getErrorMessage());
  67. }
  68. if (!$model->save()) {
  69. throw new RuntimeException($model->getErrorMessage());
  70. }
  71. return $model;
  72. } catch (Exception $e) {
  73. self::$static_error = $e->getMessage();
  74. return false;
  75. }
  76. }
  77. }