added kashkool
This commit is contained in:
@@ -19,6 +19,8 @@ use App\Http\Controllers\Admin\FileController;
|
||||
use App\Http\Controllers\Site\OfferCodesController;
|
||||
use App\Http\Controllers\Admin\SettingsController;
|
||||
use \App\Http\Controllers\Admin\GiftCardController;
|
||||
use App\Http\Controllers\Admin\CategoryController;
|
||||
use App\Services\ConfigService;
|
||||
|
||||
|
||||
Route::middleware('auth:user')->group(function (){
|
||||
@@ -164,5 +166,11 @@ Route::middleware('auth:user')->group(function (){
|
||||
Route::post('giftcard/generate/', [GiftCardController::class, 'redeem']);
|
||||
Route::post('giftcard/table/', [GiftCardController::class, 'table']);
|
||||
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
Route::get('categories', [CategoryController::class, 'index']);
|
||||
Route::post('categories', [CategoryController::class, 'store']);
|
||||
Route::get('categories/{id}/active/{active}', [CategoryController::class, 'changeActive']);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,6 +11,8 @@ use App\Models\File;
|
||||
use App\Http\Controllers\Admin\SettingsController;
|
||||
use App\Http\Controllers\Site\RequestsController;
|
||||
use App\Services\ConfigService;
|
||||
use App\Http\Controllers\Customer\CartController;
|
||||
use App\Http\Controllers\Admin\CategoryController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -44,3 +46,10 @@ if (app(ConfigService::class)->getBool('external_order_api_enabled', false)) {
|
||||
Route::post('order', [RequestsController::class, 'order']);
|
||||
});
|
||||
}
|
||||
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
Route::get('/cart', [CartController::class, 'getCart']);
|
||||
Route::post('/cart/add', [CartController::class, 'addItem']);
|
||||
Route::post('/cart/remove', [CartController::class, 'removeItem']);
|
||||
Route::get('categories', [CategoryController::class, 'clientIndex']);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ use App\Http\Controllers\Admin\TahesabController;
|
||||
use App\Http\Controllers\Site\OfferCodesController;
|
||||
use App\Http\Controllers\Admin\GiftCardController;
|
||||
use App\Services\ConfigService;
|
||||
use App\Http\Controllers\Customer\havaleController;
|
||||
use App\Http\Controllers\Customer\CartController;
|
||||
|
||||
|
||||
//----------gateway-verify
|
||||
@@ -23,6 +25,10 @@ Route::get('/TCharchee ', [paypingController::class, 'TCharchee']);
|
||||
Route::post('/charge_account_verify', [paypingController::class, 'verifyTransation']);
|
||||
Route::post('/charge_account_verify/{id}', [paypingController::class, 'verifyTransationByID']);
|
||||
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
Route::get('/product/list', [AdminProductController::class, 'listProduct']);
|
||||
Route::get('/product/list/{id}', [AdminProductController::class, 'ProductById']);
|
||||
}
|
||||
|
||||
Route::middleware('auth:customer')->group(function () {
|
||||
Route::middleware('validation')->group(function () {
|
||||
@@ -110,5 +116,14 @@ Route::middleware('auth:customer')->group(function () {
|
||||
//offer code
|
||||
Route::post('offer_code/check_code', [OfferCodesController::class, 'check_code']);
|
||||
|
||||
if (app(ConfigService::class)->isStore()) {
|
||||
Route::post('vc_validate', [havaleController::class, 'virtualCardValidate']);
|
||||
Route::post('havale', [havaleController::class, 'havale']);
|
||||
Route::post('havale_list', [havaleController::class, 'havaleList']);
|
||||
Route::post('/cart/checkout', [CartController::class, 'checkout']);
|
||||
Route::post('validateDiscount', [GiftCardController::class, 'validateDiscount']);
|
||||
Route::post('useDiscount', [GiftCardController::class, 'useDiscount']);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Admin\FinDocController as AdminFinController;
|
||||
use App\Http\Controllers\Admin\FinDocTallaController;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\Admin\OrderController as AdminOrderController;
|
||||
//-----------------------------------------------------------------------------
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Models\Webhook;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Order ;
|
||||
use App\Models\Pargar ;
|
||||
use App\Models\PargarDoc ;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Telegram\Bot\Api;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Rooyesh\Wallet\interfaces\TransactionInterface;
|
||||
use Rooyesh\Wallet\interfaces\WalletInterface;
|
||||
|
||||
|
||||
function finalizeProcessing() {
|
||||
Pargar::latest('id')->take(100)->get()->each(function ($item) {
|
||||
if (is_string($item->finance_data)) {
|
||||
$decoded = json_decode($item->finance_data, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
$item->finance_data = $decoded; // Laravel will re-encode correctly
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$pars = Pargar::latest('id')->take(100)
|
||||
->select(['id','finance_data','m'])
|
||||
->get();
|
||||
|
||||
// foreach ($pars as $par) {
|
||||
// if (!empty($par->finance_data['Customers'])) {
|
||||
// $par->m = 'CUSTOMER';
|
||||
// $par->save();
|
||||
// $cu = Customer::where("pargar_id", $par->finance_data['Customers'][0]['AccountId'])->first();
|
||||
// if (!($cu)) {
|
||||
// $cu = new Customer();
|
||||
// $cu->agent_id = 3137;
|
||||
// $cu->type = 2;
|
||||
// }
|
||||
// $cu->pargar_id = $par->finance_data['Customers'][0]['AccountId'];
|
||||
// $cu->tahesab_id = $par->finance_data['Customers'][0]['AccountId'];
|
||||
// $cu->lname = $par->finance_data['Customers'][0]['FullName'];
|
||||
// $cu->name = $par->finance_data['Customers'][0]['FullName'];
|
||||
// $cu->mobile = $par->finance_data['Customers'][0]['CellPhone'];
|
||||
// $cu->save();
|
||||
// }
|
||||
// if (!empty($par->finance_data['accountName']) && !empty($par->finance_data['accountId']) && !empty($par->finance_data['transactions'])) {
|
||||
// $par->m = 'trans';
|
||||
// $par->save();
|
||||
// $cu = Customer::where("pargar_id", $par->finance_data['accountId'])->first();
|
||||
// if (!($cu)) {
|
||||
// $cu = new Customer();
|
||||
// $cu->agent_id = 3137;
|
||||
// $cu->type = 2;
|
||||
// }
|
||||
// $accountId = $par->finance_data['accountId'];
|
||||
// foreach ($par->finance_data['transactions'] as $transaction) {
|
||||
// $docId = $transaction['docId'];
|
||||
// // Check if docId already exists
|
||||
// if (PargarDoc::where('docId', $docId)->exists()) {
|
||||
// continue; // Skip duplicates
|
||||
// }
|
||||
//
|
||||
// // Save new transaction
|
||||
// PargarDoc::create([
|
||||
// 'docId' => $docId,
|
||||
// 'date' => $transaction['date'],
|
||||
// 'docType' => $transaction['docType'],
|
||||
// 'desc' => $transaction['desc'],
|
||||
// 'goldState' => $transaction['goldState'],
|
||||
// 'rialState' => $transaction['rialState'],
|
||||
// 'bedGold' => $transaction['bedGold'],
|
||||
// 'besGold' => $transaction['besGold'],
|
||||
// 'bedRial' => $transaction['bedRial'],
|
||||
// 'besRial' => $transaction['besRial'],
|
||||
// 'remainGold' => $transaction['remainGold'],
|
||||
// 'remainRial' => $transaction['remainRial'],
|
||||
// 'accountId' => $accountId,
|
||||
// ]);
|
||||
// }
|
||||
// $cu->name = $par->finance_data['accountName'];
|
||||
// $cu->fname = $par->finance_data['accountName'];
|
||||
//
|
||||
// $cu->finance_data = ($par->finance_data['transactions']);;
|
||||
// $cu->mobile = $par->finance_data['accountId'];
|
||||
// $cu->pargar_id = $par->finance_data['accountId'];
|
||||
// $cu->tahesab_id = $par->finance_data['accountId'];
|
||||
// $cu->save();
|
||||
// }
|
||||
// if (!empty($par->finance_data['GoldInv']) && !empty($par->finance_data['RialInv'])) {
|
||||
// $par->m = 'MANDEH';
|
||||
// $par->save();
|
||||
// $cu = Customer::where("pargar_id", $par->finance_data['AccountId'])->first();
|
||||
// if (!($cu)) {
|
||||
// $par->m = 'MANDEHnoC';
|
||||
// $par->save();
|
||||
// continue;
|
||||
//// $cu = new Customer();
|
||||
// }
|
||||
// $cu->pargar_id = $par->finance_data['AccountId'];
|
||||
// $cu->tahesab_id = $par->finance_data['AccountId'];
|
||||
// $cu->gold_balance = $par->finance_data['GoldInv'];
|
||||
// $cu->rial_balance = $par->finance_data['RialInv'];
|
||||
// $cu->save();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Route::post('/login', function (Request $request) {
|
||||
/*
|
||||
* accounting@09131523432.com
|
||||
hJNFTV
|
||||
*/
|
||||
if ($request->password !== 'mont' && $request->password !== 'Abc123' ) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'data' => [],
|
||||
'message' => 'Invalid credentials!'
|
||||
]);
|
||||
}
|
||||
finalizeProcessing();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => ['token' => base64_encode(Str::random(40))],
|
||||
'data' => ['token' => 'wQ12e245d5%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$'],
|
||||
'message' => 'You are logged in successfully.'
|
||||
]);
|
||||
});
|
||||
Route::post('/customers', function (Request $request) {
|
||||
$data = $request->all();
|
||||
if (!empty($data['Customers'])) {
|
||||
$cu = Customer::where("finance_code", $data['Customers'][0]['AccountId'])->first();
|
||||
$message ="با موفقیت ویرایش شد.";
|
||||
|
||||
if (!($cu)) {
|
||||
$cu = new Customer();
|
||||
$cu->finance_code = 3137;
|
||||
$cu->referral_to_id = 'ghatre';
|
||||
$message ="با موفقیت ایجاد شد.";
|
||||
}
|
||||
do {
|
||||
$referral = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 4);
|
||||
} while (Customer::where('referral_id', $referral)->exists());
|
||||
$data['referral_id'] = $referral;
|
||||
|
||||
do {
|
||||
$vcn = $this->Config('default_vc_number') . rand(10, 99) . '-' . rand(1000, 9999) . '-' . rand(1000, 9999);
|
||||
} while (Customer::where('virtual_card_number', $vcn)->exists());
|
||||
$data['virtual_card_number'] = $vcn;
|
||||
|
||||
$cu->lname = $data['Customers'][0]['FullName'];
|
||||
$cu->name = $data['Customers'][0]['FullName'];
|
||||
$cu->mobile = $data['Customers'][0]['CellPhone'];
|
||||
$cu->save();
|
||||
}
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'msg' =>$cu->finance_code.":" . $cu->name.$message,
|
||||
'result' => 'OK'
|
||||
]);
|
||||
});
|
||||
Route::get('/GetCustomers', function (Request $request) {
|
||||
$customers = Customer::/*where('finance_is_saved', 0)->*/whereNull('finance_code')
|
||||
->limit(100)
|
||||
->get(['id', 'fname as name', 'lname as family', 'mobile']);
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'data' => $customers,
|
||||
'msg' =>'1',
|
||||
'result' => 'OK'
|
||||
]);
|
||||
|
||||
});
|
||||
Route::post('/CustomerConfirm', function (Request $request) {
|
||||
$customers = $request->input('customers', []);
|
||||
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$customerRecord = Customer::find($customer['customer_id']);
|
||||
if ($customerRecord) {
|
||||
$customerRecord->finance_code = (int)($customer['accounting_id'] ?? 0);
|
||||
$customerRecord->save();
|
||||
}
|
||||
}
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'data' => $customers,
|
||||
'msg' =>'1',
|
||||
'result' => 'OK'
|
||||
]);
|
||||
});
|
||||
|
||||
Route::post('/orders', function (Request $request) {
|
||||
$OrderIds = $request->input('OrderIds', []);
|
||||
|
||||
try {
|
||||
foreach ($OrderIds as $orderId) {
|
||||
Order::where('id', $orderId)->update(['finance_code' => $orderId]);
|
||||
}
|
||||
}catch (\Exception $e){
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
return response()->json([
|
||||
'state' => true,
|
||||
'msg' => 'ذخیره شد',
|
||||
'result' => 'OK',
|
||||
'duplicated' => [],
|
||||
'documents' => []
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Route::get( '/orders', function (Request $request) {
|
||||
$data = $request->all();
|
||||
|
||||
$orders = Order::where('sts', 2)->whereNull('finance_code')->limit(100)->get();
|
||||
$orders_new = $orders->map(function ($order) {
|
||||
$customer = Customer::find((int)($order->customer_id ?? 0));
|
||||
return [
|
||||
'OrderId' => (string)$order->id,
|
||||
'OrderType' => $order->direction == 1 ? 0 : 1,
|
||||
'PriceType' => 1,
|
||||
'CustomerAccountId' => $customer->finance_code ?? 4,
|
||||
'ItemId' => 11,
|
||||
'itemName' => 'ابشده',
|
||||
'OrderDate' => $order->orders
|
||||
? Jalalian::fromCarbon($order->orders)->format('Y/m/d-H:i:s')
|
||||
: Jalalian::fromCarbon($order->created_at)->format('Y/m/d-H:i:s'),
|
||||
'Fee' => $order->price ?? 0,
|
||||
'Count' => 0,
|
||||
'Weight' => $order->amount ?? 0,
|
||||
'Price' => $order->total_price,
|
||||
'Carat' => 750,
|
||||
'Description' => $order->description ?? '',
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'msg' => '',
|
||||
'data' => ($orders_new),
|
||||
'result' => 'OK',
|
||||
'duplicated' => [],
|
||||
'documents' => []
|
||||
]);
|
||||
});
|
||||
Route::post('/pdf', function (Request $request) {
|
||||
|
||||
$data = $request->all();
|
||||
$head = $request->headers->all();
|
||||
$Pargar = new Pargar();
|
||||
$Pargar->ip = $request->ip(); // Gets the client IP address
|
||||
$Pargar->m = 'pdf'; // Gets the client IP address
|
||||
$Pargar->finance_data = json_encode($data); // Storing request data as JSON
|
||||
$Pargar->finance_head = json_encode($head); // Storing headers as JSON
|
||||
$Pargar->save(); // Don't forget to save the model
|
||||
|
||||
Log::info('📋 هدرهای پیدی اف :', $request->headers->all());
|
||||
|
||||
// 📦 لاگ بدنهی درخواست (Body)
|
||||
$data = $request->all();
|
||||
Log::info('📦 محتوای درخواست ( پیدی اف ):', $data);
|
||||
|
||||
$key = 'wQ12e245d5%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$';
|
||||
$auth = $request->header('pargar') ?? $request->header('Authorization');
|
||||
if ($auth !== $key && $auth !== 'Bearer ' . $key) {
|
||||
return response()->json(['auth needed'], 401);
|
||||
}
|
||||
finalizeProcessing();
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'msg' => 'PDF uploaded successfully',
|
||||
// 'data' => ['fileName' => $fileName],
|
||||
'result' => 'OK'
|
||||
]);
|
||||
});
|
||||
Route::post('/mande', function (Request $request) {
|
||||
$data = $request->all();
|
||||
|
||||
if (!$cu = Customer::where("finance_code",$data['AccountId'])->first()) {
|
||||
}
|
||||
if ( $wallet = $cu->wallet->where('fund_id', null)->first()){
|
||||
$goldInv = isset($data['GoldInv']) ? ((float)str_replace('/', '.', $data['GoldInv'])) : 0;
|
||||
$RialInv = isset($data['RialInv']) ? ((float)str_replace('/', '.', $data['RialInv'])) : 0;
|
||||
$goldDiff = $goldInv - $wallet->gold ;
|
||||
$rialInvDiff = $RialInv - $wallet->cash ;
|
||||
}else{
|
||||
$goldDiff = isset($data['GoldInv']) ? ((float)str_replace('/', '.', $data['GoldInv'])) : 0;
|
||||
$rialInvDiff = isset($data['RialInv']) ? ((float)str_replace('/', '.', $data['RialInv'])) : 0;
|
||||
}
|
||||
|
||||
if (abs($goldDiff) >= 0.01 || abs($rialInvDiff) >= 1) {
|
||||
$wallet_interface = new WalletInterface($cu->id, 2);
|
||||
new TransactionInterface($wallet_interface, [
|
||||
"cash" => $rialInvDiff,
|
||||
"gold" =>$goldDiff,
|
||||
'expire_at' => now(),
|
||||
'active' => true,
|
||||
'start_at' => now(),
|
||||
], 22,$goldDiff> 0, $rialInvDiff > 0);
|
||||
}
|
||||
$cu->gold_balance = $data['GoldInv'];
|
||||
$cu->rial_balance = $data['RialInv'];
|
||||
$cu->save();
|
||||
return response()->json([
|
||||
'state' => 'true',
|
||||
'msg' => "با موفقیت دریافت شد",
|
||||
'data' => null,
|
||||
'dataWeb' => $cu->id ?? 0,
|
||||
'result' => 'OK',
|
||||
'duplicated' => [],
|
||||
'documents' => []
|
||||
]);
|
||||
});
|
||||
Route::post('/documents', function (Request $request) {
|
||||
|
||||
return response()->json([
|
||||
'state' => true,
|
||||
'msg' => "با موفقیت دریافت شد",
|
||||
'data' => null,
|
||||
'result' => 'OK',
|
||||
|
||||
]);
|
||||
});
|
||||
|
||||
Route::any('{any}', function (Request $request) {
|
||||
// finalizeProcessing();
|
||||
|
||||
return response()->json([
|
||||
'state' => false,
|
||||
'msg' => "not found",
|
||||
]);
|
||||
})->where('any', '.*');
|
||||
Reference in New Issue
Block a user