def event_pay(event): owner = event.zsite owner_id = event.zsite_id cent = event.cent if event.state == EVENT_STATE_END and cent: pay_count = 0 for i in EventJoiner.where(event_id=event.id).where('state>=%s', EVENT_JOIN_STATE_YES): user_id = i.user_id if user_id != owner_id: t = pay_event_get(event, user_id) if t: trade_finish(t) pay_count += 1 if pay_count: pay_money = read_cent(cent * pay_count) po = event.po rendermail( '/mail/event/event_end_draw.txt', mail_by_user_id(owner_id), owner.name, join_count=event.join_count, pay_count=pay_count, pay_money=pay_money, title=po.name, link=po.link, )
def event_joiner_can_exit(event_id, user_id): if event_joiner_state(event_id, user_id) in (EVENT_JOIN_STATE_NEW, EVENT_JOIN_STATE_YES): event = Event.mc_get(event_id) if event.cent: if pay_event_get(event, user_id): return False return True
def event_pay(event): owner = event.zsite owner_id = event.zsite_id cent = event.cent if event.state == EVENT_STATE_END and cent: pay_count = 0 for i in EventJoiner.where(event_id=event.id).where( 'state>=%s', EVENT_JOIN_STATE_YES): user_id = i.user_id if user_id != owner_id: t = pay_event_get(event, user_id) if t: trade_finish(t) pay_count += 1 if pay_count: pay_money = read_cent(cent * pay_count) po = event.po rendermail( '/mail/event/event_end_draw.txt', mail_by_user_id(owner_id), owner.name, join_count=event.join_count, pay_count=pay_count, pay_money=pay_money, title=po.name, link=po.link, )
def event_joiner_no(o, txt=''): event_id = o.event_id user_id = o.user_id event = o.event zsite_id = event.zsite_id if o.state in (EVENT_JOIN_STATE_NEW, EVENT_JOIN_STATE_YES): if event.cent: t = pay_event_get(event, user_id) if t: trade_fail(t) o.state = EVENT_JOIN_STATE_NO o.save() if zsite_id != user_id: event.join_count -= 1 event.save() if txt: notice_event_join_no(zsite_id, user_id, event_id, txt) mc_flush_by_user_id_event_id_owner_id(user_id, event_id, zsite_id)