| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\base\ErrorException;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- use Yii;
- /**
- * This is the model class for table "{{%partner_pool_award-record}}".
- *
- * @property integer $id
- * @property integer $admin_id
- * @property integer $money
- * @property integer $pool_id
- * @property integer $saas_id
- * @property integer $level_id
- * @property integer $weight
- * @property string $desc
- * @property string $level_name
- * @property integer $created_at
- */
- class UnitFounderPoolAwardRecord extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%unit_founder_pool_award_record}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ]
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [[ 'pool_id', 'saas_id','level_id','weight','admin_id'], 'integer'],
- [['desc','level_name'], 'string'],
- [['money'], 'number'],
- [['created_at'], 'safe']
- ];
- }
- public static function createRecord($admin_id,$saas_id,$pool_id,$level_id,$weight,$desc,$money){
- try {
- $record = new self();
- $record->money=$money;
- $record->admin_id=$admin_id;
- $record->pool_id=$pool_id;
- $record->saas_id=$saas_id;
- $record->level_id=$level_id?$level_id:0;
- $record->weight=$weight?$weight:0;
- $record->desc=$desc;
- $level = SaasUnitFounderLevel::findOne($level_id);
- if (empty($level)) throw new ErrorException('该等级不存在:'.$level_id.',saas_id:'.$saas_id);
- $record->level_name = $level->name;
- if (!$record->save())throw new ErrorException('保存失败'.json_encode($record->getErrors()));
- return true;
- }catch (ErrorException $e){
- //debug_log([__METHOD__, __LINE__, "发放是失败 {$e->getMessage() }"], "app_debug_partner.log");
- return false;
- }
- }
- }
|