The invention discloses a novel smart code-scanning mechanism, and belongs to the technical field of logistics. The mechanism comprises a code-scanning execution module, a package clamping module, and a package detection module, wherein the code-scanning execution module comprises a base, a sliding chute, a bearing, a lead screw, a code scanner, a round disc, a motor, a shaft coupler and a computer; the sliding chute is formed on the base, the lead screw is fixedly connected with the base through the bearing, the round disc is in threaded connection with the lead screw, a sliding rod is fixedly connected with the round disc, the sliding rod is matched with the sliding chute, the code scanner is connected with the round disc, the motor is connected with the lead screw of the shaft coupler, the motor is connected with the computer, and the computer is connected with the package detection module; the package detection module is matched with the package clamping module so as to precisely control the fluctuation distance of the code scanner, the packages with different sizes and the packages with unfixed bar code positions can be precisely scanned, so that the device is highly automatic and intelligent.