Files
boursecu_server/app/Models/Order.php
T

82 lines
2.4 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|fee_single|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',//
];
protected $casts = [
'fee_breakdown' => 'array',
];
static $STS = [
1 => 'باز',
2 => 'موفق',
3 => 'ناموفق'
];
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);
}
}