|
@@ -397,20 +397,29 @@ class Data extends BaseController
|
|
|
//9.转单率-今日
|
|
|
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' => 3, 's.is_del' => 0])//order_type==3 咨询采反
|
|
|
- ->whereDay('s.addtime')
|
|
|
- ->group('u.itemid')
|
|
|
- ->column('count(s.id) consulting', 'u.itemid');
|
|
|
|
|
|
+ //当天所有的咨询单
|
|
|
+ $temp_sql = Db::name('consult_info')
|
|
|
+ ->field('zxNo')
|
|
|
+ ->where(['is_del' => 0])
|
|
|
+ ->whereDay('addtime')
|
|
|
+ ->buildSql();
|
|
|
+
|
|
|
+ //转单成功的数据
|
|
|
+ $consulting = Db::name('consult_info')
|
|
|
+ ->alias('ci')
|
|
|
+ ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
|
|
|
+ ->where('ci.zxNo IN '.$temp_sql)
|
|
|
+ ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
|
|
|
+ ->group('co.depart')
|
|
|
+ ->column('count(ci.id) total', 'co.depart');
|
|
|
+
|
|
|
+ //处理全部数据
|
|
|
$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')
|
|
|
+ ->where('c.zxNo IN '.$temp_sql)
|
|
|
->group('c.depart')
|
|
|
->append(['transfer_rate'])
|
|
|
->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
@@ -427,20 +436,29 @@ class Data extends BaseController
|
|
|
//9.转单率-本月
|
|
|
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' => 3, 's.is_del' => 0])//order_type==3 咨询采反
|
|
|
- ->whereMonth('s.addtime')
|
|
|
- ->group('u.itemid')
|
|
|
- ->column('count(s.id) consulting', 'u.itemid');
|
|
|
|
|
|
+ //当天所有的咨询单
|
|
|
+ $temp_sql = Db::name('consult_info')
|
|
|
+ ->field('zxNo')
|
|
|
+ ->where(['is_del' => 0])
|
|
|
+ ->whereMonth('addtime')
|
|
|
+ ->buildSql();
|
|
|
+
|
|
|
+ //转单成功的数据
|
|
|
+ $consulting = Db::name('consult_info')
|
|
|
+ ->alias('ci')
|
|
|
+ ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
|
|
|
+ ->where('ci.zxNo IN '.$temp_sql)
|
|
|
+ ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
|
|
|
+ ->group('co.depart')
|
|
|
+ ->column('count(ci.id) total', 'co.depart');
|
|
|
+
|
|
|
+ //处理全部数据
|
|
|
$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')
|
|
|
+ ->where('c.zxNo IN '.$temp_sql)
|
|
|
->group('c.depart')
|
|
|
->append(['transfer_rate'])
|
|
|
->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
@@ -458,20 +476,28 @@ class Data extends BaseController
|
|
|
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' => 3, 's.is_del' => 0])//order_type==3 咨询采反
|
|
|
- ->whereYear('s.addtime', date('Y'))
|
|
|
- ->group('u.itemid')
|
|
|
- ->column('count(s.id) consulting', 'u.itemid');
|
|
|
+ //当天所有的咨询单
|
|
|
+ $temp_sql = Db::name('consult_info')
|
|
|
+ ->field('zxNo')
|
|
|
+ ->where(['is_del' => 0])
|
|
|
+ ->whereYear('addtime')
|
|
|
+ ->buildSql();
|
|
|
+
|
|
|
+ //转单成功的数据
|
|
|
+ $consulting = Db::name('consult_info')
|
|
|
+ ->alias('ci')
|
|
|
+ ->where(['ci.status' => 5, 'ci.is_del' => 0])//status==5 成功转单
|
|
|
+ ->where('ci.zxNo IN '.$temp_sql)
|
|
|
+ ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo AND co.is_del=0')
|
|
|
+ ->group('co.depart')
|
|
|
+ ->column('count(ci.id) total', 'co.depart');
|
|
|
|
|
|
+ //处理全部数据
|
|
|
$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'))
|
|
|
+ ->where('c.zxNo IN '.$temp_sql)
|
|
|
->group('c.depart')
|
|
|
->append(['transfer_rate'])
|
|
|
->withAttr('transfer_rate', function ($val, $data) use ($consulting) {
|
|
@@ -482,7 +508,6 @@ class Data extends BaseController
|
|
|
->toArray();
|
|
|
|
|
|
return app_show(0, '请求成功', $rs);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|