|
@@ -902,6 +902,7 @@ class Report extends Command
|
|
yield $value;
|
|
yield $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
//产品部门销售业绩
|
|
//产品部门销售业绩
|
|
private function Q($param=[]){
|
|
private function Q($param=[]){
|
|
$where = [["is_del","=",0],["status","in",[0,1,2]]];
|
|
$where = [["is_del","=",0],["status","in",[0,1,2]]];
|
|
@@ -920,7 +921,7 @@ class Report extends Command
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //采购部门销售业绩
|
|
|
|
|
|
+ //采购部门销售业绩
|
|
private function R($param=[]){
|
|
private function R($param=[]){
|
|
$where = [["a.is_del","=",0],["a.status","=",2],["b.is_stock","=",0]];
|
|
$where = [["a.is_del","=",0],["a.status","=",2],["b.is_stock","=",0]];
|
|
if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['a.sendtime', 'between', [date("Y-m-d 00:00:00",
|
|
if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['a.sendtime', 'between', [date("Y-m-d 00:00:00",
|
|
@@ -964,9 +965,113 @@ class Report extends Command
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //回款提成计算业绩
|
|
|
|
|
|
+ //客服部 52客服部@百辰荣达
|
|
private function L($param=[]){
|
|
private function L($param=[]){
|
|
- $where = [["b.is_del","=",0],["a.is_del","=",0],["b.status","=",2],["b.type","=",2]];
|
|
|
|
|
|
+ $where = [["b.is_del","=",0],["a.is_del","=",0],["b.status","=",2],["b.type","=",2],["a.ownerid","in",getUidByDepartId(52)]];
|
|
|
|
+ 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")
|
|
|
|
+ ->rightJoin("assoc b","a.sequenceNo=b.orderCode")
|
|
|
|
+// ->leftJoin("cgd_info c","c.sequenceNo = a.cgdNo and c.is_del=0")
|
|
|
|
+ ->field(" a.department 部门,
|
|
|
|
+ a.ownerName 销售人员,
|
|
|
|
+ platName 平台类型,
|
|
|
|
+ a.companyName 公司名称,
|
|
|
|
+ if(qrdType=1,'库存',if(qrdType=2,'非库存','咨询')) 订单类型,
|
|
|
|
+ a.sequenceNo 确认单编号,
|
|
|
|
+ a.cgdNo 采购单编号,
|
|
|
|
+ customerAttr 客户属性,
|
|
|
|
+ branch 客户分公司,
|
|
|
|
+ customerName 客户名称,
|
|
|
|
+ a.goodName 产品名称,
|
|
|
|
+ a.firstCat 一级分类,
|
|
|
|
+ a.goodPrice 销售单价,
|
|
|
|
+ if(a.cxCode='',a.sequenceNo,a.cxCode) 原销售单号,
|
|
|
|
+ a.goodNum 下单数量,
|
|
|
|
+ a.totalPrice 销售总额,
|
|
|
|
+ a.createdTime 销售下单时间,
|
|
|
|
+ b.updatetime 回款日期,
|
|
|
|
+ b.cancel_fee 回款金额,
|
|
|
|
+ ceil(DATEDIFF(b.updatetime,a.createdTime)/30) 账期,
|
|
|
|
+ a.ownerName 实际销售人员,
|
|
|
|
+ 0 提成金额
|
|
|
|
+ ")
|
|
|
|
+ ->where($where)->cursor();
|
|
|
|
+ $returnpay =[
|
|
|
|
+ 3=>1,
|
|
|
|
+ 4=>0.6,
|
|
|
|
+ 5=>0.4,
|
|
|
|
+ 6=>0,
|
|
|
|
+ ];
|
|
|
|
+ $cat=[
|
|
|
|
+ 0.0036,//常规分类
|
|
|
|
+ 0.0002,//非常规
|
|
|
|
+ 0.0018];//会议分类
|
|
|
|
+ $normal=['贵金属','工艺收藏','数码电子','大家电'];
|
|
|
|
+ $huiyi=['会议培训制品','会议培训展会服务'];
|
|
|
|
+ foreach ($list as $value){
|
|
|
|
+ $totalPrice=$value['回款金额'];
|
|
|
|
+ $rate=getPayRate($value['账期']);
|
|
|
|
+ $cat_rate=0.0036;
|
|
|
|
+ if(in_array($value['一级分类'],$normal)) $cat_rate=0.0002;
|
|
|
|
+ if(in_array($value['一级分类'],$huiyi)) $cat_rate=0.0018;
|
|
|
|
+ $value['提成'] = bcmul(bcmul($totalPrice ,$rate),$cat_rate,4);
|
|
|
|
+ yield $value;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //项目部业绩 53项目部@普润心堂
|
|
|
|
+ private function S($param=[]){
|
|
|
|
+ $where = [["b.is_del","=",0],["a.is_del","=",0],["b.status","=",2],["b.type","=",2],["a.ownerid","in",getUidByDepartId(53)]];
|
|
|
|
+ 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")
|
|
|
|
+ ->rightJoin("assoc b","a.sequenceNo=b.orderCode")
|
|
|
|
+ ->leftJoin("cgd_info c","c.sequenceNo = a.cgdNo and c.is_del=0")
|
|
|
|
+ ->field(" a.department 部门,
|
|
|
|
+ a.ownerName 销售人员,
|
|
|
|
+ platName 平台类型,
|
|
|
|
+ a.companyName 公司名称,
|
|
|
|
+ if(qrdType=1,'库存',if(qrdType=2,'非库存','咨询')) 订单类型,
|
|
|
|
+ a.sequenceNo 确认单编号,
|
|
|
|
+ a.cgdNo 采购单编号,
|
|
|
|
+ customerAttr 客户属性,
|
|
|
|
+ branch 客户分公司,
|
|
|
|
+ customerName 客户名称,
|
|
|
|
+ a.goodName 产品名称,
|
|
|
|
+ a.goodNo,
|
|
|
|
+ a.firstCat 一级分类,
|
|
|
|
+ a.goodPrice 销售单价,
|
|
|
|
+ if(a.cxCode='',a.sequenceNo,a.cxCode) 原销售单号,
|
|
|
|
+ ifnull(c.goodPrice,0) 采购单价,
|
|
|
|
+ a.goodNum 下单数量,
|
|
|
|
+ a.totalPrice 销售总额,
|
|
|
|
+ a.createdTime 销售下单时间,
|
|
|
|
+ b.updatetime 回款日期,
|
|
|
|
+ b.cancel_fee 回款金额,
|
|
|
|
+ ceil(DATEDIFF(b.updatetime,a.createdTime)/30) 账期,
|
|
|
|
+ '' 项目经理,
|
|
|
|
+ 0 总提成,
|
|
|
|
+ 0 个人提成,
|
|
|
|
+ 0 经理提成
|
|
|
|
+ ")
|
|
|
|
+ ->where($where)->cursor();
|
|
|
|
+ foreach ($list as $value){
|
|
|
|
+ if($value['订单类型']=='库存' &&$value['采购单编号']=='' && $value['采购单价']==0){
|
|
|
|
+ $value['采购单价'] = Db::name("cgd_info")->where(["goodNo"=>$value['goodNo'],"cgdSource"=>0])->order("id desc")->value("goodPrice",0);
|
|
|
|
+ }
|
|
|
|
+ $sale_rate = (1-bcdiv($value['采购单价'],$value['销售单价'],4))*100;
|
|
|
|
+ $laddrate =getLadderRate($sale_rate);
|
|
|
|
+ $rate=getPayRate($value['账期']);
|
|
|
|
+ $value['总提成']= bcmul(bcmul($value['回款金额'] ,$rate),$laddrate,4);
|
|
|
|
+ $value['个人提成']= bcmul(bcmul(bcmul($value['回款金额'] ,$rate),$laddrate,4),0.3,4);
|
|
|
|
+ $value['经理提成']= bcmul(bcmul(bcmul($value['回款金额'] ,$rate),$laddrate,4),0.7,4);
|
|
|
|
+ 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]]];
|
|
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",
|
|
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']))]];
|
|
strtotime($param['end']))]];
|
|
$list = Db::name("qrd_info")->alias("a")
|
|
$list = Db::name("qrd_info")->alias("a")
|
|
@@ -995,6 +1100,9 @@ class Report extends Command
|
|
ceil(DATEDIFF(b.updatetime,a.createdTime)/30) 账期")
|
|
ceil(DATEDIFF(b.updatetime,a.createdTime)/30) 账期")
|
|
->where($where)->cursor();
|
|
->where($where)->cursor();
|
|
foreach ($list as $value){
|
|
foreach ($list as $value){
|
|
|
|
+ if($value['订单类型']=='库存' &&$value['采购单编号']=='' && $value['采购单价']==0){
|
|
|
|
+ $value['采购单价'] = Db::name("cgd_info")->where(["goodNo"=>$value['goodNo'],"cgdSource"=>0])->order("id desc")->value("goodPrice",0);
|
|
|
|
+ }
|
|
yield $value;
|
|
yield $value;
|
|
}
|
|
}
|
|
}
|
|
}
|