| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace addons\DoubleCopy\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_double_copy_pool_source}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $level 等级(权重)
- * @property int $order_detail_id 订单详情ID
- * @property float $money 插入金额,单位:元
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int|null $created_at 创建时间
- * @property int|null $updated_at 更新时间
- * @property string $reward_currency 奖励类型:佣金-commission,积分-score
- * @property string $remark 备注
- */
- class DoubleCopyPoolSource extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_double_copy_pool_source}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'level', 'order_detail_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['money'], 'number'],
- [['reward_currency'],'string'],
- [['remark'],'string']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'level' => '等级(权重)',
- 'order_detail_id' => '订单详情ID',
- 'money' => '插入金额,单位:元',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- public static function setData($params)
- {
- try {
- $model = self::findOne(['id' => $params['id'], 'status' => StatusEnum::ENABLED]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- } else {
- }
- if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
- return $model->toArray();
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|