handle transactions
This commit is contained in:
@@ -155,11 +155,111 @@ class Controller extends BaseController
|
||||
return Setting::where('key',$name)->first()->value ?? false;
|
||||
}
|
||||
|
||||
public static function metalTypeLabel(): string
|
||||
protected static function metalTypeSettingValue(): ?string
|
||||
{
|
||||
$metalType = Setting::where('key', 'metal_type')->value('value');
|
||||
if ($metalType === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ($metalType !== null && trim((string) $metalType) !== '') ? trim((string) $metalType) : 'طلا';
|
||||
$metalType = trim((string) $metalType);
|
||||
|
||||
return $metalType !== '' ? $metalType : null;
|
||||
}
|
||||
|
||||
/** برچسب موجودی کیف اصلی: مقدار setting یا «طلا» */
|
||||
public static function metalTypeLabel(): string
|
||||
{
|
||||
return self::metalTypeSettingValue() ?? 'طلا';
|
||||
}
|
||||
|
||||
/** برچسب معاملات آبشده: مقدار setting یا «آبشده» */
|
||||
public static function meltedGoldLabel(): string
|
||||
{
|
||||
return self::metalTypeSettingValue() ?? 'آبشده';
|
||||
}
|
||||
|
||||
public static function cashTransactionTitles(): array
|
||||
{
|
||||
return ['برداشت وجه نقد', 'واریز وجه نقد'];
|
||||
}
|
||||
|
||||
public static function legacyMeltedTransactionTitles(): array
|
||||
{
|
||||
return [
|
||||
'واریز طلای ابشده',
|
||||
'واریز طلای آبشده',
|
||||
'برداشت طلای ابشده',
|
||||
'برداشت طلای آبشده',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function metalLabelVariants(): array
|
||||
{
|
||||
return array_values(array_unique([
|
||||
self::meltedGoldLabel(),
|
||||
self::metalTypeLabel(),
|
||||
'طلا',
|
||||
'آبشده',
|
||||
]));
|
||||
}
|
||||
|
||||
public static function genericMetalTransactionTitles(): array
|
||||
{
|
||||
$titles = self::legacyMeltedTransactionTitles();
|
||||
|
||||
foreach (self::metalLabelVariants() as $label) {
|
||||
$titles[] = "موجودی {$label}";
|
||||
$titles[] = "برداشت {$label}";
|
||||
$titles[] = "خرید {$label}";
|
||||
$titles[] = "فروش {$label}";
|
||||
}
|
||||
|
||||
return array_values(array_unique($titles));
|
||||
}
|
||||
|
||||
public static function isCashTransactionTitle(?string $title): bool
|
||||
{
|
||||
return $title !== null && in_array($title, self::cashTransactionTitles(), true);
|
||||
}
|
||||
|
||||
public static function isGenericMetalTransactionTitle(?string $title): bool
|
||||
{
|
||||
if ($title === null || self::isCashTransactionTitle($title)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($title, self::genericMetalTransactionTitles(), true);
|
||||
}
|
||||
|
||||
public static function productBuyTitle(string $productTitle): string
|
||||
{
|
||||
return 'خرید ' . $productTitle;
|
||||
}
|
||||
|
||||
public static function productSellTitle(string $productTitle): string
|
||||
{
|
||||
return 'فروش ' . $productTitle;
|
||||
}
|
||||
|
||||
public static function meltedGoldBuyTitle(): string
|
||||
{
|
||||
return 'خرید ' . self::meltedGoldLabel();
|
||||
}
|
||||
|
||||
public static function meltedGoldSellTitle(): string
|
||||
{
|
||||
return 'فروش ' . self::meltedGoldLabel();
|
||||
}
|
||||
|
||||
public static function meltedGoldDepositTitle(): string
|
||||
{
|
||||
return 'موجودی ' . self::meltedGoldLabel();
|
||||
}
|
||||
|
||||
public static function meltedGoldWithdrawTitle(): string
|
||||
{
|
||||
return 'برداشت ' . self::meltedGoldLabel();
|
||||
}
|
||||
|
||||
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||
|
||||
Reference in New Issue
Block a user