Files
boursecu_server/app/Models/Order.php
T
mohmdsdgandCursor d12b38a1e8 fix(montzar): persist local order before provider cover and record success or failure
Create the Elif order first (pending colleague), then submit to Liman so failed quote or wallet attempts stay visible instead of leaving orphan provider trades.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 22:14:36 +03:30

86 lines
2.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Rooyesh\Wallet\models\Transaction;
class Order extends Model
{
use HasFactory,Selector;
protected $fillable = [
'customer_id',
'product_id',
'sts',
'direction',
'amount',//میزان طلا
'price',//قیمت هر گرم طلا برای مشتری
'total_price',//قیمت کل برای مشتری
'price_original',//قیمت هر گرم طلا بدون سود
'total_price_liman',//قیمت هر گرم طلا بدون سود
'total_price_original',//قیمت کل بدون سود
'fee',//سود هر گرم
'total_fee',//سود کل
'fee_source',//settings|product|app+product|none
'fee_source_key',//sell_fee|buy_fee|cash_fee_sell|...
'fee_source_label',
'fee_breakdown',//فاکتور اقلام سود (JSON)
'service_charge_percentage',//درصد کارمزد
'service_charge',//میزان کارمزد
'service_charge_price',//مبلغ کارمزد به ریال
'fee_asset',//سمت کسر کارمزد: gold یا rial
'payment_sts',
'payment_amount',//میزان پرداخت شده
'payment_remind',//میزان مبلغ باقی مانده
'type',//نوع مشتری
'pay_at',//تاریخ انجام معامله در پنل ادمین
'price_id',//
'provider_id',
'total_price_montzar',
'description',
];
protected $casts = [
'fee_breakdown' => 'array',
];
static $STS = [
1 => 'باز',
2 => 'موفق',
3 => 'ناموفق',
4 => 'در انتظار همکار',
];
static $DIRECTION = [
1 => 'خرید',
2 => 'فروش'
];
static $PAYMENT_STS=[
1 => 'در انتظار پرداخت',
2 => 'در حال پرداخت',
3 => 'partially_paid',
4 => 'پرداخت شده',
5 => 'partially_refunded',
6 => 'مرجوعی',
7 => 'پرداخت نشده',
];
static $TYPE = [
1=>'همکار',
2=>'خانگی'
];
public function customer(){
return $this->belongsTo(Customer::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
public function transactions(){
return $this->hasMany(Transaction::class);
}
}