86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
<?php
|
||
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
|
||
|
||
namespace app\controller\admin\user;
|
||
|
||
|
||
use app\common\repositories\store\ExcelRepository;
|
||
use crmeb\basic\BaseController;
|
||
use app\common\repositories\user\UserBillRepository;
|
||
use crmeb\services\ExcelService;
|
||
use think\App;
|
||
use think\facade\Db;
|
||
|
||
class UserBill extends BaseController
|
||
{
|
||
protected $repository;
|
||
|
||
public function __construct(App $app, UserBillRepository $repository)
|
||
{
|
||
parent::__construct($app);
|
||
$this->repository = $repository;
|
||
}
|
||
|
||
public function getList()
|
||
{
|
||
[$page, $limit] = $this->getPage();
|
||
$where = $this->request->params(['keyword', 'date', 'type']);
|
||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||
}
|
||
|
||
public function type()
|
||
{
|
||
return app('json')->success($this->repository->type());
|
||
}
|
||
|
||
|
||
public function export()
|
||
{
|
||
$where = $this->request->params(['keyword', 'date', 'type']);
|
||
[$page, $limit] = $this->getPage();
|
||
$data = app()->make(ExcelService::class)->bill($where,$page,$limit);
|
||
return app('json')->success($data);
|
||
}
|
||
|
||
public function deposit(){
|
||
$where = $this->request->params(['keyword', 'date','mer_id']);
|
||
[$page, $limit] = $this->getPage();
|
||
$query= Db::name('margin_order')->where('paid',1);
|
||
if(isset($where['date'])&& $where['date']!=''){
|
||
$a=explode(' ',$where['date']);
|
||
$query->whereTime('create_time', 'between', [$a[0],$a[1]]);
|
||
}
|
||
if(isset($where['keyword'])&& $where['keyword']!=''){
|
||
$a=Db::name('merchant')->whereLike('mer_name','%'.$where['keyword'].'%')->column('mer_id');
|
||
if($a){
|
||
$query->where('mer_id', 'in', $a);
|
||
}
|
||
}
|
||
|
||
if(isset($where['mer_id'])&& $where['mer_id']!=''){
|
||
$query->where('mer_id', $where['mer_id']);
|
||
}
|
||
|
||
$count=$query->count();
|
||
|
||
$list=$query->withAttr('mer_name',function($value,$data){
|
||
return Db::name('merchant')->where('mer_id',$data['mer_id'])->value('mer_name');
|
||
})
|
||
->withAttr('nickname',function($value,$data){
|
||
return Db::name('user')->where('uid',$data['uid'])->value('nickname');
|
||
})
|
||
->page($page, $limit)->order('order_id', 'desc')->select()->toArray();
|
||
return app('json')->success(['count'=>$count,'list'=>$list]);
|
||
}
|
||
}
|