| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace addons\MembersCard\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_members_card_used_log}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property string $name 会员卡名称
- * @property int $is_enable 是否启用 0 否 1 是
- * @property float $discount 折扣
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- * @property float $child_discount 子卡折扣
- * @property int $child_num 子卡数量
- * @property int $child_expired_days 子卡有效期
- * @property string $background_url 会员卡背景图
- * @property string $member_limit 会员权限
- */
- class MembersCardUsedLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_members_card_used_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id','card_give_id','order_id','order_detail_id','status', 'created_at', 'updated_at','store_id','is_cashier'], 'integer'],
- [['discount_money', 'pay_money'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'user_id' => 'user id',
- 'card_give_id' => 'card give id',
- 'discount_money' => 'discount money',
- 'pay_money' => 'pay money',
- 'order_id' => 'order id',
- 'order_detail_id' => 'order_detail id',
- 'store_id' => 'store id',
- 'is_cashier' => 'is cashier',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new \Exception('数据不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|