where("year",date("Y"))->column("depart_id,depart_ment,tips,month,year,total,th_total,profit,rate,prate"); $data=[ [ "depart_ment"=>'总计', "content"=>[ 1=>["tips"=>0,"month"=>1,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 2=>["tips"=>0,"month"=>2,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 3=>["tips"=>0,"month"=>3,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 4=>["tips"=>0,"month"=>4,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 5=>["tips"=>0,"month"=>5,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 6=>["tips"=>0,"month"=>6,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 7=>["tips"=>0,"month"=>7,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 8=>["tips"=>0,"month"=>8,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 9=>["tips"=>0,"month"=>9,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 10=>["tips"=>0,"month"=>10,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 11=>["tips"=>0,"month"=>11,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], 12=>["tips"=>0,"month"=>12,"year"=>date("Y"),"total"=>0,"th_total"=>0,"profit"=>0,"rate"=>0,"prate"=>0], ] ] ]; foreach ($list as $value){ $temp=["tips"=>$value['tips'],"month"=>$value['month'],"year"=>date("Y"),"total"=>$value['total'],"th_total"=>$value['th_total'],"profit"=>$value['profit'],"rate"=>$value['rate'],"prate"=>$value['prate']]; $data[0]['content'][$value['month']]["tips"]+=$value['tips']; $data[0]['content'][$value['month']]["total"]+=$value['total']; $data[0]['content'][$value['month']]["th_total"]+=$value['th_total']; $data[0]['content'][$value['month']]["profit"]=$data[0]['content'][$value['month']]["total"] - $data[0]['content'][$value['month']]["th_total"]; $data[0]['content'][$value['month']]["rate"]=round($data[0]['content'][$value['month']]["total"]/$data[0]['content'][$value['month']]["tips"] *100,2); $data[0]['content'][$value['month']]["prate"]=round($data[0]['content'][$value['month']]["profit"]/$data[0]['content'][$value['month']]["tips"] *100,2); if (isset($data[$value['depart_id']])){ $data[$value['depart_id']]['content'][$value['month']]= $temp; }else{ $data[$value['depart_id']]["depart_ment"]=$value['depart_ment']; $data[$value['depart_id']]['content'][$value['month']]= $temp; } } return app_show(0,"获取成功",$data); } // // public function performance(){ // $param = $this->request->only(["start"=>"","end"=>""],"post","trim"); // $valid =Validate::rule([ // "start|起始时间"=>"require|date", // "end|结束时间"=>"require|date|gt:start", // ]); // if($valid->check($param)==false) return error_show(1005,$valid->getError()); // $list =Db::name("trade_pool")->alias("a") // ->leftJoin("assoc b","a.logNo = b.viceCode and b.is_del=0 and b.status=2 and b.type=2") // ->leftJoin("qrd_info c","b.orderCode=c.sequenceNo and c.is_del=0") // ->where(["a.status"=>2,"a.is_del"=>0]) // ->whereBetween("a.addtime",[date("Y-m-d 00:00:00",strtotime($param['start'])),date("Y-m-d 23:59:59", // strtotime($param['end']))]) // ->field(" // a.logNo 回款单号, // c.ownerName 销售人员, // c.department 部门, // c.qrdType 订单类型, // if(c.cxCode='',c.sequenceNo,c.cxCode) 确认单编号, // c.cgdNo 采购单号, // c.customerAttr 客户属性, // c.branch 客户分公司, // c.customerName 客户名称, // c.goodName 产品名称, // c.firstCat 一级分类, // c.goodPrice 销售单价, // c.goodNum-c.thNum 下单数量, // c.totalPrice 销售总额, // c.createdTime 确认单下单时间, // a.addtime 回款日期, // a.total_fee 回款金额, // ( timestampdiff( DAY, a.addtime, now())) 账期") // ->order("a.addtime desc") // ->cursor(); // $header=["回款单号","销售人员","部门","订单类型","确认单编号","采购单号","客户属性","客户分公司","客户名称","产品名称","一级分类", // "销售单价","下单数量","销售总额","确认单下单时间","回款日期","回款金额","账期"]; // excelExport("业绩报表",$header,$list); // } // // public function cgdPerformance(){ // $param = $this->request->only(["start"=>"","end"=>""],"post","trim"); // $valid =Validate::rule([ // "start|起始时间"=>"require|date", // "end|结束时间"=>"require|date|gt:start", // ]); // if($valid->check($param)==false) return error_show(1005,$valid->getError()); // $db =Db::connect("mysql_wsm"); // $list =$db->name("order_out")->alias("a") // ->leftJoin("sale b","a.orderCode=b.orderCode") // ->leftJoin("order_send c","a.outCode=c.outCode") // ->where(["a.status"=>2,"a.is_del"=>0,"b.is_stock"=>0]) // ->whereBetween("a.sendtime",[date("Y-m-d 00:00:00",strtotime($param['start'])),date("Y-m-d 23:59:59", // strtotime($param['end']))]) // ->field(" // a.outCode 发货单号, // c.cgdNo 采购单号, // a.orderCode 销售单号, // b.platform_id, // b.apply_id , // b.apply_name, // b.order_source, // a.sendtime , // b.cat_id, // b.good_name, // a.post_name, // a.post_code, // a.send_num, // b.sale_price, // b.good_num, // b.total_price, // b.supplierNo // ") // ->order("a.addtime desc") // ->cursor(); // $header=["回款单号","销售人员","部门","订单类型","确认单编号","采购单号","客户属性","客户分公司","客户名称","产品名称","一级分类", // "销售单价","下单数量","销售总额","确认单下单时间","回款日期","回款金额","账期"]; // excelExport("业绩报表",$header,$list); // } }