all(); $page_size=$input['page_size']; $page_index=$input['page_index']; $num = ($page_index - 1) * $page_size; $search_name=$input['search_name']; $type=$input['type']; // $search_name=''; // $type=''; $where=[]; $data=Store::where($where); if($type){ $data->where('type',$type); } if($search_name){ $data->where('name', 'like', '%' . $search_name . '%'); } $count=$data->count(); if($count==0){ $this->error('400001','没有数据'); } $list=$data->with(['store_user'=>function($query){ $query->with('user:id,nickname,mobile,level') ->select('id','user_id','store_id','equity_rate') ->orderByDesc('equity_rate'); }]) ->skip($num)->take($page_size) ->orderBy('id','desc') ->get(); if(empty($list)){ return $this->error('400002','没有获取到数据'); } return $this->success_list($list,'success',$count); } //根据手机号获取代理信息 public function getAgentInfo(Request $request){ $phone=$request->input('phone'); $type=$request->input('type'); switch($type){ case 1: $level=[2,3]; break; case 2: case 3: $level=[3]; break; default: $level=[]; } $user=User::where('mobile',$phone) ->whereIn('level',$level) ->whereNull('deleted_at')->where('status',0)->where('cert_status',6)->where('service_status',0) ->select('id','nickname','mobile','level','warea_id') ->first(); if($user){ return $this->success($user); }else{ return $this->error('450001','代理账号有误'); } } //添加门店信息 public function uploadStore(Request $request){ $input=$request->all(); $rules=[ 'name'=>[ 'required', Rule::unique('store')->whereNull('deleted_at') ], ]; $messages=[ 'name.required'=>'门店名称不能为空.', 'name.unique'=>'门店名称已存在.', ]; $validator = Validator::make($input, $rules, $messages); if($validator->fails()){ return $this->error('400013',$validator->errors()->first()); } if($input['type']==1 || $input['type']==3){ //1为工作室 2为体验店 3为优享店 if(count($input['member']) > 1){ return $this->error('400111','工作室与优享店只能有一个成员'); } } if($input['type']==2){ //1为工作室 2为体验店 3为优享店 if(count($input['member']) > 2){ return $this->error('400111','体验店最多只能有两个成员'); } } $data['name']=$input['name']; $data['type']=$input['type']; $data['status']=1; $data['man_id']=$input['man_id']; $data['address']=$input['address']; $data['province']=$input['province']; $data['warea_id']=$input['warea_id']; $data['city']=$input['city']; $data['area']=$input['area']; $data['size']=$input['size']; $data['cost']=$input['cost']; $data['opening_time']=$input['opening_time']; try{ DB::transaction(function()use($data,$input){ $store=Store::create($data); foreach($input['members'] as $key=>$val){ StoreUser::create(['store_id'=>$store->id,'user_id'=>$key,'equity_rate'=>$val]); } Log::info('管理员:'.Auth::user()->name.'(id='.Auth::user()->id.')添加门店信息成功(id='.$store->id.')'); },5); return $this->success([]); }catch(Exception $e){ return $this->error('450001',$e->getMessage()); } } //修改店铺人员股份 public function editStoreUserRate(Request $request){ $user_id=$request->input('user_id'); $store_id=$request->input('store_id'); $equity_rate=$request->input('equity_rate'); $res=StoreUser::where('user_id',$user_id)->where('store_id',$store_id)->update([ 'equity_rate'=>$equity_rate ]); if($res){ return $this->success([]); } return $this->error(); } //添加店铺人员 public function addStoreUser(Request $request){ $user_id=$request->input('user_id'); $store_id=$request->input('store_id'); $equity_rate=$request->input('equity_rate'); $res=StoreUser::create(['store_id'=>$store_id,'user_id'=>$user_id,'equity_rate'=>$equity_rate]); if($res){ return $this->success([]); } return $this->error(); } //删除店铺人员 public function deleteStoreUser(Request $request){ $user_id=$request->input('user_id'); $store_id=$request->input('store_id'); $res=StoreUser::where('user_id',$user_id)->where('store_id',$store_id)->delete(); if($res){ return $this->success([]); } return $this->error(); } //切换管理员 public function switchMan(Request $request){ $store_id=$request->input('store_id'); $man_id=$request->input('man_id'); $res=Store::where('id',$store_id)->update(['man_id'=>$man_id]); if($res){ return $this->success([]); } return $this->error(); } //修改门店信息 public function updateStore(Request $request){ $input=$request->all(); $rules=[ 'name'=>[ 'required', Rule::unique('store')->ignore($input['id'])->whereNull('deleted_at') ], ]; $messages=[ 'name.required'=>'门店名称不能为空.', 'name.unique'=>'门店名称已存在.', ]; $validator = Validator::make($input, $rules, $messages); if($validator->fails()){ return $this->error('400013',$validator->errors()->first()); } // if (count($input['member_ids']) != count(array_unique($input['member_ids']))) { // return $this->error('450001','店铺成员重复提交'); // } // $oldAgent=StoreUser::where('store_id',$input['id'])->pluck('user_id')->toArray(); // // $inter=array_intersect($oldAgent,$input['member']);//交集 原有保持不变代理 // // $oldDiff=array_diff($oldAgent,$inter);//需删除代理 // // $AgeDiff=array_diff($input['member'],$inter);//新增代理 // if($input['type']==1 || $input['type']==3){ // if(count($input['member']) > 1){ // return $this->error('400111','工作室和优享店只能有一个代理'); // } // } // if($input['type']==2){ // if(count($input['member']) > 2){ // return $this->error('400111','体验店最多只能有两个代理'); // } // } $data['name']=$input['name']; $data['type']=$input['type']; $data['address']=$input['address']; $data['province']=$input['province']; $data['city']=$input['city']; $data['area']=$input['area']; $data['size']=$input['size']; $data['cost']=$input['cost']; $data['man_id']=$input['man_id']; $data['warea_id']=$input['warea_id']; $data['opening_time']=$input['opening_time']; $res=Store::where('id',$input['id'])->update($data); Log::info('管理员:'.Auth::user()->name.'(id='.Auth::user()->id.')修改门店信息成功(id='.$input['id'].')'); if($res){ return $this->success([]); } return $this->error(); } /* 门店禁用/启用 */ public function shelvedStore(Request $request){ $store=Store::find($request->post('id')); $store->status=($user->status==0)?'1':'0'; $row=$store->save(); if($row){ Log::info('管理员:'.Auth::user()->name.'(id='.Auth::user()->id.')禁用门店信息成功(id='.$row->id.')'); return $this->success([]); } return $this->error(); } //删除门店信息 public function destoryStore(Request $request) { $input = $request->all(); $store = Store::find($input['id']); DB::beginTransaction(); try { $store->delete(); StoreUser::where('store_id', $input['id'])->delete(); DB::commit(); return $this->success([]); } catch (Exception $e) { DB::rollBack(); return $this->error(); } } public function uploadStoreImg(Request $request){ $file= $request->file('file'); $path_url='store/store'; $upload= new UploadFilesHandler(); $result= $upload->save($file, $path_url, null, 'image'); if($result){ return $this->success($result['path']); } return $this->error(); // $input=$request->all(); // $path_url='public/store'; // $path = $request->file('file')->store($path_url); // $url = Storage::url($path); // if($url){ // return $this->success($url); // } // return $this->error(); } public function getStoreRewardInfo(Request $request) { $input = $request->all(); $page_index = $input['page_index']; $page_size = $input['page_size']; $num = $page_size * ($page_index - 1); // $month = $input['month']; $where = []; // if ($month) { // $where['month'] = $month; // } $count = StoreRewardSet::where($where)->count(); $list = StoreRewardSet::with(['rewards'])->where($where) ->skip($num)->take($page_size) ->orderBy('month', 'desc') ->get(); return $this->success_list($list, '成功', $count); } public function addStoreRewardInfo(Request $request) { $input = $request->all(); $rules = [ 'month' => [ 'required', Rule::unique('store_rewards_set'), // ->ignore($input['id'], 'id') // ->where(function ($query) { // $query->where('deleted_at', null); // }) ], ]; $messages = [ 'month.required' => '月份不能为空.', 'month.unique' => '月份已存在.', ]; $validator = Validator::make($input, $rules, $messages); if ($validator->fails()) { return $this->error('400013', $validator->errors()->first()); } $row = StoreRewardSet::create([ 'month' => $input['month'], 'account_rate' => $input['account_rate'], // 'goods' => json_encode($input['goods']), // 'money' => $input['money'], 'enjoy_hard' => $input['enjoy_hard'], 'enjoy_other' => $input['enjoy_other'], 'over_enjoy_hard' => $input['over_enjoy_hard'], 'over_enjoy_other' => $input['over_enjoy_other'], 'experience_hard' => $input['experience_hard'], 'experience_other' => $input['experience_other'], ]); foreach($input['goods'] as $key=>$val){ StoreRewards::create([ 'month'=>$input['month'], 'name'=>$val['name'], 'price'=>$val['price'], ]); } if ($row) { return $this->success([]); } return $this->error(); } public function updateStoreRewardInfo(Request $request) { $input = $request->all(); $rules = [ 'month' => [ 'required', Rule::unique('store_rewards_set') ->ignore($input['id'], 'id') ], ]; $messages = [ 'month.required' => '月份不能为空.', 'month.unique' => '月份已存在.', ]; $validator = Validator::make($input, $rules, $messages); if ($validator->fails()) { return $this->error('400013', $validator->errors()->first()); } $row = StoreRewardSet::where('id',$input['id'])->update([ 'month' => $input['month'], 'account_rate' => $input['account_rate'], 'enjoy_hard' => $input['enjoy_hard'], 'enjoy_other' => $input['enjoy_other'], 'over_enjoy_hard' => $input['over_enjoy_hard'], 'over_enjoy_other' => $input['over_enjoy_other'], 'experience_hard' => $input['experience_hard'], 'experience_other' => $input['experience_other'], ]); $before_ids=StoreRewards::where('month',$input['month'])->pluck('id')->toArray(); // return $before_ids; $after_ids=[]; foreach($input['goods'] as $key=>$val){ if(array_key_exists('isAdd',$val)){ StoreRewards::create([ 'month'=>$input['month'], 'name'=>$val['name'], 'price'=>$val['price'], ]); }else{ $after_ids[]=$val['id']; } } $diff_ids=array_diff($before_ids,$after_ids); StoreRewards::whereIn('id',$diff_ids)->delete(); if ($row) { return $this->success([]); } return $this->error(); } public function deleteStoreRewardInfo(Request $request) { $input = $request->all(); $row = StoreRewardSet::where('id', $input['id'])->delete(); if ($row) { return $this->success([]); } return $this->error(); } public function getStoreRewardList(Request $request) { $input = $request->all(); $page_index = $input['page_index']; $page_size = $input['page_size']; $num = $page_size * ($page_index - 1); $month = $input['month']; $search_name = $input['search_name']; $type = $input['type'];//店铺级别 1工作室 3优享店 2体验店 //<<<<<<< HEAD // $where = []; // $where['store.type'] = $type; // $alr_store_ids=StoreRewardInfo::where('month',$month)->groupBy('store_id')->pluck('store_id'); // $count=Store::whereIn('id',$alr_store_ids) // ->where('type',$type) // ->where('name','like','%'.$search_name.'%') // ->count(); // $list=Store::whereIn('id',$alr_store_ids) // ->where('type',$type) // ->where('name','like','%'.$search_name.'%') //======= $alr_store_ids=StoreRewardInfo::where('month',$month)->groupBy('store_id')->pluck('store_id'); $count=Store::whereIn('id',$alr_store_ids)->where('name','like','%'.$search_name.'%')->where('type',$type)->count(); $list=Store::whereIn('id',$alr_store_ids) ->where('name','like','%'.$search_name.'%') ->where('type',$type) //>>>>>>> store_rewards ->skip($num)->take($page_size) ->orderBy('account', 'desc') ->get(); foreach($list as $key=>$val){ //<<<<<<< HEAD $list[$key]->rewards=StoreRewardInfo::where('month',$month)->where('store_id',$val->id) ->select('content','rewards','type','created_at','money') ->groupBy('store_id','month','type')->get(); //======= // $list[$key]->rewards=StoreRewardInfo::where('month',$month)->where('store_id',$val->id) // ->groupBy('type')->get(); //>>>>>>> store_rewards } return $this->success_list($list,'成功',$count); } public function getStoreNoRewardList1(Request $request) { $input = $request->all(); $page_index = $input['page_index']; $page_size = $input['page_size']; $num = $page_size * ($page_index - 1); $month = $input['month']; $search_name = $input['search_name']; $type = $input['type'];//店铺级别 1工作室 3优享店 2体验店 $where = []; $where['store.type'] = $type; $start_time = Carbon::parse($month)->startOfMonth()->toDateTimeString(); $end_time = Carbon::parse($month)->endOfMonth()->toDateTimeString(); $alr_store_ids=StoreRewardInfo::where('month',$month)->groupBy('store_id')->pluck('store_id'); $store_ids=Store::whereNotIn('id',$alr_store_ids)->pluck('id'); $data = Store::where($where)->whereIn('store.id',$store_ids) ->join('store_user as su', 'su.store_id', '=', 'store.id') ->join('users', 'users.id', '=', 'su.user_id') ->leftJoin('order_test as ot', function ($query) use ($start_time, $end_time) { $query->on('ot.user_id', '=', 'users.id') ->whereIn('ot.status', [3, 4]) ->whereBetween('ot.created_at', [$start_time, $end_time]); }) ->groupBy('store.id'); $count=$data->get()->count(); $list=$data->select('store.id', 'store.name', 'store.type','store.account as store_account','store.decorate_account', DB::raw('sum(ifNull(ot.money,0)) as account'), DB::raw('sum(ifNull(ot.total,0)) as total')) ->skip($num)->take($page_size) ->orderBy('account', 'desc') ->get(); foreach ($list as $key => $val) { $user_ids = StoreUser::where('store_id', $val->id)->pluck('user_id'); $list[$key]->goods = []; if ($user_ids) { $order_ids = Ordertest::whereIn('user_id', $user_ids) ->whereIn('status', [3, 4]) ->whereBetween('created_at', [$start_time, $end_time]) ->pluck('id'); $info = Orderdetail::join('goods_test as gt','gt.id','=','order_detail.goods_id') ->whereIn('order_detail.order_id', $order_ids)->groupBy('gt.main_attr') ->select('gt.main_attr','gt.unit', DB::raw('sum(order_detail.num) as total') ,DB::raw('sum(order_detail.money) as account'))->get(); $list[$key]->goods = $info; $rewardInfo=StoreRewardInfo::where('month',$month)->where('store_id',$val->id)->first(); $list[$key]->reward=$rewardInfo; } } return $this->success_list($list,'成功',$count); } public function getStoreNoRewardList(Request $request) { $input = $request->all(); $page_index = $input['page_index']; $page_size = $input['page_size']; $num = $page_size * ($page_index - 1); $month = $input['month']; $search_name = $input['search_name']; $type = $input['type'];//店铺级别 1工作室 3优享店 2体验店 $where = []; $where['store.type'] = $type; $start_time = Carbon::parse($month)->startOfMonth()->toDateTimeString(); $end_time = Carbon::parse($month)->endOfMonth()->toDateTimeString(); $alr_store_ids=StoreRewardInfo::where('month',$month)->groupBy('store_id')->pluck('store_id'); $count=Store::where('type',$type)->where('name','like','%'.$search_name.'%')->whereNotIn('id',$alr_store_ids)->count(); $list=Store::where('store.type',$type)->where('store.name','like','%'.$search_name.'%')->whereNotIn('store.id',$alr_store_ids) ->join('store_user as su','su.store_id','=','store.id') ->leftJoin('order_test as ot',function($query) use ($start_time, $end_time){ $query->on('ot.user_id','=','su.user_id') ->whereIn('ot.status',[3,4]) ->whereBetween('ot.created_at', [$start_time, $end_time]); }) ->select('store.name','store.id','store.account as store_account','store.decorate_account','store.type',DB::raw('sum(ifNull(ot.money,0)) as account'),DB::raw('sum(ifNull(ot.total,0)) as total')) ->groupBy('store.id') ->skip($num)->take($page_size) ->orderBy('account', 'desc') ->get(); foreach($list as $key=>$val){ $user_ids=StoreUser::where('store_id',$val->id)->pluck('user_id'); if($type==2){ $original_orders_ids=Ordertest::whereIn('status',[3,4])->where('user_id',$user_ids)->whereBetween('created_at', [$start_time, $end_time])->pluck('id')->toArray(); $manual_orders_ids=Ordertest::whereIn('status',[3,4])->where('store_id',$val->id) ->whereBetween('created_at', [$start_time, $end_time])->pluck('id')->toArray(); $order_ids=array_unique(array_merge($original_orders_ids,$manual_orders_ids)); }else{ $order_ids=Ordertest::whereIn('status',[3,4])->where('user_id',$user_ids)->whereBetween('created_at', [$start_time, $end_time])->pluck('id'); } $goods=Ordertest::join('order_detail as od','od.order_id','=','order_test.id') ->join('goods_test as gt','gt.id','=','od.goods_id')->whereIn('order_test.id',$order_ids) ->groupBy('gt.main_attr') ->select('gt.main_attr','gt.unit', DB::raw('sum(od.num) as total') ,DB::raw('sum(od.money) as account'))->get(); $list[$key]->goods=$goods; } return $this->success_list($list,'成功',$count); } public function settlement(Request $request) { $input = $request->all(); $store_id = $input['store_id']; $month = $input['month']; $info=$input['info']; $reward=StoreRewardInfo::where('month',$month)->where('store_id',$store_id)->get(); if(count($reward)>0){ return $this->error('450001','该门店当月已结算奖励'); } $start_time = Carbon::parse($month)->startOfMonth()->toDateTimeString(); $end_time = Carbon::parse($month)->endOfMonth()->toDateTimeString(); $set = StoreRewardSet::where('month', $month)->first(); $user_ids = StoreUser::where('store_id', $store_id)->pluck('user_id'); if (count($user_ids) <= 0) { return $this->error('门店无代理,不能结算'); } $account = Ordertest::whereIn('user_id', $user_ids) ->whereIn('status', [3, 4])->whereBetween('created_at', [$start_time, $end_time]) ->sum('money'); if ($account <= 0) { return $this->error('当月该门店总金额为0,不能结算'); } $store = Store::where('id',$store_id)->first(); DB::beginTransaction(); try { if ($store->type == 1) {//工作室 $goods = $input['goods']; $amount = 0; foreach ($goods as $key => $val) { $amount += $val['price'] * $val['number']; } if ($amount > $account * $set->account_rate) { return $this->error('450001','商品总价超出门店总金额,不能结算'); } foreach ($goods as $key => $val) { StoreRewardInfo::create([ 'month' => $month, 'store_id' => $store_id, 'type' => 1, 'rewards' => json_encode($goods, JSON_UNESCAPED_UNICODE), 'rewards_id' => $val['id'], 'content' => json_encode($info, JSON_UNESCAPED_UNICODE), 'num' => $val['number'], 'money' => null ]); } } elseif ($store->type == 2) {//体验店 $goods = $input['goods']; $amount = 0;//总数量 foreach ($goods as $key => $val) { $amount += $val['number'] * $val['price']; } Store::where('id',$store_id)->increment('account',$amount); StoreRewardInfo::create([ 'month' => $month, 'store_id' => $store_id, 'type' => 2, 'rewards_id' => null, 'num' => null, 'rewards' => json_encode($goods, JSON_UNESCAPED_UNICODE), 'content' => json_encode($info, JSON_UNESCAPED_UNICODE), 'money' => $amount, ]); } else {//优享店 $decorate = $store->decorate_account;//装修金额 if (empty($decorate)) { return $this->error('当前门店无装修金额,不能结算'); } $goods = $input['goods']; $amount = 0; foreach ($goods as $key => $val) { $amount += $val['price'] * $val['number']; } if ($amount > $account * $set->account_rate) { return $this->error('商品总价超出门店总金额,不能结算'); } foreach ($goods as $key => $val) { StoreRewardInfo::create([ 'month' => $month, 'store_id' => $store_id, 'type' => 1, 'rewards' => json_encode($goods, JSON_UNESCAPED_UNICODE), 'rewards_id' => $val['id'], 'content' => json_encode($info, JSON_UNESCAPED_UNICODE), 'num' => $val['number'], 'money' => null ]); } $goods_price = $input['goods_price']; $amount = 0;//总数量 foreach ($goods_price as $key => $val) { $amount += $val['number1'] * $val['price1'] + $val['number2'] * $val['price2']; } Store::where('id',$store_id)->increment('account',$amount); StoreRewardInfo::create([ 'month' => $month, 'store_id' => $store_id, 'type' => 2, 'rewards_id' => null, 'num' => null, 'rewards' => json_encode($goods_price, JSON_UNESCAPED_UNICODE), 'content' => json_encode($info, JSON_UNESCAPED_UNICODE), 'money' => $amount, ]); } DB::commit(); return $this->success([]); }catch(Exception $e){ DB::rollBack(); return $this->error($e->getMessage()); } } public function undoStoreRewardsInfo(Request $request){ $input=$request->all(); $month=$input['month']; $store_id=$input['store_id']; $next_month=date("Y-m",strtotime('+1 month',strtotime($month))); $curr_month=date("Y-m"); if($next_month!=$curr_month){ return $this->error('450001','当前月份兑换不能撤销'); } DB::beginTransaction(); try{ $amount=StoreRewardInfo::where('month',$month)->where('store_id',$store_id)->where('type',2)->value('money'); if($amount>0){ Store::where('id',$store_id)->decrement('money',$amount); } StoreRewardInfo::where('month',$month)->where('store_id',$store_id)->delete(); DB::commit(); return $this->success([]); }catch(Exception $e){ DB::rollBack(); return $this->error(); } } public function getStoreInfo(Request $request){ $input=$request->all(); $month=$input['month']; $info=StoreRewardSet::where('month',$month)->first(); $goods=StoreRewards::where('month',$month)->get(); if($info){ $info->goods=$goods; return $this->success($info); }else{ return $this->error('450001','当月未设置兑换信息'); } } //导入门店 public function import(Request $request){ if(!$request->hasFile('file')){ exit('上传文件为空!'); } $data=[]; $array = Excel::toArray(new ReportImport, request()->file('file')); DB::beginTransaction(); try{ foreach($array[0] as $key => $val){ if(!empty($val[0]) && $val[0]!='昵称'){ $user=User::where('mobile',$val[2])->select('id','nickname','warea_id')->first(); if(empty($user)){ return $this->error('450001',$val[0].'手机号不存在'); } if(!isset($user->warea_id) || empty($user->warea_id) ){ return $this->error('450001',$val[0].'没有战区'); } $data[$key]['name']=$val[0].$val[4]; $data[$key]['type']=1; $data[$key]['status']=1; $data[$key]['man_id']=$user->id; if($val[4]=='工作室'){ $type=1; }elseif($val[4]=='优享店'){ $type=3; }else{ $type=2; } $row=Store::create(['name'=>$val[0].$val[4],'type'=>$type,'status'=>1,'man_id'=>$user->id,'warea_id'=>$user->warea_id]); StoreUser::create(['user_id'=>$user->id,'user_mobile'=>$val[2],'store_id'=>$row->id]); } } DB::commit(); return $this->success([]); }catch(\Exception $e){ DB::rollback(); return $this->error(); } } //获取体验店代理 public function getExpStoreAgent(Request $request){ $page_size=$request->input('page_size'); $page_index=$request->input('page_index'); $num=$page_size*($page_index-1); $store_id=$request->input('store_id'); $data=ExpStoreAgent::query()->with(['user:id,nickname,level,mobile','store:id,name']); if(!empty($store_id)){ $data->where('store_id',$store_id); } $count=$data->count(); $list=$data->skip($num)->take($page_size)->get(); return $this->success_list($list,'',$count); } //获取体验店信息 public function getExpStore(){ $stores=Store::where('type',2)->select('id','name')->get(); return $this->success($stores); } //查询代理公司信息 public function searchCompanyInfo(Request $request){ $mobile=$request->input('mobile'); $user=User::where('mobile',$mobile) ->where('level',3) ->whereNull('deleted_at')->where('status',0)->where('cert_status',6)->where('service_status',0) ->select('id','nickname','mobile','level') ->first(); if($user){ return $this->success($user); }else{ return $this->error('450001','代理账号有误'); } } public function addExpStoreAgent(Request $request){ $store_id=$request->input('store_id'); $user_id=$request->input('user_id'); $res=ExpStoreAgent::create([ 'store_id'=>$store_id, 'user_id'=>$user_id ]); if($res){ return $this->success([]); }else{ return $this->error(); } } public function editExpStoreAgent(Request $request){ $id=$request->input('id'); $store_id=$request->input('store_id'); $user_id=$request->input('user_id'); $res=ExpStoreAgent::where('id',$id) ->update([ 'store_id'=>$store_id, 'user_id'=>$user_id ]); if($res){ return $this->success([]); }else{ return $this->error(); } } public function deleteExpStoreAgent(Request $request){ $id=$request->input('id'); $res=ExpStoreAgent::where('id',$id)->delete(); if($res){ return $this->success([]); }else{ return $this->error(); } } public function exportStoreSubsidies(){ $stores=Store::with(['store_user'=>function($query){ $query->with('user:id,nickname,mobile,level') ->select('id','user_id','store_id','equity_rate') ->orderByDesc('equity_rate'); }])->get(); return $this->success($stores); } }