Exemplo n.º 1
0
    def update_user(self, user_id, feeling, coupon=0, message_num=0, sign=0):
        data = {
            'user_id': user_id,
            'user_feeling': feeling,
            'coupon': coupon,
            'message_num': message_num,
            'sign_in': sign,
            'sign_times': sign,
        }
        update = {
            'user_feeling':
            Formula('user_feeling + %d' % feeling),
            'user_mood':
            Formula(
                'IF (user_mood + {feeling} <= 15 AND user_mood + {feeling} >= -10, '
                'user_mood + {feeling}, '
                'user_mood)'.format(feeling=feeling)),
            'coupon':
            Formula('coupon + %d' % coupon),
            'message_num':
            Formula('message_num + %d' % message_num)
        }
        if sign:
            update['sign_in'] = sign
            update['sign_times'] = Formula('sign_times + %d' % sign)

        self.db.insert(table='t_user', data=data, update=update)
Exemplo n.º 2
0
 def get_gacha_operator(self, limit=0, extra=None):
     return self.db.select('t_operator', where=Where({
         'limit': Where({
             'available': 1,
             'in_limit': ['in', Formula('(%d, 0)' % limit)]
         }),
         'operator_name': ['in', Formula('("%s")' % '", "'.join(extra or []))]
     }, operator='OR'))
Exemplo n.º 3
0
 def set_break_even(self, user_id, break_even, costs):
     self.db.update(table='t_user',
                    where=Where({'user_id': user_id}),
                    data={
                        'gacha_break_even': break_even,
                        'coupon': Formula('coupon - %d' % costs)
                    })
Exemplo n.º 4
0
 def add_function_use_num(self, function_id):
     self.db.insert(
         table='t_function',
         data={
             'function_id': function_id,
             'function_use_num': 1
         },
         update={'function_use_num': Formula('function_use_num + 1')})
Exemplo n.º 5
0
 def get_operator_gacha_config(self, group='limit'):
     limit_operator = self.db.select(
         't_operator_gacha_config',
         where=Where({
             'operator_type':
             ['in', Formula('(0, 1)')] if group == 'limit' else ['>', '1']
         }))
     return [item['operator_name'] for item in limit_operator]
Exemplo n.º 6
0
 def get_all_operator(self, names: list = None):
     if names:
         return self.db.select(
             't_operator',
             where=Where({
                 'operator_name':
                 ['in', Formula('("%s")' % '", "'.join(names))]
             }))
     return self.db.select('t_operator')