= 6) { return substr($id, 0, 6); } return str_pad($id, 6, '0', STR_PAD_RIGHT); } /** * 汇付银行卡 card_info.area_id 要求地级市编码(如安顺 520400), * 小程序省市区选到区县时可能是 520402,需上提为 XXYY00。 */ public static function toHuifuCityCode($code) { $code = self::toCode($code); if ($code === '' || strlen($code) !== 6) { return $code; } if (substr($code, 4, 2) !== '00') { return substr($code, 0, 4) . '00'; } return $code; } }