StoreReserveTechnicianSchedulingTime.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. use Exception;
  6. /**
  7. * This is the model class for table "qimall_addons_store_reserve_technician_scheduling_time".
  8. *
  9. * @property int $id id
  10. * @property int $mall_id 商城id
  11. * @property int|null $user_id user_id
  12. * @property int|null $store_id 门店id
  13. * @property int|null $sid 排期id
  14. * @property int|null $start_time 开始时间
  15. * @property int|null $end_time 结束时间
  16. * @property int $status 状态(-1:删除,0:禁用,1:启用)
  17. * @property int|null $created_at 创建时间
  18. * @property int|null $updated_at 修改时间
  19. */
  20. class StoreReserveTechnicianSchedulingTime extends BaseActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return '{{%addons_store_reserve_technician_scheduling_time}}';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['mall_id'], 'required'],
  36. [['mall_id', 'store_id','user_id', 'sid', 'start_time', 'end_time', 'status', 'created_at', 'updated_at'], 'integer'],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'user_id' => 'User ID',
  48. 'store_id' => 'store_id',
  49. 'sid' => 'Sid',
  50. 'start_time' => 'Start Time',
  51. 'end_time' => 'End Time',
  52. 'status' => 'Status',
  53. 'created_at' => 'Created At',
  54. 'updated_at' => 'Updated At',
  55. ];
  56. }
  57. public static function setData($params)
  58. {
  59. try {
  60. if (!empty($params['id'])) {
  61. $model = self::find()->where(['id' => $params['id']])->one();
  62. if (empty($model)) throw new Exception('数据不存在');
  63. } else {
  64. $model = new self();
  65. }
  66. $model->loadDefaultValues();
  67. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  68. return $model;
  69. } catch (Exception $e) {
  70. self::$static_error = $e->getMessage();
  71. return false;
  72. }
  73. }
  74. public static function getDataOne($params, $select = "*", $orderBy = 'id desc')
  75. {
  76. return self::find()->where($params)->select($select)->orderBy($orderBy)->asArray()->one();
  77. }
  78. public static function getDataAll($params, $select = "*", $orderBy = 'id desc')
  79. {
  80. return self::find()->where($params)->select($select)->orderBy($orderBy)->asArray()->all();
  81. }
  82. }