feat: stock
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user