From 59878461cc13515000bae84b84fd2ca4890f1fe1 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 8 Sep 2023 15:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A7=94=E6=89=98=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/community/Community.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controller/api/community/Community.php b/app/controller/api/community/Community.php index 4486dea8..4ac8b7c9 100644 --- a/app/controller/api/community/Community.php +++ b/app/controller/api/community/Community.php @@ -654,7 +654,7 @@ class Community extends BaseController */ public function checkEntrust($id) { - $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->find(); + $communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->where('mer_status', 0)->find(); if (!$communityInfo) { return app('json')->fail('委托商品不存在'); } @@ -694,6 +694,23 @@ class Community extends BaseController return app('json')->fail('审核委托商品失败'); } } + // 删除 + if ($status == 3) { + Db::startTrans(); + try { + $list = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select(); + foreach($list as $prod) { + Db::name('store_product')->where('product_id', $prod['product_id'])->inc('stock', $prod['number'])->update(); + Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update(); + } + Db::name('entrust')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]); + Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => -2, 'is_del' => 1]); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + return app('json')->fail('删除委托商品失败'); + } + } return app('json')->success('审核操作成功'); }