新版流量池提交
This commit is contained in:
@@ -339,24 +339,40 @@ class WorkbenchImportContactJob
|
||||
// 处理普通流量池
|
||||
if (!empty($normalPools)) {
|
||||
//过滤已删除的数据
|
||||
$packageIds = Db::name('traffic_source_package')
|
||||
$packageIds = Db::name('traffic_source_package_v1')
|
||||
->where(['isDel' => 0])
|
||||
->whereIn('id', $normalPools)
|
||||
->column('id');
|
||||
|
||||
if (!empty($packageIds)) {
|
||||
$normalData = Db::name('traffic_source_package_item')->alias('tpi')
|
||||
// ========== 旧版流量池代码(已废弃) ==========
|
||||
// $normalData = Db::name('traffic_source_package_item_v1')->alias('tpi')
|
||||
// ->join('traffic_pool_v1 tp', 'tp.identifier = tpi.identifier')
|
||||
// ->join('traffic_source_v1 ts', 'ts.identifier = tpi.identifier','left')
|
||||
// ->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id,'left')
|
||||
// ->where('tp.mobile', '>',0)
|
||||
// ->where('wici.id','null')
|
||||
// ->whereIn('tpi.packageId',$packageIds)
|
||||
// ->field('tp.id,tpi.packageId,tp.mobile as phone,ts.name')
|
||||
// ->order('tp.id DESC')
|
||||
// ->group('tpi.identifier')
|
||||
// ->limit($contactNum)
|
||||
// ->select();
|
||||
// ========== 新版流量池代码 ==========
|
||||
$normalData = Db::name('traffic_source_package_item_v1')->alias('tpi')
|
||||
->join('traffic_pool tp', 'tp.identifier = tpi.identifier')
|
||||
->join('traffic_source ts', 'ts.identifier = tpi.identifier','left')
|
||||
->join('traffic_pool_company tpc', 'tpc.poolId = tp.id AND tpc.companyId = ' . ($workbench->companyId ?? 0))
|
||||
->join('traffic_pool_source tps', 'tps.poolCompanyId = tpc.id', 'left')
|
||||
->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id,'left')
|
||||
->where('tp.mobile', '>',0)
|
||||
->where('wici.id','null')
|
||||
->whereIn('tpi.packageId',$packageIds)
|
||||
->field('tp.id,tpi.packageId,tp.mobile as phone,ts.name')
|
||||
->field('tp.id,tpi.packageId,tp.mobile as phone,tps.sourceName as name')
|
||||
->order('tp.id DESC')
|
||||
->group('tpi.identifier')
|
||||
->limit($contactNum)
|
||||
->select();
|
||||
// ========== 旧版流量池代码结束 ==========
|
||||
$data = array_merge($data, $normalData ?: []);
|
||||
}
|
||||
}
|
||||
@@ -389,12 +405,22 @@ class WorkbenchImportContactJob
|
||||
return [];
|
||||
}
|
||||
|
||||
// ========== 旧版流量池代码(已废弃) ==========
|
||||
// // 从 s2_wechat_friend 表获取好友,然后关联 traffic_pool_v1 表获取手机号
|
||||
// $data = Db::table('s2_wechat_friend')->alias('wf')
|
||||
// ->join('traffic_pool_v1 tp', 'tp.wechatId = wf.wechatId', 'left')
|
||||
// ->join('traffic_source_v1 ts', 'ts.identifier = tp.identifier', 'left')
|
||||
// ->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id, 'left')
|
||||
// ->where('wf.ownerWechatId', 'in', $wechatIds)
|
||||
// ========== 新版流量池代码 ==========
|
||||
// 从 s2_wechat_friend 表获取好友,然后关联 traffic_pool 表获取手机号
|
||||
$data = Db::table('s2_wechat_friend')->alias('wf')
|
||||
->join('traffic_pool tp', 'tp.wechatId = wf.wechatId', 'left')
|
||||
->join('traffic_source ts', 'ts.identifier = tp.identifier', 'left')
|
||||
->join('traffic_pool_company tpc', 'tpc.poolId = tp.id AND tpc.companyId = ' . ($workbench->companyId ?? 0), 'left')
|
||||
->join('traffic_pool_source tps', 'tps.poolCompanyId = tpc.id', 'left')
|
||||
->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id, 'left')
|
||||
->where('wf.ownerWechatId', 'in', $wechatIds)
|
||||
// ========== 旧版流量池代码结束 ==========
|
||||
->where('wf.isDeleted', 0)
|
||||
->where('tp.mobile', '>', 0)
|
||||
->where('wici.id', 'null')
|
||||
|
||||
Reference in New Issue
Block a user