make(FinanceRepository::class); $data = $financeRepository->order_overview(); return app('json')->success('ok', $data); } /** * 订单概况 * @return mixed */ public function user_overview() { $financeRepository = app()->make(FinanceRepository::class); $data = $financeRepository->user_overview(); return app('json')->success('ok', $data); } /** * 积分统计 * @return mixed */ public function integral_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->integral_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '积分统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('积分统计失败'); } } /** * 京豆统计 * @return mixed */ public function jingdou_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->jingdou_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '京豆统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('京豆统计失败'); } } /** * 贡献值统计 * @return mixed */ public function contribute_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->contribute_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '贡献值统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('贡献值统计失败'); } } /** * 复购金统计 * @return mixed */ public function fugou_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->fugou_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '复购金统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('复购金统计失败'); } } /** * 红包统计 * @return mixed */ public function hongbao_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->hongbao_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '红包统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('红包统计失败'); } } /** * VR统计 * @return mixed */ public function vr_list(){ try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->vr_list(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => 'VR统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('VR统计失败'); } } /** * 佣金统计 * @return mixed */ public function user_bill() { try { $financeRepository = app()->make(FinanceRepository::class); $date = $financeRepository->user_bill(); return app('json')->success($date); } catch (\Exception $e) { Db::name('log')->insert(['data' => '佣金统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('佣金统计失败'); } } /** * 交易详情 * @return mixed */ public function transaction_overview() { try { $type = input('type', 1); $day = input('day', ''); $mer_id = $this->request->merId(); $financeRepository = app()->make(FinanceRepository::class); $arr = $financeRepository->jieyu($type,$day,$mer_id); $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yingyemoney']), 'name' => '营业总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['ruzhang']), 'name' => '入账总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['shouyi']), 'name' => '佣金奖励总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jieyu']), 'name' => '结余总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hf_fee_amt']), 'name' => '汇付通道服务费金额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总数']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['tixinan']), 'name' => '提现支出总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yanglao']), 'name' => '养老金总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['gongxian']), 'name' => '贡献值总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jingdou']), 'name' => '京豆总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hongbao']), 'name' => '红包总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['fugou']), 'name' => '复购金总额']; $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['vr']), 'name' => 'VR总额']; return app('json')->success('ok', $data); } catch (\Exception $e) { Db::name('log')->insert(['data' => '交易详情统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']); return app('json')->fail('统计失败'. $e->getMessage()); } } public function day_bill_list() { [$page, $limit] = $this->getPage(); $where['mer_id'] = 0; $query = Db::name('enterprise_day_bill')->where($where); $date['count'] = $query->count(); $date['list'] = $query->page($page, $limit)->order('day desc')->select(); return app('json')->success($date); } public function month_bill_list() { [$page, $limit] = $this->getPage(); $where['mer_id'] = 0; $query = Db::name('enterprise_month_bill')->field('id,month ,flow,expenditure,accounting')->where($where); $date['count'] = $query->count(); $date['list'] = $query->page($page, $limit)->order('month desc')->select(); return app('json')->success($date); } /** * 列表中的时间条件 */ public function date_where($Db, $where, $prefix = 'so.create_time', $field = '-') { if (!isset($where)) return $Db; switch ($where) { case 'today': $Db->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('today')), date('Y-m-d H:i:s', strtotime('tomorrow -1second'))]); break; case 'week': $Db->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this week 00:00:00')), date('Y-m-d H:i:s', strtotime('next week 00:00:00 -1second'))]); break; case 'month': $Db->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('first Day of this month 00:00:00')), date('Y-m-d H:i:s', strtotime('first Day of next month 00:00:00 -1second'))]); break; case 'year': $Db->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this year 1/1')), date('Y-m-d H:i:s', strtotime('next year 1/1 -1second'))]); break; case 'yesterday': $Db->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('yesterday')), date('Y-m-d H:i:s', strtotime('today -1second'))]); break; case 'quarter': list($startTime, $endTime) = getMonth(); $Db = $Db->where($prefix, '>', $startTime); $Db = $Db->where($prefix, '<', $endTime); break; case 'lately7': $Db = $Db->where($prefix, 'between', [date('Y-m-d', strtotime("-7 day")), date('Y-m-d H:i:s')]); break; case 'lately30': $Db = $Db->where($prefix, 'between', [date('Y-m-d', strtotime("-30 day")), date('Y-m-d H:i:s')]); break; default: if (strstr($where, $field) !== false) { list($startTime, $endTime) = explode($field, $where); if (strlen($startTime) == 4) { $Db->whereBetweenTime($prefix, date('Y-m-d H:i:s', strtotime($startTime)), date('Y-m-d H:i:s', strtotime($startTime . ' +1day -1second'))); } else { if ($startTime == $endTime) { $Db = $Db->whereDay($prefix, $startTime); } else { $Db = $Db->where($prefix, '>', date('Y-m-d H:i:s', strtotime($startTime))); $Db = $Db->where($prefix, '<', date('Y-m-d H:i:s', strtotime($endTime))); } } } break; } return $Db; } }