From 829a250047018e41d1cf6a95ec5adc11b1689731 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 28 Feb 2024 14:19:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/product/ProductAttrValueDao.php | 3 + app/common/dao/store/product/SpuDao.php | 3 +- .../system/financial/FinancialRecordDao.php | 94 +++++++++++++++++++ app/controller/api/store/product/StoreSpu.php | 3 +- 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 app/common/dao/system/financial/FinancialRecordDao.php diff --git a/app/common/dao/store/product/ProductAttrValueDao.php b/app/common/dao/store/product/ProductAttrValueDao.php index d9b431bc..d51cf3fa 100644 --- a/app/common/dao/store/product/ProductAttrValueDao.php +++ b/app/common/dao/store/product/ProductAttrValueDao.php @@ -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'])){ diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index 1b27b61b..ca9ed84e 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -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]; diff --git a/app/common/dao/system/financial/FinancialRecordDao.php b/app/common/dao/system/financial/FinancialRecordDao.php new file mode 100644 index 00000000..1eb37c6a --- /dev/null +++ b/app/common/dao/system/financial/FinancialRecordDao.php @@ -0,0 +1,94 @@ +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); + } + } + +} diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 4f895b9c..10d932d6 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -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;