| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace addons\ShortVideo\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_short_video_commission_item_setting_detail}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $short_video_commission_item_setting_id
- * @property int $level
- * @property int $calculate_type 计算方式,1:百分比,2:固定值
- * @property float $value 值,calculate_type = 1 时表示百分比(计算时需要 /100);calculate_type = 2 时表示设置的固定值
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class ShortVideoCommissionItemSettingDetail extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_short_video_commission_item_setting_detail}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'short_video_commission_item_setting_id'], 'required'],
- [['mall_id', 'short_video_commission_item_setting_id', 'calculate_type', 'status', 'created_at', 'updated_at'], 'integer'],
- [['value'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'short_video_commission_item_setting_id' => 'Short Video Commission Item Setting ID',
- 'calculate_type' => 'Calculate Type',
- 'value' => 'Value',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData($data)
- {
- $model = self::findOne(['mall_id' => $data['mall_id'], 'short_video_commission_item_setting_id' => $data['short_video_commission_item_setting_id']]);
- if (empty($model)) {
- $model = new self();
- }
- if(!$model->load($data,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return true;
- }
- }
|