OrderBehaviorLogs.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace common\models\order;
  3. use Exception;
  4. use RuntimeException;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_order_behavior_logs".
  8. *
  9. * @property int $id
  10. * @property int $mall_id
  11. * @property int $operator_user_id 操作人用户id
  12. * @property int $operator_user_type 操作用户类型 1后台 2用户
  13. * @property int $behavior 1创建订单 2取消订单 3订单未付款自动关闭 4提醒发货 5订单发货 6确认收货 7已收货订单超时关闭 8订单完成 9评价 10申请售后 11已收到退货 12售后发货 13取消售后 14同意售后 15拒绝售后 16退款超限 17主动退款 18删除 19批量删除 20备注 21批量备注 22留言 23批量留言 24修改地址
  14. * @property string $desc
  15. * @property string|null $extra_info
  16. * @property int $ip
  17. * @property int $status
  18. * @property int $operation_time 实际操作时间
  19. * @property int $order_id 订单ID
  20. * @property int $created_at
  21. * @property int $updated_at
  22. */
  23. class OrderBehaviorLogs extends \common\models\base\BaseActiveRecord
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return 'qimall_order_behavior_logs';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['mall_id', 'operator_user_id', 'operator_user_type', 'behavior', 'ip', 'status', 'operation_time', 'order_id', 'created_at', 'updated_at'], 'integer'],
  39. [['extra_info'], 'safe'],
  40. [['desc'], 'string', 'max' => 500],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'ID',
  50. 'mall_id' => 'Mall ID',
  51. 'operator_user_id' => 'Operator User ID',
  52. 'operator_user_type' => 'Operator User Type',
  53. 'behavior' => 'Behavior',
  54. 'desc' => 'Desc',
  55. 'extra_info' => 'Extra Info',
  56. 'ip' => 'Ip',
  57. 'status' => 'Status',
  58. 'operation_time' => 'Operation Time',
  59. 'order_id' => 'Order Id',
  60. 'created_at' => 'Created At',
  61. 'updated_at' => 'Updated At',
  62. ];
  63. }
  64. /**
  65. * @param $params
  66. *
  67. * @return false|self
  68. */
  69. public static function setData($params)
  70. {
  71. try {
  72. $model = new self();
  73. $model->loadDefaultValues();
  74. if (!empty($params['ip'])) {
  75. $params['ip'] = ip2long($params['ip']);
  76. }
  77. if (empty($params['operation_time'])) {
  78. $params['operation_time'] = time();
  79. }
  80. if (!$model->load($params, '')) {
  81. throw new RuntimeException($model->getErrorMessage());
  82. }
  83. if (!$model->save()) {
  84. throw new RuntimeException($model->getErrorMessage());
  85. }
  86. return $model;
  87. } catch (Exception $e) {
  88. self::$static_error = $e->getMessage();
  89. return false;
  90. }
  91. }
  92. /**
  93. * @return \yii\db\ActiveQuery
  94. */
  95. public function getOrder()
  96. {
  97. return $this->hasOne(Order::class, ['id' => 'order_id']);
  98. }
  99. }