53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class DrawMoney extends BaseModel
|
|
{
|
|
//
|
|
public $table='draw_moneys';
|
|
public function getDrawTypeNameAttribute()
|
|
{
|
|
$draw_type = config('adconfig.draw_type');
|
|
return $draw_type[$this->draw_type];
|
|
}
|
|
|
|
public function getStatusNameAttribute()
|
|
{
|
|
$draw_type = config('adconfig.draw_money_status');
|
|
return $draw_type[$this->status];
|
|
}
|
|
|
|
public function merchants()
|
|
{
|
|
return $this->belongsTo('App\Models\Merchant', 'merchant_id', 'id');
|
|
}
|
|
|
|
public static function getDrawMoney($where, $field = 'draw_money')
|
|
{
|
|
|
|
$model = self::getSearchModel(new self(), $where);
|
|
return $model->sum($field);
|
|
}
|
|
|
|
//某个商户提现结算总额
|
|
public static function merchantDrawMoney($merchant_id)
|
|
{
|
|
return self::where(['merchant_id' => $merchant_id])->whereIn('status', [0, 2, 1])->sum('draw_money');
|
|
}
|
|
|
|
public static function merchantDrawMoneyOk($merchant_id)
|
|
{
|
|
return self::where(['merchant_id' => $merchant_id])->whereIn('status', [1])->sum('draw_money');
|
|
}
|
|
|
|
//提现状态
|
|
public static function drawStatus()
|
|
{
|
|
return config('adconfig.draw_money_status');
|
|
}
|
|
}
|