From e924c14f8a74d4eac310f3a962d8fe790e453343 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 8 Jan 2025 17:41:27 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(admin):=20=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E9=80=80=E6=AC=BE=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 StoreOrderCartInfoLists 类中添加了 refund_num 和 refund_amount 字段的查询 - 在返回的数据中增加了退款数量和退款金额的展示 --- .../lists/store_order_cart_info/StoreOrderCartInfoLists.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index e2441d5e6..b604a7f79 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -51,7 +51,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI public function lists(): array { return StoreOrderCartInfo::where($this->searchWhere) - ->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) + ->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time,refund_num,refund_amount')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->withTrashed()->find(); $item['nickname']='无'; @@ -136,6 +136,8 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'refund_num' => '退款数量', + 'refund_amount' => '退款金额', 'nickname' => '用户', 'mobile' => '手机', 'create_time' => '时间', From caab5cca6facfde0249b6279cf069f04bf2be388 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 8 Jan 2025 17:56:14 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(admin):=20=E6=B7=BB=E5=8A=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E6=95=B0=E9=87=8F=E5=92=8C=E9=80=80=E6=AC=BE=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 StoreOrderCartInfoTwoLists 类中添加了 refund_num 和 refund_amount 字段 - 更新了查询条件,使其包含这两个新字段 - 在输出数据中增加了退款数量和退款金额的相关信息 --- .../store_order_cart_info/StoreOrderCartInfoTwoLists.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php index e17ba9e03..c6e8de399 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoTwoLists.php @@ -70,9 +70,9 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear $this->searchWhere[] = ['status', '>=', 0]; $query = StoreOrderCartInfo::where($this->searchWhere); if ($is_group == 1) { - $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group(['store_id', 'product_id']); + $query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num,SUM(refund_num) as refund_num,SUM(refund_amount) as refund_amount')->group(['store_id', 'product_id']); } else { - $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid'); + $query->field('store_id,product_id,price,total_price,cart_num,create_time,uid,oid,refund_num,refund_amount'); } return $query->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) use($is_group,$export){ @@ -167,6 +167,8 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'refund_num' => '退款数量', + 'refund_amount' => '退款金额', ]; } else { $data = [ @@ -180,6 +182,8 @@ class StoreOrderCartInfoTwoLists extends BaseAdminDataLists implements ListsSear 'cart_num' => '数量', 'price' => '单价', 'total_price' => '总价', + 'refund_num' => '退款数量', + 'refund_amount' => '退款金额', 'nickname' => '用户', 'mobile' => '手机', 'create_time' => '时间', 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 3/5] =?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 4/5] =?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); } } } From bbdd0081a0d7786c12d366aeb828fe3414d0855a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 9 Jan 2025 14:24:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?perf(StoreFinanceFlowLogic):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=94=A8=E6=88=B7=E4=BD=99=E9=A2=9D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将用户余额更新逻辑从先查询再更新的方式改为直接更新 - 这种方式减少了数据库查询次数,提高了代码执行效率 --- app/common/logic/StoreFinanceFlowLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index e5c3d4c87..d989ba95c 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -139,7 +139,7 @@ class StoreFinanceFlowLogic extends BaseLogic $find = User::where('id', $uid)->find(); $capitalFlowDao = new CapitalFlowLogic($find); $capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money); - $find->inc('now_money', $money)->update(); + User::where('id', $uid)->inc('now_money', $money)->update(); } /** * 核销后更新门店余额