| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <?php
- namespace app\controller\admin\finance;
- use app\common\repositories\finance\FinanceRepository;
- use app\controller\api\entropybarter\User;
- use crmeb\basic\BaseController;
- use think\facade\Db;
- class Finance extends BaseController
- {
- /**
- * 订单概况
- * @return mixed
- */
- public function order_overview()
- {
- $financeRepository = app()->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 member_overview()
- {
- $financeRepository = app()->make(FinanceRepository::class);
- $data = $financeRepository->member_overview();
- return app('json')->success('ok', $data);
- }
- /**
- * pv概况
- * @return mixed
- */
- public function pv_overview()
- {
- $financeRepository = app()->make(FinanceRepository::class);
- $data = $financeRepository->pv_overview();
- return app('json')->success('ok', $data);
- }
- /**
- * vr概况
- * @return mixed
- */
- public function vr_overview()
- {
- $financeRepository = app()->make(FinanceRepository::class);
- $data = $financeRepository->vr_overview();
- return app('json')->success('ok', $data);
- }
- /**
- * 积分概况
- * @return mixed
- */
- public function jifen_overview()
- {
- $financeRepository = app()->make(FinanceRepository::class);
- $data = $financeRepository->jifen_overview();
- return app('json')->success('ok', $data);
- }
- /**
- * 交易概况
- * @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['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['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yanglao']), 'name' => '养老金总额'];
- $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['shouyi']), 'name' => '佣金总额'];
- $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['suoke']), 'name' => '锁客收益总额'];
- $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['fugou']), 'name' => '复购金总额'];
- $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hongbao']), 'name' => '红包总额'];
- $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jingdou']), 'name' => '京豆总额'];
- $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['gongxian']), 'name' => '贡献值总额'];
- $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总额'];
- $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['pv']), 'name' => 'PV总额'];
- $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['vr']), 'name' => 'VR总额'];
- $res['left'] = $data;
- //底部大模块
- $list1 = array(
- array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '已完成提现总额'),
- array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '审核中总额'),
- );
- $list2 = array(
- array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '合伙分红总额'),
- array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '联创分红总额'),
- array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '股权分红总额'),
- );
- $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '提现总额', 'list' => $list1];
- $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '分红总额', 'list' => $list2];
-
- return app('json')->success('ok', $res);
- } catch (\Exception $e) {
- Db::name('log')->insert(['data' => '交易详情统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
- return app('json')->fail('统计失败'. $e->getMessage());
- }
- }
- /**
- * 积分统计
- * @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统计失败');
- }
- }
- /**
- * PV统计
- * @return mixed
- */
- public function pv_list(){
- try {
- $financeRepository = app()->make(FinanceRepository::class);
- $date = $financeRepository->pv_list();
- return app('json')->success($date);
- } catch (\Exception $e) {
- Db::name('log')->insert(['data' => 'PV统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
- return app('json')->fail('PV统计失败' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】');
- }
- }
- /**
- * 商户分润统计
- * @return mixed
- */
- public function fenrun_list(){
- try {
- $financeRepository = app()->make(FinanceRepository::class);
- $date = $financeRepository->fenrun_list();
- return app('json')->success($date);
- } catch (\Exception $e) {
- Db::name('log')->insert(['data' => '商户分润统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
- return app('json')->fail('商户分润统计失败' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】');
- }
- }
- /**
- * 佣金统计
- * @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('佣金统计失败');
- }
- }
- 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;
- }
- }
|