6
0
Fork 0

退款单号

release
李静 2021-12-20 13:49:38 +08:00
parent 92f441b75b
commit 08eb0f11d9
2 changed files with 19 additions and 0 deletions

View File

@ -19,10 +19,27 @@ class OrderRefundTask extends Model
* @var array
*/
protected $fillable = [
'sn',
'order_id',
'after_sale_id',
'amount',
'status',
'failed_reason',
];
/**
* 只查询待退款的任务
*/
public function scopePending($query)
{
return $query->where('status', static::STATUS_PENDING);
}
/**
* 此退款任务所属的订单
*/
public function order()
{
return $this->belongsTo(Order::class);
}
}

View File

@ -15,6 +15,7 @@ class CreateOrderRefundTasksTable extends Migration
{
Schema::create('order_refund_tasks', function (Blueprint $table) {
$table->id();
$table->string('sn')->comment('退款单号');
$table->unsignedBigInteger('order_id')->comment('订单ID');
$table->unsignedBigInteger('after_sale_id')->nullable()->comment('售后ID');
$table->unsignedBigInteger('amount')->comment('退款金额');
@ -22,6 +23,7 @@ class CreateOrderRefundTasksTable extends Migration
$table->string('failed_reason')->nullable()->comment('失败原因');
$table->timestamps();
$table->unique('sn');
$table->unique(['order_id', 'after_sale_id']);
});
}