102 lines
3.3 KiB
PHP
102 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace app\api\lists\withdraw;
|
|
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
use app\common\model\bank\Bank;
|
|
use app\common\model\merchant\Merchant;
|
|
use app\common\model\merchant\MerchantBank;
|
|
use app\common\model\supplier\Supplier;
|
|
use app\common\model\withdraw\MerchantWithdraw;
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
|
|
|
/**
|
|
* 商户供应商提现表列表
|
|
* Class MerchantWithdrawLists
|
|
* @package app\admin\listswithdraw
|
|
*/
|
|
class MerchantWithdrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author likeadmin
|
|
* @date 2024/05/14 11:21
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取商户供应商提现表列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author likeadmin
|
|
* @date 2024/05/14 11:21
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
$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)
|
|
->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();
|
|
}
|
|
|
|
} |