<?php
declare(strict_types=1);date_default_timezone_set('Asia/Shanghai');require __DIR__.'/db.php';require __DIR__.'/StrictWire.php';
$gate=json_decode(file_get_contents(__DIR__.'/structure-'.$lane.'.json'),true);foreach(['sign_action','sign_address','upload_file','wxapp_setting','store_setting','sign','sign_user'] as $t){$g=$gate['tables'][$t];$check(count($g['columns'])>0&&$g['foreign_keys']===0&&$g['triggers']===0,'Original metadata '.$t);if(isset($g['own_collision']))$check($g['own_collision']===0,'Original own collision '.$t);}
$boundary=json_decode(file_get_contents($base.'/__boundary'),true);foreach($boundary['hashes'] as $f=>$sha)$check(hash_file('sha256',$root.'/'.$f)===$sha,'Actual source '.$f);$check($boundary['hashes']['app/common/database/DmBuilder.php']==='58e1e79ce69881cc305c6fd33adec0e9a3d030ac15b4c00ae464cbaa4cce2b59','Builder source lock');
define('TP_ENV','poc');define('BUSINESS','aizhct');define('ENTERPRISE_NO','10001');require $root.'/vendor/autoload.php';spl_autoload_register(static function($class)use($root){foreach(['app\\'=>'app/','cores\\'=>'cores/'] as $prefix=>$dir)if(strpos($class,$prefix)===0){$f=$root.'/'.$dir.str_replace('\\','/',substr($class,strlen($prefix))).'.php';if(is_file($f))require $f;}},true,true);$app=new \think\App($root);$app->setEnvName('poc');$app->setRuntimePath($runtime.'/fixture-runtime/');$app->initialize();$log=$app->config->get('log');$log['close']=true;foreach($log['channels'] as &$lc)$lc['close']=true;unset($lc);$app->config->set($log,'log');$cache=new \think\cache\driver\File($app,['path'=>$runtime.'/cache/','prefix'=>'','expire'=>0]);
$snapshot=static function()use($q){$out=[];foreach(['sign_action'=>'store_id NOT IN (2147001571,2147001572)','sign_address'=>'action_id NOT IN (SELECT id FROM yoshop_sign_action WHERE store_id IN (2147001571,2147001572))','upload_file'=>'store_id NOT IN (2147001571,2147001572)','store_setting'=>'store_id NOT IN (2147001571,2147001572)','wxapp_setting'=>'1=1','sign'=>'1=1','sign_user'=>'1=1'] as $t=>$where){$pk=in_array($t,['wxapp_setting','store_setting'],true)?'store_id':($t==='upload_file'?'file_id':'id');$r=$q('SELECT * FROM yoshop_'.$t.' WHERE '.$where.' ORDER BY '.$pk);$out[$t]=['rows'=>count($r),'sha256'=>hash('sha256',serialize($r))];}return $out;};
$own=static function()use($q){$out=[];$out['action']=$q('SELECT * FROM yoshop_sign_action WHERE store_id IN (2147001571,2147001572) ORDER BY id');$out['address']=$q('SELECT * FROM yoshop_sign_address WHERE action_id IN (SELECT id FROM yoshop_sign_action WHERE store_id IN (2147001571,2147001572)) ORDER BY id');$out['file']=$q('SELECT * FROM yoshop_upload_file WHERE store_id IN (2147001571,2147001572) ORDER BY file_id');$out['setting']=$q('SELECT * FROM yoshop_store_setting WHERE store_id IN (2147001571,2147001572) ORDER BY store_id');return $out;};
$cast=static function(array $row,string $table)use($gate){$out=[];foreach($gate['tables'][$table]['columns'] as $col){$k=$col['column_name'];$v=$row[$k];$type=strtolower($col['data_type']);if(in_array($type,['int','integer','bigint','tinyint','smallint'],true))$out[$k]=(int)$v;elseif(in_array($type,['datetime','timestamp','date'],true))$out[$k]=substr((string)$v,0,19);else $out[$k]=$v;}return $out;};
