You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\GoodsInventoryServiceInterface;use Hyperf\Redis\Redis;use Hyperf\Utils\ApplicationContext;
class GoodsInventoryService implements GoodsInventoryServiceInterface{
/** * @inheritDoc */ public function doSold($activityType, $goodsId, $num) { $redis = ApplicationContext::getContainer()->get(Redis::class); $hName = 'goods:inventory_sold_' . $activityType; $hKey = 'goods_id_' . $goodsId;
$redis->hIncrBy($hName, $hKey, $num); }
/** * @inheritDoc */ public function undoSold($activityType, $goodsId, $num) { $redis = ApplicationContext::getContainer()->get(Redis::class); $hName = 'goods:inventory_sold_' . $activityType; $hKey = 'goods_id_' . $goodsId;
$redis->hIncrBy($hName, $hKey, -1*$num); }
/** * @inheritDoc */ public function getSold($activityType, $goodsId) { $redis = ApplicationContext::getContainer()->get(Redis::class); $hName = 'goods:inventory_sold_' . $activityType; $hKey = 'goods_id_' . $goodsId;
return $redis->hGet($hName, $hKey); }}
|