修改商户获取商品的接口逻辑

This commit is contained in:
liu 2024-03-16 11:36:14 +08:00
parent 9a0b08b32a
commit c026b087d6

View File

@ -2572,18 +2572,37 @@ class StoreOrderRepository extends BaseRepository
}
public function dealGoodsList($where,$money)
public function dealDataDiv($where,$_where)
{
$data = ProductAttrValue::alias('a')
->leftJoin('store_product p', 'a.product_id = p.product_id')
->where($where)
->where($_where)
->field('a.value_id,a.product_id,a.mer_id,a.sku,a.stock,a.image,a.price,
a.svip_price,
a.unique,p.store_name,p.store_info');
a.unique,p.store_name,p.store_info')
->limit(50)->select();
return $data;
}
$list = $data->limit(100)->select();
$count = $data->count();
public function dealGoodsList($where,$money)
{
//拆分2种方式 大于该金额的 50 +小于该金额的50条
$greaterWhere = function ($query) use ($money) {
$query->where('a.price', '>', $money);
};
$maxData = $this->dealDataDiv($where,$greaterWhere);
$lessWhere = function ($query) use ($money) {
$query->where('a.price', '<=', $money);
};
$mixData = $this->dealDataDiv($where,$lessWhere);
$list = array_merge($maxData->toArray(), $mixData->toArray());
$count = count($list);
$minMoney = bcsub($money, 600, 2);
if ($count) {
@ -2597,7 +2616,7 @@ class StoreOrderRepository extends BaseRepository
return app('json')->fail('不在区间情况中');
}
}
$deal = $this->dealArr($list->toArray());
$deal = $this->dealArr($list);
//平均2个左右 0 1 2 阶梯往上查寻找
$end = array($this->findNearestPriceProduct($deal[$range]['items'], $minMoney));//17jiji
if ($range == 0 && $deal[$range]['quantity'] = 1) { //第一个并且只有一条数据