From 81feb225eb90f5d559c34e98cb8e2f11438c3375 Mon Sep 17 00:00:00 2001 From: mzeros Date: Sun, 5 Jan 2025 18:08:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(channel):=20=E4=BF=AE=E5=A4=8D=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E5=95=86=E5=93=81=E8=A7=84=E5=88=99=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 - 添加对空规则的处理,避免保存空值- 优化 gid_rule、rule 和 order_limit_rule 的处理逻辑 - 提高代码可读性和稳定性 --- app/channel/controller/ChannelProduct.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/channel/controller/ChannelProduct.php b/app/channel/controller/ChannelProduct.php index 3f0267b..a896e59 100644 --- a/app/channel/controller/ChannelProduct.php +++ b/app/channel/controller/ChannelProduct.php @@ -343,10 +343,13 @@ class ChannelProduct extends Controller $gid_rule[$v] = $input; } } + if ($gid_rule) { $gid_rule = json_encode($gid_rule); } + + $order_limit_rule = array(); foreach ($this->cash as $k => $v) { $input = input('cash_order_limit_' . $k); @@ -371,9 +374,13 @@ class ChannelProduct extends Controller $update['percent_type'] = $percent_type; if ($rule) { $update['rule'] = $rule; + }else{ + $update['rule'] = null; } if ($gid_rule) { $update['gid_rule'] = $gid_rule; + }else{ + $update['gid_rule'] = null; } $gid = input('gid'); if ($gid) { @@ -382,6 +389,8 @@ class ChannelProduct extends Controller if ($order_limit_rule) { $update['order_limit_rule'] = $order_limit_rule; + }else{ + $update['order_limit_rule'] = null; } $order_limit = input('order_limit'); $update['order_limit'] = $order_limit;