14 private $tradePlatform =
null;
38 'ORDER_ID',
'EXTERNAL_ORDER_ID',
39 'TRADING_PLATFORM_ID',
'PARAMS',
'XML_ID'
56 return TradingPlatform\OrderTable::getMap();
69 $entity = static::createEntityObject();
73 if ($platform !==
null)
75 $entity->setFieldNoDemand(
'TRADING_PLATFORM_ID', $platform->getId());
76 $entity->tradePlatform = $platform;
79 $entity->setFieldNoDemand(
'XML_ID', static::generateXmlId());
98 private static function createEntityObject(array $fields = array())
103 return new $entityClassName($fields);
114 public static function loadForOrder($id)
116 if (intval($id) <= 0)
125 $dbRes = $tradeBindingCollection::getList([
126 'filter' => [
'ORDER_ID' => $id]
130 while ($data = $dbRes->fetch())
132 $entityList[] = static::createEntityObject($data);
142 public function save()
144 $result =
new Result();
151 $id = $this->getId();
155 $fields = $this->
getFields()->getChangedValues();
157 $result->setId($r->getId());
169 if ((
int)$this->getField(
'EXTERNAL_ORDER_ID') <= 0)
174 $fields = $this->
getFields()->getValues();
183 if (!$r->isSuccess())
185 $result->addErrors($r->getErrors());
203 if ($this->tradePlatform ===
null)
205 if ($this->getField(
'TRADING_PLATFORM_ID') > 0)
207 $dbRes = TradingPlatformTable::getList([
208 'select' => [
'CODE'],
210 '=ID' => $this->getField(
'TRADING_PLATFORM_ID')
214 if ($item = $dbRes->fetch())
216 $this->tradePlatform = TradingPlatform\Landing\Landing::getInstanceByCode($item[
'CODE']);
221 return $this->tradePlatform;
232 return TradingPlatform\OrderTable::update($primary, $data);
242 return TradingPlatform\OrderTable::add($data);
252 return 'SaleTradeBindingEntity';
263 parent::setFieldNoDemand($name, $value);
265 if ($name ===
'TRADING_PLATFORM_ID')
267 $this->tradePlatform =
null;
273 $result = parent::onFieldModify($name, $oldValue, $value);
274 if (!$result->isSuccess())
279 if ($name ===
'TRADING_PLATFORM_ID')
281 $this->tradePlatform =
null;