更新删掉转售商品
This commit is contained in:
parent
797863acd9
commit
b55658764c
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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.');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user