weigang 5 years ago
parent
commit
e55bcc86b2
  1. 12
      app/Service/v3/Implementations/BadgeService.php
  2. 6
      app/Service/v3/Implementations/GoodsInventoryService.php

12
app/Service/v3/Implementations/BadgeService.php

@ -77,7 +77,7 @@ class BadgeService implements BadgeServiceInterface
public function allByUserOrder($userId) public function allByUserOrder($userId)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_user';
$redisHName = 'badge:user';
$redisHKey = 'user_id_'.$userId; $redisHKey = 'user_id_'.$userId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)
@ -115,7 +115,7 @@ class BadgeService implements BadgeServiceInterface
public function allByStoreOrder($storeId) public function allByStoreOrder($storeId)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_store';
$redisHName = 'badge:store';
$redisHKey = 'store_id_'.$storeId; $redisHKey = 'store_id_'.$storeId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)
@ -153,7 +153,7 @@ class BadgeService implements BadgeServiceInterface
public function sAddUserOrder($badge, $userId, $globalOrderId) public function sAddUserOrder($badge, $userId, $globalOrderId)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_user';
$redisHName = 'badge:user';
$redisHKey = 'user_id_'.$userId; $redisHKey = 'user_id_'.$userId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)
@ -185,7 +185,7 @@ class BadgeService implements BadgeServiceInterface
public function sAddStoreOrder($badge, $storeId, $globalOrderId) public function sAddStoreOrder($badge, $storeId, $globalOrderId)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_store';
$redisHName = 'badge:store';
$redisHKey = 'store_id_'.$storeId; $redisHKey = 'store_id_'.$storeId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)
@ -217,7 +217,7 @@ class BadgeService implements BadgeServiceInterface
public function clearUserOrder($userId, $badge = 'all', $globalOrderId = '') public function clearUserOrder($userId, $badge = 'all', $globalOrderId = '')
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_user';
$redisHName = 'badge:user';
$redisHKey = 'user_id_'.$userId; $redisHKey = 'user_id_'.$userId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)
@ -253,7 +253,7 @@ class BadgeService implements BadgeServiceInterface
public function clearStoreOrder($storeId, $badge = 'all', $globalOrderId = '') public function clearStoreOrder($storeId, $badge = 'all', $globalOrderId = '')
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$redisHName = 'badge_store';
$redisHName = 'badge:store';
$redisHKey = 'store_id_'.$storeId; $redisHKey = 'store_id_'.$storeId;
// 取出当前用户的key的badge(key=>value json串) // 取出当前用户的key的badge(key=>value json串)

6
app/Service/v3/Implementations/GoodsInventoryService.php

@ -15,7 +15,7 @@ class GoodsInventoryService implements GoodsInventoryServiceInterface
public function doSold($activityType, $goodsId, $num) public function doSold($activityType, $goodsId, $num)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$hName = 'goods_inventory_sold_' . $activityType;
$hName = 'goods:inventory_sold_' . $activityType;
$hKey = 'goods_id_' . $goodsId; $hKey = 'goods_id_' . $goodsId;
$redis->hIncrBy($hName, $hKey, $num); $redis->hIncrBy($hName, $hKey, $num);
@ -27,7 +27,7 @@ class GoodsInventoryService implements GoodsInventoryServiceInterface
public function undoSold($activityType, $goodsId, $num) public function undoSold($activityType, $goodsId, $num)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$hName = 'goods_inventory_sold_' . $activityType;
$hName = 'goods:inventory_sold_' . $activityType;
$hKey = 'goods_id_' . $goodsId; $hKey = 'goods_id_' . $goodsId;
$redis->hIncrBy($hName, $hKey, -1*$num); $redis->hIncrBy($hName, $hKey, -1*$num);
@ -39,7 +39,7 @@ class GoodsInventoryService implements GoodsInventoryServiceInterface
public function getSold($activityType, $goodsId) public function getSold($activityType, $goodsId)
{ {
$redis = ApplicationContext::getContainer()->get(Redis::class); $redis = ApplicationContext::getContainer()->get(Redis::class);
$hName = 'goods_inventory_sold_' . $activityType;
$hName = 'goods:inventory_sold_' . $activityType;
$hKey = 'goods_id_' . $goodsId; $hKey = 'goods_id_' . $goodsId;
return $redis->hGet($hName, $hKey); return $redis->hGet($hName, $hKey);

Loading…
Cancel
Save