def handle_drpconfig_edit(): """ 分销设置修改接口 :return: json """ res = ResMsg() req = request.get_json(force=True) now_timestr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) sysid = 1 drp_layers = req.get("drp_layers", 1) profit_percentage = req.get("profit_percentage", '') need_setreal = req.get("need_setreal", 1) daily_max = int(req.get("daily_max", 1)) handling_fee = req.get("handling_fee", 1) min_money = int(req.get("min_money", 1)) withdrawal_condition = req.get("withdrawal_condition", '') daily_withdrawal = req.get("daily_withdrawal", 9) update_dict = { "drp_layers": drp_layers, "profit_percentage": profit_percentage, "need_setreal": need_setreal, "daily_max": daily_max, "handling_fee": handling_fee, "min_money": min_money, "withdrawal_condition": withdrawal_condition, "daily_withdrawal": daily_withdrawal, "update_time": now_timestr } update_dict_ready = helpers.rmnullkeys(update_dict) drpconfigs = db.session.query(EtDrpConfig).filter( EtDrpConfig.id == sysid).first() if drpconfigs: db.session.query(EtDrpConfig).filter( EtDrpConfig.id == sysid).update(update_dict_ready) try: db.session.commit() Redis.delete(redis_key_drp) r_data = helpers.model_to_dict(drpconfigs) del r_data['update_time'] Redis.hmset(redis_key_drp, r_data) res.update(code=ResponseCode.Success, data={}, msg=f'分销设置配置成功') return res.data except Exception as why: res.update(code=ResponseCode.Success, data={}, msg=f'修改失败,请稍后再试{why}') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='修改失败,请稍后再试') return res.data
def handle_configs(): """ 获取系统信息接口 :return: json """ res = ResMsg() id = request.args.get("id", 1) sysid = 1 sys_configs = db.session.query(EtGlobalConfig).filter( EtGlobalConfig.id == sysid).first() res_data = dict() if sys_configs: res_data['data'] = helpers.model_to_dict(sys_configs) # logger.error(Redis.hgetall(redis_key_sys)) if Redis.hgetall(redis_key_sys) == {}: del res_data['data']['update_time'] cache_data = helpers.rmnullkeys(res_data['data']) logger.error(res_data['data']) ret = Redis.hmset(redis_key_sys, cache_data) logger.error(ret) res.update(code=ResponseCode.Success, data=res_data, msg='系统信息获取成功') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='系统信息数据异常') return res.data
def handle_drpconfigs(): """ 获取系统分销配置信息接口 :return: json """ res = ResMsg() sysid = 1 drp_configs = db.session.query(EtDrpConfig).filter( EtDrpConfig.id == sysid).first() res_data = dict() if drp_configs: res_data['data'] = helpers.model_to_dict(drp_configs) del res_data['data']['update_time'] Redis.hmset(redis_key_drp, res_data['data']) res.update(code=ResponseCode.Success, data=res_data, msg=f'分销信息获取成功') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='分销信息数据异常') return res.data
def handle_sysconfig_edit(): """ 系统全局设置修改 :return: json """ res = ResMsg() req = request.get_json(force=True) now_timestr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) sysid = 1 notice = req.get("notice", '') domains = req.get("domains", '') share_domains = req.get("share_domains", '') task_limit = req.get("task_limit", 20) banners = req.get("banners", '') limit_withdrawal = req.get("limit_withdrawal", '') sys_status = int(req.get("status", 1)) rules = req.get("rules", 1) helper = req.get("helpers", 1) start_page = req.get("start_page", 1) upgrade = int(req.get("upgrade", 10)) update_dict = { "notice": notice, "domains": domains, "share_domains": share_domains, "task_limit": task_limit, "banners": banners, "limit_withdrawal": limit_withdrawal, "sys_status": sys_status, "rules": rules, "helpers": helper, "start_page": start_page, "upgrade": upgrade, "update_time": now_timestr } update_dict_ready = helpers.rmnullkeys(update_dict) sysdata = db.session.query(EtGlobalConfig).filter( EtGlobalConfig.id == sysid).first() if sysdata: db.session.query(EtGlobalConfig).filter( EtGlobalConfig.id == sysid).update(update_dict_ready) if notice: data = {'content': notice, 'time': now_timestr} json_data = json.dumps(data) redis_res = Redis.lpush(system_logging, json_data) try: db.session.commit() Redis.delete(redis_key_sys) res_data = helpers.queryToDict(sysdata) del res_data['update_time'] Redis.hmset(redis_key_sys, res_data) res.update(code=ResponseCode.Success, data={}, msg='系统全局配置成功') return res.data except Exception as why: res.update(code=ResponseCode.Success, data={}, msg=f'修改失败,请稍后再试{why}') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='修改失败,请稍后再试') return res.data