def __initLogicDataMgr(): classSqlBaseMgr() classSqlBaseMgr(__instanceName__='probet_oss') if procVariable.debug: yield from classSqlBaseMgr.getInstance(instanceName='probet_oss').connetSql(gmweb_config.mysqlAddress_debug, 3306, 'root',gmweb_config.mysqlPwd_debug,'probet_oss', g_obj_loop,'utf8') yield from classSqlBaseMgr.getInstance().connetSql(gmweb_config.mysqlAddress_debug, 3306, 'root', gmweb_config.mysqlPwd_debug, 'probet_data', g_obj_loop) classDataBaseMgr( gmweb_config.redis_config_debug, g_obj_loop,procVariable.debug, 1, 1) else: yield from classSqlBaseMgr.getInstance(instanceName='probet_oss').connetSql(gmweb_config.mysqlAddress, 3306, 'root', gmweb_config.mysqlPwd, 'probet_oss', g_obj_loop, 'utf8') yield from classSqlBaseMgr.getInstance().connetSql(gmweb_config.mysqlAddress, 3306, 'root', gmweb_config.mysqlPwd, 'probet_data', g_obj_loop) classDataBaseMgr(gmweb_config.redis_config, g_obj_loop,procVariable.debug, 1,1) yield from classDataBaseMgr.getInstance().connectRedis() yield from classDataBaseMgr.getInstance().loadRedisLuaScript()
def handleHttp(dict_param: dict): """个人信息""" objRsp = cResp() agentId = dict_param.get("agentId", "") objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData( agentId) objAgentData = yield from classDataBaseMgr.getInstance().getAgentData( agentId) allAccountNum = yield from classSqlBaseMgr.getInstance( ).getAccountCountByAgent(agentId) unReadNum = yield from classSqlBaseMgr.getInstance().getAgentMsgUnReadNum( agentId) # 构造回包 objRsp.data = cData() objRsp.data.agentId = agentId objRsp.data.realName = objPlayerData.strRealName objRsp.data.phoneNum = objPlayerData.strPhone objRsp.data.email = objPlayerData.strEmail objRsp.data.count = allAccountNum objRsp.data.balance = objPlayerData.iCoin objRsp.data.loginTime = objPlayerData.iLastLoginTime objRsp.data.cid = objAgentData.iCid objRsp.data.unReadNum = unReadNum return classJsonDump.dumps(objRsp)
def handleHttp(dict_param: dict): """交易记录""" objRsp = cResp() strAccountId = dict_param.get("accountId", "") iTradeType = dict_param.get("tradeType", "") iPage = int(dict_param.get("pageNum",1)) """ orderDataList = yield from classDataBaseMgr.getInstance().getTradeTypeRecord(strAccountId, iTradeType, timeHelp.getNow(), timeHelp.todayStartTimestamp()) typeDataList = [] for orderData in orderDataList: if iTradeType == orderData.iTradeType: typeDataList.append(orderData) """ count = yield from classSqlBaseMgr.getInstance().appGetCoinHisCount(iTradeType, strAccountId) listCoinHisIds = yield from classSqlBaseMgr.getInstance().appGetCoinHistory(iTradeType,strAccountId,iPage,10) listCoinHisDatas = yield from classDataBaseMgr.getInstance().getCoinHisList(listCoinHisIds) listCoinHisData = [] for CoinHisData in listCoinHisDatas: CoinHisData.iCoin = float("%.2f"%round(CoinHisData.iCoin/100,2)) if CoinHisData.iTradeType == 2: CoinHisData.strTransTo = str(CoinHisData.strTransTo)[-4:] listCoinHisData.append(CoinHisData) # 构造回包 objRsp.data = cData() objRsp.data.orderData = listCoinHisData objRsp.data.count = count return classJsonDump.dumps(objRsp)
def handleHttp(dictParam: dict): #每月VIP活动 objResp = cResp() strAccountId = dictParam.get('accountId', '') strToken = dictParam.get('token', '') certifytoken.certify_token(strAccountId, strToken) objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData( strAccountId) objActiveData = yield from classDataBaseMgr.getInstance().getActiveData( strAccountId) if objPlayerData is None: raise exceptionLogic(errorLogic.player_data_not_found) if objActiveData is None: raise exceptionLogic(errorLogic.active_not_find) #判断活动是否完成 objActiveItme = objActiveData.dictActiveItem.get(2001) if objActiveItme is None: raise exceptionLogic(errorLogic.active_not_find) if objActiveItme.iActiveState == 1: raise exceptionLogic(errorLogic.active_have_already_get) #升级需要的流水 upWater = vipConfig.vip_config[objPlayerData.iLevel].get( 'upGradeValidWater') #保级需要的流水 keepWater = vipConfig.vip_config[objPlayerData.iLevel].get( 'keepValidWater') #这个月24小时内充值存款 payMonthly, orderTime = yield from classSqlBaseMgr.getInstance( ).getAccountFirstPayByDay(strAccountId) # 获取当月有效流水自己平台 validWater = yield from classSqlBaseMgr.getInstance().getValidWaterMonthly( strAccountId) #获取平博当月有效流水 pingboValidWater = yield from classSqlBaseMgr.getInstance( ).getAccountPinboHistoryValidWater(timeHelp.monthStartTimestamp(), timeHelp.nextMonthStartTimestamp(), strAccountId) pingboValidWater = 0 if pingboValidWater.get( 'validWaterCoin') is None else pingboValidWater.get('validWaterCoin') data = cData() data.accountId = strAccountId #升级还需要的流水 data.upLevelWater = "%.2f" % round( (upWater - objPlayerData.iLevelValidWater) / 100, 2) data.keepLevelWater = "%.2f" % round( (keepWater - (validWater + pingboValidWater)) / 100, 2) data.level = objPlayerData.iLevel data.rebate = vipConfig.vip_config[objPlayerData.iLevel].get('rebate') data.recharge = "%.2f" % round(payMonthly / 100, 2) data.activeTime = objActiveData.dictActiveItem.get(2001).iActiveTime data.validWater = "%.2f" % round((pingboValidWater + validWater) / 100, 2) data.activeId = 2001 objResp.data = data return classJsonDump.dumps(objResp)
def handleHttp(request: dict): """新增推广素材""" objRep = cResp() bytesBase64Png = request.get("base64Png", "") imageSize = request.get("imageSize", "") if not all([bytesBase64Png, imageSize]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) materialName = hashlib.md5(bytesBase64Png.encode()).hexdigest() imageData = base64.b64decode(bytesBase64Png[22:]) dirPrefix = "material/" uploadDataFileToOss(imageData, dirPrefix, materialName + ".png") image_url = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format( dirPrefix, materialName) imageId = str(uuid.uuid1()) try: sql = tb_material.insert().values(imageId=imageId, image_url=image_url, imageSize=imageSize, create_time=timeHelp.getNow(), update_time=timeHelp.getNow()) yield from classSqlBaseMgr.getInstance()._exeCuteCommit(sql) sql = "select * from dj_material order by update_time desc" result = yield from classSqlBaseMgr.getInstance()._exeCute(sql) if result.rowcount <= 0: return classJsonDump.dumps(objRep) else: for var in result: materialData = {} materialData['imageId'] = var.imageId materialData['image_url'] = var.image_url materialData['imageSize'] = var.imageSize objRep.data.append(materialData) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "新增推广素材", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "新增推广素材imageId:{}".format(imageId), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(request: dict): # 新增轮播图信息 accountId = request.get('accountId') title = request.get('title', '') bytesBase64Png = request.get("base64Png", "") link_url = request.get('link_url', '') if not all([title, bytesBase64Png]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) bannerName = hashlib.md5(bytesBase64Png.encode()).hexdigest() imageData = base64.b64decode(bytesBase64Png[22:]) dirPrefix = "banner/" uploadDataFileToOss(imageData, dirPrefix, bannerName + ".png") try: sql = "select dj_banner.index from dj_banner" listRest = yield from classSqlBaseMgr.getInstance()._exeCute(sql) listRest = yield from listRest.fetchall() if len(listRest) == 0: index = 0 else: sql = "select max(dj_banner.index) from dj_banner" ret = yield from classSqlBaseMgr.getInstance()._exeCute(sql) ret = yield from ret.fetchone() index = ret[0] + 1 sql = tb_banner.insert().values( index=index, link_url=link_url, image_url="http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png" .format(dirPrefix, bannerName), title=title, addAccount=accountId, create_time=timeHelp.getNow(), update_time=timeHelp.getNow()) yield from classSqlBaseMgr.getInstance()._exeCuteCommit(sql) objResp = cResp() fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "新增轮播图", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "新增轮播图,标题:{}".format(title), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objResp) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(dict_param: dict): """交易记录""" objRsp = cResp() strAccountId = dict_param.get("accountId", "") iTradeType = dict_param.get("tradeType", "") iDateType = dict_param.get("dateType", "") iPage = int(dict_param.get("pageNum", 1)) if not all([iTradeType, iDateType]): raise exceptionLogic(errorLogic.client_param_invalid) if iDateType == enumGetTradeHistoryType.getType1: """ orderDataList = yield from classDataBaseMgr.getInstance().getTradeTypeRecord(strAccountId, iTradeType, timeHelp.getNow(), timeHelp.todayStartTimestamp()) typeDataList = [] for orderData in orderDataList: if iTradeType == orderData.iTradeType: typeDataList.append(orderData) """ listCoinHisIds = yield from classSqlBaseMgr.getInstance( ).getCoinHistory(timeHelp.todayStartTimestamp(), iTradeType, strAccountId, iPage, 7) listCoinHisDatas = yield from classDataBaseMgr.getInstance( ).getCoinHisList(listCoinHisIds) elif iDateType == enumGetTradeHistoryType.getType3: listCoinHisIds = yield from classSqlBaseMgr.getInstance( ).getCoinHistory(timeHelp.threeDayTimestamp(), iTradeType, strAccountId, iPage, 7) listCoinHisDatas = yield from classDataBaseMgr.getInstance( ).getCoinHisList(listCoinHisIds) elif iDateType == enumGetTradeHistoryType.getType7: listCoinHisIds = yield from classSqlBaseMgr.getInstance( ).getCoinHistory(timeHelp.sevenDayTimestamp(), iTradeType, strAccountId, iPage, 7) listCoinHisDatas = yield from classDataBaseMgr.getInstance( ).getCoinHisList(listCoinHisIds) else: listCoinHisIds = yield from classSqlBaseMgr.getInstance( ).getCoinHistory(timeHelp.thirtyDayTimestamp(), iTradeType, strAccountId, iPage, 7) listCoinHisDatas = yield from classDataBaseMgr.getInstance( ).getCoinHisList(listCoinHisIds) listCoinHisData = [] for CoinHisData in listCoinHisDatas: CoinHisData.iCoin = float("%.2f" % round(CoinHisData.iCoin / 100, 2)) listCoinHisData.append(CoinHisData) # 构造回包 objRsp.data = cData() objRsp.data.orderData = listCoinHisData return classJsonDump.dumps(objRsp)
def handleHttp(request: dict): """编辑域名""" objRep = cResp() domainName = request.get('domainName', '') domainId = request.get('domainId', '') if not all([domainName, domainId]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: sql = "update dj_domain set domainName='{}' where domainId='{}' ".format( domainName, domainId) yield from classSqlBaseMgr.getInstance()._exeCuteCommit(sql) sql = "select * from dj_domain" result = yield from classSqlBaseMgr.getInstance()._exeCute(sql) if result.rowcount <= 0: return classJsonDump.dumps(objRep) else: pcDomainName = [] appDomainName = [] for var_row in result: if var_row.domainType == 'pc': domainDict = {} domainDict['domainId'] = var_row.domainId domainDict['domainName'] = var_row.domainName pcDomainName.append(domainDict) elif var_row.domainType == 'app': domainDict = {} domainDict['domainId'] = var_row.domainId domainDict['domainName'] = var_row.domainName appDomainName.append(domainDict) objRep.data = cData() objRep.data.pc = pcDomainName objRep.data.app = appDomainName fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "修改域名", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "修改域名Id:{},域名:{}".format(domainId, domainName), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise e
def handleHttp(dict_param: dict): """个人中心入口""" objRsp = cResp() strAccountId = dict_param.get("accountId", "") objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData( strAccountId) payMonthly, orderTime = yield from classSqlBaseMgr.getInstance( ).getAccountFirstPayByDay(strAccountId) validWaterMonthly = yield from classSqlBaseMgr.getInstance( ).getValidWaterMonthly(strAccountId) if orderTime: # surplusTime = orderTime+86400 - timeHelp.getNow() endTime = orderTime + 86400 else: # surplusTime = 0 endTime = 0 # 构造回包 objRsp.data = cData() objRsp.data.accountId = objPlayerData.strAccountId objRsp.data.coin = "%.2f" % round(objPlayerData.iCoin / 100, 2) objRsp.data.headAddress = objPlayerData.strHeadAddress objRsp.data.phoneNum = objPlayerData.strPhone objRsp.data.realName = objPlayerData.strRealName objRsp.data.sex = objPlayerData.strSex objRsp.data.born = objPlayerData.strBorn objRsp.data.address = objPlayerData.dictAddress objRsp.data.email = objPlayerData.strEmail objRsp.data.bankCard = objPlayerData.arrayBankCard objRsp.data.level = objPlayerData.iLevel objRsp.data.levelValidWater = "%.2f" % round( objPlayerData.iLevelValidWater / 100, 2) objRsp.data.paymonthly = "%.2f" % round(payMonthly / 100, 2) objRsp.data.validWaterMonthly = "%.2f" % round(validWaterMonthly / 100, 2) objRsp.data.endTime = endTime for var_value in vip_config.values(): if var_value['level'] == objPlayerData.iLevel: objRsp.data.upGradeValidWater = "%.2f" % round( var_value['upGradeValidWater'] / 100, 2) objRsp.data.keepValidWater = "%.2f" % round( var_value['keepValidWater'] / 100, 2) if objPlayerData.strTradePassword: objRsp.data.tradePwd = 1 # 表示已经设置了交易密码 else: objRsp.data.tradePwd = 0 # 表示没有设置交易密码 return classJsonDump.dumps(objRsp)
def doCheck(): from datawrapper.sqlBaseMgr import classSqlBaseMgr engine = classSqlBaseMgr.getInstance().getEngine() with (yield from engine) as conn: # 检查写入新信息 var_aio_redis = classDataBaseMgr.getInstance( ).dictAioRedis[userConfig].objAioRedis try: # 获取新生成的佣金账单信息 new_commission_bill_list = yield from classDataBaseMgr.getInstance( ).getAgentCommissionDataNewList(var_aio_redis) #logging.debug(new_coin_history_list) if len(new_commission_bill_list) <= 0: pass else: for var_id in new_commission_bill_list: try: if var_id is None: logging.error( "[{}] bill id is none".format(var_id)) continue yield from flushInsertToDb(var_id.decode(), var_aio_redis, conn) yield from classDataBaseMgr.getInstance( ).removeAgentCommissionDataNew(var_aio_redis, var_id) logging.info( "Save new commission bill [{}]".format(var_id)) except Exception as e: logging.error( "Save new commission bill exception bill id=[{}], error=[{}]" .format(var_id, str(e))) dirty_commission_bill_list = yield from classDataBaseMgr.getInstance( ).getAgentCommissionDataDirtyList(var_aio_redis) # logging.debug(new_coin_history_list) if len(dirty_commission_bill_list) <= 0: pass else: for var_id in dirty_commission_bill_list: try: if var_id is None: logging.error( "[{}] order id is none".format(var_id)) continue yield from flushUpdateToDb(var_id.decode(), var_aio_redis, conn) yield from classDataBaseMgr.getInstance( ).removeAgentCommissionDataDirty( var_aio_redis, var_id) logging.info( "Save dirty commission bill [{}]".format(var_id)) except Exception as e: logging.error( "Save dirty commission bill exception order id=[{}], error=[{}]" .format(var_id, str(e))) except Exception as e: logging.error(str(e)) finally: pass
def handleHttp(request: dict): try: conn = classSqlBaseMgr.getInstance() sql = "select * from dj_admin_role" listRest = yield from conn._exeCute(sql) roles = yield from listRest.fetchall() sql = "select * from dj_admin_account" listRest = yield from conn._exeCute(sql) accounts = yield from listRest.fetchall() resp = cResp() data = cData() for x in roles: dict1 = {} dict1['id'] = x['id'] dict1['name'] = x['role_name'] data.roles.append(dict1) for x in accounts: dict1 = {} dict1['name'] = x['accountId'] data.accounts.append(dict1) resp.data = data resp.ret = errorLogic.success[0] return classJsonDump.dumps(resp) except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(request: dict): # 登出 accountId = request.get('accountId', '') try: conn = classSqlBaseMgr.getInstance() sql = "update dj_admin_account set token='{}' where accountId='{}'".format( '', accountId) yield from conn._exeCute(sql) #构建回包 resp = cResp() resp.ret = errorLogic.success[0] fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "登出", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "登出", 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(resp) except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(dict_param: dict): """ 后台查询历史系统消息 """ objRsp = cResp() pn = dict_param.get("pn", 1) if not checkIsInt(pn): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) conn = classSqlBaseMgr.getInstance() # 去重获取msgId sql = "select distinct msgId from dj_all_msg WHERE type=3 " listRest = yield from conn._exeCute(sql) msgIds = yield from listRest.fetchall() if len(msgIds) == 0: return classJsonDump.dumps(objRsp) else: ids = [] for x in msgIds: ids.append(x[0]) # 根据id获取消息 for x in msgIds: sql = "select msgId,msgTime,msgDetail,msgTitle,sendFrom,sendTo from dj_all_msg WHERE msgId='{}' ".format( x[0]) listRest = yield from conn._exeCute(sql) msgs = yield from listRest.fetchall() if len(msgs) == 0: return classJsonDump.dumps(objRsp) if len(msgs) > 5: # 全体发送 data = cData() data.msgId = msgs[0]['msgId'] data.msgTime = msgs[0]['msgTime'] data.detail = msgs[0]['msgDetail'] data.title = msgs[0]['msgTitle'] data.sendFrom = msgs[0]['sendFrom'] data.receiver = '全体' objRsp.data.append(data) continue else: for x in msgs: data = cData() data.msgId = x['msgId'] data.msgTime = x['msgTime'] data.detail = x['msgDetail'] data.title = x['msgTitle'] data.receiver = x['sendTo'] data.sendFrom = x['sendFrom'] objRsp.data.append(data) objRsp.count = len(objRsp.data) objRsp.data = sorted(objRsp.data, key=lambda data: data.msgTime, reverse=True) objRsp.data = objRsp.data[(pn - 1) * MSG_PAGE_COUNT:pn * MSG_PAGE_COUNT:] return classJsonDump.dumps(objRsp)
def handleHttp(dict_param: dict): """ 获取指定消息 """ objRsp = cResp() strAccountId = dict_param.get("accountId", "") strMsgId = dict_param.get("msgId", "") if not strMsgId: raise exceptionLogic(errorLogic.client_param_invalid) yield from classSqlBaseMgr.getInstance().changeReadFlag(strMsgId) MsgData = yield from classDataBaseMgr.getInstance().getOneSystemMsg(strMsgId, strAccountId) if MsgData: sysMsgData = {} sysMsgData['msgTime'] = MsgData.iMsgTime sysMsgData['msgTitle'] = MsgData.strMsgTitle sysMsgData['msgDetail'] = MsgData.strMsgDetail sysMsgData['readFlag'] = MsgData.iReadFlag sysMsgData['msgId'] = MsgData.strMsgId else: sysMsgData = MsgData # 构造回包 objRsp.data = sysMsgData return classJsonDump.dumps(objRsp)
def handleHttp(dict_param: dict): """代理申请查询""" objRsp = cResp() startTime = dict_param.get("startTime", 0) endTime = dict_param.get("endTime", 0) if not all([startTime,endTime]): sql = "select * from dj_agent_apply" params = [] else: sql = "select * from dj_agent_apply where applyTime between %s and %s" params = [startTime,endTime] try: with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: result = yield from conn.execute(sql,params) if result.rowcount <= 0: return classJsonDump.dumps(objRsp) else: for var_row in result: applyInfo = {} applyInfo['agentId'] = var_row.agentId applyInfo['time'] = var_row.applyTime applyInfo['qq'] = var_row.qq applyInfo['website'] = var_row.website applyInfo['introduction'] = var_row.introduction applyInfo['status'] = var_row.status objRsp.data.append(applyInfo) return classJsonDump.dumps(objRsp) except Exception as e: logging.error(repr(e)) raise e
def handleHttp(request: dict): """获取渠道LTV数据""" channel = request.get('channel', '') startTime = request.get('startTime', 0) endTime = request.get('endTime', 0) objRep = cResp() if not all([startTime,endTime]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) if (not checkIsInt(startTime)) or (not checkIsInt(endTime)): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: # conn=classSqlBaseMgr.getInstance(instanceName='probet_oss') with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: over_all_data=cData() #todo return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(request: dict): role_id = request.get('role_id', '') account_ids = request.get('account_ids', []) if (not role_id) or (len(account_ids) == 0): logging.debug(exceptionLogic(errorLogic.client_param_invalid)) raise exceptionLogic(errorLogic.client_param_invalid) try: conn = classSqlBaseMgr.getInstance() for x in account_ids: sql = "update dj_admin_account set role_id={} WHERE accountId='{}'".format( role_id, x) yield from conn._exeCuteCommit(sql) resp = cResp() sql = "select * from dj_admin_role" listRest = yield from conn._exeCute(sql) roles = yield from listRest.fetchall() for role in roles: data = cData() data.id = role['id'] data.role_name = role['role_name'] sql = "select accountId from dj_admin_account WHERE role_id={}".format( role['id']) listRest = yield from conn._exeCute(sql) accounts = yield from listRest.fetchall() data.accounts = [{"id": x['accountId']} for x in accounts] sql = "select id,action_name from dj_admin_action WHERE(id IN (select action_id from dj_admin_role_action WHERE role_id={})) ".format( role['id']) listRest = yield from conn._exeCute(sql) actions = yield from listRest.fetchall() data.actions = [{ "id": x['id'], "name": x['action_name'] } for x in actions] resp.data.append(data) resp.ret = errorLogic.success[0] fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "修改角色权限", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "修改角色id:{} 权限".format(role_id), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(resp) except IntegrityError as e: logging.debug(e) raise exceptionLogic(errorLogic.account_already_exists) except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(request: dict): """获取推广素材""" objRep = cResp() try: sql = "select * from dj_material order by update_time desc" result = yield from classSqlBaseMgr.getInstance()._exeCute(sql) if result.rowcount <= 0: return classJsonDump.dumps(objRep) else: for var in result: materialData = {} materialData['imageId'] = var.imageId materialData['image_url'] = var.image_url materialData['imageSize'] = var.imageSize objRep.data.append(materialData) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "获取推广素材", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "获取推广素材", 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(dict_param: dict): """ 获取维护状态 :param dict_param: json数据 :return: """ objRsp = cResp() objRsp.data = cData() platform = dict_param.get('platform', 1) if not platform: raise exceptionLogic(errorLogic.client_param_invalid) try: with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: sql = "select start_time,end_time,repairFlag from dj_repair where repairFlag=1 and platform=%s" result = yield from conn.execute(sql, [platform]) if result.rowcount <= 0: return classJsonDump.dumps(objRsp) else: for var_row in result: start_time = var_row.start_time end_time = var_row.end_time repairFlag = var_row.repairFlag surplus_time = end_time - timeHelp.getNow() if (surplus_time < 0) or (start_time > timeHelp.getNow()): surplus_time = 0 repairFlag = 0 objRsp.data.surplus_time = surplus_time objRsp.data.repairFlag = repairFlag return classJsonDump.dumps(objRsp) except Exception as e: logging.exception(e)
def handleHttp(request: dict): # 更新轮播图信息 bannerId = request.get('bannerId') title = request.get('title', '') link_url = request.get('link_url', '') bytesBase64Png = request.get("base64Png", "") if not bannerId: logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) if bytesBase64Png: bannerName = hashlib.md5(bytesBase64Png.encode()).hexdigest() imageData = base64.b64decode(bytesBase64Png[22:]) dirPrefix = "banner/" image_url = "http://probet-avator.oss-us-west-1.aliyuncs.com/{}{}.png".format(dirPrefix, bannerName) uploadDataFileToOss(imageData, dirPrefix, bannerName + ".png") sql = "update dj_banner set title='{}',link_url='{}',image_url='{}' WHERE id={} ".format(title, link_url,image_url, bannerId) else: sql = "update dj_banner set title='{}',link_url='{}' WHERE id={} ".format(title, link_url, bannerId) conn=classSqlBaseMgr.getInstance() try: yield from conn._exeCuteCommit(sql) sql="select * from dj_banner" listRest=yield from conn._exeCute(sql) banners=yield from listRest.fetchall() objRsp=cResp() if len(banners) == 0: return classJsonDump.dumps(objRsp) else: for var_row in banners: dataDict = cData() dataDict.index = var_row['index'] dataDict.title = var_row['title'] dataDict.image_url = var_row['image_url'] dataDict.link_url = var_row['link_url'] dataDict.update_time = var_row['update_time'] dataDict.addAccount = var_row['addAccount'] dataDict.id = var_row['id'] objRsp.data.append(dataDict) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "修改轮播图信息", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "修改轮播图信息Id:{}".format(bannerId), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRsp) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(dict_param: dict): """ 消息详情 """ objRsp = cResp() agentId = dict_param.get("agentId", "") msgId = dict_param.get("msgId", "") if not msgId: raise exceptionLogic(errorLogic.client_param_invalid) yield from classSqlBaseMgr.getInstance().changeReadFlag(msgId) MsgData = yield from classDataBaseMgr.getInstance().getOneAgentMsg( msgId, agentId) if MsgData: agentMsgData = {} agentMsgData['msgTime'] = MsgData.iMsgTime agentMsgData['msgTitle'] = MsgData.strMsgTitle agentMsgData['msgDetail'] = MsgData.strMsgDetail agentMsgData['readFlag'] = MsgData.iReadFlag agentMsgData['msgId'] = MsgData.strMsgId else: agentMsgData = [] # 构造回包 objRsp.data = agentMsgData return classJsonDump.dumps(objRsp)
def get_permission(accountId): # 获取该用户的权限名 try: conn = classSqlBaseMgr.getInstance() sql = select([tb_admin]).where(tb_admin.c.accountId == accountId) listRest = yield from conn._exeCute(sql) user = yield from listRest.fetchone() if not user: logging.debug(errorLogic.player_data_not_found) raise exceptionLogic(errorLogic.player_data_not_found) if not user['role_id']: logging.debug(errorLogic.player_data_not_found) raise exceptionLogic(errorLogic.player_data_not_found) sql = "SELECT dj_admin_action.action_name FROM dj_admin_action WHERE dj_admin_action.id IN (SELECT dj_admin_role_action.action_id FROM dj_admin_role_action WHERE dj_admin_role_action.role_id ={})".format( user['role_id']) listRest = yield from conn._exeCute(sql) objNames = yield from listRest.fetchall() action_names = [] for x in objNames: action_names.append(x['action_name']) return action_names except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
def handleHttp(dict_param: dict): """ 获取消息 """ objRsp = cResp() iPageNum = int(dict_param.get("pageNum", 1)) iType = int(dict_param.get("type", 0)) if not all([iType, iPageNum]): raise exceptionLogic(errorLogic.client_param_invalid) if iPageNum <= 0: raise exceptionLogic(errorLogic.client_param_invalid) MsgDataList, count = yield from classSqlBaseMgr.getInstance().getMsg( iType, iPageNum, 10) # 构造回包 objRsp.data = MsgDataList objRsp.count = count fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': dict_param.get('accountId', ''), 'action': "获取新闻/公告", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "获取新闻/公告", 'actionIp': dict_param.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) yield from asyncio.sleep(1) return classJsonDump.dumps(objRsp)
def wrapper(*args, **kwargs): conn = classSqlBaseMgr.getInstance() accountId = args[0].get('accountId', '') token = args[0].get('token', '') if not all([accountId, token]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: sql = select([tb_admin]).where(tb_admin.c.accountId == accountId) listRest = yield from conn._exeCute(sql) account = yield from listRest.fetchone() except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error) if not account: logging.debug(errorLogic.wrong_accountId_or_password) raise exceptionLogic(errorLogic.wrong_accountId_or_password) if account['token'] != token: logging.debug(errorLogic.token_not_valid) raise exceptionLogic(errorLogic.token_not_valid) is_pass = certify_admin_token(accountId, token) if not is_pass: #用户未登录 logging.debug(errorLogic.token_not_valid) raise exceptionLogic(errorLogic.token_not_valid) args[0]['account'] = account a = yield from view_func(*args, **kwargs) return a
def handleHttp(request: dict): """获取域名""" objRep = cResp() try: sql = "select * from dj_domain" result = yield from classSqlBaseMgr.getInstance()._exeCute(sql) if result.rowcount <= 0: return classJsonDump.dumps(objRep) else: pcDomainName = [] appDomainName = [] for var_row in result: if var_row.domainType == 'pc': domainDict = {} domainDict['domainId'] = var_row.domainId domainDict['domainName'] = var_row.domainName pcDomainName.append(domainDict) elif var_row.domainType == 'app': domainDict = {} domainDict['domainId'] = var_row.domainId domainDict['domainName'] = var_row.domainName appDomainName.append(domainDict) objRep.data = cData() objRep.data.pc = pcDomainName objRep.data.app = appDomainName return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise e
def deal_with_pingboBet_bill(self, dictBill): engine = classSqlBaseMgr.getInstance().getEngine() with (yield from engine) as conn: objSql = PingboBetBill.getSqlObj(dictBill) #print(objSql) #print(objSql.compile().params) trans = yield from conn.begin() try: yield from conn.execute(objSql) except IntegrityError as e: # 如果主键重复 logging.debug(repr(e)) sql = PingboBetBill.getUpdateSql(dictBill) yield from conn.execute(sql) yield from trans.commit() except Exception as e: # TODO log error logging.exception(e) yield from trans.rollback() else: yield from trans.commit()
def handleHttp(dict_param: dict): """ app消息详情 """ objRsp = cResp() agentId = dict_param.get("agentId", "") with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: sql_read = "update dj_all_msg set readFlag=1 where dj_all_msg.type=3 and sendTo=%s" yield from conn.execute(sql_read, [agentId]) sql = "select msgTime,msgTitle,msgDetail,msgId,readFlag from dj_all_msg where sendTo=%s and dj_all_msg.type=3 order by msgTime desc limit 0,10" result = yield from conn.execute(sql, [agentId]) if result.rowcount<=0: agentMsgList = [] else: agentMsgList = [] for var in result: agentMsgData = {} agentMsgData['msgTime'] = var.msgTime agentMsgData['msgTitle'] = var.msgTitle agentMsgData['msgDetail'] = var.msgDetail agentMsgData['readFlag'] = var.readFlag agentMsgData['msgId'] = var.msgId agentMsgList.append(agentMsgData) # 构造回包 objRsp.data = agentMsgList return classJsonDump.dumps(objRsp)
def handleHttp(dict_param: dict): """删除收件箱消息""" strMsgId = dict_param.get("msgId", "") if not strMsgId: raise exceptionLogic(errorLogic.client_param_invalid) # yield from classDataBaseMgr.getInstance().delSystemMsg(strMsgId) yield from classSqlBaseMgr.getInstance().delUserMsg(strMsgId)
def __update(session): try: retList = yield from get_settle_wagers(session) update_count = 0 if retList is None: logging.exception("retList is NoneType!") total_count = len(retList) engine = classSqlBaseMgr.getInstance().getEngine() with (yield from engine) as mysql_conn: for x in retList: with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: is_exist_sql = "select * from dj_pinbo_wagers WHERE wagerId=%s " is_exist = yield from conn.execute(is_exist_sql, [x['wagerId']]) is_exist = yield from is_exist.fetchone() if is_exist.status != 'SETTLED' and x[ 'status'] == 'SETTLED': strAccount = x["loginId"][7:] objPlayerData, objPlayerLock = yield from classDataBaseMgr.getInstance( ).getPlayerDataByLock(strAccount) if objPlayerData is None: logging.error( "accountId[{}] not valid".format(strAccount)) else: # 不可提现额度减投注额,直到0为止 if objPlayerData.iNotDrawingCoin - x[ 'toRisk'] * 100 < 0: objPlayerData.iNotDrawingCoin = 0 else: objPlayerData.iNotDrawingCoin -= int( x['toRisk'] * 100) yield from classDataBaseMgr.getInstance( ).setPlayerDataByLock(objPlayerData, objPlayerLock) ret = yield from updateBetOrder(x, mysql_conn) if ret[0] is True: if ret[1] == 'update': update_count += 1 logging.debug('total pingbo_wagers[{}],update success[{}]'.format( total_count, update_count)) except Exception as e: logging.exception(e) g_obj_loop.call_later(3 * 60, lambda: asyncio. async (__update(session)))
def handleHttp(request: dict): """删除推广素材""" objRep = cResp() imageId = request.get("imageId", "") if not imageId: logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: with (yield from classSqlBaseMgr.getInstance().objDbMysqlMgr) as conn: sql = "delete from dj_material where imageId=%s" yield from conn.execute(sql, [imageId]) sql = "select * from dj_material order by update_time desc" result = yield from classSqlBaseMgr.getInstance()._exeCute(sql) if result.rowcount <= 0: return classJsonDump.dumps(objRep) else: for var in result: materialData = {} materialData['imageId'] = var.imageId materialData['image_url'] = var.image_url materialData['imageSize'] = var.imageSize objRep.data.append(materialData) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "删除推广素材", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "删除推广素材imageId:{}".format(imageId), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRep) except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)