新增委托商品审核
This commit is contained in:
parent
e3296e297f
commit
ac09055d1a
@ -549,7 +549,7 @@ class Community extends BaseController
|
|||||||
}
|
}
|
||||||
$status = $this->request->param('status');
|
$status = $this->request->param('status');
|
||||||
if (!$status) {
|
if (!$status) {
|
||||||
app('json')->fail('请设置审核状态');
|
return app('json')->fail('请设置审核状态');
|
||||||
}
|
}
|
||||||
if ($status == 1) {
|
if ($status == 1) {
|
||||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]);
|
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]);
|
||||||
@ -629,4 +629,42 @@ class Community extends BaseController
|
|||||||
$res = $this->repository->create($data);
|
$res = $this->repository->create($data);
|
||||||
return app('json')->success(['community_id' => $res]);
|
return app('json')->success(['community_id' => $res]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核委托商品
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function checkEntrust($id)
|
||||||
|
{
|
||||||
|
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->find();
|
||||||
|
if (!$communityInfo) {
|
||||||
|
return app('json')->fail('委托商品不存在');
|
||||||
|
}
|
||||||
|
$status = $this->request->param('status');
|
||||||
|
if (!$status) {
|
||||||
|
return app('json')->fail('请设置审核状态');
|
||||||
|
}
|
||||||
|
// 同意
|
||||||
|
if ($status == 1) {
|
||||||
|
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]);
|
||||||
|
}
|
||||||
|
// 拒绝
|
||||||
|
if ($status == 2) {
|
||||||
|
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('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => $status, 'mer_status' => 2]);
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return app('json')->fail('审核委托商品失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return app('json')->success('审核操作成功');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,6 +376,7 @@ Route::group('api/', function () {
|
|||||||
Route::post('resale/check/:id', 'Community/checkResale');
|
Route::post('resale/check/:id', 'Community/checkResale');
|
||||||
|
|
||||||
Route::post('/entrust', 'Community/entrust');
|
Route::post('/entrust', 'Community/entrust');
|
||||||
|
Route::post('/entrust/check/:id', 'Community/checkEntrust');
|
||||||
|
|
||||||
})->prefix('api.community.');
|
})->prefix('api.community.');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user