def addUserInfo(self, newUserInfo, ownerTaobaoId, max_acceptable_price): # Don't buy the item from yourself. if ownerTaobaoId == newUserInfo.taobaoId: return if newUserInfo.buyer_payment > max_acceptable_price: return # If the userInfo exists, below is the logic which allow to continue. Otherwise just return, don't add userInfo anymore. userInfo = database.getActiveUserByTaobaoId(newUserInfo.taobaoId) if userInfo: # Succeed buy/Confirmed order and the last status time more than 31 days will allow to continue. if (userInfo.status == UserInfo.Status_Succeed_Buy or userInfo.status == UserInfo.Status_Confirmed_Payment): if (datetime.now() - userInfo.last_status_time).days < 31: return # NotTo buy and the last status time more than 6 days will allow to continue. elif userInfo.status == UserInfo.Status_NotTo_Buy: if (datetime.now() - userInfo.last_status_time).days < 6: return # Failed buy and the last status time more than 1 days will allow to continue. elif userInfo.status == UserInfo.Status_Failed_Buy: if (datetime.now() - userInfo.last_status_time).days < 1: return elif userInfo.status == UserInfo.Status_RETRY: pass else: return database.updateUser(userInfo, active = 0) database.saveUser(newUserInfo)
def getActiveUserByTaobaoId(self, taobaoId): return database.getActiveUserByTaobaoId(taobaoId)