問(wèn)題:秒殺商品有確認(rèn)庫(kù)存,但是購(gòu)買(mǎi)的時(shí)候提示商品已售空
修復(fù)方法:
一、 如果未二開(kāi),源碼可直接將附件中的文件替換到項(xiàng)目中;
二、修改代碼
1. 修改代碼
注意:這里是將這幾個(gè)方法都改了,注意方法名, 我這里移動(dòng)了方法的位置
路徑:
app\common\model\store\product\Product.php
代碼:
if (empty($value)) return [];
return !is_array($value) ? explode(',', $value) : $value;
2. 修改代碼:
路徑:
app\common\repositories\store\ProductRepository.php
代碼:
foreach ($settleParams['attrValue'] as $v) {
Queue::push(SetSeckillStockCacheJob::class, ['res'=> $res, 'attrValue' => $v]);
}
3. 修改代碼
路徑:
app\common\repositories\store\ProductRepository.php
代碼:
foreach ($attrValue_ as $item) {
Queue::push(SetSeckillStockCacheJob::class,['res'=>$res,'attrValue'=> $item]);
}
4. 修改代碼
路徑:
app\common\repositories\store\ProductRepository.php
代碼:
$cache_keys = array_map(function($item) use($attrValue) {
$item[] = $attrValue['unique'];
$item = implode('_',$item);
return $item;
},$cache_key_times);
$cache_array = array_combine($cache_keys, array_fill(0, count($cache_keys), $attrValue['stock']));
$cache_key_unique = array_merge($cache_key_unique,$cache_keys);