From dd1033aee9fef8dc3686b831ad40c0fa0261012f Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Mon, 9 Dec 2024 11:40:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/store_product/StoreProductLogic.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 06eb1d96b..8fa601ab1 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -288,7 +288,11 @@ class StoreProductLogic extends BaseLogic */ public static function detail($params): array { - $data = StoreProduct::where('id', $params['id'])->findOrEmpty()->toArray(); + $query = StoreProduct::where('id', $params['id']); + if (isset($params['is_show'])) { + $query->where('is_show', $params['is_show']); + } + $data = $query->findOrEmpty()->toArray(); if(empty($data)){ throw new BusinessException('商品不存在'); } From a7a1c0bff4ca3be6e68904823ba5e42594a3cae2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 9 Dec 2024 17:04:35 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=20DemoLogic?= =?UTF-8?q?=20=E7=B1=BB=E5=92=8C=20test=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 DemoLogic 类,继承自 BaseLogic - 实现 test 方法,用于同步不同群体的价格信息 - 支持门店供货、种养殖、酒店、一条龙、厨师、商户会员和食堂会员等群体的价格更新 --- app/api/logic/DemoLogic.php | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/api/logic/DemoLogic.php diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php new file mode 100644 index 000000000..6e8fb6791 --- /dev/null +++ b/app/api/logic/DemoLogic.php @@ -0,0 +1,62 @@ +select(); + foreach ($arr as $k => $v) { + //门店供货、商户、零售 + StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]); + //种养殖 + $find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find(); + if ($find) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->update(['price' => bcadd($v['price8'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]); + } + //酒店 + $find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find(); + if ($find2) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]); + } + //一条龙 + $find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find(); + if ($find3) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->update(['price' => bcadd($v['price5'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 18, 'price' => bcadd($v['price5'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv5'], 100), 100, 2)]); + } + //厨师 + $find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 1)->find(); + if ($find4) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 1)->update(['price' => bcadd($v['price7'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 1, 'price' => bcadd($v['price7'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv7'], 100), 100, 2)]); + } + //商户会员 + $find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 19)->find(); + if ($find4) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 19)->update(['price' => bcadd($v['price2'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]); + } + //食堂会员 + + $find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find(); + if ($find4) { + Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]); + } else { + Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 20, 'price' => bcadd($v['price4'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv4'], 100), 100, 2)]); + } + } + } +} From e3cff35799164fe2ae7a24e23b2ca180decf1daf Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Mon, 9 Dec 2024 17:18:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E5=95=86=E5=93=81=E5=88=86=E7=BB=84=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/CartList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index d2d6fd7b5..6339325e6 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -76,6 +76,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists $find = StoreProduct::where(['id' => $item['product_id']]) ->field($field) ->find(); + $find = StoreProductGroupPrice::resetProductPrice($find, $user_ship); if ($find) { if ($off_activity == 1) { $this->activity_price = bcadd(bcmul($find['cost'], $item['cart_num'], 2), $this->activity_price, 2); @@ -93,7 +94,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); } } - $list = StoreProductGroupPrice::resetProductsPrice($list, $user_ship); return $list; } From 942a04f514921203d6886276bfe49da18c908d98 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Mon, 9 Dec 2024 17:37:48 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=95=86=E5=93=81=E5=88=86=E7=BB=84=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 12 +++++++++--- app/admin/logic/store_product/StoreProductLogic.php | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 2a505cc47..3b6290cb6 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -64,10 +64,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } } $is_warehouse=$this->request->get('is_warehouse',0); + $userShip = 0; + if (!empty($this->params['user_id'])) { + $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); + } $list = StoreProduct::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($is_warehouse) { + ->select()->each(function ($item) use($is_warehouse, $userShip) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -111,10 +115,12 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $item['stock'] = bcadd($nums, $stock); } + if ($userShip == 4) { + $item['price'] = $item['cost']; + } return $item; })?->toArray(); - if (!empty($this->params['user_id'])) { - $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); + if ($userShip > 0 && $userShip != 4) { $list = StoreProductGroupPrice::resetProductsPrice($list, $userShip); } return $list; diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 8fa601ab1..8852b7a0d 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -11,9 +11,11 @@ use app\common\model\store_branch_product_exchange\StoreBranchProductExchange; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\model\store_product_cate\StoreProductCate; +use app\common\model\store_product_group_price\StoreProductGroupPrice; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; use app\common\model\system_store_storage\SystemStoreStorage; +use app\common\model\user\User; use Illuminate\Support\Facades\Log; use support\exception\BusinessException; use think\facade\Db; @@ -304,6 +306,14 @@ class StoreProductLogic extends BaseLogic $data['cate_arr'][]=$data['cate_id']; } $data['unit_name']=StoreProductUnit::where('id', $data['unit'])->value('name'); + if (!empty($params['user_id'])) { + $userShip = User::where('id', $params['user_id'])->value('user_ship'); + if ($userShip == 4) { + $data['price'] = $data['cost']; + } else { + $data = StoreProductGroupPrice::resetProductPrice($data, $userShip); + } + } return $data; } From b28e68966fbd299ec805216a03f75a36789b93a2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 10 Dec 2024 14:33:27 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat(=E5=BA=93=E5=AD=98):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=B1=BB=E5=9E=8B=E4=B8=89=E7=9A=84=E8=B4=9F=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 WorkbenchController 中增加对类型三的处理逻辑 - 新增 WarehouseProductStoregeTwoLists 类实现仓库商品存储列表查询 - 支持按仓库 ID 和商品 ID 搜索 - 可对库存数量进行排序 - 实现负库存列表导出功能 --- app/admin/controller/WorkbenchController.php | 4 + .../WarehouseProductStoregeTwoLists.php | 135 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 app/admin/lists/warehouse_product_storege/WarehouseProductStoregeTwoLists.php diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index d739c8436..444ab1160 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -17,6 +17,7 @@ namespace app\admin\controller; use app\admin\lists\statistics\StoreProductLists; use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupLists; use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupMonthLists; +use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeTwoLists; use app\admin\logic\statistic\ProductStatisticLogic; use app\admin\logic\statistic\TradeStatisticLogic; use app\admin\logic\statistic\UserStatisticLogic; @@ -322,6 +323,9 @@ class WorkbenchController extends BaseAdminController public function negative_inventory() { $parmas = $this->request->get(); + if($parmas['type'] == 3){ + return $this->dataLists(new WarehouseProductStoregeTwoLists()); + } $data = WarehouseLogic::negativeInventory($parmas); return $this->data($data); } diff --git a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeTwoLists.php b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeTwoLists.php new file mode 100644 index 000000000..e14ea5daf --- /dev/null +++ b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeTwoLists.php @@ -0,0 +1,135 @@ + ['warehouse_id', 'product_id'], + ]; + } + /** + * @notes 设置支持排序字段 + * @return string[] + * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名']; + */ + public function setSortFields(): array + { + return ['nums' => 'nums']; + } + /** + * @notes 设置默认排序 + * @return string[] + */ + public function setDefaultOrder(): array + { + return ['id' => 'desc', 'nums' => 'desc',]; + } + + /** + * @notes 获取仓库商品存储列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/08/01 10:22 + */ + public function lists(): array + { + if ($this->request->get('store_name')) { + $ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; + } else { + return []; + } + } + $this->searchWhere[] = ['nums', '<=', 0]; + return WarehouseProductStorege::where($this->searchWhere) + ->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order($this->sortOrder) + ->select()->each(function ($item) { + $item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name'); + $find = StoreProduct::where('id', $item->product_id)->withTrashed()->find(); + $item->store_name = $find->store_name; + $item->image = $find->image; + $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); + $item['stock'] = $item['nums']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取仓库商品存储数量 + * @return int + * @author admin + * @date 2024/08/01 10:22 + */ + public function count(): int + { + return WarehouseProductStorege::where($this->searchWhere)->count(); + + } + + /** + * @notes 导出文件名 + * @return string + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + + return '仓库商品列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + + $data = [ + 'warehouse_name' => '仓库名称', + 'product_id' => '商品id', + 'store_name' => '商品名称', + 'unit_name' => '单位', + 'stock' => '数量', + ]; + + return $data; + } +}