/
proc
/
self
/
root
/
home
/
henzagold
/
server
/
app
/
Http
/
Controllers
/
Customer
/
File Upload :
llllll
Current File: //proc/self/root/home/henzagold/server/app/Http/Controllers/Customer/TahesabController.php
<?php namespace App\Http\Controllers\Customer; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\DB\Te\TableEngine; use Illuminate\Support\Facades\Http; use Morilog\Jalali\Jalalian; use Illuminate\Support\Facades\Response; use App\Models\Customer; use Illuminate\Support\Facades\DB; class TahesabController extends Controller { public function index(Request $request) { $user = auth()->user()->mcode; $db = 1; $fromDate = $request->fromDate ?? Jalalian::forge(time())->subMonths(1)->format('Y/m/d'); $toDate = $request->toDate ?? Jalalian::forge(time())->format('Y/m/d'); return $responseMandeh = Http::withoutVerifying()->get("https://hesab.henzagold.com/fin_tahesab/fin_tahesab?tahesab_id=$user&db=$db&fromDate=$fromDate&toDate=$toDate&sfx=wcG97tkF@uKj8%NY4pbtVNFdp*2te6nmAiuo7zx%dLcEHXdUO@wDoD*Otm%x76h8eU6oYtC4FDtnF1K*fcQ%%26B93MDzsPn%26MNXzeK%26iNHAijdMZj%26UKxJ**Vr%G!0JdXn")->json(); } public function my_detail(Request $request, $offset = 0) { $user = auth()->user()->mcode; $db = 1; $offset = 0; return $responseDetails = Http::withoutVerifying()->get("https://hesab.henzagold.com/fin_tahesab/my_detail?tahesab_id=$user&db=$db&offset=$offset&sfx=wcG97tkF@uKj8%NY4pbtVNFdp*2te6nmAiuo7zx%dLcEHXdUO@wDoD*Otm%x76h8eU6oYtC4FDtnF1K*fcQ%%26B93MDzsPn%26MNXzeK%26iNHAijdMZj%26UKxJ**Vr%G!0JdXn")->json(); } public function detail(Request $request, $id) { $db = 1; $Factor_Code = $id; return $responseDetails = Http::withoutVerifying()->get("https://hesab.henzagold.com/fin_tahesab/GetHesabDetailByFactorCode?db=$db&Factor_Code=$Factor_Code&sfx=wcG97tkF@uKj8%NY4pbtVNFdp*2te6nmAiuo7zx%dLcEHXdUO@wDoD*Otm%x76h8eU6oYtC4FDtnF1K*fcQ%%26B93MDzsPn%26MNXzeK%26iNHAijdMZj%26UKxJ**Vr%G!0JdXn")->json(); } public function mandeh() { // try{ // return $mainResponce = Http::withoutVerifying() // ->withHeaders(['DBName' => "tahesabDB1"]) // ->withToken("S3F1P8Q4W7X5F7P5B5V5W2D3U3M1N2C5N6E3W6M1E4X4V2Y1Q3O2L6W5W3G2B8T4U2V1S1W4A4S5A1U8") // ->post("https://31.7.68.147:3030/", [ // 'DoListMoshtari' => [1, 200] // ])->json(); // } catch (\Exception $ex) { // return $ex->getMessage(); // } $mainResponce = Http::withoutVerifying() ->withHeaders(['DBName' => "tahesabDB1"]) ->withToken("S3F1P8Q4W7X5F7P5B5V5W2D3U3M1N2C5N6E3W6M1E4X4V2Y1Q3O2L6W5W3G2B8T4U2V1S1W4A4S5A1U8") ->post("https://31.7.68.147:3030/", [ 'getmandehesabbycode' => [auth()->user()->mcode] ])->json(); $response['status'] =200; $response['message'] =''; $response['result'][0] = [ 'arz' => 'IRR', 'mandeh' => $mainResponce['MandeHesab'][0]['MandeyeMali']*-1 ?? 0, ]; $response['result'][1] = [ 'arz' => 'gold', 'mandeh' => $mainResponce['MandeHesab'][0]['MandeyeVazni']*-1 ?? 0, ]; $response['result'][2] = [ 'arz' => 'IRR', 'mandeh' => $mainResponce['MandeHesab'][0]['MandeyeMali']*-1 ?? 0, ]; return $response; $user = auth()->user()->mcode; $db = 1; $responseMandeh = Http::withoutVerifying()->timeout(2)->get("https://hesab.henzagold.com/fin_tahesab/mandeh?tahesab_id=$user&db=$db&sfx=wcG97tkF@uKj8%NY4pbtVNFdp*2te6nmAiuo7zx%dLcEHXdUO@wDoD*Otm%x76h8eU6oYtC4FDtnF1K*fcQ%%26B93MDzsPn%26MNXzeK%26iNHAijdMZj%26UKxJ**Vr%G!0JdXn")->json(); if ($responseMandeh['status']==422) { return response()->json(['message' => $responseMandeh['message'],'status' => 422], 400); } return $responseMandeh ; } public function test(){ $start = microtime(true); $res = Http::withoutVerifying() ->withHeaders(['DBName' => "tahesabDB1"]) ->withToken("S3F1P8Q4W7X5F7P5B5V5W2D3U3M1N2C5N6E3W6M1E4X4V2Y1Q3O2L6W5W3G2B8T4U2V1S1W4A4S5A1U8") ->post("https://31.7.68.147:3030/", [ 'DoListMoshtari' => [0,2000] ]); $raw = preg_replace('/^\x{FEFF}/u', '', $res); $raw = preg_replace('/[\x00-\x1F\x7F]/u', '', $raw); $raw = preg_replace('/\\\\(?!["\\\\\/bfnrtu])/', '-', $raw); $raw = preg_replace('/\?{2,}/u', '?', $raw); if (preg_match('/[\{\[]/', $raw, $m, PREG_OFFSET_CAPTURE)) { $raw = substr($raw, $m[0][1]); } $data = json_decode($raw, true, 512, JSON_INVALID_UTF8_SUBSTITUTE); if (json_last_error() !== JSON_ERROR_NONE) { return response()->json([ 'error' => 'Invalid JSON from upstream', 'msg' => json_last_error_msg(), 'raw' => $raw ], 502); } $customers = Customer::whereNull('deleted_at')->select('id', 'mobile', 'mcode')->get(); $updates = []; $caseStatements = []; $ids = []; $i =0; foreach($customers as $customer){ foreach ($data as $item){ if($customer['mobile'] == $item['Mobile'] ){ $caseStatements[] = "WHEN {$customer->id} THEN '{$item['Code']}'"; $ids[] = "'{$customer->id}'"; $i +=1; break; } } } echo microtime(true) - $start; $startQ = microtime(true); if (!empty($caseStatements)) { $caseSql = "CASE id " . implode(' ', $caseStatements) . " END"; $idsList = implode(',', $ids); DB::statement(" UPDATE customers SET mcode = {$caseSql} WHERE id IN ({$idsList}) "); } echo "\n"; echo microtime(true) - $startQ; return "\n update done ".$i; } }
Copyright ©2k19 -
Hexid
|
Tex7ure