| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace addons\Seed\common\models;
- use addons\Seed\common\enums\SeedEnum;
- use common\enums\StatusEnum;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%addons_seed_energy_pool}}".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $release_num 第N次能量池释放
- * @property int|null $total_seed_num 本次释放种子金总数量
- * @property float|null $release_energy_pool 释放能量池总额
- * @property float|null $unit_price 释放的增长值,单位:元
- * @property int $release_at 释放时间
- * @property string $reason 失败原因
- * @property int $release_status 释放状态【0:释放中 1释放成功 2释放失败】
- * @property int $status 状态【1启用 0禁用 -1删除】
- * @property int $created_at 创建时间
- * @property int $updated_at 更新数据时间
- */
- class SeedEnergyPool extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_seed_energy_pool}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'release_num', 'total_seed_num', 'release_at', 'release_status', 'status', 'created_at', 'updated_at'], 'integer'],
- [['release_energy_pool', 'unit_price'], 'number'],
- [['reason'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'release_num' => '第N次能量池释放',
- 'total_seed_num' => '本次释放种子金总数量',
- 'release_energy_pool' => '释放能量池总额',
- 'unit_price' => '释放的增长值,单位:元',
- 'release_at' => '释放时间',
- 'reason' => '释放失败原因',
- 'release_status' => '[0:释放中,1:释放成功,2:释放失败]',
- 'status' => '状态【1启用 0禁用 -1删除】',
- 'created_at' => '创建时间',
- 'updated_at' => '更新数据时间',
- ];
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2022/8/1 0001 18:40
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $params
- * @return array|bool
- */
- public static function setData($params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- if ($params['release_energy_pool'] <= 0 && $params['unit_price'] <= 0) {
- $model->release_status = SeedEnum::RELEASE_FAIL;
- $model->reason = '本次释放的能量池总额不足';
- }
- if (!$model->load($params, '') || !$model->save())throw new Exception($model->getErrorMessage());
- return $model->toArray();
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|