feat : refund

This commit is contained in:
2025-02-21 19:10:58 +08:00
parent ab0aff0d7f
commit 6754d2969e
17 changed files with 694 additions and 127 deletions

View File

@@ -17,6 +17,7 @@ use App\Exception\ErrException;
use App\Extend\DateUtil;
use App\Model\Order;
use App\Model\OrderGood;
use App\Service\ServiceTrait\Common\OrderChangeStatusTrait;
use Exception;
use Hyperf\Amqp\Producer;
use Hyperf\Context\ApplicationContext;
@@ -26,6 +27,8 @@ use Psr\Container\NotFoundExceptionInterface;
class PlaceOrderService extends BaseOrderService
{
use OrderChangeStatusTrait;
public function __construct()
{
parent::__construct();
@@ -61,28 +64,17 @@ class PlaceOrderService extends BaseOrderService
$this->placeOrder();
// 加入取消延迟队列
$this->joinCancelDelayQueue();
$this->joinCancelDelayQueue(
$this->orderId,
OrderCode::ORDER_TYPE_GOOD,
(int)$this->configCache->getConfigValue(ConfigCode::ORDER_CANCEL_TIME_KEY) * DateUtil::MINUTE * DateUtil::MS
);
$this->sendStockMq($this->orderId,OrderCode::WAIT_PAY);
return $this->return->success('success',$this->orderRes);
}
/**
* 加入取消队列
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function joinCancelDelayQueue(): void
{
$message = new CancelOrderProducer([
'order_id' => $this->orderId,
'type' => OrderCode::ORDER_TYPE_GOOD
]);
$message->setDelayMs((int)$this->configCache->getConfigValue(ConfigCode::ORDER_CANCEL_TIME_KEY) * DateUtil::MINUTE * DateUtil::MS);
$producer = ApplicationContext::getContainer()->get(Producer::class);
$producer->produce($message);
}
/**
* @return void
* @throws ContainerExceptionInterface