代码优化
This commit is contained in:
@@ -24,11 +24,17 @@ class CustomerServiceController extends BaseController
|
||||
|
||||
|
||||
$wechatAliveTime = time() - 86400 * 30;
|
||||
$list = Db::table('s2_wechat_account')
|
||||
->whereIn('id',$accountIds)
|
||||
->where('wechatAliveTime','>',$wechatAliveTime)
|
||||
->order('id desc')
|
||||
->group('id')
|
||||
$list = Db::table('s2_wechat_account')->alias('wa')
|
||||
->join(['s2_device' => 'd'],'wa.currentDeviceId = d.id','LEFT')
|
||||
->whereIn('wa.id',$accountIds)
|
||||
->where('wa.wechatAliveTime','>',$wechatAliveTime)
|
||||
->order('wa.id desc')
|
||||
->group('wa.id')
|
||||
->field([
|
||||
'wa.*',
|
||||
'd.imei',
|
||||
'd.extra',
|
||||
])
|
||||
->select();
|
||||
foreach ($list as $k=>&$v){
|
||||
$v['createTime'] = !empty($v['createTime']) ? date('Y-m-d H:i:s',$v['createTime']) : '';
|
||||
@@ -37,11 +43,16 @@ class CustomerServiceController extends BaseController
|
||||
$momentsSetting = Db::name('kf_moments_settings')->where(['userId' => $userId,'companyId' => $companyId,'wechatId' =>$v['id']])->find();
|
||||
$v['momentsMax'] = !empty($momentsSetting['max']) ? $momentsSetting['max'] : 5;
|
||||
$v['momentsNum'] = !empty($momentsSetting['sendNum']) ? $momentsSetting['sendNum'] : 0;
|
||||
|
||||
$v['deviceExtra'] = json_decode($v['extra'],true);
|
||||
$v['deviceExtra']['imei'] = $v['imei'];
|
||||
$v['deviceExtra']['memo'] = $v['deviceMemo'];
|
||||
unset(
|
||||
$v['accountUserName'],
|
||||
$v['accountRealName'],
|
||||
$v['accountNickname'],
|
||||
$v['extra'],
|
||||
$v['imei'],
|
||||
$v['deviceMemo'],
|
||||
);
|
||||
}
|
||||
unset($v);
|
||||
|
||||
Reference in New Issue
Block a user