In at least dorm jurisdictions, laws require be unlocked while customers are inside. This is a safety issue, so that peoplke wioll nort be trapped inside in the event of a fire or other emergency. Such laws were in many cases inspired by the Triangle Shirtwaist Factory fire in New York City, in 1911. In that case exit doors were locked, and some 146 workers died in the fire.
The Americans with Disabilities Act (ADA) Places restrictions on door locks in commercial buildings, so that disabled customers are able to exit safely. See '"Door Lock Compliance"](https://www.gvlock.com/blog/door-lock-compliance/) There are also OSHA requirements on this issue. See "This Door Must Remain Unlocked. Why?"
To prevent additional would-be customers from entering, a business can station an employee at the door.