mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge branch 'dillon/146-izyim-ui-update' into vapor/staging
This commit is contained in:
@@ -30,7 +30,7 @@ class CreatesClaudeResponse
|
||||
'anthropic-version' => config('anthropic.api_version', '2023-06-01'),
|
||||
'Content-Type' => 'application/json',
|
||||
])->post(config('anthropic.base_url') . '/v1/messages', [
|
||||
'model' => config('anthropic.default_model', 'claude-sonnet-4-5-20250929'),
|
||||
'model' => !empty($model) ? $model : config('anthropic.default_model', 'claude-sonnet-4-5-20250929'),
|
||||
'max_tokens' => 8192,
|
||||
'messages' => [
|
||||
[
|
||||
|
||||
+30
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\YD\FetchPackingListsFromYdPortalV2CommandJob;
|
||||
use App\Classes\Modules\PackingLists\Services\DeletesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
@@ -11,6 +12,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\PackingList;
|
||||
use Carbon\Carbon;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -84,7 +86,35 @@ class DeletePackingListByPackageIdLogic extends AbstractControllerLogic
|
||||
|
||||
$childPackingList->each->delete();
|
||||
|
||||
$jobs1 = $this->fetchPackingListsFromYdPortalV2CommandJobs();
|
||||
foreach ($jobs1 as $index => $job) {
|
||||
dispatch($job)->delay(now()->addSeconds($index * 2));
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
|
||||
private function fetchPackingListsFromYdPortalV2CommandJobs()
|
||||
{
|
||||
$jobs = [];
|
||||
$count = 0;
|
||||
|
||||
// Always take last 10 days INCLUDING today
|
||||
for ($x = 0; $x < 10; $x++) {
|
||||
|
||||
$startDate = Carbon::today()->subDays($x)->startOfDay();
|
||||
$endDate = Carbon::today()->subDays($x - 1)->startOfDay();
|
||||
|
||||
$jobs[] = new FetchPackingListsFromYdPortalV2CommandJob($startDate, $endDate);
|
||||
|
||||
Log::info('Dispatched FetchPackingListsFromYdPortalV2CommandJob for start date: ' . $startDate . ', end date: ' . $endDate);
|
||||
$count++;
|
||||
}
|
||||
|
||||
Log::info('Total FetchPackingListsFromYdPortalV2CommandJob dispatched: ' . $count);
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+46
-16
@@ -221,13 +221,19 @@ class FetchByTrakingNoYdPortalV2Processor
|
||||
{$remark}
|
||||
What are the ETA and ETD?";
|
||||
Log::info('prompt: '.$userPrompt);
|
||||
$result = $this->createsClaudeResponse->execute($userPrompt);
|
||||
$result = $this->createsClaudeResponse->execute($userPrompt, 'claude-haiku-4-5-20251001');
|
||||
Log::info('result (json_encoded): '.json_encode($result));
|
||||
// $content = $result['choices'][0]['message']['content'] ?? null;
|
||||
$content = $result['content'][0]['text'] ?? '[]';
|
||||
Log::info('content (json_encoded):'. json_encode($content));
|
||||
if ($content) {
|
||||
$parsedContent = json_decode($content, true);
|
||||
|
||||
Log::info('raw ETA/ETD content: ' . $content);
|
||||
|
||||
// Remove markdown code fences if they exist
|
||||
$contentClean = preg_replace('/^```json\s*|\s*```$/', '', $content);
|
||||
$contentClean = trim($contentClean);
|
||||
|
||||
if ($contentClean) {
|
||||
$parsedContent = json_decode($contentClean, true);
|
||||
|
||||
// $parsedContent = json_decode(str_replace("'", '"', $content), true);
|
||||
if (is_array($parsedContent) && isset($parsedContent['ETA'], $parsedContent['ETD'])) {
|
||||
@@ -327,22 +333,46 @@ class FetchByTrakingNoYdPortalV2Processor
|
||||
|
||||
private function translateTracking($textToTranslate)
|
||||
{
|
||||
$userPrompt = "Please translate mandarin to english and return result in this format, e.g. {'mandarin': '.$textToTranslate.', 'english': ''}. ".$textToTranslate." ";
|
||||
Log::info('prompt: '.$userPrompt);
|
||||
$result = $this->createsClaudeResponse->execute($userPrompt);
|
||||
Log::info('result (json_encoded): '.json_encode($result));
|
||||
// $content = $result['choices'][0]['message']['content'] ?? null;
|
||||
$content = $result['content'][0]['text'] ?? '[]';
|
||||
Log::info('content (json_encoded):'. json_encode($content));
|
||||
$parsedContent = json_decode(str_replace("'", '"', $content), true);
|
||||
// Return null immediately if no Mandarin character is present
|
||||
if (!preg_match('/\p{Han}/u', $textToTranslate)) {
|
||||
Log::info('No Mandarin characters detected, skipping translation.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if($parsedContent && $parsedContent['english']){
|
||||
$userPrompt = "Translate the following Mandarin text to English.
|
||||
|
||||
You must respond with raw JSON only.
|
||||
No explanations.
|
||||
No markdown.
|
||||
No code fences.
|
||||
No comments.
|
||||
Only this JSON structure:
|
||||
|
||||
{\"mandarin\": \"".$textToTranslate."\", \"english\": \"<translation>\"}
|
||||
|
||||
Text: ".$textToTranslate;
|
||||
|
||||
Log::info('prompt: '.$userPrompt);
|
||||
$result = $this->createsClaudeResponse->execute($userPrompt, 'claude-haiku-4-5-20251001');
|
||||
|
||||
Log::info('result (json_encoded): '.json_encode($result));
|
||||
|
||||
$content = $result['content'][0]['text'] ?? '[]';
|
||||
Log::info('raw content: ' . $content);
|
||||
|
||||
// Remove markdown code fences if they exist
|
||||
$contentClean = preg_replace('/^```json\s*|\s*```$/', '', $content);
|
||||
$contentClean = trim($contentClean);
|
||||
|
||||
// Decode JSON safely
|
||||
$parsedContent = json_decode($contentClean, true);
|
||||
|
||||
if($parsedContent && isset($parsedContent['english'])){
|
||||
Log::info('Translated Text: ' . $parsedContent['english']);
|
||||
return $parsedContent['english'];
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -158,6 +158,7 @@ class FetchPackingListsFromYdPortalV2Processor
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
Log::info('Fetch SHIPPING_PACKING_LIST expressno: ' . $row->expressno);
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
Log::info('Fetch SHIPPING_PACKING_LIST id: ' . $packingList->id);
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
<div class="col">
|
||||
<div class="row" v-show="!$store.getters.isShowing('resetPasswordSuccess')">
|
||||
<div class="col">
|
||||
<div class="row m-b-15">
|
||||
<!-- <div class="row m-b-15">
|
||||
<div class="col">
|
||||
<div class="inline v-align-middle">
|
||||
<div class="font-heading fs-20 all-caps text-primary no-margin lh-28 bold">Reset your password</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row m-r-0 m-l-0 m-b-20" v-if="error">
|
||||
<div class="col p-l-50">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,4 +101,4 @@
|
||||
mixins: [request]
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
<loading-component style="height: 350px;" key="1" color="primary" v-show="$store.getters.isLoading('resetPasswordSection')"></loading-component>
|
||||
<div class="row" key="2" v-show="!$store.getters.isLoading('resetPasswordSection')">
|
||||
<div class="col all-caps">
|
||||
<div class="row m-l-0">
|
||||
<div class="row m-l-0">
|
||||
<div class="col p-l-50">
|
||||
<h5 class="font-lato light animate__animated animate__fadeInRightBig animate__slow" style=" line-height: 50px; letter-spacing: 5px; ">Reset your password</h5>
|
||||
</div>
|
||||
</div>
|
||||
<reset-password-form-component section="resetPasswordSection" token="{{$token}}"></reset-password-form-component>
|
||||
<div class="row m-l-0">
|
||||
<div class="col p-l-50">
|
||||
<reset-password-form-component section="resetPasswordSection" token="{{$token}}"></reset-password-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition-component>
|
||||
@@ -47,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center h-100 bg-white text-center" key="2" v-show="$store.getters.isShowing('resetPasswordSuccess')">
|
||||
<div class="col">
|
||||
<div class="col p-t-40">
|
||||
<div class="row m-b-20 animate__animated animate__fadeInDownBig">
|
||||
<div class="col">
|
||||
<i class="fa fa-check-circle animate__animated animate__tada animate__slower animate__infinite fs-70 text-success"></i>
|
||||
@@ -71,4 +75,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</transition-component>
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user