| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace addons\Happiness\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_happiness_voucher_wallet".
- *
- * @property int $id
- * @property int $level 商品标签权重
- * @property float $balance 提货券数量
- * @property float $freeze_balance 提货券数量
- * @property int $store_id 小店ID
- * @property int $mall_id 商城ID
- * @property int $status 状态:0:禁用,1:正常
- * @property int $created_at
- * @property int $updated_at
- */
- class HappinessVoucherWallet extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_happiness_voucher_wallet';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['level', 'store_id', 'mall_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['balance','freeze_balance'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'level' => 'Level',
- 'balance' => 'Balance',
- 'freeze_balance'=>'Freeze Balance',
- 'store_id' => 'Store ID',
- 'mall_id' => 'Mall ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData($params)
- {
- try {
- if (isset($params['id']) && !empty($params['id'])) {
- $model = self::findOne(['id' => $params['id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (!$model) {
- throw new \Exception('数据不存在或者已被删除');
- }
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|