| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace addons\ScoreBonus\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_score_bonus_commission_item_setting_detail}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $score_bonus_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 ScoreBonusCommissionItemSettingDetail extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_score_bonus_commission_item_setting_detail}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'score_bonus_commission_item_setting_id'], 'required'],
- [['mall_id', 'score_bonus_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',
- 'score_bonus_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'], 'score_bonus_commission_item_setting_id' => $data['score_bonus_commission_item_setting_id']]);
- if (empty($model)) {
- $model = new self();
- }
- if(!$model->load($data,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return true;
- }
- public static function lists($params=[],$is_array=true){
- $list = [];
- $query = static::find();
- try{
- self::paramPack($params, $query);
- if(!empty($params['limit'])){
- $query->limit($params['limit']);
- }
- if(!empty($params['offset'])){
- $query->offset($params['offset']);
- }
- elseif(!empty($params['page']) && !empty($params['limit'])){
- $query->offset(($params['page']-1)*$params['limit']);
- }
- self::$_sql[] = $query->createCommand()->getRawSql();
- $list = $query->AsArray($is_array)->all();
- return $list;
- }catch (\Exception $e){
- var_dump($e->getMessage());
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|