|
|
|
|
@ -410,4 +410,18 @@ class Orders extends SoftDeletesModel
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getOnlineRefundableRecharge($amount)
|
|
|
|
|
{
|
|
|
|
|
//todo:根据交易状态是否可以退款、以及多次退款金额是否足够进行更精准筛选
|
|
|
|
|
//but:出问题的几率微乎其微可以忽略
|
|
|
|
|
$recharge = Recharge::where("order_id", $this->id)
|
|
|
|
|
->whereNotNull("paid_at")
|
|
|
|
|
->whereIn("payment", ["weixin", "alipay"])
|
|
|
|
|
->where("money",">=",$amount)
|
|
|
|
|
->doesntHave("refunds")
|
|
|
|
|
->orderBy("id", "desc")
|
|
|
|
|
->first();
|
|
|
|
|
return $recharge;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|