fix some bug
This commit is contained in:
@@ -234,9 +234,10 @@ class SingleOrderController extends Controller
|
||||
{
|
||||
|
||||
$response = [];
|
||||
$config = app(ConfigService::class);
|
||||
$feeFromGold = $config->feeDeductFromGold();
|
||||
$data['price'] += $data['difference'];
|
||||
$data['total_price'] = $data['amount'] * $data['price'];
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
|
||||
$this->enforceProductOrderLimits($data, (float) $data['total_price']);
|
||||
|
||||
@@ -248,7 +249,12 @@ class SingleOrderController extends Controller
|
||||
|
||||
$data['service_charge'] = isset($data['fee_free']) && $data['fee_free'] === true ? 0 : $data['service_charge_percentage'] * $data['amount'];
|
||||
$data['service_charge_price'] = $data['service_charge'] * $data['price_original'];
|
||||
$data['amount'] -= $data['service_charge'];
|
||||
if ($feeFromGold) {
|
||||
$data['payment_amount'] = $data['total_price'] + $data['service_charge_price'];
|
||||
} else {
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
$data['amount'] -= $data['service_charge'];
|
||||
}
|
||||
if ($wallet->cash < $data['payment_amount']) {
|
||||
throw new UnprocessableEntityHttpException('موجودی شما کمتر از میزان سفارش است');
|
||||
}
|
||||
@@ -420,22 +426,30 @@ class SingleOrderController extends Controller
|
||||
private function processSellTransaction(&$data, $wallet, $wallet_interface)
|
||||
{
|
||||
$response = [];
|
||||
$config = app(ConfigService::class);
|
||||
$feeFromGold = $config->feeDeductFromGold();
|
||||
$data['price'] -= $data['difference'];
|
||||
$grossTotal = $data['amount'] * $data['price'];
|
||||
$this->enforceProductOrderLimits($data, (float) $grossTotal);
|
||||
$data['service_charge'] = isset($data['fee_free']) && $data['fee_free'] === true ? 0 : $data['service_charge_percentage'] * $data['amount'];
|
||||
$data['service_charge_price'] = $data['service_charge'] * $data['price_original'];
|
||||
$data['total_price'] = $data['amount'] * $data['price'] - $data['service_charge_price'];
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
$data['payment_amount'] -= $data['service_charge_price'];
|
||||
if ($wallet->gold < $data['amount']) {
|
||||
if ($feeFromGold) {
|
||||
$data['total_price'] = $data['amount'] * $data['price'];
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
$goldDebit = $data['amount'] + $data['service_charge'];
|
||||
} else {
|
||||
$data['total_price'] = $data['amount'] * $data['price'] - $data['service_charge_price'];
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
$goldDebit = $data['amount'];
|
||||
}
|
||||
if ($wallet->gold < $goldDebit) {
|
||||
throw new UnprocessableEntityHttpException($this->insufficientGoldBalanceMessage($data));
|
||||
}
|
||||
$data['order'] = $order = Order::create($data);
|
||||
$abshode = $this->resolveAbshodeProductContext($data);
|
||||
$productId = (int) ($data['product_id'] ?? $abshode['id'] ?? 0);
|
||||
$sellTransaction = [
|
||||
"gold" => $data['amount'],
|
||||
"gold" => $goldDebit,
|
||||
"cash" => $data['total_price'],
|
||||
'expire_at' => now(),
|
||||
'active' => true,
|
||||
|
||||
Reference in New Issue
Block a user