gift added to tahesab
This commit is contained in:
@@ -60,16 +60,21 @@ class SingleOrderController extends Controller
|
||||
$data['customer_id'] = auth('customer')->id();
|
||||
$latestPrice = Price::latest()->first();
|
||||
|
||||
if($latestPrice->price == 0){
|
||||
if (!$latestPrice || $latestPrice->price == 0) {
|
||||
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||
}
|
||||
$data['all_price'] = $latestPrice;
|
||||
$data['price'] = $latestPrice->price;
|
||||
$data['price_id'] = $latestPrice->id;
|
||||
// $data['difference'] = config('fee.cash');
|
||||
$data['difference'] = Setting::where('key', 'fee_cash')->first()->value;
|
||||
$feeCash = Setting::where('key', 'fee_cash')->first();
|
||||
$feeServiceCharge = Setting::where('key', 'fee_service_charge_percentage')->first();
|
||||
if (!$feeCash || !$feeServiceCharge) {
|
||||
throw new UnprocessableEntityHttpException('تنظیمات کارمزد یافت نشد.');
|
||||
}
|
||||
$data['difference'] = $feeCash->value;
|
||||
// $data['service_charge_percentage'] = config('fee.service_charge_percentage');
|
||||
$data['service_charge_percentage'] = Setting::where('key', 'fee_service_charge_percentage')->first()->value;
|
||||
$data['service_charge_percentage'] = $feeServiceCharge->value;
|
||||
|
||||
$fee_free = Setting::where('key', 'fee_free')->where('is_active', true)->value('value');
|
||||
|
||||
@@ -94,6 +99,9 @@ class SingleOrderController extends Controller
|
||||
$data['fee'] = $data['difference'];
|
||||
$wallet_interface = new WalletInterface($data['customer_id'], 2);
|
||||
$wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first();
|
||||
if (!$wallet) {
|
||||
throw new UnprocessableEntityHttpException('کیف پول یافت نشد.');
|
||||
}
|
||||
$response = [];
|
||||
|
||||
|
||||
@@ -136,7 +144,12 @@ class SingleOrderController extends Controller
|
||||
// Calculate total price and fee for non-product (gold) transaction
|
||||
$data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0);
|
||||
$data['total_fee'] = $data['amount'] * $data['difference'];
|
||||
$data['product'] = Product::find(13);
|
||||
$mainProductId = Cnt::where('key', 'main_product')->value('value');
|
||||
$data['product'] = $mainProductId ? Product::find($mainProductId) : null;
|
||||
if (!$data['product']) {
|
||||
throw new UnprocessableEntityHttpException('محصول آبشده یافت نشد.');
|
||||
}
|
||||
$data['product_id'] = $data['product']->id;
|
||||
// Check if the user wants to buy
|
||||
if ($data['direction'] == 1) {
|
||||
if (!$data['product']['open_buy']) {
|
||||
|
||||
Reference in New Issue
Block a user