2023-05-10 13:38:51 +08:00
|
|
|
|
<?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;
|
2023-10-08 15:23:44 +08:00
|
|
|
|
use think\facade\Db;
|
2023-05-10 13:38:51 +08:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2023-10-08 15:23:44 +08:00
|
|
|
|
|
|
|
|
|
public function deposit(){
|
2023-10-08 16:09:31 +08:00
|
|
|
|
$where = $this->request->params(['keyword', 'date','mer_id']);
|
2023-10-08 15:23:44 +08:00
|
|
|
|
[$page, $limit] = $this->getPage();
|
|
|
|
|
$query= Db::name('margin_order')->where('paid',1);
|
2023-10-08 16:07:40 +08:00
|
|
|
|
if(isset($where['date'])&& $where['date']!=''){
|
|
|
|
|
$a=explode(' ',$where['date']);
|
2023-10-08 16:45:55 +08:00
|
|
|
|
$query->whereTime('create_time', 'between', [$a[0],$a[1]]);
|
2023-10-08 16:07:40 +08:00
|
|
|
|
}
|
2023-10-08 16:09:31 +08:00
|
|
|
|
if(isset($where['keyword'])&& $where['keyword']!=''){
|
2023-10-08 17:01:03 +08:00
|
|
|
|
$a=Db::name('merchant')->whereLike('mer_name','%'.$where['keyword'].'%')->column('mer_id');
|
|
|
|
|
if($a){
|
|
|
|
|
$query->where('mer_id', 'in', $a);
|
|
|
|
|
}
|
2023-10-08 16:07:40 +08:00
|
|
|
|
}
|
2023-10-08 16:45:55 +08:00
|
|
|
|
|
2023-10-08 16:09:31 +08:00
|
|
|
|
if(isset($where['mer_id'])&& $where['mer_id']!=''){
|
|
|
|
|
$query->where('mer_id', $where['mer_id']);
|
|
|
|
|
}
|
2023-10-08 16:45:55 +08:00
|
|
|
|
|
2023-10-08 16:07:40 +08:00
|
|
|
|
$count=$query->count();
|
2023-10-08 15:23:44 +08:00
|
|
|
|
|
|
|
|
|
$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();
|
2023-10-08 16:07:40 +08:00
|
|
|
|
return app('json')->success(['count'=>$count,'list'=>$list]);
|
2023-10-08 15:23:44 +08:00
|
|
|
|
}
|
2023-05-10 13:38:51 +08:00
|
|
|
|
}
|