handleDiyData(); } /** * 处理自定义数据 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function handleDiyData() { $diy_model = new Diy(); $where = [ [ 'value', '<>', '' ] ]; $field = 'id,name,title,template,value'; $list = $diy_model->where($where)->field($field)->select()->toArray(); if (!empty($list)) { foreach ($list as $k => $v) { $diy_data = json_decode($v[ 'value' ], true); foreach ($diy_data[ 'value' ] as $ck => $cv) { // 图片广告 组件 if ($cv[ 'componentName' ] == 'ImageAds') { if (!isset($diy_data[ 'value' ][ $ck ][ 'isSameScreen' ])) { $diy_data[ 'value' ][ $ck ][ 'isSameScreen' ] = false; } } } $diy_data = json_encode($diy_data); $diy_model->where([ [ 'id', '=', $v[ 'id' ] ] ])->update([ 'value' => $diy_data ]); } } } }