From e2bacc76b83bf197c3257d2d3c74f4b7489e3790 Mon Sep 17 00:00:00 2001 From: fengxinyhyl Date: Sun, 24 Mar 2024 21:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E4=BB=A3=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E9=80=89=E6=8B=A9=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon/StoreCouponProductRepository.php | 12 ++++++++++++ app/common/repositories/user/UserRepository.php | 4 ++-- app/controller/admin/store/Coupon.php | 13 +++++++++++++ app/controller/admin/user/User.php | 17 +++++++++++++++++ route/admin/coupon.php | 3 +++ route/admin/user.php | 4 ++++ 6 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/store/coupon/StoreCouponProductRepository.php b/app/common/repositories/store/coupon/StoreCouponProductRepository.php index a751b31..93cfffc 100644 --- a/app/common/repositories/store/coupon/StoreCouponProductRepository.php +++ b/app/common/repositories/store/coupon/StoreCouponProductRepository.php @@ -46,4 +46,16 @@ class StoreCouponProductRepository extends BaseRepository $list = $query->page($page, $limit)->select(); return compact('count', 'list'); } + + + public function updateProduct($coupon_id, $productIds) + { + $this->dao->clear( $coupon_id); + $data = []; + foreach ($productIds as $product_id) { + $data[] = compact('coupon_id', 'product_id'); + } + $this->dao->insertAll($data); + } + } diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index 2ac5d6e..d7d641d 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -313,14 +313,14 @@ class UserRepository extends BaseRepository $data = app()->make(UserGroupRepository::class)->allOptions(); return Elm::createForm(Route::buildUrl($isArray ? 'systemUserBatchChangeGroup' : 'systemUserChangeGroup', $isArray ? [] : compact('id'))->build(), [ Elm::hidden('ids', $isArray ? $id : [$id]), - Elm::select('group_id', '用户分组', $isArray ? '' : $user->group_id)->options(function () use ($data) { + Elm::select('group_id', '项目经理等级', $isArray ? '' : $user->group_id)->options(function () use ($data) { $options = [['label' => '不设置', 'value' => '0']]; foreach ($data as $value => $label) { $options[] = compact('value', 'label'); } return $options; }) - ])->setTitle('修改用户分组'); + ])->setTitle('设置项目经理等级'); } /** diff --git a/app/controller/admin/store/Coupon.php b/app/controller/admin/store/Coupon.php index 78e3dbd..fb84b93 100644 --- a/app/controller/admin/store/Coupon.php +++ b/app/controller/admin/store/Coupon.php @@ -152,6 +152,19 @@ class Coupon extends BaseController return app('json')->success('修改成功'); } + + public function updateProduct($id){ + $data = $this->request->params(['product_id']); + $productIdArr = explode(',',$data['product_id']); + + $exists = app()->make(StoreCouponRepository::class)->exists($id); + if (!$exists) { + return app('json')->fail('优惠券不存在'); + } + app()->make(StoreCouponProductRepository::class)->updateProduct($id, $productIdArr); + return app('json')->success('修改成功'); + } + public function delete($id) { if (!$this->repository->merExists(0, $id)) diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index b27d0b8..d25379c 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -402,6 +402,23 @@ class User extends BaseController return app('json')->success(formToData($this->repository->changeGroupForm($id))); } + + public function changeAgent($id){ + $agent_district_id = (int)$this->request->param('agent_district_id', 0); + $agent_district = $this->request->param('agent_district'); + if (!$this->repository->exists($id)) + return app('json')->fail('数据不存在'); + $where = array(); + $where[] = array('agent_district_id' , '=', $agent_district_id); + $where[] = array('uid' , '<>', $id); + $exist = $this->repository->getWhere($where); + if($exist){ + return app('json')->fail('该代理已存在'); + } + $this->repository->update($id, array('agent_district_id' => $agent_district_id, 'agent_district' => $agent_district)); + return \app('json')->success('修改成功'); + } + /** * @param $id * @return mixed diff --git a/route/admin/coupon.php b/route/admin/coupon.php index 62cca8c..a29227e 100644 --- a/route/admin/coupon.php +++ b/route/admin/coupon.php @@ -56,6 +56,9 @@ Route::group(function () { Route::post('update/:id', '/update')->name('systemCouponUpdate')->option([ '_alias' => '编辑', ]); + Route::post('update_product/:id', '/updateProduct')->name('systemCouponUpdateProduct')->option([ + '_alias' => '编辑选择商品', + ]); Route::delete('delete/:id', '/delete')->name('systemCouponDelete')->option([ '_alias' => '删除', ]); diff --git a/route/admin/user.php b/route/admin/user.php index 6fa92fe..84bd0c1 100644 --- a/route/admin/user.php +++ b/route/admin/user.php @@ -158,6 +158,10 @@ Route::group(function () { '_alias' => '用户分组批量编辑', ]); + Route::post('change_agent/:id', '/changeAgent')->name('systemUserChangeAgent')->option([ + '_alias' => '用户代理区域编辑', + ]); + //修改用户标签 Route::get('change_label/form/:id', '/changeLabelForm')->name('systemUserChangeLabelForm')->option([ '_alias' => '用户标签编辑表单',