fix some bugs 3
This commit is contained in:
@@ -38,7 +38,10 @@ class OrderController extends Controller
|
||||
|
||||
$lastPrice = (float) (Price::latest('created_at')->value('price') ?? 0);
|
||||
|
||||
$goldAmount = app(WalletBalanceService::class)->effectiveMainWalletGold((int) $customerId);
|
||||
$goldAmount = app(WalletBalanceService::class)->effectiveMainWalletGold(
|
||||
(int) $customerId,
|
||||
(int) ($customer->type ?? 2)
|
||||
);
|
||||
|
||||
$orders = Order::query()
|
||||
->where('customer_id', $customerId)
|
||||
|
||||
@@ -59,7 +59,7 @@ class ProductController extends SuperController
|
||||
}
|
||||
|
||||
if ($representativeId !== null) {
|
||||
$mainWalletGold = $balanceService->effectiveMainWalletGold((int) $user->id);
|
||||
$mainWalletGold = $balanceService->effectiveMainWalletGold((int) $user->id, (int) $user->type);
|
||||
}
|
||||
|
||||
$products = $products->filter(function ($product) use ($mainWalletProductIds, $representativeId) {
|
||||
|
||||
@@ -271,17 +271,15 @@ class PargarInboundController extends Controller
|
||||
$goldInv = isset($data['GoldInv']) ? (float) str_replace('/', '.', (string) $data['GoldInv']) : 0;
|
||||
$rialInv = isset($data['RialInv']) ? (float) str_replace('/', '.', (string) $data['RialInv']) : 0;
|
||||
|
||||
$wallet = $customer->wallet->where('fund_id', null)->first();
|
||||
if ($wallet) {
|
||||
$goldDiff = $goldInv - (float) $wallet->gold;
|
||||
$rialDiff = $rialInv - (float) $wallet->cash;
|
||||
} else {
|
||||
$goldDiff = $goldInv;
|
||||
$rialDiff = $rialInv;
|
||||
}
|
||||
// خواندن و نوشتن روی همان کیف اصلی مشتری — نه first() تصادفی
|
||||
$ownerType = (int) ($customer->type ?? 2);
|
||||
$walletInterface = new WalletInterface($customer->id, $ownerType);
|
||||
$wallet = $walletInterface->wallet;
|
||||
|
||||
$goldDiff = $goldInv - (float) ($wallet->gold ?? 0);
|
||||
$rialDiff = $rialInv - (float) ($wallet->cash ?? 0);
|
||||
|
||||
if (abs($goldDiff) >= 0.01 || abs($rialDiff) >= 1) {
|
||||
$walletInterface = new WalletInterface($customer->id, 2);
|
||||
new TransactionInterface($walletInterface, [
|
||||
'cash' => $rialDiff,
|
||||
'gold' => $goldDiff,
|
||||
|
||||
Reference in New Issue
Block a user