区域代理,优惠券选择商品接口

main
fengxinyhyl 8 months ago
parent f0dfc83388
commit e2bacc76b8
  1. 12
      app/common/repositories/store/coupon/StoreCouponProductRepository.php
  2. 4
      app/common/repositories/user/UserRepository.php
  3. 13
      app/controller/admin/store/Coupon.php
  4. 17
      app/controller/admin/user/User.php
  5. 3
      route/admin/coupon.php
  6. 4
      route/admin/user.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);
}
}

@ -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('设置项目经理等级');
}
/**

@ -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))

@ -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

@ -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' => '删除',
]);

@ -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' => '用户标签编辑表单',

Loading…
Cancel
Save