def setHonorField(is_honor, id): mysql = Mysql_instance() sql = "update reward_course_config set is_honor='%s' where id ='%s'" % ( is_honor, id) mysql.cursor.execute(sql) mysql.commit() mysql.close()
def updateCourseInfo(id, title, cost, price, item_id, cost_type, cost_num, cost_type_name, icon, item_type, limit_price): mysql = Mysql_instance() sql = "update reward_course_config set title='%s',cost='%s',price='%s',item_id='%s',cost_type='%s',cost_num='%s',cost_type_name='%s',icon='%s',item_type='%s',limit_price='%s' where id='%s'" % ( title, cost, price, item_id, cost_type, cost_num, cost_type_name, icon, item_type, limit_price, id) mysql.cursor.execute(sql) mysql.commit() mysql.close()
def createRewardCourse(title, cost, price, item_id, cost_type, cost_num, cost_type_name, icon, item_type, limit_price): mysql = Mysql_instance() cost = int(float(cost) * 100) price = int(float(price) * 100) sql = "insert into reward_course_config(title,cost,price,item_id,cost_type,cost_num,cost_type_name,icon,item_type,limit_price) values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % ( title, cost, price, item_id, cost_type, cost_num, cost_type_name, icon, item_type, limit_price) mysql.cursor.execute(sql) mysql.commit() mysql.close()
def sendReward(redis, key_code, card_no, card_pwd): mysql = Mysql_instance() # 有可能重复记录,所以获取是否第一次记录 is_first_get = True sql_is_first_record = 'select * from reward_record where status = 1 and key_code = "%s"' % key_code mysql.cursor.execute(sql_is_first_record) is_first_res = mysql.cursor.fetchall() if len(is_first_res) > 0: is_first_get = False sql = "select status,item_id,uid,reward_value from reward_record where key_code = '%s'" % key_code mysql.cursor.execute(sql) res = mysql.cursor.fetchone() sql = "update reward_record set card_no = '%s',card_pwd = '%s' where key_code = '%s'" % ( card_no, card_pwd, key_code) if res and res[0] == 0: now = str(datetime.now()) if res[1] is not None: bag_redis.hdel('reward:%s:user:%s:keycode' % (res[1], res[2]), res[3]) sql = "update reward_record set card_no = '%s',card_pwd = '%s',status = 1,deliver_time = '%s' where key_code = '%s'" % ( card_no, card_pwd, now, key_code) mysql.cursor.execute(sql) mysql.commit() mysql.close() # 金币追踪 if is_first_get: record_player_balance_change(bag_redis, '', -1, 0, 0, 59, extra1=key_code) return getRewardUserInfo(key_code)
def delRewardCourse(id): mysql = Mysql_instance() sql = "delete from reward_course_config where id = '%s'" % id mysql.cursor.execute(sql) mysql.commit() mysql.close()