Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
def getRewardDataInfo(startDate, endDate):
    mysql = Mysql_instance()
    startDate = str(datetime.strptime(startDate, '%Y-%m-%d'))
    endDate = str(datetime.strptime(endDate, '%Y-%m-%d') + timedelta(1))
    sql = "select uid,nickname,key_code,reward_cost,reward_value,reward_time,deliver_time,card_no,card_pwd,status,reward_name,cost_type_name,cost_num from reward_record "\
          +"where reward_time >= '%s' and reward_time < '%s'"%(startDate,endDate)
    print '---------------------------'
    print sql
    print '---------------------------'
    mysql.cursor.execute(sql)
    res = mysql.cursor.fetchall()
    data = []
    for row in res:
        data.append({
            "uid": row[0],
            "nickname": row[1],
            "key_code": row[2],
            "reward_cost": round(float(row[3]) / 100, 2),
            "reward_value": round(float(row[4]) / 100, 2),
            "reward_time": str(row[5]),
            "deliver_time": str(row[6] or ""),
            "card_no": row[7] or "",
            "card_pwd": row[8] or "",
            "status": row[9],
            "reward_name": row[10],
            "cost_type_name": row[11],
            "cost_num": row[12],
        })
    mysql.close()
    return json.dumps({"count": len(data), "data": data})
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
def delRewardCourse(id):
    mysql = Mysql_instance()
    sql = "delete from reward_course_config where id = '%s'" % id
    mysql.cursor.execute(sql)
    mysql.commit()
    mysql.close()