Whether the cart product ID condition is met
@param array $condition
@param array $data
@return boolean
352014
public function productId(array $condition, array $data)
    {
        if (empty($data['cart']['items']) || !in_array($condition['operator'], array('=', '!='))) {
            return false;
        }

        $ids = array();

        foreach ($data['cart']['items'] as $item) {
            $ids[] = $item['product_id'];
        }

        return $this->compare($ids, $condition['value'], $condition['operator']);
    }
924198
public function product(array $condition, array $data)
    {
        $is_product = (int) isset($data['product_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_product, $value, $condition['operator']);
    }
992886
protected final function validateUpdateData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			$newRules = [];
			foreach ($data as $key => $v) {
				if (isset($this->rules[ $key ])) {
					$newRules[ $key ] = $this->rules[ $key ];
				}
			}
			if ($newRules) {
				return $this->validateData($newRules, $data);
			}
		}

		return true;
	}
1154734
public function categoryId(array $condition, array $data)
    {
        if (empty($data['product_id']) || empty($data['category_id'])) {
            return false;
        }

        return $this->compare($data['category_id'], $condition['value'], $condition['operator']);
    }
447314
public function findId($id, $data = [])
    {
        if ($id) {
            $this->findOneById($id);
        } else {
            // Reset status when record not found
            $this->isNew = true;
        }

        return $this->fromArray($data);
    }
1276784
private function checkRequiredData($data, $isNew)
    {
        // Either name or products must be set.
        if (array_key_exists('product', $data)) {
            // Product-id must be defined.
            $this->getProductId($data['product'], 'product.id');
        } else {
            $this->checkDataSet($data, 'name', $isNew);
            $this->checkDataSet($data, 'quantityUnit', $isNew);
        }
        $this->checkDataSet($data, 'quantity', $isNew);
    }
220861
protected function checkZoneIdByAddressId($condition, $data, $key)
    {
        $address = $this->address->get($data['data']['order'][$key]);

        if (empty($address)) {
            return false;
        }

        $fields = array('country_zone_id', 'state_zone_id', 'city_zone_id');

        $ids = array();

        foreach ($fields as $field) {
            $ids[] = $address[$field];
        }

        return $this->compare($ids, $condition['value'], $condition['operator']);
    }
1184923
public function delete($condition)
    {
        $result = null;
        $this->hook->attach('product.class.field.delete.before', $condition, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if (!is_array($condition)) {
            $condition = array('product_class_field_id' => $condition);
        }

        $result = (bool) $this->db->delete('product_class_field', $condition);
        $this->hook->attach('product.class.field.delete.after', $condition, $result, $this);
        return (bool) $result;
    }
602734
public function doesCartWithIdExist(string $cartId): bool
    {
        $qb = $this->connection->createQueryBuilder();
        $qb->select('COUNT(*)')
            ->from('dumplie_customer_cart')
            ->where('id = :id')
            ->setParameter('id', $cartId)
            ->getSQL();

        return (bool)$this->connection->fetchColumn($qb->getSQL(), $qb->getParameters());
    }
356929
public function id(array $condition)
    {
        $user_id = $this->user->getId();
        return $this->compare($user_id, $condition['value'], $condition['operator']);
    }
714860
public function isContainsProduct($productId, $combinationId = null)
    {
        if (Yii::$app->user->isGuest) {
            if (!empty(Yii::$app->session[self::SESSION_KEY])) {
                $sessionProducts = Yii::$app->session[self::SESSION_KEY];

                foreach ($sessionProducts as $item) {
                    $condition = (empty($combinationId))
                        ? (ArrayHelper::getValue($item, 'id') == $productId)
                        : (ArrayHelper::getValue($item, 'id') == $productId && ArrayHelper::getValue($item, 'combinationId') == $combinationId);

                    if($condition) {
                        return $condition;
                    }
                }
            }
        } else {
            /** @var Order $order */
            $order = Order::find()
                ->where(['user_id' => Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])
                ->one();

            if (!empty($order)) {
                $condition = (empty($combinationId))
                    ? ['order_id' => $order->id, 'product_id' => $productId]
                    : ['order_id' => $order->id, 'product_id' => $productId, 'combination_id' => $combinationId];

                $product = OrderProduct::find()
                    ->where($condition)
                    ->one();

                return (!empty($product));
            }
        }

        return false;
    }
68740
public function is($condition, $arguments = [])
    {
        if (is_array($arguments)) {
            return call_user_func_array($this->{$condition}, $arguments);
        }

        return call_user_func($this->{$condition}, $arguments);
    }
910729
public function stateId(array $condition, array $data, $key)
    {
        // Check form fields
        if (isset($data['data']['address']['state_id'])) {
            $state_id = $data['data']['address']['state_id'];
            return $this->compare($state_id, $condition['value'], $condition['operator']);
        }

        if (!isset($data['data']['order'][$key])) {
            return false;
        }

        $address = $this->address->get($data['data']['order'][$key]);

        if (empty($address['state_id'])) {
            return false;
        }

        return $this->compare($address['state_id'], $condition['value'], $condition['operator']);
    }
1025546
public function setData(Condition $condition, $data)
    {
        $this->clearData();
        $this->addData($condition, $data);
    }
115381
public function isValid(array $data)
    {
        if ($this->isCli) {
            return true;
        }

        return isset($data[self::TOKEN_KEY]) && $data[self::TOKEN_KEY] == $this->getToken();
    }
51671
public function update($id, array $data): bool
    {
        $bool = $this->repo->update($data, $id);
        if (false === $bool) {
            throw new CommodityCateException('商品分类没有修改成功', ExceptionCode::UPDATED_FAILURE);
        }

        return $bool;
    }
1197424
public function isExists($condition) {
		/** @var Query $query */
		$query = $this->prepareQuery();
		if(is_array($condition)) {
			$query->whereFromCondition($condition);
		} else {
			$query->where($this->primaryKey, $condition);
		}
		try {
			$this->one($query);
			return true;
		} catch(NotFoundHttpException $e) {
			return false;
		}
	}