feat(tahesab,colleague): push app balance to Tahesab and always wait callback

Add admin decision to write app wallet onto Tahesab even when zero, always await colleague callback regardless of the wait switch, and SMS admins on colleague reject.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-05 22:30:56 +03:30
co-authored by Cursor
parent 8cee34bfba
commit 00b23ac404
6 changed files with 176 additions and 15 deletions
@@ -807,7 +807,7 @@ class TahesabController extends Controller
/**
* همگام‌سازی مانده یک مشتری با ته‌حساب.
* body: overwrite=1 | keep=1 | ask_if_conflict=1 (پیش‌فرض ask برای جلوگیری از overwrite ناخواسته)
* body: overwrite=1 | keep=1 | push_to_tahesab=1 | ask_if_conflict=1
*/
public function syncCustomerWallet(Request $request, $customerId)
{
@@ -826,12 +826,26 @@ class TahesabController extends Controller
], 422);
}
$walletService = app(TahesabInboundWalletService::class);
if ($request->boolean('push_to_tahesab')) {
$result = $walletService->pushWalletToTahesab($customer);
$applied = (bool) ($result['applied'] ?? false);
return response()->json([
'ok' => $applied,
'needs_decision' => false,
'message' => $result['message'] ?? '',
'result' => $result,
], $applied ? 200 : 422);
}
$overwrite = $request->boolean('overwrite');
$keep = $request->boolean('keep');
$alwaysAsk = $request->boolean('always_ask');
$askIfConflict = $request->boolean('ask_if_conflict', ! $overwrite && ! $keep && ! $alwaysAsk);
$result = app(TahesabInboundWalletService::class)->syncWalletFromTahesab(
$result = $walletService->syncWalletFromTahesab(
$customer,
null,
[