NASER close orders when hamkar is closed, fix tahesab issues, fix singleorder issues
This commit is contained in:
@@ -17,15 +17,15 @@ use Hekmatinasser\Verta\Verta;
|
|||||||
class TahesabController extends Controller
|
class TahesabController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function storeTrade($input = null)
|
public function storeTrade($data)
|
||||||
{
|
{
|
||||||
if ($input instanceof \Illuminate\Http\Request) {
|
// if ($input instanceof \Illuminate\Http\Request) {
|
||||||
$data = $input->all();
|
// $data = $input->all();
|
||||||
} elseif (is_array($input)) {
|
// } elseif (is_array($input)) {
|
||||||
$data = $input;
|
// $data = $input;
|
||||||
} else {
|
// } else {
|
||||||
$data = request()->all();
|
// $data = request()->all();
|
||||||
}
|
// }
|
||||||
// return ($data);
|
// return ($data);
|
||||||
|
|
||||||
if (!isset($data['customer_id']) || !isset($data['product']['amount'])) {
|
if (!isset($data['customer_id']) || !isset($data['product']['amount'])) {
|
||||||
@@ -53,6 +53,7 @@ class TahesabController extends Controller
|
|||||||
"customer_id" => $customer->id,
|
"customer_id" => $customer->id,
|
||||||
"desc" => $data['direction'] == 1 ? "خرید آبشده" : "فروش آبشده",
|
"desc" => $data['direction'] == 1 ? "خرید آبشده" : "فروش آبشده",
|
||||||
"amount" => $amount,
|
"amount" => $amount,
|
||||||
|
"order_id" => $data['order']['id'] ?? null,
|
||||||
"date" => $data['pay_at'],
|
"date" => $data['pay_at'],
|
||||||
"type" => $data['product']['metal_id'] == 1 ? "طلا" : "نقره",
|
"type" => $data['product']['metal_id'] == 1 ? "طلا" : "نقره",
|
||||||
"created_at" => Carbon::now(),
|
"created_at" => Carbon::now(),
|
||||||
@@ -88,18 +89,20 @@ class TahesabController extends Controller
|
|||||||
$data['product']['metal_id'] == 1 ? 0 : 2, //Jens_Felez
|
$data['product']['metal_id'] == 1 ? 0 : 2, //Jens_Felez
|
||||||
(string)Verta::instance($data['pay_at']),
|
(string)Verta::instance($data['pay_at']),
|
||||||
]
|
]
|
||||||
]);
|
])->json();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
if ($response['OK']) {
|
if ($response['OK']) {
|
||||||
$tahesab->sh_factor = $response['Sh_factor'];
|
Tahesab::where('id', $tahesab->id)->update([
|
||||||
$tahesab->tahesab_id = $response['OK'];
|
"sh_factor" => $response['Sh_factor'],
|
||||||
$tahesab->factor_number = $response['Factor_Number'];
|
"tahesab_id" => $response['OK'],
|
||||||
$tahesab->tah_id = $response['ID'];
|
"factor_number" => $response['Factor_Number'],
|
||||||
$tahesab->res = $response;
|
"tah_id" => $response['ID'],
|
||||||
$tahesab->data = $data;
|
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||||
$tahesab->save();
|
"res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||||
|
]);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -139,6 +142,7 @@ class TahesabController extends Controller
|
|||||||
"customer_id" => $customer->id,
|
"customer_id" => $customer->id,
|
||||||
"desc" => $data['direction'] == 0 ? "شارژ حساب" : "برداشت از حساب",
|
"desc" => $data['direction'] == 0 ? "شارژ حساب" : "برداشت از حساب",
|
||||||
"amount" => $data['value'],
|
"amount" => $data['value'],
|
||||||
|
"type" => "ريال",
|
||||||
"date" => Carbon::now(),
|
"date" => Carbon::now(),
|
||||||
"created_at" => Carbon::now(),
|
"created_at" => Carbon::now(),
|
||||||
]);
|
]);
|
||||||
@@ -177,6 +181,9 @@ class TahesabController extends Controller
|
|||||||
Tahesab::where('id', $tahesab->id)->update([
|
Tahesab::where('id', $tahesab->id)->update([
|
||||||
"sh_factor" => $response['Sh_factor'],
|
"sh_factor" => $response['Sh_factor'],
|
||||||
"tahesab_id" => $response['OK'],
|
"tahesab_id" => $response['OK'],
|
||||||
|
"tah_id" => $response['ID'],
|
||||||
|
"factor_number" => $response['Factor_Number'],
|
||||||
|
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||||
"res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
"res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ class SingleOrderController extends Controller
|
|||||||
{
|
{
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
$goldir = Cnt::where('key', 'goldir_closed')->first();
|
||||||
|
if(isset($goldir) && $goldir['value'] == "true"){
|
||||||
|
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||||
|
}
|
||||||
|
|
||||||
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
|
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
|
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
|
||||||
@@ -157,7 +162,7 @@ class SingleOrderController extends Controller
|
|||||||
'start_at' => now(),
|
'start_at' => now(),
|
||||||
], 1, true, false);
|
], 1, true, false);
|
||||||
$response['1'] = 2;
|
$response['1'] = 2;
|
||||||
//send to liman
|
//send to Goldir
|
||||||
$this->sendGoldir($data);
|
$this->sendGoldir($data);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
@@ -268,7 +273,7 @@ class SingleOrderController extends Controller
|
|||||||
'order_id' => $order->id
|
'order_id' => $order->id
|
||||||
], 2, false, true);
|
], 2, false, true);
|
||||||
|
|
||||||
//send to liman
|
//send to Goldir
|
||||||
$this->sendGoldir($data);
|
$this->sendGoldir($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -441,8 +446,8 @@ class SingleOrderController extends Controller
|
|||||||
{
|
{
|
||||||
if ($this->Config('send_to_goldir') == "true") {
|
if ($this->Config('send_to_goldir') == "true") {
|
||||||
|
|
||||||
$liman_diff = Cnt::where('key', 'goldir_diff')->value('value');
|
// $liman_diff = Cnt::where('key', 'goldir_diff')->value('value');
|
||||||
$liman_price = Cnt::where('key', 'goldir_price')->value('value');
|
// $liman_price = Cnt::where('key', 'goldir_price')->value('value');
|
||||||
$mazaneh = ($data['direction'] == 1) ? Cnt::where('key', 'goldir_truly_buy_mazaneh')->value('value') : Cnt::where('key', 'goldir_truly_sell_mazaneh')->value('value');
|
$mazaneh = ($data['direction'] == 1) ? Cnt::where('key', 'goldir_truly_buy_mazaneh')->value('value') : Cnt::where('key', 'goldir_truly_sell_mazaneh')->value('value');
|
||||||
$cash = Cnt::where('key', 'goldir_price')->value('value') * $data['amount'];
|
$cash = Cnt::where('key', 'goldir_price')->value('value') * $data['amount'];
|
||||||
|
|
||||||
@@ -476,11 +481,11 @@ class SingleOrderController extends Controller
|
|||||||
throw new UnprocessableEntityHttpException('سفارشات توسط ارائه دهنده بسته شده است.');
|
throw new UnprocessableEntityHttpException('سفارشات توسط ارائه دهنده بسته شده است.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['provider_id'] = $response[1]['id'];
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
// $data['total_price_goldir'] = ($data['direction'] == 1) ? ($liman_price+$liman_diff) : ($liman_price-$liman_diff) ;
|
// $data['total_price_goldir'] = ($data['direction'] == 1) ? ($liman_price+$liman_diff) : ($liman_price-$liman_diff) ;
|
||||||
$data['provider_id'] = $response[1]['id'];
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeBackUp(Request $request)
|
public function storeBackUp(Request $request)
|
||||||
|
|||||||
Reference in New Issue
Block a user