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
|
||||
{
|
||||
|
||||
public function storeTrade($input = null)
|
||||
public function storeTrade($data)
|
||||
{
|
||||
if ($input instanceof \Illuminate\Http\Request) {
|
||||
$data = $input->all();
|
||||
} elseif (is_array($input)) {
|
||||
$data = $input;
|
||||
} else {
|
||||
$data = request()->all();
|
||||
}
|
||||
// if ($input instanceof \Illuminate\Http\Request) {
|
||||
// $data = $input->all();
|
||||
// } elseif (is_array($input)) {
|
||||
// $data = $input;
|
||||
// } else {
|
||||
// $data = request()->all();
|
||||
// }
|
||||
// return ($data);
|
||||
|
||||
if (!isset($data['customer_id']) || !isset($data['product']['amount'])) {
|
||||
@@ -53,6 +53,7 @@ class TahesabController extends Controller
|
||||
"customer_id" => $customer->id,
|
||||
"desc" => $data['direction'] == 1 ? "خرید آبشده" : "فروش آبشده",
|
||||
"amount" => $amount,
|
||||
"order_id" => $data['order']['id'] ?? null,
|
||||
"date" => $data['pay_at'],
|
||||
"type" => $data['product']['metal_id'] == 1 ? "طلا" : "نقره",
|
||||
"created_at" => Carbon::now(),
|
||||
@@ -88,18 +89,20 @@ class TahesabController extends Controller
|
||||
$data['product']['metal_id'] == 1 ? 0 : 2, //Jens_Felez
|
||||
(string)Verta::instance($data['pay_at']),
|
||||
]
|
||||
]);
|
||||
])->json();
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
if ($response['OK']) {
|
||||
$tahesab->sh_factor = $response['Sh_factor'];
|
||||
$tahesab->tahesab_id = $response['OK'];
|
||||
$tahesab->factor_number = $response['Factor_Number'];
|
||||
$tahesab->tah_id = $response['ID'];
|
||||
$tahesab->res = $response;
|
||||
$tahesab->data = $data;
|
||||
$tahesab->save();
|
||||
Tahesab::where('id', $tahesab->id)->update([
|
||||
"sh_factor" => $response['Sh_factor'],
|
||||
"tahesab_id" => $response['OK'],
|
||||
"factor_number" => $response['Factor_Number'],
|
||||
"tah_id" => $response['ID'],
|
||||
"data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||
"res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||
]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
return false;
|
||||
@@ -139,6 +142,7 @@ class TahesabController extends Controller
|
||||
"customer_id" => $customer->id,
|
||||
"desc" => $data['direction'] == 0 ? "شارژ حساب" : "برداشت از حساب",
|
||||
"amount" => $data['value'],
|
||||
"type" => "ريال",
|
||||
"date" => Carbon::now(),
|
||||
"created_at" => Carbon::now(),
|
||||
]);
|
||||
@@ -177,6 +181,9 @@ class TahesabController extends Controller
|
||||
Tahesab::where('id', $tahesab->id)->update([
|
||||
"sh_factor" => $response['Sh_factor'],
|
||||
"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),
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user