@param array $data
@param Order $order
@param bool $patch

@throws MissingOrderAttributeException
@throws OrderDependencyNotFoundException

@return null|object
187547
private function setTermsOfPayment($data, Order $order, $patch = false)
    {
        $terms = null;
        // terms of delivery
        $termsOfPaymentData = $this->getProperty($data, 'termsOfPayment');
        $termsOfPaymentContentData = $this->getProperty($data, 'termsOfPaymentContent');
        if ($termsOfPaymentData) {
            if (!array_key_exists('id', $termsOfPaymentData)) {
                throw new MissingOrderAttributeException('termsOfPayment.id');
            }
            // TODO: inject repository class
            $terms = $this->em->getRepository(static::$termsOfPaymentEntityName)->find($termsOfPaymentData['id']);
            if (!$terms) {
                throw new OrderDependencyNotFoundException(
                    static::$termsOfPaymentEntityName,
                    $termsOfPaymentData['id']
                );
            }
            $order->setTermsOfPayment($terms);
            $order->setTermsOfPaymentContent($terms->getTerms());
        } elseif (!$patch) {
            $order->setTermsOfPayment(null);
            $order->setTermsOfPaymentContent(null);
        }
        // set content data
        if ($termsOfPaymentContentData) {
            $order->setTermsOfPaymentContent($termsOfPaymentContentData);
        }

        return $terms;
    }
1269071
public function query(array $order)
    {
        Datasheet::set($order);
        $result = Helper::request(Helper::GATEWAY_TRADEQUERY, ['AuthCode']);
        return $this->callback($result);
    }
433390
public function cancelOrders(RequestOrder $order = null) {
        return $this->delete(['orders'], RawData::class, ($order !== null) ? $order->toArray() : []);
    }
408290
public function set_sort($field,$order=false){
		if (!$field && !$order)
			$this->sort_by=array();
		else{
			if ($order===false)
				$this->sort_by[] = $field;
			else {
				$order=strtolower($order)=="asc"?"ASC":"DESC";
				$this->sort_by[]=array("name"=>$field,"direction" => $order);
			}
		}
	}
137416
public function order($field, $order = null, $intSort = true)
    {
        return $this->sort(function ($a, $b) use ($field, $order, $intSort) {
            $fieldA = isset($a[$field]) ? $a[$field] : null;
            $fieldB = isset($b[$field]) ? $b[$field] : null;

            if ($intSort) {
                return 'desc' == strtolower($order) ? $fieldB >= $fieldA : $fieldA >= $fieldB;
            } else {
                return 'desc' == strtolower($order) ? strcmp($fieldB, $fieldA) : strcmp($fieldA, $fieldB);
            }
        });
    }
206247
public function loadBy(array $whereArr = [], $order = '')
    {
        $this->mustBeDataModel();

        if (empty($whereArr)) {
            throw new Exception('The $whereArr param format error in '.get_called_class().'::loadBy($whereArr)!');
        }

        $array = $this->find(['where' => $whereArr, 'order' => $order])->fetchRow();

        if($array) {
            $this->fromArray($array);
            $this->setLoaded();
            return true;
        }

        return false;
    }
319677
public function orderByMultiple($order = array('_leftnode' => 'asc'), $alias = null)
    {
        if (true === empty($order)) {
            $order = array('_leftnode' => 'asc');
        }

        $this->resetDQLPart('orderBy');
        $alias = $this->getFirstAlias($alias);
        foreach ($order as $field => $sort) {
            if (0 < count($this->getDQLPart('orderBy'))) {
                $this->addOrderBy($alias.'.'.$field, $sort);
            } else {
                $this->orderBy($alias.'.'.$field, $sort);
            }
        }

        return $this;
    }
83749
public static function rebuildOrder ($whereCondition = null, $order = null)
		{
			if ($order === null)
			{
				$order = [ 'order' => SORT_ASC ];
			}

			$query = self::find()->orderBy($order);
			if ($whereCondition !== null)
			{
				$query->where($whereCondition);
			}

			$objects = $query->all();
			foreach ($objects as $k => $object)
			{
				$object->order = $k + 1;
				$object->save();
			}
		}
684956
public function allowCancel($order)
    {
        /** @var SalesDependencyClassInterface $dependency */
        foreach ($this->dependencyClasses as $dependency) {
            if (!$dependency->allowCancel($order)) {
                return false;
            }
        }

        return true;
    }
249699
protected function createItemBagForOrder(Order $order)
    {
        if (!$this->sendCartInfo) {
            return null;
        }

        $items = $this->getItemListForOrder($order);
        $itemBagClassName = $this->getItemBagClassName();

        return new $itemBagClassName($items);
    }
1057476
public function findRelation($entity, $relationName, $orderColumn = null, $orderType = null) {
        $this->load();
        $mapper = MapperBuilder::buildFromClassName($this->mapping, get_class($entity));
        $relation = $mapper->getRelation($relationName);
        $relationMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());

        $selectQuery = "SELECT tmain.* FROM `" . $relationMapper->getTable() . "` tmain ";
        $joinQuery = QueryBuilder::buildJoinRelationQuery($relation, "tmain", "j1");
        $whereQuery = "WHERE j1." . $relation->getLocalColumn() . " = '" . $entity->getId() . "'";

        $orderQuery = "";
        if (!is_null($orderColumn)) {
            $orderQuery .= "ORDER BY $orderColumn ";
            if (!is_null($orderType)) {
                $orderQuery .= "$orderType";
            } else {
                $orderQuery .= "ASC";
            }
        }

        $query = $selectQuery . $joinQuery . $whereQuery . $orderQuery;
        $queryResult = $this->getDataSource()->query($query);
        if ($queryResult) {
            $collection = new Collection($relationMapper->getClass(), $queryResult, $relationMapper);
        } else {
            $collection = new Collection($relationMapper->getClass(), array(), $relationMapper);
        }

        return $collection;
    }
1360934
public function sort($field = null, $order = 'a') {
        if ($field === null) {
            $field = rqst('sort.name');
            $order = rqst('sort.dir', 'a');
        }
        if ($field) {
            if (is_string($field)) {
                $orders = explode(',', strtolower($order));
                $fields = explode(',', $field);
                foreach ($fields as $i => $field) {
                    $this->order [] = [$field, isset($orders[ $i ]) ? $orders[ $i ] : $orders[0]];
                }
            } else if (is_array($field)) {
                $this->sort($field[0], isset($field[1]) ? $field[1] : 'a');
            }
        }

        return $this;
    }
903651
function order($order)
    {
        if (!empty($order))
        {
            self::sql_safe($order);
            $this->order = "order by $order";
        }
        else
        {
            $this->order = '';
        }
    }
363566
public function order(array $condition, array $data)
    {
        $is_order = (int) isset($data['order_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_order, $value, $condition['operator']);
    }
429767
protected function fromArray( \Aimeos\MShop\Order\Item\Base\Iface $order, array $data )
	{
		$invoiceIds = $this->getValue( $data, 'order.id', [] );
		$manager = \Aimeos\MShop::create( $this->getContext(), 'order' );

		$search = $manager->createSearch()->setSlice( 0, count( $invoiceIds ) );
		$search->setConditions( $search->compare( '==', 'order.id', $invoiceIds ) );

		$items = $manager->searchItems( $search );


		foreach( $invoiceIds as $idx => $id )
		{
			if( !isset( $items[$id] ) ) {
				$item = $manager->createItem();
			} else {
				$item = $items[$id];
			}

			if( isset( $data['order.statusdelivery'][$idx] ) ) {
				$item->setDeliveryStatus( $data['order.statusdelivery'][$idx] );
			}

			if( isset( $data['order.statuspayment'][$idx] ) ) {
				$item->setPaymentStatus( $data['order.statuspayment'][$idx] );
			}

			if( isset( $data['order.datedelivery'][$idx] ) ) {
				$item->setDateDelivery( $data['order.datedelivery'][$idx] );
			}

			if( isset( $data['order.datepayment'][$idx] ) ) {
				$item->setDatePayment( $data['order.datepayment'][$idx] );
			}

			if( isset( $data['order.relatedid'][$idx] ) ) {
				$item->setRelatedId( $data['order.relatedid'][$idx] );
			}

			if( isset( $data['order.type'][$idx] ) ) {
				$item->setType( $data['order.type'][$idx] );
			}

			$item->setBaseId( $order->getId() );

			$manager->saveItem( $item );
		}
	}
83773
public function setOrderDelivery($order_id, $need_delivery = 0, $delivery_company = null, $delivery_track_no = null, $is_others = 0){
		if (!$this->access_token && !$this->checkAuth()) return false;
		if (!$order_id) return false;

		$data = array();
		$data['order_id'] = $order_id;
		if ($need_delivery) {
			$data['delivery_company'] = $delivery_company;
			$data['delivery_track_no'] = $delivery_track_no;
			$data['is_others'] = $is_others;
		}
		else {
			$data['need_delivery'] = $need_delivery;
		}

		$result = $this->http_post(self::API_BASE_URL_PREFIX.self::MERCHANT_ORDER_SETDELIVERY.'access_token='.$this->access_token, self::json_encode($data));
		if ($result)
		{
			$json = json_decode($result,true);
			if (isset($json['errcode']) && $json['errcode']) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'];
				return false;
			}
			return true;
		}
		return false;
	}
478780
public function setOrder(\Librinfo\EcommerceBundle\Entity\Order $order = null)
    {
        $this->order = $order;

        return $this;
    }