NASER fix conflicts
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
|
class SettingsController extends Controller
|
||||||
|
{
|
||||||
|
public function index(){
|
||||||
|
$Setting = Setting::where('can_edit',1)->select('id','title_fa', 'key','value','description','is_active')->get();
|
||||||
|
return response()->json($Setting);
|
||||||
|
}
|
||||||
|
public function edit(Request $request)
|
||||||
|
{
|
||||||
|
// Check if the setting exists
|
||||||
|
$setting = Setting::where('key', $request->key)->first();
|
||||||
|
|
||||||
|
if ($setting) {
|
||||||
|
// Update the existing setting
|
||||||
|
$setting->value = $request->value;
|
||||||
|
$setting->description = $request->description;
|
||||||
|
$setting->is_active = $request->is_active;
|
||||||
|
$setting->save();
|
||||||
|
} else {
|
||||||
|
// Create a new setting
|
||||||
|
$setting = new Setting();
|
||||||
|
$setting->key = $request->key;
|
||||||
|
$setting->value = $request->value;
|
||||||
|
$setting->description = $request->description;
|
||||||
|
$setting->is_active = $request->is_active;
|
||||||
|
$setting->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the setting as a JSON response
|
||||||
|
return response()->json($setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,52 +8,80 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Models\Tahesab;
|
use App\Models\Tahesab;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
|
use Morilog\Jalali\Jalalian;
|
||||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
use Hekmatinasser\Verta\Verta;
|
use Hekmatinasser\Verta\Verta;
|
||||||
|
|
||||||
|
|
||||||
class TahesabController extends Controller
|
class TahesabController extends Controller
|
||||||
{
|
{
|
||||||
public function store()
|
public function create_user($customer_id)
|
||||||
{
|
{
|
||||||
$customer = auth()->user();
|
|
||||||
if (!$customer) {
|
|
||||||
throw new UnprocessableEntityHttpException("Auth needed");
|
|
||||||
}
|
|
||||||
$customer = Customer::where('id', $customer->id)->first();
|
|
||||||
|
|
||||||
if ($customer && ($customer->moshtari_code !== null)) {
|
|
||||||
return "customer exists";
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$response = Http::withoutVerifying()->timeout(10)->withHeaders([
|
|
||||||
'DBName' => $this->Config('tahesab_db'),
|
|
||||||
'Content-Type' => 'application/json',
|
|
||||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
|
||||||
])->post('https://185.252.86.194:8081', [
|
|
||||||
"DoNewMoshtari" => [
|
|
||||||
$customer->name,
|
|
||||||
$this->Config('name_fa'),
|
|
||||||
$customer->mobile,
|
|
||||||
"",
|
|
||||||
$customer->n_code ?? "",
|
|
||||||
$customer->birth_date ?? "", // !== null ? jalalian::fromCarbon(Carbon::parse($customer->birth_date))->format('Y/m/d') : null,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
-1,
|
|
||||||
0 // tala
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
$customer = Customer::findOrFail($customer_id);
|
||||||
return $e->getMessage();
|
|
||||||
|
if ($customer && ($customer->moshtari_code == null)) {
|
||||||
|
try {
|
||||||
|
$response = Http::withoutVerifying()->timeout(10)->withHeaders([
|
||||||
|
'DBName' => $this->Config('tahesab_db'),
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||||
|
])->post((string)env('TAHESAB'), [
|
||||||
|
"DoNewMoshtari" => [
|
||||||
|
(string)$customer->name,
|
||||||
|
$this->Config('name_fa'),
|
||||||
|
(string)$customer->mobile,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
-1,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
//{"DoNewMoshtari":["Name", "GroupName", "Tel", "Address", "CodeMeli", "Tarikh_Tavalod", "Moaref", "Code_Moaref", Moshtari_Code, Jens_Felez]}
|
||||||
|
]);
|
||||||
|
if (!empty($response['OK'])) {
|
||||||
|
$customer->moshtari_code = $response['OK'];
|
||||||
|
$customer->save();
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if($customer && $customer->birth_date !== null){
|
||||||
|
$birth_date = Verta::instance(Carbon::parse($customer->birth_date))->format('Y-m-d');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$response = Http::withoutVerifying()->timeout(10)->withHeaders([
|
||||||
|
'DBName' => $this->Config('tahesab_db'),
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||||
|
])->post((string)env('TAHESAB'), [
|
||||||
|
"DoEditMoshtari" => [
|
||||||
|
$customer->name,
|
||||||
|
$this->Config('name_fa'),
|
||||||
|
$customer->mobile,
|
||||||
|
"",
|
||||||
|
$customer->n_code ?? "",
|
||||||
|
$birth_date ?? "",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
(int)$customer->moshtari_code,
|
||||||
|
0 // tala
|
||||||
|
]
|
||||||
|
//{"DoEditMoshtari":["Name","GroupName", "Tel", "Address", "CodeMeli", "Tarikh_Tavalod", "Moaref", "Code_Moaref", Moshtari_Code]}
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response($e->getMessage(), 500);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (empty($response['OK'])) {
|
if (empty($response['OK'])) {
|
||||||
return "tahesab api error!!!";
|
return "tahesab api error!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer->moshtari_code = $response['OK'];
|
|
||||||
$customer->save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -104,7 +132,7 @@ class TahesabController extends Controller
|
|||||||
'DBName' => $this->Config('tahesab_db'),
|
'DBName' => $this->Config('tahesab_db'),
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||||
])->post('https://185.252.86.194:8081', [
|
])->post((string)env('TAHESAB'), [
|
||||||
"DoNewSanadBuySaleGOLD" => [
|
"DoNewSanadBuySaleGOLD" => [
|
||||||
1,//Sabte_Kol_Or_Movaghat_1_0
|
1,//Sabte_Kol_Or_Movaghat_1_0
|
||||||
(int)$customer->moshtari_code, //Moshtari_Code
|
(int)$customer->moshtari_code, //Moshtari_Code
|
||||||
@@ -187,7 +215,7 @@ class TahesabController extends Controller
|
|||||||
'DBName' => $this->Config('tahesab_db'),
|
'DBName' => $this->Config('tahesab_db'),
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||||
])->post('https://185.252.86.194:8081', [
|
])->post((string)env('TAHESAB'), [
|
||||||
"DoNewSanadVKHBank" => [
|
"DoNewSanadVKHBank" => [
|
||||||
1,//Sabte_Kol_Or_Movaghat_1_0
|
1,//Sabte_Kol_Or_Movaghat_1_0
|
||||||
$customer->moshtari_code,//Moshtari_Code
|
$customer->moshtari_code,//Moshtari_Code
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\SuperController;
|
|||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Setting;
|
||||||
|
|
||||||
class UserController extends SuperController
|
class UserController extends SuperController
|
||||||
{
|
{
|
||||||
@@ -29,6 +30,9 @@ class UserController extends SuperController
|
|||||||
->findOrFail(auth()->id());
|
->findOrFail(auth()->id());
|
||||||
// $permission = Permission::where('user_type',$user->user_type)->select('rid')->distinct('rid')->get()->pluck('rid')->toArray();
|
// $permission = Permission::where('user_type',$user->user_type)->select('rid')->distinct('rid')->get()->pluck('rid')->toArray();
|
||||||
// $user['permission'] = $permission;
|
// $user['permission'] = $permission;
|
||||||
|
$query = Setting::query();
|
||||||
|
$settings = $query->get();
|
||||||
|
$user->settings= $settings;
|
||||||
return response()->json($user);
|
return response()->json($user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Rooyesh\Wallet\models\Transaction;
|
|||||||
use Rooyesh\Wallet\models\Wallet;
|
use Rooyesh\Wallet\models\Wallet;
|
||||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
use App\Http\Controllers\Admin\TahesabController;
|
use App\Http\Controllers\Admin\TahesabController;
|
||||||
|
use App\Models\Setting;
|
||||||
|
|
||||||
|
|
||||||
class WalletController extends Controller
|
class WalletController extends Controller
|
||||||
@@ -117,9 +118,16 @@ class WalletController extends Controller
|
|||||||
'active' => true
|
'active' => true
|
||||||
], 7, true, $deposit, $gold_block);
|
], 7, true, $deposit, $gold_block);
|
||||||
|
|
||||||
$data['direction'] = 0;
|
if(Setting::where('key', 'send_to_tahesab')->first()->value == "true"){
|
||||||
// $tahesab = new TahesabController();
|
try {
|
||||||
// $tahesab->wallet($data);
|
$data['direction'] = 0;
|
||||||
|
$tahesab = new TahesabController();
|
||||||
|
$tahesab->wallet($data);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
return response($e->getMessage(), 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
||||||
$message = 'کیف پول شما به اندازه ' . number_format(abs($data['value'])) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
$message = 'کیف پول شما به اندازه ' . number_format(abs($data['value'])) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||||
. $data['note']
|
. $data['note']
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Admin\TahesabController;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Cnt;
|
use App\Models\Cnt;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
@@ -160,6 +161,12 @@ class AuthController extends Controller
|
|||||||
$data['active'] = true;
|
$data['active'] = true;
|
||||||
// Create customer
|
// Create customer
|
||||||
$customer = Customer::create($data);
|
$customer = Customer::create($data);
|
||||||
|
|
||||||
|
// $tah = new TahesabController();
|
||||||
|
// return $tah->store([
|
||||||
|
// 'customer_id' => $customer->id,
|
||||||
|
// ]);
|
||||||
|
|
||||||
$message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\n\nورود به نرم افزار:\n{$this->Config('app_url')}";
|
$message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\n\nورود به نرم افزار:\n{$this->Config('app_url')}";
|
||||||
$this->Send($data['mobile'], $message);
|
$this->Send($data['mobile'], $message);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use Rooyesh\Wallet\models\Transaction;
|
|||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use App\Http\Controllers\Admin\TahesabController;
|
||||||
|
|
||||||
|
|
||||||
//use App\Models\Price;
|
//use App\Models\Price;
|
||||||
@@ -102,6 +103,9 @@ class CustomerController extends Controller
|
|||||||
$updateData['credential_id'] = $request->credential_id;
|
$updateData['credential_id'] = $request->credential_id;
|
||||||
}
|
}
|
||||||
$customer->update($updateData);
|
$customer->update($updateData);
|
||||||
|
|
||||||
|
// $tah = new TahesabController();
|
||||||
|
// $tah->store(["customer_id" => $customer->id]);
|
||||||
if (!$customer->is_legal) {
|
if (!$customer->is_legal) {
|
||||||
|
|
||||||
$response = Http::withHeaders([
|
$response = Http::withHeaders([
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use Rooyesh\Wallet\models\Wallet;
|
|||||||
use App\Models\TransactionsAdmin;
|
use App\Models\TransactionsAdmin;
|
||||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Models\Setting;
|
||||||
|
|
||||||
|
|
||||||
class SingleOrderController extends Controller
|
class SingleOrderController extends Controller
|
||||||
@@ -36,8 +37,19 @@ class SingleOrderController extends Controller
|
|||||||
$data['all_price'] = $latestPrice;
|
$data['all_price'] = $latestPrice;
|
||||||
$data['price'] = $latestPrice->price;
|
$data['price'] = $latestPrice->price;
|
||||||
$data['price_id'] = $latestPrice->id;
|
$data['price_id'] = $latestPrice->id;
|
||||||
$data['difference'] = config('fee.cash');
|
// $data['difference'] = config('fee.cash');
|
||||||
$data['service_charge_percentage'] = config('fee.service_charge_percentage');
|
$data['difference'] = Setting::where('key', 'fee_cash')->first()->value;
|
||||||
|
// $data['service_charge_percentage'] = config('fee.service_charge_percentage');
|
||||||
|
$data['service_charge_percentage'] = Setting::where('key', 'fee_service_charge_percentage')->first()->value;
|
||||||
|
|
||||||
|
$fee_free = Setting::where('key', 'fee_free')->where('is_active', true)->value('value');
|
||||||
|
|
||||||
|
if($fee_free && $this->feeFree($data['customer_id'], $fee_free)){
|
||||||
|
$data['service_charge_percentage'] = 0;
|
||||||
|
$data['difference'] = 0;
|
||||||
|
$data['fee_free'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$data['pay_at'] = (new \DateTime())->format('Y-m-d H:i:s');
|
$data['pay_at'] = (new \DateTime())->format('Y-m-d H:i:s');
|
||||||
} else if (auth('user')->id()) {//admin
|
} else if (auth('user')->id()) {//admin
|
||||||
$data['service_charge_percentage'] = 0;
|
$data['service_charge_percentage'] = 0;
|
||||||
@@ -62,6 +74,13 @@ class SingleOrderController extends Controller
|
|||||||
$data['difference'] = $data['fee'] = $data['product']['cash_fee_buy'];
|
$data['difference'] = $data['fee'] = $data['product']['cash_fee_buy'];
|
||||||
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
|
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
|
||||||
|
|
||||||
|
$fee_free = Setting::where('key', 'fee_free')->where('is_active', true)->value('value');
|
||||||
|
|
||||||
|
if($fee_free && $this->feeFree($data['customer_id'], $fee_free)){
|
||||||
|
$data['service_charge_percentage'] = 0;
|
||||||
|
$data['difference'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the method is cash
|
// Check if the method is cash
|
||||||
if ($data['method'] == "cash") {
|
if ($data['method'] == "cash") {
|
||||||
$response['buy'] = $this->processBuyTransactionProduct($data, $wallet, $wallet_interface);
|
$response['buy'] = $this->processBuyTransactionProduct($data, $wallet, $wallet_interface);
|
||||||
@@ -76,6 +95,12 @@ class SingleOrderController extends Controller
|
|||||||
$data['difference'] = $data['fee'] = $data['product']['cash_fee_sell'];
|
$data['difference'] = $data['fee'] = $data['product']['cash_fee_sell'];
|
||||||
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
|
$data['total_price_original'] = $data['product']['amount'] * ($data['price_original'] ?? 0);
|
||||||
|
|
||||||
|
$fee_free = Setting::where('key', 'fee_free')->where('is_active', true)->value('value');
|
||||||
|
|
||||||
|
if($fee_free && $this->feeFree($data['customer_id'], $fee_free)){
|
||||||
|
$data['service_charge_percentage'] = 0;
|
||||||
|
$data['difference'] = 0;
|
||||||
|
}
|
||||||
// Check if the method is cash
|
// Check if the method is cash
|
||||||
if ($data['method'] == "cash") {
|
if ($data['method'] == "cash") {
|
||||||
$response['sell'] = $this->processSellTransactionProduct($data, $wallet, $wallet_interface);
|
$response['sell'] = $this->processSellTransactionProduct($data, $wallet, $wallet_interface);
|
||||||
@@ -87,7 +112,7 @@ class SingleOrderController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
// Calculate total price and fee for non-product (gold) transaction
|
// Calculate total price and fee for non-product (gold) transaction
|
||||||
$data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0);
|
$data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0);
|
||||||
$data['total_fee'] = $data['amount'] * $data['difference'];
|
$data['total_fee'] = $data['amount'] * ($data['difference'] == 0 ? 1 : $data['difference']);
|
||||||
$data['product'] = Product::find(13);
|
$data['product'] = Product::find(13);
|
||||||
// Check if the user wants to buy
|
// Check if the user wants to buy
|
||||||
if ($data['direction'] == 1) {
|
if ($data['direction'] == 1) {
|
||||||
@@ -103,13 +128,14 @@ class SingleOrderController extends Controller
|
|||||||
$response['sell'] = $this->processSellTransaction($data, $wallet, $wallet_interface);
|
$response['sell'] = $this->processSellTransaction($data, $wallet, $wallet_interface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// try {
|
if(Setting::where('key', 'send_to_tahesab')->first()->value == "true"){
|
||||||
// $tahesab = new TahesabController();
|
try {
|
||||||
// $data['tahesab'] = $tahesab->storeTrade($data);
|
$tahesab = new TahesabController();
|
||||||
// }catch (\Exception $e){
|
$data['tahesab'] = $tahesab->storeTrade($data);
|
||||||
// return response($e->getMessage(), 500);
|
}catch (\Exception $e){
|
||||||
// }
|
return response($e->getMessage(), 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
// $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface);
|
// $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface);
|
||||||
$response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);
|
$response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);
|
||||||
return response()->json([$response, $data]);
|
return response()->json([$response, $data]);
|
||||||
@@ -159,7 +185,7 @@ class SingleOrderController extends Controller
|
|||||||
|
|
||||||
private function processBuyTransactionProduct(&$data, $wallet, $wallet_interface)
|
private function processBuyTransactionProduct(&$data, $wallet, $wallet_interface)
|
||||||
{
|
{
|
||||||
|
$data['price'] = $data['product']["price"];
|
||||||
$data['price'] += $data['difference'];
|
$data['price'] += $data['difference'];
|
||||||
$data['amount'] = $data['number'] * $data['product']['amount'];
|
$data['amount'] = $data['number'] * $data['product']['amount'];
|
||||||
$data['total_amount'] = $data['amount']+($data['product']['percent_fee_buy']*$data['amount']);
|
$data['total_amount'] = $data['amount']+($data['product']['percent_fee_buy']*$data['amount']);
|
||||||
@@ -266,6 +292,7 @@ class SingleOrderController extends Controller
|
|||||||
|
|
||||||
private function processSellTransactionProduct(&$data, $wallet, $wallet_interface)
|
private function processSellTransactionProduct(&$data, $wallet, $wallet_interface)
|
||||||
{
|
{
|
||||||
|
$data['price'] = $data['product']["price"];
|
||||||
$data['price'] -= $data['difference'];
|
$data['price'] -= $data['difference'];
|
||||||
$data['amount'] = $data['number'] * $data['product']['amount'];
|
$data['amount'] = $data['number'] * $data['product']['amount'];
|
||||||
$data['total_amount'] = $data['amount']-($data['product']['percent_fee_sell']*$data['amount']) ;
|
$data['total_amount'] = $data['amount']-($data['product']['percent_fee_sell']*$data['amount']) ;
|
||||||
@@ -538,4 +565,13 @@ class SingleOrderController extends Controller
|
|||||||
])->export($records);
|
])->export($records);
|
||||||
return response()->json($records);
|
return response()->json($records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function feeFree($customer_id, $count)
|
||||||
|
{
|
||||||
|
return Order::where('customer_id', $customer_id)
|
||||||
|
->where('type', 2)
|
||||||
|
->where('sts', 2)
|
||||||
|
->where('payment_sts', 4)
|
||||||
|
->count() < (int)$count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Admin\PriceController;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Mail\YourMailableClass;
|
use App\Mail\YourMailableClass;
|
||||||
use App\Models\Cnt;
|
use App\Models\Cnt;
|
||||||
|
use App\Models\Setting;
|
||||||
use App\Models\ConfigStatic;
|
use App\Models\ConfigStatic;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Price;
|
use App\Models\Price;
|
||||||
@@ -18,6 +19,7 @@ use Illuminate\Support\Arr;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Morilog\Jalali\Jalalian;
|
use Morilog\Jalali\Jalalian;
|
||||||
|
use App\Http\Controllers\Admin\ProductController;
|
||||||
|
|
||||||
class ReportController extends Controller
|
class ReportController extends Controller
|
||||||
{
|
{
|
||||||
@@ -43,7 +45,8 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
public function updatePrise()
|
public function updatePrise()
|
||||||
{
|
{
|
||||||
$difference = config('fee.single');
|
// $difference = config('fee.single');
|
||||||
|
$difference = Setting::where('key', 'fee_single')->first()->value;
|
||||||
$lastPrice = Price::latest()->first();
|
$lastPrice = Price::latest()->first();
|
||||||
$PriceTriggers = PriceTrigger::where("is_active", true)->get();
|
$PriceTriggers = PriceTrigger::where("is_active", true)->get();
|
||||||
foreach ($PriceTriggers as $PriceTrigger) {
|
foreach ($PriceTriggers as $PriceTrigger) {
|
||||||
@@ -71,7 +74,8 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
public function upDownPrice()
|
public function upDownPrice()
|
||||||
{
|
{
|
||||||
$difference = config('fee.single');
|
// $difference = config('fee.single');
|
||||||
|
$difference = Setting::where('key', 'fee_single')->first()->value;
|
||||||
$today = Carbon::now()->format("Y-m-d");
|
$today = Carbon::now()->format("Y-m-d");
|
||||||
$prises = Price::where('date_at', $today)->get("price");
|
$prises = Price::where('date_at', $today)->get("price");
|
||||||
|
|
||||||
@@ -119,7 +123,8 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
public function lastPrice()
|
public function lastPrice()
|
||||||
{
|
{
|
||||||
$difference = config('fee.single');
|
// $difference = config('fee.single');
|
||||||
|
$difference = Setting::where('key', 'fee_single')->first()->value;
|
||||||
|
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
@@ -127,9 +132,20 @@ class ReportController extends Controller
|
|||||||
// } catch (\Exception $e) {$tala_ir = 0;}
|
// } catch (\Exception $e) {$tala_ir = 0;}
|
||||||
|
|
||||||
$main_product_id = Cnt::where('key', 'main_product')->first()['value'];
|
$main_product_id = Cnt::where('key', 'main_product')->first()['value'];
|
||||||
|
$refpricer = new ProductController();
|
||||||
|
if ($refpricer->getPrice()) {
|
||||||
|
$ref = true;
|
||||||
|
} else {
|
||||||
|
$ref = false;
|
||||||
|
}
|
||||||
$pr_product = Product::find($main_product_id);
|
$pr_product = Product::find($main_product_id);
|
||||||
|
|
||||||
$priceValue = $pr_product['price'] + $pr_product['price_profit'];//$tala_ir;//4000
|
try {
|
||||||
|
$taban_gohar = Http::timeout(2)->get('https://tabangohar.com/GheymatKhan/prices_in_table.html')->json();
|
||||||
|
$tgn = (int)$taban_gohar['c']*10;
|
||||||
|
}catch (\Exception $e){$tgn = 0;}
|
||||||
|
|
||||||
|
$priceValue = $tgn !== 0 ? $tgn : $pr_product['price'] + $pr_product['price_profit'];//$tala_ir;//4000
|
||||||
$lastPrice = Price::latest()->first();
|
$lastPrice = Price::latest()->first();
|
||||||
if (!$lastPrice || $lastPrice->price != $priceValue and $priceValue > 30000000) {
|
if (!$lastPrice || $lastPrice->price != $priceValue and $priceValue > 30000000) {
|
||||||
$price = new Price();
|
$price = new Price();
|
||||||
@@ -167,7 +183,9 @@ class ReportController extends Controller
|
|||||||
// 'henzagold' => $henzagold_18,
|
// 'henzagold' => $henzagold_18,
|
||||||
// 'Ounce' => $henzagold_ons_gold,
|
// 'Ounce' => $henzagold_ons_gold,
|
||||||
// 'milli' => $milli,
|
// 'milli' => $milli,
|
||||||
'main_product' => $pr_product['price'] + $pr_product['price_profit']
|
'main_product' => $pr_product['price'] + $pr_product['price_profit'],
|
||||||
|
'taban_gohar' => $tgn,
|
||||||
|
'refpricer' => $ref
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ class ValidationMiddleware
|
|||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if($request->acceptsJson()){
|
if($request->acceptsJson()){
|
||||||
|
//convert fa digits to en digits
|
||||||
|
$allData = array_merge($request->all(), $request->query());
|
||||||
|
$converted = $this->fa2en_numbers($allData);
|
||||||
|
$request->merge($converted);
|
||||||
|
|
||||||
$method = $request->getMethod();
|
$method = $request->getMethod();
|
||||||
$path =$request->path();
|
$path =$request->path();
|
||||||
if(preg_match('/[0-9]+$/',$request->path(),$match)) {
|
if(preg_match('/[0-9]+$/',$request->path(),$match)) {
|
||||||
@@ -46,4 +51,16 @@ class ValidationMiddleware
|
|||||||
}
|
}
|
||||||
throw new BadRequestHttpException();
|
throw new BadRequestHttpException();
|
||||||
}
|
}
|
||||||
|
private function fa2en_numbers($input) {
|
||||||
|
if (is_string($input)) {
|
||||||
|
$fa_numbers = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||||
|
$en_numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||||
|
return str_replace($fa_numbers, $en_numbers, $input);
|
||||||
|
} elseif (is_array($input)) {
|
||||||
|
return array_map([$this, __FUNCTION__], $input);
|
||||||
|
} else {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,24 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Rooyesh\Wallet\models\Transaction;
|
||||||
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||||
|
|
||||||
class Setting extends Model
|
class Setting extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory,Selector;
|
||||||
protected $table = 'settings';
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'key',
|
'key',
|
||||||
'title_fa',
|
'title_fa',
|
||||||
|
'is_active',
|
||||||
|
'description',
|
||||||
'value',
|
'value',
|
||||||
'value_json'
|
'value_json'
|
||||||
];
|
];
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'value_json'=>'array'
|
'value_json'=>'array',
|
||||||
|
'is_active'=>'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -12,9 +12,7 @@
|
|||||||
"laravel/framework": "^8.75",
|
"laravel/framework": "^8.75",
|
||||||
"laravel/sanctum": "^2.11",
|
"laravel/sanctum": "^2.11",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"tymon/jwt-auth": "^1.0",
|
"tymon/jwt-auth": "^1.0"},
|
||||||
"morilog/jalali": "^3.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"facade/ignition": "^2.5",
|
"facade/ignition": "^2.5",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
|||||||
+10
-10
@@ -15,14 +15,24 @@ use App\Http\Controllers\Customer\PriceTriggerController;
|
|||||||
use App\Http\Controllers\Finance\FinanceController;
|
use App\Http\Controllers\Finance\FinanceController;
|
||||||
use App\Http\Controllers\Admin\ProductController;
|
use App\Http\Controllers\Admin\ProductController;
|
||||||
use App\Http\Controllers\Admin\TahesabController;
|
use App\Http\Controllers\Admin\TahesabController;
|
||||||
|
<<<<<<< HEAD
|
||||||
use App\Http\Controllers\Admin\FileController;
|
use App\Http\Controllers\Admin\FileController;
|
||||||
use App\Http\Controllers\Site\OfferCodesController;
|
use App\Http\Controllers\Site\OfferCodesController;
|
||||||
|
=======
|
||||||
|
use App\Http\Controllers\Admin\SettingsController;
|
||||||
|
|
||||||
|
>>>>>>> a0a788ce53f1b3dff84bd16f3b7db585071bc159
|
||||||
|
|
||||||
Route::middleware('auth:user')->group(function (){
|
Route::middleware('auth:user')->group(function (){
|
||||||
Route::middleware('validation')->group(function (){
|
Route::middleware('validation')->group(function (){
|
||||||
Route::get('/p', function () {
|
Route::get('/p', function () {
|
||||||
return Http::get('https://pricing.liman.gold/pricingApi', [])->json();
|
return Http::get('https://pricing.liman.gold/pricingApi', [])->json();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//settigs
|
||||||
|
Route::get('get_settings',[SettingsController::class, 'index']);
|
||||||
|
Route::post('get_settings',[SettingsController::class, 'edit']);
|
||||||
|
|
||||||
//------------balence
|
//------------balence
|
||||||
Route::post('getBalance', [DashboardController::class, 'getBalance']);
|
Route::post('getBalance', [DashboardController::class, 'getBalance']);
|
||||||
//------------PriceTrigger
|
//------------PriceTrigger
|
||||||
@@ -135,15 +145,5 @@ Route::middleware('auth:user')->group(function (){
|
|||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//file
|
|
||||||
Route::post('/file',[FileController::class, 'store']);
|
|
||||||
|
|
||||||
//Offer codes
|
|
||||||
Route::post('/offer_code/table',[OfferCodesController::class, 'table']);
|
|
||||||
Route::post('/offer_code',[OfferCodesController::class, 'store']);
|
|
||||||
Route::resource('/offer_code',OfferCodesController::class);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user