| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- namespace app\agent\controller\finance;
- use app\common\controller\AgentController;
- use app\common\model\GoodsOrder;
- use app\common\model\MissionOrder;
- use app\common\model\SkillOrder;
- use app\common\model\TaxiOrder;
- use app\http\IResponse;
- use Lettered\Support\Auth as IAuth;
- use think\App;
- use think\db\Query;
- use think\Request;
- class Stats extends AgentController
- {
- protected $model;
- public function __construct(App $app = null, IAuth $auth)
- {
- parent::__construct($app, $auth);
- $this->model = new \app\agent\model\finance\Stats();
- }
- /**
- * 显示资源列表
- *
- * @return \think\Response
- * @throws \Lettered\Support\Exceptions\FailedException
- */
- public function index()
- {
- $area_id = $this->auth->user()['area_id'];
- $TaxiOrder = new TaxiOrder();
- // $GoodsOrder = new GoodsOrder();
- // $SkillOrder = new SkillOrder();
- // $MissionOrder = new MissionOrder();
- $modelArray = [$TaxiOrder];
- // 消费总额包含 商品、接单、技能、摩的
- $where = [
- 'area_id' => $area_id,
- 'status' => [0,2,3,4]
- ];
- // 直接读取支付记录表吧
- $count = [
- 'total' => $TaxiOrder->where($where)->sum('price'),
- 'today' => $TaxiOrder->where($where)->whereTime('created_at', 'd')->sum('price'),
- 'month' => $TaxiOrder->where($where)->whereTime('created_at', 'm')->sum('price'),
- 'year' => $TaxiOrder->where($where)->whereTime('created_at', 'y')->sum('price')
- ];
- // 订单统计
- $order = [
- 'total' => $TaxiOrder->where($where)->count(),
- 'today' => $TaxiOrder->where($where)->whereTime('created_at', 'd')->count(),
- 'month' => $TaxiOrder->where($where)->whereTime('created_at', 'm')->count(),
- 'year' => $TaxiOrder->where($where)->whereTime('created_at', 'y')->count()
- ];
- /*foreach ($modelArray as $key => $item) {
- $row = $this->model->getStats(
- $item,
- $key ? 'pay_price' : 'price',
- 'id',
- [
- 'area_id' => $area_id,
- 'status' => [0,2,3,4]
- ],
- [
- 'paylog'
- ]
- );
- foreach ($row as $index => $value) {
- $count[$index] += array_sum($row[$index]);
- $order[$index] += count($row[$index]);
- }
- }*/
- // 统计图
- $res = [];
- for ($month = 1; $month <=12 ; $month ++){
- $res[] = model('common/GoodsOrder')->whereTime('created_at', 'between', $this->model->getMonthTime($month))
- ->count('*');;
- }
- $data['coun'] = $count;
- $data['chart'] = $res;
- $data['order'] = $order;
- return IResponse::success($data,"加载数据成功");
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function create()
- {
- //
- }
- /**
- * 保存新建的资源
- *
- * @param \think\Request $request
- * @return \think\Response
- */
- public function save(Request $request)
- {
- //
- }
- /**
- * 显示指定的资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function read($id)
- {
- //
- }
- /**
- * 显示编辑资源表单页.
- *
- * @param int $id
- * @return \think\Response
- */
- public function edit($id)
- {
- //
- }
- /**
- * 保存更新的资源
- *
- * @param \think\Request $request
- * @param int $id
- * @return \think\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
- /**
- * 删除指定资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function delete($id)
- {
- //
- }
- }
|