新增委托商品删除

This commit is contained in:
yaooo 2023-09-08 15:08:17 +08:00
parent 2e2a31df0d
commit 59878461cc

View File

@ -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('审核操作成功');
}