wugg 1 year ago
parent
commit
71e2c3bf7a
2 changed files with 19 additions and 4 deletions
  1. 6 2
      app/admin/controller/Stat.php
  2. 13 2
      app/command/stat.php

+ 6 - 2
app/admin/controller/Stat.php

@@ -77,20 +77,24 @@ class Stat extends BaseController{
 		$everyday =Db::name("depart_everyday")
 		             ->where("day_time",date("Y-m-d",strtotime($post["daytime"])))
 		             ->where("companyNo","GS2203161855277894")
-		             ->column("sale_total,th_total","depart_id");
+		             ->column("sale_total,th_total,zy_sale_total,channel_sale_total","depart_id");
 		$everymonth =Db::name("depart_everyday")
 		             ->whereBetween("day_time",[date("Y-m-01",strtotime($post["daytime"])),date("Y-m-t",  strtotime($post["daytime"]))])
 		             ->where("companyNo","GS2203161855277894")
 			->group("depart_id")
-		             ->column("sum(sale_total) as msale_total,sum(th_total) as mth_total,depart_id","depart_id");
+		             ->column("sum(sale_total) as msale_total,sum(th_total) as mth_total,sum(zy_sale_total) as mzy_sale_total,sum(channel_sale_total) as mchannel_sale_total,depart_id","depart_id");
 		foreach ($depart_tips as $value){
 			$temp=[];
 			$temp["depart"] = $value['depart_item'];
 			$temp["total_tips"] = $value['total_tips'];
 			$temp["sale_total"] =isset($everyday[$value['depart_id']])?$everyday[$value['depart_id']]['sale_total']:0;
+			$temp["zy_sale_total"] =isset($everyday[$value['depart_id']])?$everyday[$value['depart_id']]['zy_sale_total']:0;
+			$temp["channel_sale_total"] =isset($everyday[$value['depart_id']])?$everyday[$value['depart_id']]['channel_sale_total']:0;
 			$temp["th_total"] =isset($everyday[$value['depart_id']])?$everyday[$value['depart_id']]['th_total']:0;
 			$temp["msale_total"] =isset($everymonth[$value['depart_id']])?$everymonth[$value['depart_id']]['msale_total']:0;
 			$temp["mth_total"] = isset($everymonth[$value['depart_id']])?$everymonth[$value['depart_id']]['mth_total']:0;
+			$temp["mchannel_sale_total"] = isset($everymonth[$value['depart_id']])?$everymonth[$value['depart_id']]['mchannel_sale_total']:0;
+			$temp["mzy_sale_total"] = isset($everymonth[$value['depart_id']])?$everymonth[$value['depart_id']]['mzy_sale_total']:0;
 			$return[]=$temp;
 		}
 		return app_show(0,"获取成功",$return);

+ 13 - 2
app/command/stat.php

@@ -32,9 +32,13 @@ class stat extends Command
 			                                ->findOrEmpty();
 			$uidArr =$this->getuid($itmeid);
 			$sale=$this->GetData($uidArr,$companyNo,$date);
+			$zy=$this->GetData($uidArr,$companyNo,$date,1);
+			$channel=$this->GetData($uidArr,$companyNo,$date,2);
 			if($ist){
 				$ist['sale_total']=$sale['sale_total']??0;
 				$ist['th_total']=$sale['th_total']??0;
+				$ist['zy_sale_total']=$zy['sale_total']-$zy['th_total'];
+				$ist['channel_sale_total']=$channel['sale_total']-$channel['th_total'];
 			}else{
 				$ist=[
 					"depart_id"=>$itmeid,
@@ -42,6 +46,8 @@ class stat extends Command
 					"day_time"=>date("Y-m-d"),
 					"sale_total"=>$sale['sale_total']??0,
 					"th_total"=>$sale['th_total']??0,
+					"zy_sale_total"=>$zy['sale_total']-$zy['th_total'],
+					"channel_sale_total"=>$channel['sale_total']-$channel['th_total'],
 					"companyNo"=>$companyNo,
 					"companyName"=>$company[$companyNo],
 				];
@@ -60,20 +66,25 @@ class stat extends Command
 	 * @param $date
 	 * @return array
 	 */
-	public  function GetData($uid,$companyNo,$date):array{
-
+	public  function GetData($uid,$companyNo,$date,$type=0):array{
 
+		$where=[];
+		if($type==1) $where=["cxCode","=",''];
+		if($type==2) $where=["cxCode","<>",''];
 		$day_total =Db::name("qrd_info")->where([["ownerid","in",$uid],["is_del","=",0],['companyNo',"=",$companyNo]])
 		                         ->whereDay("createdTime",$date)
+		                         ->where($where)
 		              ->sum(Db::raw('totalPrice+th_fee'));
 		$day_thtotal=Db::name("th_source")->alias("a")
 		               ->leftJoin("qrd_info b","a.th_qrdNo=b.sequenceNo or a.th_qrdNo=b.cxCode")
 		               ->where([["b.ownerid","in",$uid],['a.th_companyNo',"=",$companyNo]])
+		               ->where($where)
 		               ->whereDay("a.createtime",$date)->sum('a.th_qrd_fee');
 		return ["sale_total"=>$day_total,"th_total"=>$day_thtotal];
 	}
 
 
+
 	/**
 	 * @param $depart_id
 	 * @return array|mixed