私域操盘手 - 调整扫码添加设备后的回调检测逻辑
This commit is contained in:
@@ -62,17 +62,36 @@ class GetAddResultedV1Controller extends BaseController
|
||||
{
|
||||
$ids = implode(',', $ids);
|
||||
|
||||
$sql = "insert into ck_device(`id`, `imei`, `model`, phone, operatingSystem,memo,alive,brand,rooted,xPosed,softwareVersion,extra,createTime,updateTime,deleteTime,companyId)
|
||||
select
|
||||
d.id,d.imei,d.model,d.phone,d.operatingSystem,d.memo,d.alive,d.brand,d.rooted,d.xPosed,d.softwareVersion,d.extra,d.createTime,d.lastUpdateTime,d.deleteTime,a.departmentId companyId
|
||||
from s2_device d
|
||||
join s2_company_account a on d.currentAccountId = a.id
|
||||
where isDeleted = 0 and deletedAndStop = 0 and d.id not in ({$ids}) and a.departmentId = {$companyId}
|
||||
";
|
||||
$sql = "INSERT INTO ck_device(`id`, `imei`, `model`, phone, operatingSystem, memo, alive, brand, rooted, xPosed, softwareVersion, extra, createTime, updateTime, deleteTime, companyId)
|
||||
SELECT
|
||||
d.id, d.imei, d.model, d.phone, d.operatingSystem, d.memo, d.alive, d.brand, d.rooted, d.xPosed, d.softwareVersion, d.extra, d.createTime, d.lastUpdateTime, d.deleteTime, a.departmentId AS companyId
|
||||
FROM s2_device d
|
||||
JOIN s2_company_account a ON d.currentAccountId = a.id
|
||||
WHERE isDeleted = 0 AND deletedAndStop = 0 AND d.id NOT IN ({$ids}) AND a.departmentId = {$companyId}
|
||||
ON DUPLICATE KEY UPDATE
|
||||
imei = VALUES(imei),
|
||||
model = VALUES(model),
|
||||
phone = VALUES(phone),
|
||||
operatingSystem = VALUES(operatingSystem),
|
||||
memo = VALUES(memo),
|
||||
alive = VALUES(alive),
|
||||
brand = VALUES(brand),
|
||||
rooted = VALUES(rooted),
|
||||
xPosed = VALUES(xPosed),
|
||||
softwareVersion = VALUES(softwareVersion),
|
||||
extra = VALUES(extra),
|
||||
updateTime = VALUES(updateTime),
|
||||
deleteTime = VALUES(deleteTime),
|
||||
companyId = VALUES(companyId)";
|
||||
|
||||
Db::query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前设备数量
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getCkbDeviceCount(): int
|
||||
{
|
||||
return DeviceModel::where(
|
||||
|
||||
@@ -30,7 +30,13 @@ class PostCreateAddFriendPlanV1Controller extends Controller
|
||||
$params = $this->request->only(['name', 'sceneId', 'status', 'reqConf', 'msgConf', 'tagConf']);
|
||||
|
||||
|
||||
dd($params);
|
||||
dd(
|
||||
|
||||
json_decode($params['reqConf']),
|
||||
json_decode($params['tagConf']),
|
||||
json_decode($params['msgConf'])
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,22 @@ class GetAddResultedDevicesController extends Controller
|
||||
$this->getNewDeviceFromS2_device($deviceIds, $companyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前设备数量
|
||||
*
|
||||
* @param int $accountId
|
||||
* @return int
|
||||
*/
|
||||
protected function getCkbDeviceCount(int $accountId): int
|
||||
{
|
||||
return DeviceModel::where(
|
||||
[
|
||||
'companyId' => $this->getCompanyIdByAccountId($accountId)
|
||||
]
|
||||
)
|
||||
->count('*');
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 s2_device 导入数据。
|
||||
*
|
||||
@@ -62,13 +78,27 @@ class GetAddResultedDevicesController extends Controller
|
||||
{
|
||||
$ids = implode(',', $ids);
|
||||
|
||||
$sql = "insert into ck_device(`id`, `imei`, `model`, phone, operatingSystem,memo,alive,brand,rooted,xPosed,softwareVersion,extra,createTime,updateTime,deleteTime,companyId)
|
||||
select
|
||||
d.id,d.imei,d.model,d.phone,d.operatingSystem,d.memo,d.alive,d.brand,d.rooted,d.xPosed,d.softwareVersion,d.extra,d.createTime,d.lastUpdateTime,d.deleteTime,a.departmentId companyId
|
||||
from s2_device d
|
||||
join s2_company_account a on d.currentAccountId = a.id
|
||||
where isDeleted = 0 and deletedAndStop = 0 and d.id not in ({$ids}) and a.departmentId = {$companyId}
|
||||
";
|
||||
$sql = "INSERT INTO ck_device(`id`, `imei`, `model`, phone, operatingSystem, memo, alive, brand, rooted, xPosed, softwareVersion, extra, createTime, updateTime, deleteTime, companyId)
|
||||
SELECT
|
||||
d.id, d.imei, d.model, d.phone, d.operatingSystem, d.memo, d.alive, d.brand, d.rooted, d.xPosed, d.softwareVersion, d.extra, d.createTime, d.lastUpdateTime, d.deleteTime, a.departmentId AS companyId
|
||||
FROM s2_device d
|
||||
JOIN s2_company_account a ON d.currentAccountId = a.id
|
||||
WHERE isDeleted = 0 AND deletedAndStop = 0 AND d.id NOT IN ({$ids}) AND a.departmentId = {$companyId}
|
||||
ON DUPLICATE KEY UPDATE
|
||||
imei = VALUES(imei),
|
||||
model = VALUES(model),
|
||||
phone = VALUES(phone),
|
||||
operatingSystem = VALUES(operatingSystem),
|
||||
memo = VALUES(memo),
|
||||
alive = VALUES(alive),
|
||||
brand = VALUES(brand),
|
||||
rooted = VALUES(rooted),
|
||||
xPosed = VALUES(xPosed),
|
||||
softwareVersion = VALUES(softwareVersion),
|
||||
extra = VALUES(extra),
|
||||
updateTime = VALUES(updateTime),
|
||||
deleteTime = VALUES(deleteTime),
|
||||
companyId = VALUES(companyId)";
|
||||
|
||||
Db::query($sql);
|
||||
}
|
||||
@@ -85,7 +115,7 @@ class GetAddResultedDevicesController extends Controller
|
||||
[
|
||||
'accountId' => $accountId,
|
||||
'pageIndex' => 0,
|
||||
'pageSize' => 1
|
||||
'pageSize' => 100
|
||||
],
|
||||
true
|
||||
);
|
||||
@@ -94,8 +124,7 @@ class GetAddResultedDevicesController extends Controller
|
||||
$result = $result['data']['results'][0] ?? false;
|
||||
|
||||
return $result ? (
|
||||
// 125是前端延迟5秒 + 轮询120次 1次/s
|
||||
time() - strtotime($result['lastUpdateTime']) <= 65
|
||||
count($result) > $this->getCkbDeviceCount($accountId)
|
||||
) : false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user