The invention provides a method and system for opening a door by scanning a code, a smart cabinet and a terminal. The method for opening the door by scanning the code is used for the smart cabinet andcomprises the steps of S102, detecting the type of the two-dimensional code or the barcode scanned by a scanner and a cabinet number corresponding to the code; S104, judging whether or not the two-dimensional code or the barcode belongs to item storage codes in type, and if yes, executing S106; S106, sending out a door opening signal to open the cabinet door corresponding to the cabinet number, and executing S108; S108, judging whether or not the cabinet door is opened, if yes, executing S110, and if not, executing S112; S110, uploading item storage information to a server so that the servercan push the item storage information to the user terminal; S112, uploading fault information to the server, redistributing the cabinet door, and executing S108. By means of the method for opening thedoor by scanning the code, the scanner is applied to multiple links, and the hardware utilization efficiency and the user experience are improved.