Is it okay if the patent is invalid after the previous patent is invalid?

I can rewrite it. The party who applied before can declare your patent invalid unless you have used it before them, so you can declare the other party's patent invalid. The appearance of utility models is different, which cannot be a reason for you to defend yourself, because this lawsuit will only be aimed at utility models that protect the internal structure. The utility model you applied for is similar in structure. It seems that the other party is prepared, one year earlier than you, and the structure and function are similar. Your chances of winning are really slim.

Basically, your defense can be based on the fact that the design is your own, but it happens to be similar to the other party. You can also grant yourself a patent right to the Patent Office because you didn't know that the other party applied for a patent and your application was successful. Since it is almost the same, why can the application be successful? Since the application was successful, why can't it be sold? After that, the court debate is up to you.

I suggest you find an intellectual property lawyer, because the current situation is really unfavorable to you. If the court finally decides that you have to pay compensation, at least hiring a lawyer will make you lose a lot. Moreover, hiring a lawyer does not necessarily compensate, and this lawsuit is not necessarily without room for manoeuvre.

Good luck.