StoreExpireSmsLog.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_store_expire_sms_log".
  7. *
  8. * @property int $id id
  9. * @property int $mall_id 商城id
  10. * @property int $store_id 门店id
  11. * @property int $date_time 门店过期时间
  12. * @property int $status 状态
  13. * @property int|null $created_at 添加时间
  14. * @property int|null $updated_at 修改时间
  15. */
  16. class StoreExpireSmsLog extends \common\models\base\BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return 'qimall_addons_store_expire_sms_log';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['mall_id', 'store_id', 'date_time'], 'required'],
  32. [['mall_id', 'store_id', 'date_time', 'status', 'created_at', 'updated_at'], 'integer'],
  33. ];
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function attributeLabels()
  39. {
  40. return [
  41. 'id' => 'ID',
  42. 'mall_id' => 'Mall ID',
  43. 'store_id' => 'Store ID',
  44. 'date_time' => 'Date Time',
  45. 'status' => 'Status',
  46. 'created_at' => 'Created At',
  47. 'updated_at' => 'Updated At',
  48. ];
  49. }
  50. public static function setData(array $params)
  51. {
  52. try {
  53. if (!empty($params['id'])) {
  54. $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
  55. if (empty($model)) throw new \Exception('数据不存在或已删除');
  56. } else {
  57. $model = new self();
  58. $model->loadDefaultValues();
  59. }
  60. if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
  61. return $model;
  62. } catch (\Exception $e) {
  63. self::$static_error = $e->getMessage();
  64. return false;
  65. }
  66. }
  67. }