fix report
This commit is contained in:
@@ -20,6 +20,8 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
use App\Http\Controllers\Admin\TahesabController;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\TransactionMetalService;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
|
||||
@@ -178,12 +180,14 @@ class WalletController extends Controller
|
||||
"note" => $data['note'],
|
||||
'sts' => 4,
|
||||
]);
|
||||
$representative = app(ConfigService::class)->mainWalletRepresentativeProduct();
|
||||
new TransactionInterface($wallet_interface, $_inp = [
|
||||
'cash' => 0,
|
||||
'gold' => $data['value'],
|
||||
'expire_at' => now(),
|
||||
"note" => $data['note'],
|
||||
'withdraw_id' => $Withdraw->id,
|
||||
'product_id' => $representative?->id,
|
||||
'active' => true
|
||||
], 7, $deposit, false, $gold_block);
|
||||
|
||||
@@ -199,8 +203,9 @@ class WalletController extends Controller
|
||||
}
|
||||
//send sms to users and customer
|
||||
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
||||
$weightUnit = self::tradeWeightUnit();
|
||||
if($this->Config('charge_notif') == "true"){
|
||||
$message = 'کیف پول کاربر ' . $customer->name . ' به مقدار ' . self::formatSmsGoldWeight($data['value']) . " گرم در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
$message = 'کیف پول کاربر ' . $customer->name . ' به مقدار ' . self::formatSmsGoldWeight($data['value']) . " {$weightUnit} در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
. "\n"
|
||||
. $this->Config('name_fa');
|
||||
@@ -209,44 +214,27 @@ class WalletController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsGoldWeight($data['value']) . " گرم در تاریخ " . verta()->format('Y/n/j H:i:s') . $status . " بابت" . "\n"
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsGoldWeight($data['value']) . " {$weightUnit} در تاریخ " . verta()->format('Y/n/j H:i:s') . $status . " بابت" . "\n"
|
||||
. $data['note']
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
return response()->json(true);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
public function index(Request $request, TransactionMetalService $transactionMetalService)
|
||||
{
|
||||
$records = Transaction::with(['customer'])->whereNull('fund_id');
|
||||
$records = Transaction::with(['customer', 'wallet.product:id,metal_id', 'product:id,metal_id'])
|
||||
->whereNull('fund_id');
|
||||
TableEngine::create($records, $request->all())
|
||||
->initSearch(['order_id', 'customer.name'])
|
||||
->select([
|
||||
'*', Transaction::$SELECT_CAJ, Transaction::$SELECT_TYPE_STR, Transaction::$SELECT_SAJ, Transaction::$SELECT_EAJ
|
||||
])->export($records);
|
||||
// foreach ($records['rows'] as &$record) {
|
||||
// if (empty($record->title) or $record->title == "تعریف نشده"){
|
||||
// $record->title = $record->type_str ;
|
||||
// $record->unit = "گرم";
|
||||
// if (isset($record->wallet)) {
|
||||
// $wallet = Wallet::with('product')->where('id',$record->wallet)->first();
|
||||
// if (isset($wallet->product)) {
|
||||
// if ($record->gold > 0){
|
||||
// $record->title = " خرید " ;
|
||||
//
|
||||
// }else{
|
||||
// $record->title = " فروش " ;
|
||||
//
|
||||
// }
|
||||
// $record->title .= $wallet->product->title ;
|
||||
// $record->unit = "عدد";
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// $record->save();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
if (isset($records['rows'])) {
|
||||
$records['rows'] = $transactionMetalService->enrichTransactionRows($records['rows']);
|
||||
}
|
||||
$records['catalogMetals'] = $transactionMetalService->catalogMetals();
|
||||
|
||||
return response()->json($records);
|
||||
}
|
||||
|
||||
@@ -206,6 +206,27 @@ class Controller extends BaseController
|
||||
return self::metalTypeSettingValue() ?? 'طلا';
|
||||
}
|
||||
|
||||
public static function metalIdLabel(int $metalId): string
|
||||
{
|
||||
return match ($metalId) {
|
||||
1 => 'طلا',
|
||||
2 => 'نقره',
|
||||
3 => 'مس',
|
||||
default => self::metalTypeLabel(),
|
||||
};
|
||||
}
|
||||
|
||||
/** برچسب فلز کیف اصلی از `main_wallet_products` یا setting */
|
||||
public static function mainWalletMetalLabel(): string
|
||||
{
|
||||
$product = app(ConfigService::class)->mainWalletRepresentativeProduct();
|
||||
if ($product && (int) ($product->metal_id ?? 0) > 0) {
|
||||
return self::metalIdLabel((int) $product->metal_id);
|
||||
}
|
||||
|
||||
return self::metalTypeLabel();
|
||||
}
|
||||
|
||||
/** برچسب معاملات آبشده: مقدار setting یا «آبشده» */
|
||||
public static function meltedGoldLabel(): string
|
||||
{
|
||||
@@ -239,10 +260,14 @@ class Controller extends BaseController
|
||||
|
||||
public static function genericMetalTransactionTitles(): array
|
||||
{
|
||||
$titles = self::legacyMeltedTransactionTitles();
|
||||
$titles = array_merge(self::legacyMeltedTransactionTitles(), [
|
||||
'واریز طلایی',
|
||||
'برداشت طلایی',
|
||||
]);
|
||||
|
||||
foreach (self::metalLabelVariants() as $label) {
|
||||
$titles[] = "موجودی {$label}";
|
||||
$titles[] = "واریز {$label}";
|
||||
$titles[] = "برداشت {$label}";
|
||||
$titles[] = "خرید {$label}";
|
||||
$titles[] = "فروش {$label}";
|
||||
@@ -277,12 +302,22 @@ class Controller extends BaseController
|
||||
|
||||
public static function mainMetalBuyTitle(): string
|
||||
{
|
||||
return self::productBuyTitle(self::metalTypeLabel());
|
||||
return self::productBuyTitle(self::mainWalletMetalLabel());
|
||||
}
|
||||
|
||||
public static function mainMetalSellTitle(): string
|
||||
{
|
||||
return self::productSellTitle(self::metalTypeLabel());
|
||||
return self::productSellTitle(self::mainWalletMetalLabel());
|
||||
}
|
||||
|
||||
public static function mainMetalDepositTitle(): string
|
||||
{
|
||||
return 'واریز ' . self::mainWalletMetalLabel();
|
||||
}
|
||||
|
||||
public static function mainMetalWithdrawTitle(): string
|
||||
{
|
||||
return 'برداشت ' . self::mainWalletMetalLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -476,9 +476,17 @@ class WalletController extends Controller
|
||||
}
|
||||
|
||||
if (preg_match('/^(موجودی|واریز)/u', (string) $record->title)) {
|
||||
$record->title = self::meltedGoldDepositTitle();
|
||||
if ((int) ($record->type ?? 0) === 7) {
|
||||
$record->title = self::mainMetalDepositTitle();
|
||||
} else {
|
||||
$record->title = self::meltedGoldDepositTitle();
|
||||
}
|
||||
} elseif (preg_match('/^برداشت /u', (string) $record->title)) {
|
||||
$record->title = self::meltedGoldWithdrawTitle();
|
||||
if ((int) ($record->type ?? 0) === 10) {
|
||||
$record->title = self::mainMetalWithdrawTitle();
|
||||
} else {
|
||||
$record->title = self::meltedGoldWithdrawTitle();
|
||||
}
|
||||
} elseif (preg_match('/^خرید /u', (string) $record->title)) {
|
||||
$record->title = self::meltedGoldBuyTitle();
|
||||
} elseif (preg_match('/^فروش /u', (string) $record->title)) {
|
||||
@@ -525,11 +533,19 @@ class WalletController extends Controller
|
||||
private function resolveMainWalletTransactionTitle($record): string
|
||||
{
|
||||
if ((int) $record->type === 1) {
|
||||
return self::meltedGoldBuyTitle();
|
||||
return self::mainMetalBuyTitle();
|
||||
}
|
||||
|
||||
if ((int) $record->type === 2) {
|
||||
return self::meltedGoldSellTitle();
|
||||
return self::mainMetalSellTitle();
|
||||
}
|
||||
|
||||
if ((int) $record->type === 7) {
|
||||
return self::mainMetalDepositTitle();
|
||||
}
|
||||
|
||||
if ((int) $record->type === 10) {
|
||||
return self::mainMetalWithdrawTitle();
|
||||
}
|
||||
|
||||
return $record->type_str;
|
||||
|
||||
Reference in New Issue
Block a user