修改商品匹配的错误

This commit is contained in:
luofei 2024-03-21 17:40:03 +08:00
parent f9caf19c5e
commit e25473971a

View File

@ -2680,8 +2680,12 @@ class StoreOrderRepository extends BaseRepository
$range = $this->getRangeNumber($money); //减少一般的区间 $range = $this->getRangeNumber($money); //减少一般的区间
$deal = $this->dealArr($list); $deal = $this->dealArr($list);
//平均2个左右 0 1 2 阶梯往上查寻找 //平均2个左右 0 1 2 阶梯往上查寻找
$deal = [];
[$products, $minNum] = $this->getRange($deal, $range); [$products, $minNum] = $this->getRange($deal, $range);
$list = $this->findNearestPriceProduct($products, $money, $minNum); $list = [];
if (!empty($products)) {
$list = $this->findNearestPriceProduct($products, $money, $minNum);
}
$count = count($list);//计算数量的 $count = count($list);//计算数量的
return compact('count', 'list','merInfo'); return compact('count', 'list','merInfo');
@ -2692,6 +2696,9 @@ class StoreOrderRepository extends BaseRepository
public function getRange($array, $range) public function getRange($array, $range)
{ {
if (!isset($array[$range])) {
return [[], 0];
}
if (!empty($array[$range]['items'])) { if (!empty($array[$range]['items'])) {
return [$array[$range]['items'], $array[$range]['minNum']]; return [$array[$range]['items'], $array[$range]['minNum']];
} else { } else {