| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- namespace addons\BossWeight\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_boss_weight_level_setting}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $level
- * @property string $commission_type 分佣类型:积分score;佣金:commission
- * @property string $from_type 分佣类型:股东;
- * @property float $prize 永久分红,单位:百分比
- * @property float $extra_prize 额外分红,单位:百分比
- * @property int $is_extra 是否开启额外分红【0否,1是】
- * @property int $extra_type 获取额外分红的类型:1购物,2条件,3任意
- * @property int $extra_is_limit 额外分红是否存在上限【0否,1是】
- * @property float $extra_limit_price 额外分红上限金额,单位:元
- * @property int $weight_status 是否开启加权分红。0-不开启,1-开启
- * @property int $weight_member_num 加权分红条件,直推会员数量
- * @property int $weight_product_num 加权分红条件,购买产品数量
- * @property int $weight_num 加权分红配置,满足条件奖励的权重数量
- * @property int $weight_level_ratio 加权分红配置,等级分红比例
- * @property int $weight_turnover_ratio 加权分红配置,营业额比例
- * @property int $weight_max_price 加权分红配置。分红上限金额
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- * @property int $weight_member_num_team 伞下团队每有一个市场业绩
- * @property int $weight_num_team 市场业绩达标,获得权重数量
- */
- class AddonsBossLevelSetting extends \common\models\base\BaseActiveRecord
- {
- const STATUS_ENABLE = 1;
- const STATUS_DISABLE = 0;
- const STATUS_DELETE = -1;
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_boss_weight_level_setting}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'level', 'is_extra', 'extra_type', 'extra_is_limit', 'status','created_at', 'updated_at',
- 'weight_status', 'weight_member_num', 'weight_product_num', 'weight_num','weight_num_team', 'weight_level_ratio', 'weight_turnover_ratio','weight_max_price','weight_is_limit','weight_member_level_second','weight_num_second'], 'integer'],
- [['prize', 'extra_prize', 'extra_limit_price','weight_member_num_team'], 'number'],
- [['commission_type', 'from_type','weight_member_num_second'], 'string', 'max' => 255],
- [['checked_weight_values'],'safe']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'level' => 'Level',
- 'commission_type' => '分佣类型:积分score;佣金:commission',
- 'from_type' => '分佣类型:股东;',
- 'prize' => '永久分红,单位:百分比',
- 'extra_prize' => '额外分红,单位:百分比',
- 'is_extra' => '是否开启额外分红【0否,1是】',
- 'extra_type' => '获取额外分红的类型:1购物,2条件,3任意',
- 'extra_is_limit' => '额外分红是否存在上限【0否,1是】',
- 'extra_limit_price' => '额外分红上限金额,单位:元',
- 'weight_status' => '是否开启加权分红。0-不开启,1-开启',
- 'weight_member_num' => '加权分红条件,直推会员数量',
- 'weight_product_num' => '加权分红条件,购买产品数量',
- 'weight_num' => '加权分红配置,满足条件奖励的权重数量',
- 'weight_level_ratio' => '加权分红配置,等级分红比例',
- 'weight_turnover_ratio' => '加权分红配置,营业额比例',
- 'weight_max_price' => '加权分红配置。分红上限金额',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'weight_is_limit' => '是否开启权重限制',
- 'checked_weight_values' => '权重限制规则',
- 'weight_member_num_second' => '加权分红条件,直推会员数量',
- 'weight_member_level_second' => '加权分红条件,会员等级',
- 'weight_num_second' => '加权分红配置,满足条件奖励的权重数量',
- 'weight_member_num_team' => '伞下团队每有一个市场业绩',
- 'weight_num_team' => '市场业绩达标,获得权重数量'
- ];
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2021/11/4 0004 14:23
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $params
- * @return bool
- */
- public static function setData($params)
- {
- try{
- $model = self::findOne([
- 'mall_id' => $params['mall_id'],
- 'level' => $params['level'],
- 'status' => [StatusEnum::ENABLED]
- ]);
- if (empty($model)) {
- $model = new self();
- $model->mall_id = $params['mall_id'];
- $model->level = $params['level'];
- $model->loadDefaultValues();
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return true;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- /**
- * 获取等级分佣配置
- * @Author: lun
- * @DateTime: 2021/11/4 0004 14:23
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $cond
- * @param array $with
- * @param bool $is_array
- * @param string $select
- * @return array|\yii\db\ActiveRecord[]
- */
- public static function getBossLevelSetting(array $cond=[], array $with=[],bool $is_array=true,string $select='*'){
- $default_cond = [['<>','status',StatusEnum::DELETE]];
- $cond = array_merge($default_cond,$cond);
- $query = self::find()->select($select);
- self::paramPack(['where'=>$cond, 'with'=>$with],$query);
- $data = $query->asArray($is_array)->all();
- return $data;
- }
- }
|