Update ConversionLogic.php
This commit is contained in:
@@ -9,6 +9,7 @@ use app\adminapi\logic\tcm\DiagnosisLogic;
|
||||
use app\common\model\finance\AccountCost;
|
||||
use app\common\service\DataScope\DataScopeService;
|
||||
use app\common\service\qywx\MediaChannelService;
|
||||
use think\db\Query;
|
||||
use think\facade\Db;
|
||||
|
||||
class ConversionLogic
|
||||
@@ -904,10 +905,16 @@ class ConversionLogic
|
||||
->leftJoin('tcm_diagnosis u', 'a.patient_id = u.id')
|
||||
->where('a.appointment_date', '>=', $startDate)
|
||||
->where('a.appointment_date', '<=', $endDate)
|
||||
->whereRaw('(u.id IS NULL OR u.delete_time IS NULL)')
|
||||
->fieldRaw("{$sourceExpr} AS source_admin_id, a.patient_id AS diagnosis_id, COUNT(*) AS appointment_count, SUM(CASE WHEN a.status = 3 THEN 1 ELSE 0 END) AS interview_count")
|
||||
->group("{$sourceExpr}, a.patient_id");
|
||||
|
||||
$query->where(static function (Query $subQuery): void {
|
||||
$subQuery->whereNull('u.id')
|
||||
->whereOr(static function (Query $orQuery): void {
|
||||
$orQuery->whereNull('u.delete_time');
|
||||
});
|
||||
});
|
||||
|
||||
if ($mediaChannel !== null) {
|
||||
$legacyChannelValues = MediaChannelService::getLegacyAppointmentChannelValues($mediaChannel);
|
||||
if ($legacyChannelValues !== []) {
|
||||
@@ -976,7 +983,9 @@ class ConversionLogic
|
||||
->where('o.status', 2)
|
||||
->where('o.order_type', 1)
|
||||
->where('o.amount', 5)
|
||||
->whereRaw('(o.payment_time IS NOT NULL AND o.payment_time <> "" AND o.payment_time >= ? AND o.payment_time <= ?)', [$startDateTime, $endDateTime])
|
||||
->whereNotNull('o.payment_time')
|
||||
->where('o.payment_time', '<>', '')
|
||||
->whereBetweenTime('o.payment_time', $startDateTime, $endDateTime)
|
||||
->fieldRaw('o.creator_id AS source_admin_id, COUNT(*) AS paid_appointment_count')
|
||||
->group('o.creator_id');
|
||||
|
||||
@@ -1896,7 +1905,8 @@ class ConversionLogic
|
||||
// 单条 LIKE 没命中再退化全表(量大时会慢,因此仅在极少数员工场景下兜底)。
|
||||
$followRows = Db::name('qywx_external_contact')
|
||||
->whereNull('delete_time')
|
||||
->whereRaw('follow_users IS NOT NULL AND follow_users <> ""')
|
||||
->whereNotNull('follow_users')
|
||||
->where('follow_users', '<>', '')
|
||||
->limit(2000)
|
||||
->field('follow_users')
|
||||
->select()
|
||||
@@ -2385,4 +2395,5 @@ class ConversionLogic
|
||||
|
||||
return round($numerator / $denominator, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user