isAjax()) { $bill = new DividemoneyBill(); $search_text = input('search_text', ''); $states = input('status', ''); $channel_type = input('channel_type', ''); $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $condition = []; if ($this->site_id != 1) { $condition[] = ['b.ag_site_id', '=', $this->site_id]; $condition[] = ['b.is_platform', '=', 2]; } if ($states != '') { $condition[] = ['b.states', '=', $states]; } if ($channel_type != '') { $condition[] = ['b.channel_type', '=', $channel_type]; } //下单时间 $start_time = input('start_time', ''); $end_time = input('end_time', ''); if ($start_time && $end_time) { $condition[] = ['b.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; } elseif (!$start_time && $end_time) { $condition[] = ['b.create_time', '<=', date_to_time($end_time)]; } elseif ($start_time && !$end_time) { $condition[] = ['b.create_time', '>=', date_to_time($start_time)]; } if ($search_text) { $condition[] = ['s.username|s.site_name|s.contacts_mobile', 'like', '%' . $search_text . '%']; } $res = $bill->getPageList($condition, $page, $page_size); return $res; } $condition = []; if ($this->site_id != 1) { $condition[] = ['ag_site_id', '=', $this->site_id]; $condition[] = ['is_platform', '=', 2]; // } else { // $condition[] = ['is_platform', '=', 1]; //统计平台 } $totalCommission = model('dividemoney_bill')->getSum($condition, 'amount'); $todayCondition = $condition; //今日统计 $todayCondition[] = ['create_time', 'BETWEEN', Time::today()]; $todaytalCommission = model('dividemoney_bill')->getSum($todayCondition, 'amount'); $yesterdayCondition = $condition; //昨日统计 $yesterdayCondition[] = ['create_time', 'BETWEEN', Time::yesterday()]; $yesterdaytalCommission = model('dividemoney_bill')->getSum($yesterdayCondition, 'amount'); $noCondition = $condition; $noCondition[] = ['states', '=', 0];//未分配 $nototalCommission = model('dividemoney_bill')->getSum($noCondition, 'amount'); $yesCondition = $condition; $yesCondition[] = ['states', '=', 1];//成功统计 $yestotalCommission = model('dividemoney_bill')->getSum($yesCondition, 'amount'); $failCondition = $condition; $failCondition[] = ['states', '>=', 2];//失败统计 $failtotalCommission = model('dividemoney_bill')->getSum($failCondition, 'amount'); $this->assign('yesterdaytalCommission', $yesterdaytalCommission); $this->assign('todaytalCommission', $todaytalCommission); $this->assign('failtotalCommission', $failtotalCommission); $this->assign('yestotalCommission', $yestotalCommission); $this->assign('nototalCommission', $nototalCommission); $this->assign('totalCommission', $totalCommission); $this->forthMenu(); return $this->fetch('bill/lists'); } /*** * 支出明细 * @return array|mixed */ public function explists() { if (request()->isAjax()) { $bill = new AgentAccount(); $search_text = input('search_text', ''); $states = input('status', ''); $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $condition[] = ['b.ag_site_id', '=', $this->site_id]; //下单时间 $start_time = input('start_time', ''); $end_time = input('end_time', ''); if ($start_time && $end_time) { $condition[] = ['b.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; } elseif (!$start_time && $end_time) { $condition[] = ['b.create_time', '<=', date_to_time($end_time)]; } elseif ($start_time && !$end_time) { $condition[] = ['b.create_time', '>=', date_to_time($start_time)]; } if ($search_text) { $condition[] = ['s.username|s.site_name|s.contacts_mobile', 'like', '%' . $search_text . '%']; } $res = $bill->getPageList($condition, $page, $page_size); return $res; } $this->forthMenu(); return $this->fetch('explists/lists'); } /*** * 平台佣金 * @return void */ public function commission() { if (request()->isAjax()) { $bill = new AgentAccount(); $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $condition[] = ['w.agent_site_id', '=', $this->site_id]; //下单时间 $start_time = input('w.start_time', ''); $end_time = input('w.end_time', ''); if ($start_time && $end_time) { $condition[] = ['w.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; } elseif (!$start_time && $end_time) { $condition[] = ['w.create_time', '<=', date_to_time($end_time)]; } elseif ($start_time && !$end_time) { $condition[] = ['w.create_time', '>=', date_to_time($start_time)]; } $res = $bill->getCommissionPageList($condition, $page, $page_size); return $res; } $settled_commission = model('website_commission')->getSum(['agent_site_id' => $this->site_id, 'is_settlement' => 1], 'commission_money'); $not_commission = model('website_commission')->getSum(['agent_site_id' => $this->site_id, 'is_settlement' => 0], 'commission_money'); $this->assign('settled_commission', $settled_commission); $this->assign('not_commission', $not_commission); $this->forthMenu(); return $this->fetch('commission/lists'); } /*** * 结算异常商户 * @return array|mixed */ public function exalist() { if (request()->isAjax()) { $bill = new AgentAccount(); $search_text = input('search_text', ''); $states = input('status', ''); $page = input('page', 1); $page_size = input('page_size', PAGE_LIST_ROWS); $condition[] = ['b.ag_site_id', '=', $this->site_id]; //下单时间 $start_time = input('start_time', ''); $end_time = input('end_time', ''); if ($start_time && $end_time) { $condition[] = ['b.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; } elseif (!$start_time && $end_time) { $condition[] = ['b.create_time', '<=', date_to_time($end_time)]; } elseif ($start_time && !$end_time) { $condition[] = ['b.create_time', '>=', date_to_time($start_time)]; } if ($search_text) { $condition[] = ['s.username|s.site_name|s.contacts_mobile', 'like', '%' . $search_text . '%']; } $res = $bill->getPageList($condition, $page, $page_size); return $res; } $this->forthMenu(); return $this->fetch('explists/lists'); } /*** * 重置分账 * @return void */ public function resetDivide() { $site_id = input('site_id'); $where = [ 'site_id' => $site_id, 'states' => 2 ]; $info = model('dividemoney_bill')->getList($where); $cron = new Cron(); if ($info) { model('dividemoney_bill')->update(['states' => 0], $where); foreach ($info as $key => $item) { $cron->addCron(1, 1, '重启执行自动分账', 'AutoCronOrderDividemoney', time() + $key * 5, $item['order_id']); } } return success(0, '刷新成功'); } public function verifyDivide() { $site_id = input('site_id'); return $this->fetch('bill/verify'); } }