mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 11:41:27 +08:00
去除退款延迟
This commit is contained in:
parent
122b4adfa8
commit
bb38d90d53
@ -53,13 +53,6 @@ class RefundTask extends Task
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款存在延迟,给取消退款调解机会
|
||||
*/
|
||||
if (isset($itemInfo['deadline']) && $itemInfo['deadline'] > time()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$this->db->begin();
|
||||
|
@ -103,9 +103,17 @@ class Refund extends Service
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
$itemInfo = [
|
||||
'refund' => [
|
||||
'id' => $refund->id,
|
||||
'order_id' => $refund->order_id,
|
||||
'trade_id' => $refund->trade_id,
|
||||
],
|
||||
];
|
||||
|
||||
$task->item_id = $refund->id;
|
||||
$task->item_type = TaskModel::TYPE_REFUND;
|
||||
$task->item_info = ['refund' => $refund->toArray()];
|
||||
$task->item_info = $itemInfo;
|
||||
$task->priority = TaskModel::PRIORITY_HIGH;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Services\Logic\Refund;
|
||||
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Models\Task;
|
||||
use App\Models\Task as TaskModel;
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Services\Logic\OrderTrait;
|
||||
@ -19,6 +18,8 @@ class RefundCreate extends Service
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$logger = $this->getLogger('refund');
|
||||
|
||||
$post = $this->request->getPost();
|
||||
|
||||
$order = $this->checkOrderBySn($post['order_sn']);
|
||||
@ -47,6 +48,10 @@ class RefundCreate extends Service
|
||||
|
||||
$validator->checkAmount($order->amount, $refundAmount);
|
||||
|
||||
try {
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$refund = new RefundModel();
|
||||
|
||||
$refund->subject = $order->subject;
|
||||
@ -58,20 +63,18 @@ class RefundCreate extends Service
|
||||
$refund->status = RefundModel::STATUS_APPROVED;
|
||||
$refund->review_note = '退款周期内无条件审批';
|
||||
|
||||
$refund->create();
|
||||
if ($refund->create() === false) {
|
||||
throw new \RuntimeException('Create Refund Failed');
|
||||
}
|
||||
|
||||
$task = new TaskModel();
|
||||
|
||||
/**
|
||||
* 设定延迟,给取消退款一个调解机会
|
||||
*/
|
||||
$itemInfo = [
|
||||
'refund' => [
|
||||
'id' => $refund->id,
|
||||
'order_id' => $refund->order_id,
|
||||
'trade_id' => $refund->trade_id,
|
||||
],
|
||||
'deadline' => time() + 3600 * 24 * 2,
|
||||
];
|
||||
|
||||
$task->item_id = $refund->id;
|
||||
@ -80,9 +83,26 @@ class RefundCreate extends Service
|
||||
$task->priority = TaskModel::PRIORITY_MIDDLE;
|
||||
$task->status = TaskModel::STATUS_PENDING;
|
||||
|
||||
$task->create();
|
||||
if ($task->create() === false) {
|
||||
throw new \RuntimeException('Create Refund Task Failed');
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return $refund;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->db->rollback();
|
||||
|
||||
$logger->error('Create Refund Exception ' . kg_json_encode([
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'message' => $e->getMessage(),
|
||||
]));
|
||||
|
||||
throw new \RuntimeException('sys.trans_rollback');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user