pages = [ 'name' => '资金变动' ]; } public function indexData() { return ['type'=>config('adconfig.money_log_type')]; } public function checkRule($id = '') { } public function setErrorMsg() { $messages = [ ]; return $messages; } public function setModel() { return new MerchantMoneyLog(); } public function apiJson(Request $request) { $offset = $request->input('page', 1); $pagesize = $request->input('limit', 1); $offset = ($offset - 1) * $pagesize; $type = $request->input('type', ''); $merchant_id = $request->input('merchant_id'); $order_id = $request->input('sort', 'id'); $order_type = $request->input('order', 'desc'); $debug = $request->input('debug', 0); $model = $this->setModel(); //是否查看下级 $sub_show=$request->input('sub_show'); if($sub_show!=1) { //不是下级查看,就是查看自己的 $merchant_id = $this->getMerchantId(); }else{ //是否是代理,下级是否属于这个上级,如果属于给权限,如果没有,则返回自己的 if ($this->isProxy()) { $sub_id_arr=Merchant::subAllMerchant($this->getMerchantId()); if(!in_array($merchant_id,$sub_id_arr)) { $merchant_id = $this->getMerchantId(); } }else { $merchant_id = $this->getMerchantId(); } } $model=$model->where('merchant_id',$merchant_id); $search_arr = [ 'type' => [ 'value' => $type, 'type' => '=' ] ]; $model = $this->searchKey($model, $search_arr, 2); $search=new SearchServices($model,$request->all()); $model=$search->getModel(); $total = $model->count(); $result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();; $narr = array(); foreach ($result as $k => $v) { $v['type_name'] = $v->type_name; $v['name'] = $v->merchants->name; $narr[] = $v; } $json = [ "status" => 1, 'code' => $total > 0 ? 0 : 1, 'msg' => $total > 0 ? '请求数据成功' : '暂无数据', 'count' => $total, 'data' => $narr ]; if ($debug) { return $this->jsonDebug($json); } return response()->json($json); } }