wugg 1 yıl önce
ebeveyn
işleme
7e2c8a0727
3 değiştirilmiş dosya ile 60 ekleme ve 21 silme
  1. 8 6
      app/admin/controller/ExecStat.php
  2. 40 15
      app/command/Report.php
  3. 12 0
      app/common.php

+ 8 - 6
app/admin/controller/ExecStat.php

@@ -105,14 +105,16 @@ class ExecStat extends \app\admin\BaseController{
 		->toArray();
 		return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
 	}
-		public function actionList(){
+	/**
+	* @return \think\response\Json|void
+	*/
+	public function actionList(){
 		$ation=[
-			["action"=>"Q","name"=>'产品部门销售业绩'],
-			["action"=>"R","name"=>'采购部门销售业绩'],
+			["action"=>"R","name"=>'采购部门发货明细'],
 			["action"=>"L","name"=>'客服部提成业绩'],
-			["action"=>"S","name"=>'项目部提成业绩'],
-			["action"=>"T","name"=>'新媒体提成业绩'],
-			["action"=>"U","name"=>'项目部2月前提成业绩'],
+			["action"=>"S","name"=>'项目部新政策提成业绩'],
+			["action"=>"T","name"=>'新媒体回款明细'],
+			["action"=>"U","name"=>'项目部旧政策回款明细'],
 			];
 		return app_show(0,"获取成功",$ation);
 	}

+ 40 - 15
app/command/Report.php

@@ -929,9 +929,14 @@ class Report extends Command
 		$list =$Db->name("sale")->field("orderCode 销售单号,apply_name 业务人员,apply_id 业务部门,cat_id 分类,total_price 产品货款总额,addtime 日期")
 		->where($where)
 		->cursor();
+		$depart=[];
 		foreach ($list as $value){
-			$value['业务部门'] = $Db->name("depart_user")->alias("a")->leftjoin("company_item b","a.itemid=b.id")
-			->where(["a.is_del"=>0,"a.status"=>1,"a.uid"=>$value['业务部门']])->value("b.name",'');
+			if(!isset($depart[$value['业务部门']])){
+				$temp = getDepartByUid($value['业务部门']);
+				if(isset($temp['data']) && !empty($temp['data']))
+					$depart[$value['业务部门']]=$temp['data'][$value['业务部门']];
+			}
+			$value['业务部门'] = $depart[$value['业务部门']]??"";
 			$value['分类'] = $Db->name("cat")->where(["id"=>$value['分类']])->value("search","");
 			yield $value;
 		}
@@ -961,18 +966,25 @@ class Report extends Command
 			b.good_name 商品名称,
 			a.post_name 物流公司,
 			a.post_code 物流单号,
+			d.supplier_name `供应商名称`,
 			a.send_num 本次发货数量,
-			a.send_num*b.sale_price 本次发货金额,
-			b.sale_price 销售单价,
-			b.good_num-b.th_num 销售数量,
-			b.total_price-b.th_fee 销售金额,
-			d.supplier_name `供应商名称`
+			a.send_num*d.good_price 本次发货金额,
+			d.good_price 采购单价,
+			d.send_num-d.th_num 采购总数,
+			d.total_fee-d.th_fee 采购金额,
+			d.good_creater`商品创建人`,
+			d.addtime`采购单时间`
 		")
 		->where($where)
 		->cursor();
+		$depart=[];
 		foreach ($list as $value){
-			$value['业务部门'] = $Db->name("depart_user")->alias("a")->leftjoin("company_item b","a.itemid=b.id")
-			->where(["a.is_del"=>0,"a.status"=>1,"a.uid"=>$value['业务部门']])->value("b.name",'');
+			if(!isset($depart[$value['业务部门']])){
+				$temp = getDepartByUid($value['业务部门']);
+				if(isset($temp['data']) && !empty($temp['data']))
+					$depart[$value['业务部门']]=$temp['data'][$value['业务部门']];
+			}
+			$value['业务部门'] = $depart[$value['业务部门']]??"";
 			$value['一级分类'] = $Db->name("cat")->where(["id"=>$value['一级分类']])->value("search","");
 			$value['平台类型'] = $Db->name("platform")->where(["id"=>$value['平台类型']])->value("platform_name","");
 			$value['咨询类型']=$this->qrdSource[$value['咨询类型']]??"";
@@ -1042,7 +1054,8 @@ class Report extends Command
 			["b.status","=",2],
 			["b.type","=",2],
 			["a.createdTime",">=",'2023-02-01 00:00:00'], //二月之后订单
-			["a.ownerid","in",getUidByDepartId(53)]
+			["a.ownerid","in",getUidByDepartId(53)],
+			["a.ownerid","not in",[143,125]]
 			];
 		if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['b.updatetime', 'between', [date("Y-m-d 00:00:00",strtotime($param['start'])),date("Y-m-d 23:59:59",
 		strtotime($param['end']))]];
@@ -1077,8 +1090,8 @@ class Report extends Command
 						'' 毛利率区间,
 						'' 毛利率提成系数,
 						'' 明细总提成,
-						'' 明细提成30%,
-						'' 明细提成70%
+						'' `明细提成30%`,
+						'' `明细提成70%`
 				")->where($where)->cursor();
 		$ladder = [
 			"0"=>"X<10",
@@ -1094,18 +1107,25 @@ class Report extends Command
 			}
 			$value['账期回款系数']=getPayRate($value['账期']);
 			$value['毛利率'] = (1-bcdiv($value['采购单价'],$value['销售单价'],4))*100;
-			$value['毛利率区间'] =$ladder[$value['毛利率']];
 			$value['毛利率提成系数'] =getLadderRate($value['毛利率']);
+			$value['毛利率区间'] =$ladder[$value['毛利率提成系数'].''];
 			$value['明细总提成']= bcmul(bcmul($value['回款金额'] ,$value['账期回款系数']),$value['毛利率提成系数'],4);
 			$value['明细提成30%']= bcmul(bcmul(bcmul($value['回款金额'] ,$value['账期回款系数']),$value['毛利率提成系数'],4),0.3,4);
 			$value['明细提成70%']= bcmul(bcmul(bcmul($value['回款金额'] ,$value['账期回款系数']),$value['毛利率提成系数'],4),0.7,4);
+			unset($value['goodNo']);
 			yield $value;
 		}
 	}
 
 	//新媒体部门  聂亚男&&新媒体业务账户
 	private function T($param=[]){
-		$where = [["b.is_del","=",0],["a.is_del","=",0],["b.status","=",2],["b.type","=",2],["a.ownerid","in",[143,152]]];
+		$where = [
+			["b.is_del","=",0],
+			["a.is_del","=",0],
+			["b.status","=",2],
+			["b.type","=",2],
+			["a.ownerid","in",[143,125]]
+		];
 		if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['b.updatetime', 'between', [date("Y-m-d 00:00:00",strtotime($param['start'])),date("Y-m-d 23:59:59",
 		strtotime($param['end']))]];
 		$list = Db::name("qrd_info")->alias("a")
@@ -1123,6 +1143,7 @@ class Report extends Command
 		branch 客户分公司,
 		customerName 客户名称,
 		a.goodName 产品名称,
+		a.goodNo,
 		a.firstCat 一级分类,
 		a.goodPrice 销售单价,
 		if(a.cxCode='',a.sequenceNo,a.cxCode)  原销售单号,
@@ -1138,6 +1159,7 @@ class Report extends Command
 			if($value['订单类型']=='库存' &&$value['采购单编号']=='' && $value['采购单价']==0){
 				$value['采购单价'] = Db::name("cgd_info")->where(["goodNo"=>$value['goodNo'],"cgdSource"=>0])->order("id desc")->value("goodPrice",0);
 			}
+			unset($value['goodNo']);
 			yield $value;
 		}
 	}
@@ -1150,7 +1172,8 @@ class Report extends Command
 			["b.status","=",2],
 			["b.type","=",2],
 			["a.createdTime","<=",'2023-02-01 00:00:00'], //二月之前订单
-			["a.ownerid","in",getUidByDepartId(53)]
+			["a.ownerid","in",getUidByDepartId(53)],
+			["a.ownerid","not in",[143,125]]
 			];
 		if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['b.updatetime', 'between', [date("Y-m-d 00:00:00",strtotime($param['start'])),date("Y-m-d 23:59:59",
 		strtotime($param['end']))]];
@@ -1169,6 +1192,7 @@ class Report extends Command
 		branch 客户分公司,
 		customerName 客户名称,
 		a.goodName 产品名称,
+		a.goodNo,
 		a.firstCat 一级分类,
 		a.goodPrice 销售单价,
 		if(a.cxCode='',a.sequenceNo,a.cxCode)  原销售单号,
@@ -1184,6 +1208,7 @@ class Report extends Command
 			if($value['订单类型']=='库存' &&$value['采购单编号']=='' && $value['采购单价']==0){
 				$value['采购单价'] = Db::name("cgd_info")->where(["goodNo"=>$value['goodNo'],"cgdSource"=>0])->order("id desc")->value("goodPrice",0);
 			}
+			unset($value['goodNo']);
 			yield $value;
 		}
 	}

+ 12 - 0
app/common.php

@@ -717,6 +717,18 @@ if(!function_exists("getUidByDepartId")){
 		return $uidArr;
 	}
 }
+if(!function_exists("getDepartByUid")){
+	/**
+	 * @param $depart_id
+	 * @return array|mixed
+	 */
+	function getDepartByUid($uid=0,$get_tops=2):array{
+		$host = Config::get("app");
+        $url = $host["api_host"]."/get_company_name_by_uid";
+        $response=curl_request($url,['uid'=>$uid,'get_tops'=>$get_tops]);
+        return json_decode($response,true);
+	}
+}
 
 if(!function_exists("getPayRate")){
 	/**