input('search', "")); $start = $end = null; $fieldSearchable = $this->repository->getFieldsSearchable(); foreach ($search as $value) { if (!empty($value)) { list($one, $tow) = explode(":", $value); if (!empty($fieldSearchable[$one])) { if ($fieldSearchable[$one] == 'like') $tow = "%{$tow}%"; $where[] = [$one, $fieldSearchable[$one], $tow]; } elseif ($one == 'start') { $start = $tow . " 00:00:00"; } elseif ($one == 'end') { $end = $tow . " 23:59:59"; } else { continue; } } } return function ($query) use ($where, $start, $end) { if ($start) $where[] = ['created_at', '>=', $start]; if ($end) $where[] = ['created_at', '<=', $end]; if ($where) { $query->where($where); } }; } /** * 数据更新 */ protected function _indexPost($datum) { foreach ($datum as $value){ if ($value->status ==1) { $value->skip = ''; } else { $value->skip = 'skip'; } $value->{'withdraw_type_str'}=WithdrawServer::creatServer()->getType($value->{'withdraw_type'}); $value->{'status_str'}=WithdrawServer::creatServer()->getStatusArr($value->{'status'}); } return $datum; } /** * 查询组合 * @return \Illuminate\Database\Query\Builder */ function _indexJoin() { return Withdraw::from('withdraws as w') ->leftJoin('members as m', 'm.id', '=', 'w.m_id'); } function _indexSelect(){ return ['w.*','m.phone', 'm.nickname']; } function _updatePost(){ $status=request()->input('status'); $id=request()->input('id'); $withdraw_type=request()->input('withdraw_type'); $info=Withdraw::where('id',$id)->first(); if(empty($withdraw_type) && !in_array($withdraw_type,[1,2])){ $this->errorMsg='审核类型错误'; return false; } if(empty($info)){ $this->errorMsg='审核信息不存在'; return false; } if($info->{'status'}!=1){ $this->errorMsg='状态异常'; return false; } if($status==2){ $wx_data=''; if($withdraw_type==1){ $openid=MemberOpenId::where('m_id',$info->{'m_id'})->where('type',1)->value('openid'); if(empty($openid)){ $this->errorMsg='当前用户未绑定微信'; return false; } //转账到微信零钱 $request=WeixinServer::creatServer()->setVerified('TX'.$info->{'id'}.date('YmdHis'),$info->{'withdraw_money'},$openid,''); if(empty($request['code'])){ $this->errorMsg=empty($request['msg'])?'微信零钱划转失败':$request['msg']; return false; }else{ $wx_data=json_encode($request); } } $ret=$info->update(['status'=>2,'withdraw_type'=>$withdraw_type,'wx_data'=>$wx_data]); }else{ MoneyDetailServer::creatServer()->write(1, 14, $info->{'money'}, 1, $info->{'m_id'}, '余额提现驳回', $info->{'id'}); $ret=$info->update(['status'=>3]); } if($ret){ $this->successMsg='操作成功'; return true; }else{ $this->errorMsg='操作失败'; return false; } } /** * 提现审核 */ function audit(){ $status=request()->input('status'); $id=request()->input('id'); $withdraw_type=request()->input('withdraw_type'); $info=Withdraw::where('id',$id)->first(); if(empty($info)){ return $this->error('审核信息不存在'); } if($info->{'status'}!=1){ return $this->response('状态异常', 'error', '', ''); } if($status==2){ if($withdraw_type==1){ $openid=MemberOpenId::where('m_id',$info->{'m_id'})->where('type',1)->value('openid'); if(empty($openid)){ return $this->error('当前用户未绑定微信'); } } $ret=$info->update(['status'=>2,'withdraw_type'=>$withdraw_type]); //转账到微信零钱 }else{ MoneyDetailServer::creatServer()->write(1, 14, $info->{'money'}, 1, $info->{'m_id'}, '余额提现驳回', $info->{'id'}); $ret=$info->update(['status'=>3]); } if($ret){ return $this->success('操作成功'); }else{ return $this->error('操作失败'); } } }