ShortVideoCommissionItemSettingDetail.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\ShortVideo\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_short_video_commission_item_setting_detail}}".
  6. *
  7. * @property int $id
  8. * @property int $mall_id 商城ID
  9. * @property int $short_video_commission_item_setting_id
  10. * @property int $level
  11. * @property int $calculate_type 计算方式,1:百分比,2:固定值
  12. * @property float $value 值,calculate_type = 1 时表示百分比(计算时需要 /100);calculate_type = 2 时表示设置的固定值
  13. * @property int $status 状态[-1:删除;0:禁用;1启用]
  14. * @property int $created_at
  15. * @property int $updated_at
  16. */
  17. class ShortVideoCommissionItemSettingDetail extends \common\models\base\BaseActiveRecord
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return '{{%addons_short_video_commission_item_setting_detail}}';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['mall_id', 'short_video_commission_item_setting_id'], 'required'],
  33. [['mall_id', 'short_video_commission_item_setting_id', 'calculate_type', 'status', 'created_at', 'updated_at'], 'integer'],
  34. [['value'], 'number'],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'mall_id' => 'Mall ID',
  45. 'short_video_commission_item_setting_id' => 'Short Video Commission Item Setting ID',
  46. 'calculate_type' => 'Calculate Type',
  47. 'value' => 'Value',
  48. 'status' => 'Status',
  49. 'created_at' => 'Created At',
  50. 'updated_at' => 'Updated At',
  51. ];
  52. }
  53. public static function setData($data)
  54. {
  55. $model = self::findOne(['mall_id' => $data['mall_id'], 'short_video_commission_item_setting_id' => $data['short_video_commission_item_setting_id']]);
  56. if (empty($model)) {
  57. $model = new self();
  58. }
  59. if(!$model->load($data,'') || !$model->save()){
  60. throw new \Exception($model->getErrorMessage());
  61. }
  62. return true;
  63. }
  64. }