An Assistant Magistrate is equivalent to a Deputy Prefect, and the relationship between the Assistant Magistrate and the Magistrate has always been a struggle for dominance. In Yun City, the Magistrate has the stronger backing, so naturally, Yan Tongzhi can't overpower her.
Fortunately, Yan Tongzhi has always been perceptive and doesn't antagonize the Magistrate, so he's lived quite well. Despite bungling the task this time, he might still retain his position if he offers a proper gift.
Furthermore, Yan Tongzhi is Boss Zhang's support. If Yan Tongzhi falls, Boss Zhang's gambling house will have to close immediately. Hence, Fang Miaozhen didn't suspect Boss Zhang handed over all his money to Yan Tongzhi.
Since Boss Zhang is willing to yield benefits, Fang Miaozhen agreed to put up the bulk of the money. Although she habitually seeks out Qi Guanshuangshuang for money during emergencies, it doesn't mean she can't gather funds from her own family.
