123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\manage\controller;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use app\common\library\SysLogs;
- use app\common\library\UUIDs;
- /**
- * 合作伙伴及医院的统计查看
- */
- class Stats extends Base {
- public function index() {
- // 只显示最近半年的报表
- $admin = Session::get('session_manager');
- $dateStr = date("Ym");
- $whereArr = array();
- $whereArr["role_id"] = $admin["id"];
- // 取最近5个月的数据
- $whereArr["month"] = array(">=", date("Ym", strtotime("201808 - 180 day")));
- $stats = Db::table("operating")->where($whereArr)->order("month", "1")->select();
- if (count($stats) > 0) {
- $this->assign("stats", json_encode($stats));
- } else {
- $this->assign("stats", json_encode(array()));
- }
- return $this->fetch('index');
- }
- public function insstat() {
- // 查询出代理机构
- $admin = Session::get('session_manager');
- $insts = array();
- $defNode = array();
- $defNode["id"] = "";
- $defNode["text"] = "请选择下级机构";
- array_push($insts, $defNode);
- $instsRows = Db::table("institution")->where("agent_id", $admin["id"])->field("id,name as text")->select();
- if (count($instsRows) > 0) {
- foreach ($instsRows as $key => $val) {
- array_push($insts, $val);
- }
- $this->assign("insts", json_encode($insts));
- }
- $months = array();
- for ($i = 0; $i < 6; $i++) {
- $monthNode1 = array();
- $monthNode1["id"] = date("Ym", strtotime("- " . $i . " month"));
- $monthNode1["text"] = date("Ym", strtotime("- " . $i . " month"));
- array_push($months, $monthNode1);
- }
- $this->assign("months", json_encode($months));
- return $this->fetch('insstat');
- }
- /**
- * 代理商统计
- */
- public function insdatas() {
- $admin = Session::get('session_manager');
- $request = Request::instance();
- $params = $request->param();
- $page = empty($params["page"]) ? 1 : $params["page"];
- $pagesize = empty($params["rows"]) ? 1 : $params["rows"];
- $whereArr = array();
- if (!empty($params["month"])) {
- $whereArr["month"] = $params["month"];
- }
- // 查出全部代理机构
- $instsRows = DB::table('institution')->where("agent_id", $admin["id"])->field("id")->select();
- $iidArr=array();
- if(count($instsRows)>0){
- foreach($instsRows as $key=>$val){
- array_push($iidArr, $val["id"]);
- }
- }
- if (!empty($params["insts"])) {
- if (in_array($params["insts"], $iidArr)) {
- $whereArr["role_id"] = $params["insts"];
- } else {
- $whereArr["role_id"] = array("in", $iidArr);
- }
- }else{
- $whereArr["role_id"] = array("in", $iidArr);
- }
- if (empty($page) || $page < 1) {
- $page = 1;
- }
- if (empty($pagesize) || $pagesize < 1) {
- $pagesize = 30;
- }
- $info = DB::table('operating')->where($whereArr)->page($page, $pagesize)->select();
- $num = DB::table('operating')->where($whereArr)->count();
- $data = array();
- $data['total'] = $num;
- $data['rows'] = $info;
- echo json_encode($data);
- }
- }
|