$param_data['num'] = 1000;标签:read,where,list,一致,msg,data,id,赋值 From: https://blog.51cto.com/u_15902893/5912447
$list = (new \app\common\model\Order())->get_user_list($param_data);
$list = $list->toArray();
$list_data = $list['data'];
$not_read_msg = [];
if (!empty($list_data)){
$g_ids = array_column($list_data,'id');
// 判断 是否 有 未读 的 消息
$msg_where['is_source'] = ['=','order'];
$msg_where['operate_id'] = ['in',$g_ids];
$msg_where['is_read'] = ['=',0];
$msg_where['is_admin'] = ['=',1];
$not_read_msg = (new LeaveMessage())
->where($msg_where)
// ->column('operate_id,count(id) as num')
->select();
$lists = json_decode( json_encode( $not_read_msg),true);//将对象转换成数组
if ($list){
$arr = array_column($lists, 'operate_id', 'id');
$not_read_msg = array_count_values($arr);//统计每一个商品出现的次数
}
}
//循环判断key是否一致
foreach ($list_data as $k=>$v){
foreach ($not_read_msg as $key=>$val){
if ($v['id'] == $key){
$list_data[$k]['tip_count'] = $val;
}
}
}