修改商品上架的错误
This commit is contained in:
parent
a78270cc20
commit
031f66da22
@ -17,6 +17,8 @@ use app\common\model\BaseModel;
|
||||
class CloudProduct extends BaseModel
|
||||
{
|
||||
|
||||
const CacheKey = 'CloudMerchantSpu_%s';
|
||||
|
||||
public static function tablePk(): string
|
||||
{
|
||||
return 'product_id';
|
||||
|
@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\common\repositories\store\product;
|
||||
|
||||
use app\common\model\store\product\CloudProduct;
|
||||
use app\common\repositories\store\coupon\StoreCouponProductRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\StoreActivityRepository;
|
||||
@ -179,7 +180,7 @@ class SpuRepository extends BaseRepository
|
||||
}
|
||||
|
||||
if ($rand) {
|
||||
$dataKey = 'CloudMerchantSpu_' . $where['mer_id'];
|
||||
$dataKey = sprintf(CloudProduct::CacheKey, $where['mer_id']);
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
$exists = $RedisCacheService->exists($dataKey);
|
||||
if (!$exists) {
|
||||
@ -224,8 +225,8 @@ class SpuRepository extends BaseRepository
|
||||
*/
|
||||
public function getSpuFromCache($merId, $page): array
|
||||
{
|
||||
$dataKey = 'CloudMerchantSpu_' . $merId;
|
||||
$takenKey = 'CloudMerchantSpu_' . $merId . '_page_'. $page;
|
||||
$dataKey = sprintf(CloudProduct::CacheKey, $merId);
|
||||
$takenKey = $dataKey . '_page_'. $page;
|
||||
$remainKey = 'CloudMerchantSpuRemain_' . $merId;
|
||||
/** @var RedisCacheService $RedisCacheService */
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
|
@ -13,6 +13,9 @@ class CloudProduct
|
||||
|
||||
public function handle($event)
|
||||
{
|
||||
if (!$event['source_mer_id']) {
|
||||
return true;
|
||||
}
|
||||
$sourceMerchant = Merchant::getDB()->where('mer_id', $event['source_mer_id'])->field('category_id,type_id')->find();
|
||||
if ($sourceMerchant['type_id'] != Merchant::TypeStore) {
|
||||
return true;
|
||||
@ -36,12 +39,13 @@ class CloudProduct
|
||||
$repo->update((int)$productId, $values);
|
||||
}
|
||||
}
|
||||
$cacheKey = sprintf(\app\common\model\store\product\CloudProduct::CacheKey, $cloudMerchant);
|
||||
$RedisCacheService = app()->make(RedisCacheService::class);
|
||||
foreach ($event['product_id'] as $productId) {
|
||||
if ($event['status'] == 1) {
|
||||
$RedisCacheService->SADD('CloudMerchantSpu_' . $cloudMerchant, $productId);
|
||||
$RedisCacheService->SADD($cacheKey, $productId);
|
||||
} else {
|
||||
$RedisCacheService->SREM('CloudMerchantSpu_' . $cloudMerchant, $productId);
|
||||
$RedisCacheService->SREM($cacheKey, $productId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user