|
@@ -295,23 +295,93 @@ class Data extends BaseController
|
|
|
}
|
|
|
|
|
|
//9.转单率-今日
|
|
|
- public function orderTransferRateToday(){
|
|
|
-
|
|
|
-// sale order_type==2 咨询生成订单数
|
|
|
-
|
|
|
+ public function orderTransferRateToday()
|
|
|
+ {
|
|
|
+ $consulting = Db::name('sale')
|
|
|
+ ->alias('s')
|
|
|
+ ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
|
|
|
+ ->where(['s.order_type' => 2, 's.is_del' => 0])
|
|
|
+ ->whereDay('s.addtime')
|
|
|
+ ->group('u.itemid')
|
|
|
+ ->column('count(s.id) consulting', 'u.itemid');
|
|
|
+
|
|
|
+ $rs = Db::name('consult_order')
|
|
|
+ ->alias('c')
|
|
|
+ ->field('count(c.id) total,c.depart companyId,i.name companyName')
|
|
|
+ ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
|
|
|
+ ->where(['c.is_del' => 0])
|
|
|
+ ->whereDay('c.addtime')
|
|
|
+ ->group('c.depart')
|
|
|
+ ->append(['transfer_rate'])
|
|
|
+ ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
|
+ $consult = isset($consulting[$data['companyId']]) ? $consulting[$data['companyId']] : 0;
|
|
|
+ return round(($consult / $data['total']) * 100, 2);
|
|
|
+ })
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
|
|
|
+ return app_show(0, '请求成功', $rs);
|
|
|
|
|
|
}
|
|
|
|
|
|
//9.转单率-本月
|
|
|
- public function orderTransferRateMonth(){
|
|
|
+ public function orderTransferRateMonth()
|
|
|
+ {
|
|
|
+ $consulting = Db::name('sale')
|
|
|
+ ->alias('s')
|
|
|
+ ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
|
|
|
+ ->where(['s.order_type' => 2, 's.is_del' => 0])
|
|
|
+ ->whereMonth('s.addtime')
|
|
|
+ ->group('u.itemid')
|
|
|
+ ->column('count(s.id) consulting', 'u.itemid');
|
|
|
+
|
|
|
+ $rs = Db::name('consult_order')
|
|
|
+ ->alias('c')
|
|
|
+ ->field('count(c.id) total,c.depart companyId,i.name companyName')
|
|
|
+ ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
|
|
|
+ ->where(['c.is_del' => 0])
|
|
|
+ ->whereMonth('c.addtime')
|
|
|
+ ->group('c.depart')
|
|
|
+ ->append(['transfer_rate'])
|
|
|
+ ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
|
+ $consult = isset($consulting[$data['companyId']]) ? $consulting[$data['companyId']] : 0;
|
|
|
+ return round(($consult / $data['total']) * 100, 2);
|
|
|
+ })
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return app_show(0, '请求成功', $rs);
|
|
|
|
|
|
}
|
|
|
|
|
|
//9.转单率-今年
|
|
|
- public function orderTransferRateYear(){
|
|
|
+ public function orderTransferRateYear()
|
|
|
+ {
|
|
|
|
|
|
+ $consulting = Db::name('sale')
|
|
|
+ ->alias('s')
|
|
|
+ ->leftJoin('depart_user u', 'u.uid=s.apply_id AND u.is_del=0')
|
|
|
+ ->where(['s.order_type' => 2, 's.is_del' => 0])
|
|
|
+ ->whereYear('s.addtime', date('Y'))
|
|
|
+ ->group('u.itemid')
|
|
|
+ ->column('count(s.id) consulting', 'u.itemid');
|
|
|
+
|
|
|
+ $rs = Db::name('consult_order')
|
|
|
+ ->alias('c')
|
|
|
+ ->field('count(c.id) total,c.depart companyId,i.name companyName')
|
|
|
+ ->leftJoin('company_item i', 'i.id=c.depart AND i.is_del=0')
|
|
|
+ ->where(['c.is_del' => 0])
|
|
|
+ ->whereYear('c.addtime', date('Y'))
|
|
|
+ ->group('c.depart')
|
|
|
+ ->append(['transfer_rate'])
|
|
|
+ ->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
|
+ $consult = isset($consulting[$data['companyId']]) ? $consulting[$data['companyId']] : 0;
|
|
|
+ return round(($consult / $data['total']) * 100, 2);
|
|
|
+ })
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
|
|
|
+ return app_show(0, '请求成功', $rs);
|
|
|
|
|
|
}
|
|
|
|