From 19d9ca9734c3b9eab56869cd323d9d4ebce074e3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 9 Jan 2025 12:03:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(store-product):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E4=BB=B7=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 - 在 StoreProductLists 类中添加 order_type 参数处理 - 当 order_type 为 2 时,查询并应用活动价 - 更新商品列表,显示活动价和相应标识 --- app/admin/lists/store_product/StoreProductLists.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 3bfcd58e7..c864e6e15 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -66,6 +66,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } } $is_warehouse=$this->request->get('is_warehouse',0); + $order_type=$this->request->get('order_type',0); $userShip = 0; if (!empty($this->params['user_id'])) { $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); @@ -87,7 +88,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $list = $query->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($is_warehouse, $userShip) { + ->select()->each(function ($item) use($is_warehouse, $userShip,$order_type) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -142,6 +143,15 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa }else{ $item['status_msg']='下架|不常用|是否有替换'; } + if ($order_type == 2) { + $price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); + if($price>0){ + $item['price'] = $price; + $item['store_name'] = $item['store_name'].'|活动价'; + } + } + + return $item; })?->toArray(); // if ($userShip > 0 && $userShip != 4) { From 945097566e4c6c3b6c0839e0e3b4d3eb24efd0dc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 9 Jan 2025 13:47:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(api):=20=E4=BF=AE=E5=A4=8D=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E6=9B=B4=E6=96=B0=E5=92=8C=E5=BA=93=E5=AD=98=E6=89=A3?= =?UTF-8?q?=E5=87=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新产品价格信息,包括供货价、成本价、会员价和零售价 - 添加活动价更新逻辑,针对特定客户群体 - 实现库存扣减功能,根据购物车数量更新门店库存 - 优化代码格式和结构,提高可读性 --- app/api/logic/DemoLogic.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 15574a51b..83e01edb2 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -3,6 +3,7 @@ namespace app\api\logic; use app\common\logic\BaseLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_group_price\StoreProductGroupPrice; use think\facade\Db; @@ -14,8 +15,8 @@ class DemoLogic extends BaseLogic $arr = Db::name('ceshi_two')->select(); foreach ($arr as $k => $v) { //门店供货、商户、零售 - $res=Db::name('store_product')->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)]); - if($res){ + $res = Db::name('store_product')->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)]); + if ($res) { Db::name('ceshi_two')->where('product_id', $v['product_id'])->update(['status' => 1]); } //种养殖 @@ -67,6 +68,23 @@ class DemoLogic extends BaseLogic } else { StoreProductGroupPrice::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)]); } + //活动价 + $find42 = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', 42)->find(); + if ($find42) { + $find42->save(['price' => bcadd($v['price4'], 0, 2)]); + } else { + StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]); + } + } + } + + public static function test2($store_id, $srr) + { + foreach ($srr as $k => $v) { + $find = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $v['product_id'])->find(); + $find->stock = bcsub($find->stock, $v['cart_num'], 2); + $find->save(); + SqlChannelLog('StoreBranchProduct', $find['id'], $v['cart_num'], -1, Request()->url(), 1); } } }