Merge branch 'dev' of https://gitea.lihaink.cn/mkm/shop-new into dev
This commit is contained in:
commit
70ef71d1a1
@ -2629,7 +2629,8 @@ class StoreOrderRepository extends BaseRepository
|
||||
if ($money < $end[0]['price']) {
|
||||
$list = $end;
|
||||
} else {
|
||||
$list = array_merge($end, $end);//满足2条数据
|
||||
$end[0]['num'] =2;
|
||||
$list = $end;//满足2条数据
|
||||
}
|
||||
} else {
|
||||
//在1 或者 2区间
|
||||
@ -2637,7 +2638,9 @@ class StoreOrderRepository extends BaseRepository
|
||||
$list = $this->findNearestPriceProductDg($deal, $minMoney, $range, $newArray, $money, $money);
|
||||
|
||||
}
|
||||
$count = count($list);
|
||||
|
||||
// $count = array_sum(array_column($list, 'num')); //重复拿
|
||||
$count = count($list);//计算数量的
|
||||
return compact('count', 'list');
|
||||
|
||||
} else {
|
||||
@ -2647,6 +2650,26 @@ class StoreOrderRepository extends BaseRepository
|
||||
|
||||
|
||||
|
||||
//合并数组相同value_id
|
||||
public function mergeSameValueIds($array) {
|
||||
$result = [];
|
||||
foreach ($array as $item) {
|
||||
// 如果$result中已经有相同的value_id,则增加num并移除旧数组中的项
|
||||
if (isset($result[$item['value_id']])) {
|
||||
$result[$item['value_id']]['num'] += $item['num'];
|
||||
} else {
|
||||
// 否则,直接添加到结果数组中
|
||||
$result[$item['value_id']] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// 将键值数组转换回索引数组
|
||||
return array_values($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getRangeNumber($price, $ranges = [[0, 100], [100, 500], [500, PHP_INT_MAX]])
|
||||
{
|
||||
@ -2708,6 +2731,9 @@ class StoreOrderRepository extends BaseRepository
|
||||
$nearestProduct = $product;
|
||||
}
|
||||
}
|
||||
if($nearestProduct){
|
||||
$nearestProduct['num']=1;
|
||||
}
|
||||
|
||||
return $nearestProduct;
|
||||
}
|
||||
@ -2730,7 +2756,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
$nearestProduct = $product;
|
||||
}
|
||||
}
|
||||
|
||||
$nearestProduct['num'] = 1;
|
||||
$newArray[] = $nearestProduct;
|
||||
$remarkId = $nearestProduct['value_id'];
|
||||
$totalPrice = array_sum(array_column($newArray, 'price')); //本次全部的价格之和
|
||||
|
@ -34,7 +34,7 @@ class SpuRepository extends BaseRepository
|
||||
{
|
||||
public $dao;
|
||||
public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id';
|
||||
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,P.sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,P.stock,mer_svip_status';
|
||||
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,P.sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,P.stock,mer_svip_status,P.wholesale_price';
|
||||
public function __construct(SpuDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
|
Loading…
x
Reference in New Issue
Block a user