feat: shayegan inbound charges workflow and copper kilogram unit enforcement

This commit is contained in:
2026-11-05 17:15:38 +03:30
parent e65b8053fd
commit 7dd5304638
13 changed files with 787 additions and 18 deletions
@@ -16,6 +16,7 @@ use App\Services\BalanceReportService;
use App\Services\ConfigService;
use App\Services\CustomerPresenceService;
use App\Services\ReferralGiftService;
use App\Services\ShayeganSyncService;
use App\Services\WalletBalanceService;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@@ -198,6 +199,23 @@ class CustomerController extends SuperController
$updated = $data === [] ? false : $customer->update($data);
// همگام‌سازی با شایگان در صورت تغییر دستی کد حسابداری
if (array_key_exists('moshtari_code', $data) && app(ConfigService::class)->isShayeganAccounting()) {
$newCode = $data['moshtari_code'];
if ($newCode !== null && $newCode !== '') {
try {
$shayeganSync = app(ShayeganSyncService::class);
$shayeganSync->registerCustomer($customer, $newCode);
} catch (\Throwable $e) {
\Illuminate\Support\Facades\Log::warning('shayegan.manual_code_sync_failed', [
'customer_id' => $customer->id,
'code' => $newCode,
'error' => $e->getMessage(),
]);
}
}
}
return response()->json([
'g' => $goldUpdated,
'u' => $updated,