request->get(); $uid = $this->request->userInfo['user_id']; $merchant = Merchant::where('uid',$uid)->findOrEmpty(); $supplier = Supplier::where('uid',$uid)->findOrEmpty(); $where = []; if(!$merchant->isEmpty()){ $where[] = ['mer_id','=',$merchant['mer_id']]; }elseif(!$supplier->isEmpty()){ $where[] = ['supplier_id','=',$supplier['id']]; } if(isset($params['create_time']) && $params['create_time'] != ''){ $firstDayOfMonth = strtotime("{$params['create_time']}-01"); $lastDayOfMonth = strtotime("+1 month -1 second", $firstDayOfMonth); $where[] = ['create_time','between',[$firstDayOfMonth,$lastDayOfMonth]]; } return MerchantWithdraw::where($this->searchWhere)->where($where) ->field(['id', 'mer_id', 'supplier_id', 'merchant_bank_id', 'amount', 'is_check', 'fail_msg', 'is_arrival', 'arrival_proof', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $merchant_bank = MerchantBank::where('id',$data['merchant_bank_id'])->findOrEmpty(); $bank = Bank::where('id',$merchant_bank['bank_id'])->findOrEmpty(); $merchant_bank['bank_info'] = $bank; $data['merchant_bank_info'] = $merchant_bank; }) ->toArray(); } /** * @notes 获取商户供应商提现表数量 * @return int * @author likeadmin * @date 2024/05/14 11:21 */ public function count(): int { $params = $this->request->get(); $uid = $this->request->userInfo['user_id']; $merchant = Merchant::where('uid',$uid)->findOrEmpty(); $supplier = Supplier::where('uid',$uid)->findOrEmpty(); $where = []; if(!$merchant->isEmpty()){ $where[] = ['mer_id','=',$merchant['mer_id']]; }elseif(!$supplier->isEmpty()){ $where[] = ['supplier_id','=',$supplier['id']]; } if(isset($params['create_time']) && $params['create_time'] != ''){ $firstDayOfMonth = strtotime("{$params['create_time']}-01"); $lastDayOfMonth = strtotime("+1 month -1 second", $firstDayOfMonth); $where[] = ['create_time','between',[$firstDayOfMonth,$lastDayOfMonth]]; } return MerchantWithdraw::where($this->searchWhere)->where($where)->count(); } }