feat : refund
This commit is contained in:
63
app/Service/ServiceTrait/Common/OrderChangeStatusTrait.php
Normal file
63
app/Service/ServiceTrait/Common/OrderChangeStatusTrait.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\ServiceTrait\Common;
|
||||
|
||||
use App\Amqp\Producer\CancelOrderProducer;
|
||||
use App\Amqp\Producer\RefundOrderProducer;
|
||||
use App\Cache\Redis\Common\ConfigCache;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Constants\ConfigCode;
|
||||
use App\Extend\DateUtil;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
trait OrderChangeStatusTrait
|
||||
{
|
||||
/**
|
||||
* @var ConfigCache $configCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected ConfigCache $configCache;
|
||||
|
||||
/**
|
||||
* 加入取消队列
|
||||
* @param int $orderId
|
||||
* @param int $type
|
||||
* @param int $millisecond
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function joinCancelDelayQueue(int $orderId,int $type,int $millisecond): void
|
||||
{
|
||||
$message = new CancelOrderProducer([
|
||||
'order_id' => $orderId,
|
||||
'type' => $type
|
||||
]);
|
||||
$message->setDelayMs($millisecond);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $orderId
|
||||
* @param int $type
|
||||
* @param float|int $amount amount = 0 全部 amount > 0 部分
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function joinRefundQueue(int $orderId, int $type, float|int $amount = 0): void
|
||||
{
|
||||
$message = new RefundOrderProducer([
|
||||
'order_id' => $orderId,
|
||||
'type' => $type,
|
||||
'amount' => $amount,
|
||||
]);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user