新增编辑委托商品详情
This commit is contained in:
parent
41d3c27a80
commit
44e9640ab1
@ -820,6 +820,48 @@ class Community extends BaseController
|
||||
return app('json')->success($communityInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑委托商品
|
||||
* @return mixed
|
||||
*/
|
||||
public function editEntrust($id)
|
||||
{
|
||||
$communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->where('mer_status', 0)->find();
|
||||
if (!$communityInfo) {
|
||||
return app('json')->fail('委托商品不存在');
|
||||
}
|
||||
if ($communityInfo['mer_status'] > 0) {
|
||||
return app('json')->fail('该委托商品已审核');
|
||||
}
|
||||
if ($communityInfo['uid'] != $this->request->uid()) {
|
||||
return app('json')->fail('当前商户无编辑此委托商品权限');
|
||||
}
|
||||
$this->checkUserAuth();
|
||||
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('编辑委托商品失败');
|
||||
}
|
||||
$data = $this->checkParams();
|
||||
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
|
||||
$merchantInfo = Db::name('merchant')->where('mer_id', $data['entrust_mer_id'] ?? 0)->where('type_id', $typeSupplyChainId)->fetchSql(false)->find();
|
||||
if (!$merchantInfo) {
|
||||
return app('json')->fail('此商户不支持委托');
|
||||
}
|
||||
$data['uid'] = $this->request->uid();
|
||||
$res = $this->repository->create($data);
|
||||
return app('json')->success(['community_id' => $res]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应链商家申请结束商品委托
|
||||
* @return mixed
|
||||
|
@ -383,6 +383,7 @@ Route::group('api/', function () {
|
||||
Route::post('/entrust', 'Community/entrust');
|
||||
Route::get('/entrust/list', 'Community/entrustList');
|
||||
Route::get('/entrust/:id', 'Community/entrustDetail');
|
||||
Route::post('entrust/edit/:id', 'Community/editEntrust');
|
||||
Route::post('/entrust/check/:id', 'Community/checkEntrust');
|
||||
Route::post('/entrust/addEntrustCart', 'Community/addEntrustCart');
|
||||
Route::post('/entrust/apply/finish/:id', 'Community/applyFinishEntrust');
|
||||
|
Loading…
x
Reference in New Issue
Block a user