Комиссионка. Наброски.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Battles;
|
||||
|
||||
use Battles\Database\DBPDO;
|
||||
use Battles\Models\PresentsModel;
|
||||
use Exceptions\GameException;
|
||||
|
||||
class ShopItem extends Item
|
||||
@@ -13,7 +14,7 @@ class ShopItem extends Item
|
||||
private const BUTTON = [
|
||||
'setmarket' => 'Сдать в магазин',
|
||||
'unsetmarket' => 'Снять с продажи',
|
||||
'buymarket' => 'Совершить обмен',
|
||||
'buymarket' => 'Купить с рук',
|
||||
'sellshop' => 'Продать',
|
||||
'buyshop' => 'Купить',
|
||||
];
|
||||
@@ -53,6 +54,7 @@ SQL;
|
||||
public static string $status = '';
|
||||
private ?string $jsonBarterList;
|
||||
private int $offerId;
|
||||
private int $ownerId = 0;
|
||||
|
||||
public function __construct($row, $operationType = null)
|
||||
{
|
||||
@@ -63,9 +65,12 @@ SQL;
|
||||
$this->price = $row->price ?? null;
|
||||
$this->shop_item_quantity = $row->shop_item_quantity ?? null;
|
||||
$this->item_id = $row->item_id ?? $row->id;
|
||||
if ($operationType === 'buyshop') {
|
||||
$this->offerId = $row->offer_id; // Ид позиции в магазине.
|
||||
$this->jsonBarterList = $row->barter_items_list_json;
|
||||
if ($operationType === 'buyshop' || $operationType === 'buymarket') {
|
||||
$this->offerId = $row->offer_id ?? 0; // Ид позиции в магазине.
|
||||
$this->jsonBarterList = $row->barter_items_list_json ?? null;
|
||||
}
|
||||
if ($operationType === 'buymarket') {
|
||||
$this->ownerId = $row->owner_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +84,10 @@ SQL;
|
||||
if ($this->optype === 'sellshop') {
|
||||
$str .= $this->getTextBasedOnPrice();
|
||||
}
|
||||
if ($this->optype === 'buymarket') {
|
||||
$str .= $this->getBarterList();
|
||||
$str .= '<br><br>Продавец: ' . Nick::id($this->ownerId)->full(1);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
@@ -247,6 +256,9 @@ SQL;
|
||||
return '';
|
||||
}
|
||||
$str = $this->optype == 'setmarket' ? '<input placeholder=" ' . $this->price . ' " name="cost">' : '';
|
||||
if ($this->optype === 'buymarket' && $this->ownerId === User::$current->getId()) {
|
||||
$this->optype = 'unsetmarket';
|
||||
}
|
||||
$hiddenValue = $this->optype === 'buyshop' ? $this->offerId : $this->item_id;
|
||||
$button_name = self::BUTTON[$this->optype];
|
||||
return <<<FORM
|
||||
|
||||
Reference in New Issue
Block a user