调整商品列表搜索

This commit is contained in:
luofei 2024-02-28 14:19:08 +08:00
parent 10919fb275
commit 829a250047
4 changed files with 101 additions and 2 deletions

View File

@ -40,6 +40,9 @@ class ProductAttrValueDao extends BaseDao
public function add($data,$isType)
{
foreach ($data as &$item) {
$item['profit_rate'] = bcdiv(bcsub($item['price'], $item['procure_price'], 2), $item['price'], 2) * 100;
}
if ($isType == 2) {
foreach ($data as $datum) {
if (!isset($datum['cdkey'])){

View File

@ -201,10 +201,11 @@ class SpuDao extends BaseDao
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
})
->when(isset($where['deduction_rate']) && $where['deduction_rate'] !== '',function($query)use($where){
$maxRate = $where['deduction_rate'] == 25 ? 100 : $where['deduction_rate'] + 5;
$productIds = ProductAttrValue::when(isset($where['mer_id']) && $where['mer_id'] !== '', function($query) use ($where) {
$query->where('mer_id', $where['mer_id']);
})->where('profit_rate', '>=', $where['deduction_rate'])
->where('profit_rate', '<', ($where['deduction_rate'] + 5))
->where('profit_rate', '<', $maxRate)
->column('product_id');
if (empty($productIds)) {
$productIds = [0];

View File

@ -0,0 +1,94 @@
<?php
namespace app\common\dao\system\financial;
use app\common\dao\BaseDao;
use app\common\model\system\supply\FinancialRecord;
use app\common\repositories\system\merchant\FinancialRecordRepository;
class FinancialRecordDao extends BaseDao
{
public $order;
public $user;
public $index = 0;
public $financeSn;
public $list = [];
protected function getModel(): string
{
return FinancialRecord::class;
}
/**
* 平台出账财务流水
* @param $number
* @param $financialType
* @param $merId
*/
public function platformOut($number, $financialType, $merId = 0)
{
$this->setData($number, $financialType, 0, 2, $merId);
}
/**
* 平台入账财务流水
* @param $number
* @param $financialType
* @param $merId
*/
public function platformIn($number, $financialType, $merId = 0)
{
$this->setData($number, $financialType, 1, 2, $merId);
}
/**
* 公共入账财务流水
* @param $number
* @param $financialType
* @param $merId
*/
public function publicOut($number, $financialType, $merId = '')
{
$this->setData($number, $financialType, 0, 1, $merId);
}
/**
* 公共入账财务流水
* @param $number
* @param $financialType
* @param $merId
*/
public function publicIn($number, $financialType, $merId = '')
{
$this->setData($number, $financialType, 1, 1, $merId);
}
public function setData($number, $financialType, $pm, $type = 2, $merId = '')
{
if (empty($this->financeSn)) {
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
$this->financeSn = $financialRecordRepository->getSn();
}
$this->list[] = [
'order_id' => $this->order['order_id'],
'order_sn' => $this->order['order_sn'],
'user_info' => $this->user['nickname'],
'user_id' => $this->user['uid'],
'financial_type' => $financialType,
'financial_pm' => $pm,
'type' => $type,
'number' => $number,
'mer_id' => $merId !== '' ? $merId : $this->order->mer_id,
'financial_record_sn' => $this->financeSn . ($this->index++)
];
}
public function save()
{
if (count($this->list) > 0) {
(new FinancialRecord())->insertAll($this->list);
}
}
}

View File

@ -60,6 +60,7 @@ class StoreSpu extends BaseController
'mer_id',
'filter_params',
'mer_type_id',
'sys_labels',
'deduction_rate'
]);
$where['is_gift_bag'] = 0;
@ -81,7 +82,7 @@ class StoreSpu extends BaseController
{
[$page, $limit] = $this->getPage();
$where = $this->request->params([
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate'
]);
if ($where['action']) unset($where['product_type']);
$where['mer_id'] = $id;