255], [['alone_agent_equal_prize_info'], 'string', 'max' => 1000], [['repurchase_subsidy_condition'], 'string'] ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'level' => 'Level', 'commission_type' => '分佣类型:积分score;佣金:commission', 'from_type' => '分佣类型:经销Agent;幸运平团:Lucky_group', 'is_percent_team' => '渠道奖类型 0百分比 1 固定金额', 'is_percent_equal' => '平级奖类型 0百分比 1 固定金额', 'is_percent_over' => '越级奖类型 0百分比 1 固定金额', 'is_percent_extra' => '额外奖类型 0百分比 1 固定金额', 'agent_team_prize' => '渠道奖', 'agent_equal_prize' => '平级奖', 'agent_over_prize' => '越级奖', 'agent_extra_prize' => '额外奖', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'is_repurchase_subsidy' => '是否开启每月复购补贴奖[0否 1是]', 'repurchase_subsidy_condition' => '每月复购补贴奖奖励条件', ]; } public static function setData($params) { try{ if (!empty($params['level'])&&!empty($params['from_type'])&&!empty($params['commission_type'])) { $where = [ 'level' => $params['level'], 'mall_id' => $params['mall_id'], 'from_type'=>$params['from_type'], 'commission_type'=>$params['commission_type'], 'status' => [StatusEnum::ENABLED]]; $model = self::findOne($where); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } else { $model = new self(); $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; } } public static function del($params){ try{ $model = self::updateAll(['status'=>StatusEnum::DELETE],['level'=>$params['level'],'mall_id'=>$params['mall_id']]); if(empty($model)) throw new \Exception("删除失败"); return true; }catch (\Exception $e){ self::$static_error = $e->getMessage(); return false; } } }