Deadlock: How to prevent Primary Key Lock in SELECT
Making queries faster is a way to minimize deadlocks, if not avoid them.

INDEX(origin, lastLogin)


should help the first query.

The UPDATE should be helped by

INDEX(uid, chips)


Please provide SHOW CREATE TABLE if you wish to discuss thing further.

How many cron jobs run at midnight?  If more than one, stagger them.  Otherwise the buffalo will stumble over each other.

If you are collecting "yesterday's" data, you should include a stopper -- else it could include a few records from "today":

WHERE lastLogin &gt;= '2017-05-31' - INTERVAL 1 DAY
  AND lastLogin  &lt; '2017-05-31'


With that, it won't matter if you schedule it a few minutes after midnight.

I cringed at --1 and + -1, but I guess they work OK.