255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => '会员id', 'code' => '兑换码', 'remarks' => '备注', 'secondary_card_id' => '次卡id', 'use_type' => '使用范围:0:全部店铺;1:指定店铺', 'is_use' => '状态:0:未使用;1:已使用', 'use_time' => '使用时间', 'order_no' => '兑换次卡号', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'create_source_type' => '创建来源类型:0:平台;1:门店', 'create_source_id' => '创建来源id', 'created_at' => '创建时间', 'updated_at' => 'Updated At', ]; } public static function getExportFields() { return [ 'code' => '兑换码', 'remarks' => '批次备注', 'is_use' => '状态', 'created_at' => '创建时间', 'use_time' => '使用时间', 'order_no' => '兑换次卡号', 'source' => '创建来源', ]; } public function getSecondaryCard() { return $this->hasOne(SecondaryCard::class, ['id' => 'secondary_card_id']); } public function getSecondaryCardOrder() { return $this->hasOne(SecondaryCardOrder::class, ['order_no' => 'order_no']); } 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; } } }