feat: stock

This commit is contained in:
2025-02-10 18:03:58 +08:00
parent c91b7c96d8
commit 387c01f91b
6 changed files with 253 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace App\Service\ServiceTrait\Api;
use App\Amqp\Producer\OrderGoodStockProducer;
use App\Cache\Redis\Api\ApiRedisKey;
use App\Cache\Redis\Api\SiteCache;
use App\Cache\Redis\RedisCache;
@@ -17,6 +18,8 @@ use App\Constants\ApiCode;
use App\Constants\Common\GoodCode;
use App\Constants\ConfigCode;
use App\Exception\ErrException;
use Hyperf\Amqp\Producer;
use Hyperf\Context\ApplicationContext;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -260,4 +263,21 @@ trait OrderTrait
$this->orderRes['total_price'] = bcadd($this->orderRes['total_good_price'],$this->orderRes['total_sundry_price'],2);
$this->orderRes['actual_price'] = bcadd($this->orderRes['good_after_discount_price'],$this->orderRes['sundry_after_discount_price'],2);
}
/**
* @param int $orderId
* @param int $orderStatus
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function sendStockMq(int $orderId,int $orderStatus): void
{
$message = new OrderGoodStockProducer([
'order_id' => $orderId,
'type' => $orderStatus
]);
$producer = ApplicationContext::getContainer()->get(Producer::class);
$producer->produce($message);
}
}