diff --git a/app/controller/api/community/Community.php b/app/controller/api/community/Community.php index 7018cae2..3f2c8995 100644 --- a/app/controller/api/community/Community.php +++ b/app/controller/api/community/Community.php @@ -503,4 +503,43 @@ class Community extends BaseController return app('json')->success(compact('count', 'list')); } + /** + * 删除转售商品 + * @return mixed + */ + public function deleteResale($id) + { + $communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->find(); + if (!$communityInfo) { + app('json')->fail('转售商品不存在'); + } + // 启动事务 + Db::startTrans(); + try { + Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->update(['is_del' => 1]); + Db::name('resale')->where('community_id', $id)->update(['is_del' => 1]); + $list = Db::name('resale')->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::commit(); + } catch (\Exception $e) { + // 回滚事务 + Db::rollback(); + return app('json')->fail('删除转售商品失败'); + } + return app('json')->success('删除成功'); + } + + /** + * 审核转售商品结算价 + * @return mixed + */ + public function checkResale($id) + { + + } + } diff --git a/route/api.php b/route/api.php index b64b2039..3722287d 100644 --- a/route/api.php +++ b/route/api.php @@ -369,7 +369,7 @@ Route::group('api/', function () { Route::get('resale/:id', 'Community/resaleDetail'); Route::post('resale/edit/:id', 'Community/editResale'); Route::post('resale/delete/:id', 'Community/deleteResale'); - Route::post('resale/check/:id', 'Community/checkesale'); + Route::post('resale/check/:id', 'Community/checkResale'); })->prefix('api.community.');