142 lines
5.6 KiB
PHP
Executable File
142 lines
5.6 KiB
PHP
Executable File
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeshop开源商城系统
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||
// | github下载:https://github.com/likeshop-github
|
||
// | 访问官网:https://www.likeshop.cn
|
||
// | 访问社区:https://home.likeshop.cn
|
||
// | 访问手册:http://doc.likeshop.cn
|
||
// | 微信公众号:likeshop技术社区
|
||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||
// | likeshop团队版权所有并拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeshop.cn.team
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\lists\finance;
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\lists\ListsExtendInterface;
|
||
use app\common\model\coach\Coach;
|
||
use app\common\model\shop\Shop;
|
||
use app\common\model\withdraw\WithdrawApply;
|
||
use app\common\service\FileService;
|
||
|
||
class WithdrawLists extends BaseAdminDataLists implements ListsExtendInterface
|
||
{
|
||
public function setWhere()
|
||
{
|
||
$source = $this->params['source'] ?? 1;
|
||
$type = $this->params['type'] ?? '';
|
||
$keyword = $this->params['keyword'] ?? '';
|
||
$channel = $this->params['channel'] ?? '';
|
||
$startTime = $this->params['start_time'] ?? '';
|
||
$endTime = $this->params['end_time'] ?? '';
|
||
$status = $this->params['status'] ?? '';
|
||
$where = [];
|
||
$where[] = ['source','=',$source];
|
||
if($keyword){
|
||
if(1 == $source){
|
||
$ids = Coach::where('sn|name','like','%'.$keyword.'%')->field('id')->select()->toArray();
|
||
$ids = array_column($ids,'id');
|
||
}else{
|
||
$ids = Shop::where('sn|name','like','%'.$keyword.'%')->field('id')->select()->toArray();
|
||
$ids = array_column($ids,'id');
|
||
}
|
||
$where[] = ['relation_id','in',$ids];
|
||
}
|
||
if($channel){
|
||
//渠道
|
||
if(1 == $channel){
|
||
$where[] = ['apply_type','=',1];
|
||
}else{
|
||
$where[] = ['apply_type','=',2];
|
||
}
|
||
}
|
||
|
||
if($type){
|
||
$where[] = ['type','=',$type];
|
||
}
|
||
if($startTime){
|
||
$where[] = ['create_time','>',$startTime];
|
||
}
|
||
if($endTime){
|
||
$where[] = ['create_time','<',$endTime];
|
||
}
|
||
switch ($status){
|
||
case 1:
|
||
$where[] = ['status','=',1];
|
||
break;
|
||
case 2:
|
||
$where[] = ['status','=',4];
|
||
break;
|
||
case 3:
|
||
$where[] = ['status','in',[2,5]];
|
||
break;
|
||
case 4:
|
||
$where[] = ['status','in',[2,3,6]];
|
||
break;
|
||
}
|
||
return $where;
|
||
}
|
||
public function lists(): array
|
||
{
|
||
$lists = WithdrawApply::where($this->setWhere())
|
||
->append(['status_desc','apply_type_desc','type_desc'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->withoutField('delete_time')
|
||
->order('id desc')
|
||
->select()
|
||
->toArray();
|
||
$source = $this->params['source'] ?? 1;
|
||
$relationLists = [];
|
||
$relationIds = array_column($lists,'relation_id');
|
||
if(1 == $source){
|
||
$relationLists = Coach::where(['id'=>$relationIds])->column('name,sn,work_photo','id');
|
||
}else{
|
||
$relationLists = Shop::where(['id'=>$relationIds])->column('name,sn,logo','id');
|
||
}
|
||
foreach ($lists as $key => $value){
|
||
if(1 == $source){
|
||
$lists[$key]['relation_info'] = [
|
||
'name' => $relationLists[$value['relation_id']]['name'] ?? '',
|
||
'sn' => $relationLists[$value['relation_id']]['sn'] ?? '',
|
||
'image' => FileService::getFileUrl($relationLists[$value['relation_id']]['work_photo'] ?? '')
|
||
];
|
||
}else{
|
||
$lists[$key]['relation_info'] = [
|
||
'name' => $relationLists[$value['relation_id']]['name'] ?? '',
|
||
'sn' => $relationLists[$value['relation_id']]['sn'] ?? '',
|
||
'image' => FileService::getFileUrl($relationLists[$value['relation_id']]['logo'] ?? '')
|
||
];
|
||
}
|
||
}
|
||
return $lists;
|
||
}
|
||
|
||
public function count(): int
|
||
{
|
||
return WithdrawApply::where($this->setWhere())->count();
|
||
}
|
||
|
||
|
||
public function extend()
|
||
{
|
||
$whereLists = $this->setWhere();
|
||
foreach ($whereLists as $key => $where){
|
||
if($where[0] == 'status'){
|
||
unset($whereLists[$key]);
|
||
}
|
||
}
|
||
return [
|
||
'all_count' => WithdrawApply::where($whereLists)->count(),
|
||
'wait_audit' => WithdrawApply::where($whereLists)->where('status','=',1)->count(),
|
||
'withdraw_ing' => WithdrawApply::where($whereLists)->where('status','=',4)->count(),
|
||
'withdraw_success' => WithdrawApply::where($whereLists)->where('status','in',[2,5])->count(),
|
||
'withdraw_failt' => WithdrawApply::where($whereLists)->where('status','in',[2,3,6])->count(),
|
||
];
|
||
}
|
||
} |