ScoreBonusErrorLogModel.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace addons\ScoreBonus\common\models;
  3. use Yii;
  4. use common\models\base\BaseActiveRecord;
  5. use yii\behaviors\TimestampBehavior;
  6. use yii\db\Exception;
  7. /**
  8. * This is the model class for table "{{%addon_default}}".
  9. */
  10. class ScoreBonusErrorLogModel extends BaseActiveRecord
  11. {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static function tableName()
  16. {
  17. return '{{%addons_score_bonus_error_log}}';
  18. }
  19. public function rules()
  20. {
  21. return [
  22. [['mall_id','bid', 'created_at', 'updated_at', 'date_time'], 'integer'],
  23. [['error_log', 'json_data'], 'string'],
  24. ];
  25. }
  26. /**
  27. * 保存数据
  28. * @Author: lun
  29. * @DateTime: 2023/6/2 0002 15:53
  30. * @Copyright: copyright (c) 2021 广东七件事集团
  31. * @param $params
  32. * @return bool
  33. */
  34. public static function setData(array $params)
  35. {
  36. try {
  37. $model = new self();
  38. $model->loadDefaultValues();
  39. if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
  40. return $model;
  41. } catch (Exception $e) {
  42. self::$static_error = $e->getMessage();
  43. return false;
  44. }
  45. }
  46. public static function getDataOne($params = [], $orderBy = 'id desc')
  47. {
  48. return self::find()->where($params)->orderBy($orderBy)->asArray()->one();
  49. }
  50. }