RedpackTask.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace addons\Redpack\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_redpack_task}}".
  6. *
  7. * @property int $id
  8. * @property string|null $content 保留执行过那些商场[1,2,3,4]
  9. * @property string|null $day 执行时间
  10. * @property int $status 0是禁用,1是启用,-1删除
  11. * @property int|null $created_at
  12. * @property int|null $updated_at
  13. */
  14. class RedpackTask extends \common\models\base\BaseActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return '{{%addons_redpack_task}}';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['content'], 'string'],
  30. [['day'], 'safe'],
  31. [['status', 'created_at', 'updated_at'], 'integer'],
  32. ];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'content' => 'Content',
  42. 'day' => 'Day',
  43. 'status' => 'Status',
  44. 'created_at' => 'Created At',
  45. 'updated_at' => 'Updated At',
  46. ];
  47. }
  48. /**
  49. * @Author: ltm
  50. * @DateTime: 2022/3/24 0024 14:37
  51. * @Copyright: copyright (c) 2021 广东七件事集团
  52. * @param $data
  53. * @return string
  54. */
  55. public static function setData(array $params,$is_execute){
  56. try{
  57. if(!empty($params['id'])){
  58. $model = self::findOne(['id'=>$params['id']]);
  59. }else{
  60. $model = new self();
  61. $model->loadDefaultValues();
  62. }
  63. if(!$model->load($params,'') || !$model->save()){
  64. throw new Exception($model->getErrorMessage());
  65. }
  66. return $model;
  67. }catch(\Exception $e){
  68. self::$static_error = $e->getMessage();
  69. return false;
  70. }
  71. }
  72. }