Ejemplo n.º 1
0
def insert(user_id, module, describe):
    try:
        sql = "INSERT INTO sys_log (user_id,[module],[describe]) VALUES ('{}','{}','{}');".format(
            user_id, module, describe)
        sql_exec(sql)
        return responseJSON_1('更新成功')
    except Exception as error:
        responseJSON_0('更新失败', error)
Ejemplo n.º 2
0
def Logout_user(mobile):
    try:
        user_id = sql_select(
            "SELECT id FROM biz_user WHERE mobile = {}".format(mobile))
        if user_id == []:
            return responseJSON_0('用户不存在!')
        sql_exec("exec RemoveUserByMobile '{}';".format(mobile))
        insert(user_id[0][0], 'Logout_user', '账户注销')
        return responseJSON_1('注销成功', mobile)
    except Exception as error:
        return responseJSON_0('deleteUser异常', error)
Ejemplo n.º 3
0
def addMoney(mobile, money):
	setMealList = [0.1, 0.5, 1, 3, 6]
	user_start = userStatus(mobile)
	if user_start['code'] == 0:
		return user_start
	if float(money) <= 6:
		if float(money) not in setMealList:
			return responseJSON_0("充值月份不在范围!")
		vip_status = vipStatus(mobile)
		status = vip_status['code']
		if status == 0:
			return vip_status
		if float(money) == 0.1:
			user_id = sql_select("SELECT id FROM biz_user WHERE mobile = {}".format(mobile))[0][0]
			if status == 2:
				user_id = vip_status['table_s'][0]
				validTime = vip_status['table_s'][1]
				timeArray = time.strptime(validTime, "%Y-%m-%d %H:%M:%S")
				timeStamp = int(time.mktime(timeArray))
				validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(864000 * money + timeStamp))
				return setBizVipRecord(user_id, validTime, money)
			else:
				validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(864000 * money + int(time.time())))
			return setBizVipRecord(user_id, validTime, money)
		# 未开通
		if status == 1:
			user_id = sql_select("SELECT id FROM biz_user WHERE mobile = {}".format(mobile))[0][0]
			validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + int(time.time())))
			return setBizVipRecord(user_id, validTime, money)

		# 已开通
		elif status == 2:
			user_id = vip_status['table_s'][0]
			validTime = vip_status['table_s'][1]
			timeArray = time.strptime(validTime, "%Y-%m-%d %H:%M:%S")
			timeStamp = int(time.mktime(timeArray))
			validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + timeStamp))
			return setBizVipRecord(user_id, validTime, money)

		# 已过期
		elif status == 3:
			user_id = vip_status['table_s'][0]
			validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + int(time.time())))
			return setBizVipRecord(user_id, validTime, money)
	else:
		money = int(money)
		if money > 4000 or money < 10:
			return responseJSON_0('充值失败!', '充值金额范围10~4000')
		sql_exec("exec GiveMeTheMoney %s,%d;" % (mobile, money))
		bizWallet = getBizWallet(mobile)
		insert(bizWallet['table_s'][0][1], 'setBizVipRecord', 'TEST:充值{}个聚源币'.format(money))
		if bizWallet['code'] == 0:
			return bizWallet
		return responseJSON_1('充值成功!', '当前余额为{}币'.format(bizWallet['table_s'][0][0]))
Ejemplo n.º 4
0
def update_base64():
    # table_s = sql_select("SELECT id,recommend_mobile FROM biz_invite_code WHERE recommend_mobile LIKE 'MT%';")
    data = sql_select(
        "SELECT id,recommend_mobile FROM biz_invite_code WHERE recommend_mobile != '' AND id > 11356;"
    )
    for i in data:
        if not is_num_by_except(i[1]):
            try:
                temp = base64.b64decode(i[1].replace('\n',
                                                     '').replace('\r', ''))
                sql_exec(
                    "UPDATE biz_invite_code SET recommend_mobile = '{}' WHERE id = {};"
                    .format(temp.decode(), i[0]))
                print(i[1], '转换为:', temp.decode())
            except:
                break
Ejemplo n.º 5
0
def removeUser(request):
	if request.method == "POST":
		print(request.body)
		mobile = json.loads(request.body.decode().replace("'", "\"")).get('mobile')
		is_mobile = sql.sql_select("SELECT status FROM biz_user WHERE mobile = '{}';".format(mobile))
		if is_mobile == []:
			return HttpResponse(json.dumps({"code": 0, "msg": "要删除的用户不存在!", "table_s": ""}))
		re = sql.sql_exec("exec RemoveUserByMobile '{}';".format(mobile))
		print("删除手机", mobile)
		return HttpResponse(json.dumps({"code": 1, "msg": "删除成功!", "table_s": "{}".format(re)}))
	else:
		return HttpResponse(json.dumps({"code": 0, "msg": "请使用POST请求!", "table_s": ""}))
Ejemplo n.º 6
0
def addMoney(request):
	if request.method == "POST":
		mobile = json.loads(request.body.decode().replace("'", "\"")).get('mobile')
		money = json.loads(request.body.decode().replace("'", "\"")).get('money')
		setMealList = [0.5, 1, 3, 6]
		if float(money) in setMealList:
			money = float(money)
			is_mobile = sql.sql_select("SELECT status FROM biz_user WHERE mobile = '{}';".format(mobile))
			if is_mobile == []:
				return HttpResponse(json.dumps({"code": 0, "msg": "用户不存在!", "table_s": ""}))
			if is_mobile[0][0] != 4:
				return HttpResponse(json.dumps({"code": 0, "msg": "用户还未完成认证!", "table_s": ""}))
			if float(money) not in [0.5, 1, 3, 6]:
				return HttpResponse(json.dumps({"code": 0, "msg": "充值失败,充值月份不在范围!", "table_s": ""}))
			is_true = sql.sql_select(
				"SELECT A.id,B.expire_time FROM biz_user A JOIN biz_vip_record B ON A.id = B.user_id WHERE sex=1 AND A.mobile='{}';".format(
					mobile))
			if is_true == []:
				user_id = sql.sql_select("SELECT id FROM biz_user WHERE mobile = '{}';".format(mobile))[0][0]
				validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + int(time.time())))
				sql.sql_exec(
					"INSERT INTO biz_vip_record (user_id,expire_time) VALUES ({},'{}');"
					"update biz_user set is_vip=1 where id={};".format(user_id, validTime, user_id))
				return HttpResponse(
					json.dumps({"code": 1, "msg": "未充值VIP!", "table_s": "user_id: {},会员时间:{}".format(user_id, validTime)}))
			user_id = is_true[0][0]
			timeArray = time.strptime(is_true[0][1], "%Y-%m-%d %H:%M:%S")
			timeStamp = int(time.mktime(timeArray))

			if timeStamp > int(time.time()):
				validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + timeStamp))
				sql.sql_exec("UPDATE biz_vip_record SET expire_time='{}' WHERE user_id= {};"
							 "update biz_user set is_vip=1 where id={};".format(validTime, user_id, user_id))
				return HttpResponse(json.dumps({"code": 1, "msg": "未过期!", "table_s": "{}".format(validTime)}))

			if timeStamp < int(time.time()):
				validTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(2678400 * money + int(time.time())))
				sql.sql_exec(
					"UPDATE biz_vip_record SET expire_time='{}' WHERE user_id= {};"
					"update biz_user set is_vip=1 where id={};".format(validTime, user_id, user_id))
				return HttpResponse(json.dumps({"code": 1, "msg": "过期!", "table_s": ""}))

		else:
			if money == "" or mobile == "":
				return HttpResponse(json.dumps({"code": 0, "msg": "金额或金额类型异常", "table_s": ""}))
			if type(money) != int:
				money = int(money)
			if is_int.is_number(money) or type(money) != int:
				return HttpResponse(json.dumps({"code": 0, "msg": "金额或金额类型异常", "table_s": ""}))
			if money > 4000 or money < 1:
				return HttpResponse(json.dumps({"code": 0, "msg": "金额充值范围1~4000币", "table_s": ""}))
			is_mobile = sql.sql_select("SELECT status FROM biz_user WHERE mobile = '{}';".format(mobile))
			if is_mobile == []:
				return HttpResponse(json.dumps({"code": 0, "msg": "用户不存在!", "table_s": ""}))
			if is_mobile[0][0] != 4:
				return HttpResponse(json.dumps({"code": 0, "msg": "用户还未完成认证!", "table_s": ""}))

			return HttpResponse(json.dumps({"code": 1, "msg": "充值成功!", "table_s": "当前账户余额:{}"}))
	else:
		return HttpResponse(json.dumps({"code": 0, "msg": "请使用POST请求!", "table_s": ""}))
Ejemplo n.º 7
0
def setBizVipRecord(user_id, expire_time, money):
    print('时间', user_id, expire_time)
    try:
        sql = "SELECT * FROM biz_vip_record WHERE user_id = '{}';".format(
            user_id)
        sql = sql_select(sql)
        if sql == []:
            sql = '''
				INSERT INTO biz_vip_record (user_id,expire_time) VALUES ({},'{}');
				update biz_user set is_vip=1 where id={};
				'''.format(user_id, expire_time, user_id)
            sql_exec(sql)
            insert(user_id, 'setBizVipRecord', 'TEST:充值{}个月会员'.format(money))
            return responseJSON_1('充值成功!', '会员时间:{}'.format(expire_time))
        sql = '''
			UPDATE biz_vip_record SET expire_time='{}' WHERE user_id= {};
			UPDATE biz_user set is_vip=1 where id={};
		'''.format(expire_time, user_id, user_id)
        sql_exec(sql)
        insert(user_id, 'setBizVipRecord', 'TEST:充值{}个月会员'.format(money))
        return responseJSON_1('充值成功!', '会员时间:{}'.format(expire_time))

    except Exception as error:
        return responseJSON_0('setBizVipRecord方法异常', error)