fix update project on server

This commit is contained in:
liman server@mobin.e 2025-09-20 19:57:58 +00:00
parent 4e5996f476
commit ce62777d5b
6 changed files with 156 additions and 25 deletions

View File

@ -335,29 +335,25 @@ class CustomerController extends SuperController
}
public function customerAll(Request $request)
{
// return $response = Http::withoutVerifying()->timeout(2)
// ->withToken($this->Config('tahesab_token'))
// ->withHeaders(['DBName' => $this->Config('tahesab_db')])
// ->post($this->Config('tahesab_api'), [
// 'DoListMoshtari' => [
// 0, // Name
// 100000000000, // GoroupName
// ]
// ])->json();
$customerSync = $this->customerSync();
try {
$customerSync = $this->customerSync();
} catch (\Exception $e) {
$customerSync = "مشکل در اتصال به ته حساب";
// return isset($_COOKIE["is_get_customer"]);
$message = "لیست مشتریان قبلا دریافت شده";
if (isset($_COOKIE["is_get_customer"]) != 1 or $request->is_get_customer) {
try {
$customerSync = $this->customerSync();
setcookie("is_get_customer", "1", time() + (30 * 60), "/");
$message = "لیست مشتریان با موفقیت دریافت شد";
} catch (\Exception $e) {
$customerSync = "مشکل در اتصال به ته حساب";
}
}
// $responce = $this->table($request);
$query_table = Customer::with($this->with)->where("is_archive", false);
$query_table = Customer::with($this->with)->where("is_archive", false)->orderByDesc("last_using_api");
TableEngine::create($query_table, $request)
->initSearch(['name', 'mobile', 'customer_type','agent.name'])
->select(['*', Customer::$SELECT_CAJ, Customer::$SELECT_TYPE_STR])
->export($query_table);
$query_table["is_get_customer"] = $message;
return $query_table;
$responce["customerSync"] = $customerSync;
return response()->json($responce);

View File

@ -499,9 +499,107 @@ class OrderController extends Controller
]);
}
}
if ($_SERVER['HTTP_HOST'] == 'zarsun.gold' or $_SERVER['HTTP_HOST'] == 'liman.gold' ){
$productPage = Http::withHeaders([
'accept' => 'application/json, text/plain, */*',
'accept-language' => 'en-US,en;q=0.9,fa;q=0.8',
'authorization' => 'Bearer wDUK4wQMvBLymXKzJetIbqqfC5zha3u20Djlu6SCxz1pleKmoAFLks5pfokH6VSQwrMyMytcr6zHnp5v5Gj1VxyD9sY794ujWPKhWE252uLSQJaFPUnBMN-b5jVUGPcoM5mb07F-Fs0uclTMW41gkeh5sH6WDbDi0siF0nFxG0zOkPtenNO0-QCvnoXjV5x4nJ-0Gw9M4SPFskLmgjgJ0i2Y4W9pWErEVDDOVw3CzfbcpUTyANgwp0-MdVbJsKixBNfb2DWZsSgbORxrpcvtvCs5M-dTe31NQ2WyRwI-SsEIvHVryVZLOq_VU2YFu7n1plPb20L09Q2oMvtStx0uLiPSH7ieGHZuHYFLw5n6XCB6NBpLnmcPOEzLRuPMH9IMuGThGJ2bdg3LkBoMafULZR0jepiq4myb1BMnaWCkd5CeLEIB_6y4pjdzWkLKZMW2fFYk6IQ1Xkbo56zCU-MT7ThqD-t7BTgo-DALnQspHMUROtIGEknwK6GFQ74ddmuBLSKLhefdoPuKb8JPkD17oQNlh8J2BFcrQCezqXgzziOSqOTkmad2gzSLg4CSM-Cz1thgsgMtTrpcVH_dK7KvXOWi3cvtVnWiaIoo0gzQkkCxwen5QNjeJnDc0e2jvMhKelHaL4O09JTdysUgBYLi9PJ72Ued00wfkMGhgs294EnUlgnY5FbxiKB5H9qF7E_1aXje8uasUt2vHk_OSKVFwjmZ4rl5NnUj6VUf97nWA8z6QS8c5uHzGqxs9kjFYWfb16xqNkk_xWQ_ABXiZxf-KE_bDiSCJ53tLiGni7xF9jQwee9ZTCmTenRxMlrYL_rp5vxSJt8x0pBkkHPMSQllkS_GGbSMBoYy4TGeTFB0sC2a9NETVvAJayrOJlW7IZgNQGVl9ezkaEq_56CndiRnB9lSjKAhM9v63HhbB6AuvwLR_GRn',
'content-type' => 'application/json;charset=UTF-8',
'origin' => 'https://pnl.arianatala.com',
'roletype' => '0',
'shopkeeperid' => 'b7ad9754-b338-ed11-bc91-00505600c58c',
'subcode' => '0',
'user-agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1',
'webappversion' => '5.10.19',
])->post('https://pnlapi.arianatala.com/api/Home/GetDealView', [
"itemId" => 1,
"shopkeeperId" => "b7ad9754-b338-ed11-bc91-00505600c58c",
"dealType" => 0,
])->json();
$responseSubmitDeal = Http::withHeaders([
'accept' => 'application/json, text/plain, */*',
'accept-language' => 'en-US,en;q=0.9,fa;q=0.8',
'authorization' => 'Bearer wDUK4wQMvBLymXKzJetIbqqfC5zha3u20Djlu6SCxz1pleKmoAFLks5pfokH6VSQwrMyMytcr6zHnp5v5Gj1VxyD9sY794ujWPKhWE252uLSQJaFPUnBMN-b5jVUGPcoM5mb07F-Fs0uclTMW41gkeh5sH6WDbDi0siF0nFxG0zOkPtenNO0-QCvnoXjV5x4nJ-0Gw9M4SPFskLmgjgJ0i2Y4W9pWErEVDDOVw3CzfbcpUTyANgwp0-MdVbJsKixBNfb2DWZsSgbORxrpcvtvCs5M-dTe31NQ2WyRwI-SsEIvHVryVZLOq_VU2YFu7n1plPb20L09Q2oMvtStx0uLiPSH7ieGHZuHYFLw5n6XCB6NBpLnmcPOEzLRuPMH9IMuGThGJ2bdg3LkBoMafULZR0jepiq4myb1BMnaWCkd5CeLEIB_6y4pjdzWkLKZMW2fFYk6IQ1Xkbo56zCU-MT7ThqD-t7BTgo-DALnQspHMUROtIGEknwK6GFQ74ddmuBLSKLhefdoPuKb8JPkD17oQNlh8J2BFcrQCezqXgzziOSqOTkmad2gzSLg4CSM-Cz1thgsgMtTrpcVH_dK7KvXOWi3cvtVnWiaIoo0gzQkkCxwen5QNjeJnDc0e2jvMhKelHaL4O09JTdysUgBYLi9PJ72Ued00wfkMGhgs294EnUlgnY5FbxiKB5H9qF7E_1aXje8uasUt2vHk_OSKVFwjmZ4rl5NnUj6VUf97nWA8z6QS8c5uHzGqxs9kjFYWfb16xqNkk_xWQ_ABXiZxf-KE_bDiSCJ53tLiGni7xF9jQwee9ZTCmTenRxMlrYL_rp5vxSJt8x0pBkkHPMSQllkS_GGbSMBoYy4TGeTFB0sC2a9NETVvAJayrOJlW7IZgNQGVl9ezkaEq_56CndiRnB9lSjKAhM9v63HhbB6AuvwLR_GRn',
'content-type' => 'application/json;charset=UTF-8',
'origin' => 'https://pnl.arianatala.com',
'roletype' => '0',
'shopkeeperid' => 'b7ad9754-b338-ed11-bc91-00505600c58c',
'subcode' => '0',
'user-agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1',
'webappversion' => '5.10.19',
])->post('https://pnlapi.arianatala.com/api/Home/SubmitDeal', [
"Id" => 1,
"ClientOrderId" => $productPage['Data']['ClientOrderId'],
"ShopName" => "آریانا",
"ShopkeeperId" => "b7ad9754-b338-ed11-bc91-00505600c58c",
"Name" => "آبشده نقد فردا",
"Unit" => "گرم",
"GoldEquivalent" => 0,
"Carat" => 750,
"Image" => null,
"DiscountPrice" =>round( $order->amount*($productPage['Data']['Price']/4.3318), -3),
"AllowRange" => 0,
"OrderHallAllowRange" => 0,
"ItemType" => 1,
"ItemGroupId" => 0,
"ItemGroupName" => null,
"IBuy" => false,
"ISell" => false,
"IsShow" => false,
"CanDeal" => false,
"IsOnline" => true,
"ShowMazaneInCloseShop" => false,
"GoldInventory" => 0,
"Description" => "",
"Discount" => 0,
"Price" => round( $order->amount*($productPage['Data']['Price']/4.3318), -3),
"MaxCount" => 3000,
"MinCount" => 1,
"RemainCount" => null,
"CanDoOrderDeal" => true,
"CanDoDeal" => true,
"WaitTime" => 60,
"CancelDealByCustomerWaitTime" => 0,
"RoundType" => 0,
"UpdatedTime" => null,
"OrderIndex" => 0,
"Credit" => null,
"CreditStr" => "0",
"OnlyShowForMazaneChannel" => false,
"OrderDealAllowRange" => 90000,
"OrderDealFromAllowRange" => 39740000,
"OrderDealToAllowRange" => 39920000,
"OrderTimes" => [
["FactorTime" => 30,"Time" => 30,"TimeStr" => "تا 30 ثانیه آینده","TimeType" => 1],
["FactorTime" => 1,"Time" => 60,"TimeStr" => "تا 1 دقیقه آینده","TimeType" => 60],
["FactorTime" => 5,"Time" => 300,"TimeStr" => "تا 5 دقیقه آینده","TimeType" => 60],
["FactorTime" => 10,"Time" => 600,"TimeStr" => "تا 10 دقیقه آینده","TimeType" => 60],
["FactorTime" => 15,"Time" => 900,"TimeStr" => "تا 15 دقیقه آینده","TimeType" => 60],
["FactorTime" => 20,"Time" => 1200,"TimeStr" => "تا 20 دقیقه آینده","TimeType" => 60],
["FactorTime" => 30,"Time" => 1800,"TimeStr" => "تا 30 دقیقه آینده","TimeType" => 60],
["FactorTime" => 40,"Time" => 2400,"TimeStr" => "تا 40 دقیقه آینده","TimeType" => 60],
["FactorTime" => 50,"Time" => 3000,"TimeStr" => "تا 50 دقیقه آینده","TimeType" => 60],
["FactorTime" => 60,"Time" => 3600,"TimeStr" => "تا 60 دقیقه آینده","TimeType" => 60],
],
"MaxOrderDealExpireTime" => 120,
"ItemName" => "آبشده نقد فردا",
"ItemUnit" => "گرم",
"ItemId" => 1,
"Count" =>$order->amount, // dynamic from your order
"IsOrderDeal" => false,
"IsRecovery" => false,
"OrderId" => "",
"DealType" => $order->direction == 1 ? 0 : 1, // dynamic buy/sell
"Fee" => $productPage['Data']['Price'],
])->json();
}
return response()->json([
'response' => $response,
'order' => $order,
'productPage' => $productPage ?? 0,
'responseSubmitDeal' => $responseSubmitDeal ?? 0,
]);
}

View File

@ -1,7 +1,7 @@
<?php
namespace App\Http\Controllers;
use App\Models\Customer;
use Illuminate\Http\Request;
use App\Models\PushSubscription;
use Illuminate\Support\Facades\Http;
@ -56,7 +56,7 @@ class PushController extends Controller {
'data' => 'array'
]);
$userIds = $data['user_ids'] ?? User::pluck('id')->toArray();
$userIds = $data['user_ids'] ?? Customer::pluck('id')->toArray();
return $this->sendWebPush($userIds, [
'title' => $data['title'],
@ -71,10 +71,11 @@ class PushController extends Controller {
* It sends a request to our Node.js microservice.
*/
protected function sendWebPush(array $userIds, array $payloadArray) {
$subscriptions = PushSubscription::whereIn('user_id', $userIds)->get();
if ($subscriptions->isEmpty()) {
return response()->json(['sent' => false, 'count' => 0, 'message' => 'No subscriptions found for the given users.']);
return response()->json(['sent' => false, 'count' => 0, 'message' => 'No subscriptions found for the given users.','users'=>$userIds]);
}
$response = Http::withHeaders([

View File

@ -0,0 +1,35 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CustomerSyncJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
}
}

View File

@ -117,10 +117,10 @@ class Customer extends Authenticatable implements JWTSubject
$user = $this->find($this->attributes['agent_id']);
if ($user) {
$CType = ' نماینده ';
if ($user->agent_id) {
$Agent = $this->find($user->agent_id);
$CType = ' مشتری ' . $Agent->name;
}
// if ($user->agent_id) {
// $Agent = $this->find($user->agent_id);
// $CType = ' مشتری ' . $Agent->name;
// }
}
}
// if ($CType != $this->attributes['customer_type']) {

View File

@ -13,6 +13,7 @@
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"maatwebsite/excel": "^3.1",
"minishlink/web-push": "^8.0",
"morilog/jalali": "^3.4",
"niklasravnsborg/laravel-pdf": "^4.1",
"tymon/jwt-auth": "^1.0"