def gen_headers(): global TOKEN_LAST_GENERAL_TIME,TOKEN_PINBO if (timeHelp.getNow() - TOKEN_LAST_GENERAL_TIME) >= 10*60: TOKEN_PINBO=gen_token() TOKEN_LAST_GENERAL_TIME = timeHelp.getNow() return {'userCode': AGENT_CODE, 'token': TOKEN_PINBO}
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(dict_param: dict): """ 维护管理 :param dict_param: json数据 :return: """ objRsp = cResp() strAccountId = dict_param.get('accountId') startTime = dict_param.get("start", 0) endTime = dict_param.get("end", 0) RepairFlag = dict_param.get("repairFlag", 0) RepairId = dict_param.get("repairId", "") platform = dict_param.get("platform", 1) if not all([startTime, endTime]): raise exceptionLogic(errorLogic.client_param_invalid) repairData = classRepairData() if len(RepairId) <= 0: repairData.strRepairId = str(uuid.uuid1()) else: repairData.strRepairId = RepairId repairData.iTime = timeHelp.getNow() repairData.iStartTime = startTime repairData.iEndTime = endTime repairData.iRepairFlag = RepairFlag repairData.strAccountId = strAccountId repairData.iTimeOfUse = endTime - startTime repairData.iPlatform = platform yield from classDataBaseMgr.getInstance().addRepairData( repairData, RepairId) surplus_time = endTime - timeHelp.getNow() yield from pushPinboRepairData(endTime, RepairFlag, 0 if surplus_time < 0 else surplus_time, startTime, "broadCastPub") objRsp.data = cData() objRsp.data.reapirId = repairData.strRepairId objRsp.data.start = repairData.iStartTime objRsp.data.end = repairData.iEndTime objRsp.data.repairFlag = RepairFlag objRsp.data.platform = repairData.iPlatform yield from asyncio.sleep(1) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': dict_param.get('accountId', ''), 'action': "第三方维护状态修改", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "第三方维护状态修改", 'actionIp': dict_param.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRsp)
def calcDayWater(): #todo 同步中午12点前24小时的平博投注单 try: betList=yield from get_wagers() for x in betList: yield from todo_pingbo_wagers(x) except Exception as e: logging.exception(e) logging.error('{},中午流水计算平博注单修复失败,请及时人工修复平博注单,计算流水'.format(timestamp2Str(getNow()))) else: strLastCheckTime = yield from classDataBaseMgr.getInstance().getCalcDayWaterTime() if strLastCheckTime is None: yield from classDataBaseMgr.getInstance().setCalcDayWaterTime(timeHelp.getNow()) iLastCheckTime = int(strLastCheckTime) if not timeHelp.isSameBetDay(iLastCheckTime,timeHelp.getNow()): #隔bet日了,中午进行计算日流水,做返利活动 #计算日流水 yield from classDataBaseMgr.getInstance().setCalcDayWaterTime(timeHelp.getNow()) iTodayStartTs = timeHelp.todayStartTimestamp() #获取昨日投注流水 funFuture = asyncio.ensure_future(runExecuteAll(iTodayStartTs,iTodayStartTs-86400)) listAllRet = yield from asyncio.wait_for(funFuture,10) #TODO log for var_ret in listAllRet: strAccountId = var_ret["loginId"] iValidCoin = int(var_ret["validWaterCoin"] * 100) #单位换算成分 #拿用户数据 if len(strAccountId) <= 0 or strAccountId is None: logging.error("account data not find") continue if iValidCoin <= 0: logging.error("account [{}] validCoin [{}] not find".format(strAccountId,iValidCoin)) continue objPlayerData, objPlayLock = yield from classDataBaseMgr.getInstance().getPlayerDataByLock(strAccountId) if objPlayerData is None: logging.error("account [{}] data not find") continue dictVipCfg = vip_config.get(objPlayerData.iLevel,None) if dictVipCfg is None: logging.error("accountId[{}] vipLevel[{}] cfg is not valid".format(objPlayerData.strAccountId,objPlayerData.iLevel)) continue yield from classDataBaseMgr.getInstance().releasePlayerDataLock(objPlayerData.strAccountId) iRebate = int(iValidCoin / 1000 * dictVipCfg[rebate]) balance = objPlayerData.iCoin + iRebate objPlayerData.iCoin += iRebate #TODO 日红利计算的bill要记录一下 yield from classDataBaseMgr.getInstance().setPlayerDataByLock(objPlayerData,objPlayLock) yield from addPlayerBill(strAccountId, iValidCoin, balance, CoinOp.coinOpPingboDayWaterRebate, iValidWater=iRebate, strDes="日有效流水[{}]返利[{}]".format(iValidCoin/100,iRebate/100))
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(request: dict): """代理账号管理""" agentId = request.get('agentId', '') lockTime = request.get('lockTime', '') lockReason = request.get('lockReason', '') status = request.get('status', '') if not agentId: logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: objAgentData = yield from classDataBaseMgr.getInstance().getAgentData( agentId) if objAgentData is None: logging.debug(errorLogic.agent_data_not_found) raise exceptionLogic(errorLogic.agent_data_not_found) if status == 0: # 解封 objAgentData.iStatus = status objAgentData.iLockStartTime = 0 objAgentData.iLockEndTime = 0 objAgentData.strLockReason = "" else: # 冻结账号 if not all([lockTime, lockReason]): logging.debug(errorLogic.lockTime_or_lockReason_lack) raise exceptionLogic(errorLogic.lockTime_or_lockReason_lack) objAgentData.iStatus = 1 objAgentData.iLockStartTime = timeHelp.getNow() objAgentData.iLockEndTime = timeHelp.getNow() + int(lockTime) objAgentData.strLockReason = lockReason yield from classDataBaseMgr.getInstance().setAgentData(objAgentData) resp = cResp() fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "代理账号管理修改", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "代理账号管理修改:{}".format(agentId), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(resp) except exceptionLogic as e: logging.error(repr(e)) raise e
def calcMonthVip(): strLastCheckTime = yield from classDataBaseMgr.getInstance().getCalcDayWaterTime() if strLastCheckTime is None: yield from classDataBaseMgr.getInstance().setCalcMonthWaterTime(timeHelp.getNow()) iLastCheckTime = int(strLastCheckTime) if not timeHelp.isSameMonth(iLastCheckTime, timeHelp.getNow()): # 计算月流水 yield from classDataBaseMgr.getInstance().setCalcMonthWaterTime(timeHelp.getNow()) iLastStartTs = timeHelp.lastMonthStartTimestamp() iNowStartTs = timeHelp.monthStartTimestamp() funFuture = asyncio.ensure_future(runExecuteAll(iLastStartTs, iNowStartTs)) listAllRet = asyncio.wait_for(funFuture,10) for var_ret in listAllRet: strAccountId = var_ret["loginId"] iValidCoin = var_ret["validWaterCoin"] * 100 #单位换算成分 #拿用户数据 if len(strAccountId) <= 0 or strAccountId is None: logging.error("account data not find") continue if int(iValidCoin) <= 0: logging.error("account [{}] validCoin [{}] not find".format(strAccountId,iValidCoin)) continue objPlayerData, objPlayLock = yield from classDataBaseMgr.getInstance().getPlayerDataByLock(strAccountId) if objPlayerData is None: logging.error("account [{}] data not find") continue dictVipCfg = vip_config.get(objPlayerData.iLevel,None) if dictVipCfg is None: logging.error("accountId[{}] vipLevel[{}] cfg is not valid".format(objPlayerData.strAccountId,objPlayerData.iLevel)) continue yield from classDataBaseMgr.getInstance().releasePlayerDataLock(objPlayerData.strAccountId) iVipLimit = dictVipCfg["keepValidWater"] if iValidCoin < iVipLimit: #降级 if objPlayerData.iVip > 0: objPlayerData.iVip -= 1 #TODO 自动发公告内容 yield from classDataBaseMgr.getInstance().setPlayerDataByLock(objPlayerData, objPlayLock) else: #TODO bill pass else: #TODO bill pass
def handleHttp(request: dict): # 获取充值账户下的待处理账单 transTo = request.get('transTo', '') money = request.get('money', '') if not transTo: logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: conn = classSqlBaseMgr.getInstance() if money: if cpv.checkIsString(money): raise exceptionLogic(errorLogic.client_param_invalid) fMoney = float(money) if not cpv.checkIsFloat(fMoney): raise exceptionLogic(errorLogic.client_param_invalid) iCoin = int(fMoney * 100) if not cpv.checkIsInt(iCoin): raise exceptionLogic(errorLogic.client_param_invalid) ids_sql = "select orderId from dj_coin_history WHERE transTo='{}' AND coinNum={} AND tradeState=2 AND tradeType=1 ".format( transTo, iCoin) else: ids_sql = "select orderId from dj_coin_history WHERE transTo='{}' AND tradeState=2 AND tradeType=1 ".format( transTo) sql = "select * from dj_pay_order WHERE payOrder IN (" + ids_sql + ") and orderTime between {} and {} order by status desc,orderTime desc".format( getNow() - 3600 * 24, getNow()) listRest = yield from conn._exeCute(sql) pay_list = yield from listRest.fetchall() resp = cResp() for x in pay_list: data = cData() data.payOrder = x['payOrder'] data.payChannel = x['payChannel'] data.accountId = x['accountId'] data.orderTime = x['orderTime'] data.buyCoin = "%.2f" % round(x['buyCoin'] / 100, 2) data.ip = x['ip'] data.status = x['status'] resp.data.append(data) resp.ret = errorLogic.success[0] return classJsonDump.dumps(resp) except exceptionLogic as e: logging.error(repr(e)) raise e except Exception as e: logging.exception(e) raise exceptionLogic(errorLogic.db_error)
def calcRank(): strLastCheckTime = yield from classDataBaseMgr.getInstance( ).getRankDayWaterTime() if strLastCheckTime is None: yield from classDataBaseMgr.getInstance().setCalcDayWaterTime( timeHelp.getNow()) iLastCheckTime = int(strLastCheckTime) if not timeHelp.isSameHour(iLastCheckTime, timeHelp.getNow()): #一个小时计算一次 yield from classDataBaseMgr.getInstance().setRankDayWaterTime( timeHelp.getNow())
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(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): """ 获取指定消息 """ objRsp = cResp() strMsgId = dict_param.get("msgId", "") iType = dict_param.get("type", 0) if not strMsgId: raise exceptionLogic(errorLogic.client_param_invalid) MsgData = yield from classDataBaseMgr.getInstance().getOneMsg(iType, strMsgId) if MsgData is None: return classJsonDump.dumps(objRsp) # 构造回包 objRsp.data = cData() objRsp.data.Msg = MsgData fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': dict_param.get('accountId', ''), 'action': "获取消息", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "获取消息Id:{}".format(strMsgId), 'actionIp': dict_param.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRsp)
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(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(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 initActiveData(strAccountId): # 初始化 活动数据 objActiveData = yield from classDataBaseMgr.getInstance().getActiveData( strAccountId) if objActiveData is not None: # raise exceptionLogic(errorLogic.active_already_exist) logging.error( "account[{}] active data already exist".format(strAccountId)) return objNewActiveData = classActiveData() objNewActiveData.strAccountId = strAccountId iNowTime = timeHelp.getNow() for var_cfg in activeConfig_cfg.values(): if (var_cfg["actStartTime"] < iNowTime) and (iNowTime < var_cfg["actEndTime"]): #在活动有效时间内 if var_cfg["getTaskCondition"] == enumActiveStartType.startRegist: objNewActiveItem = classActiveItem() objNewActiveItem.iActiveId = int(var_cfg['id']) # objNewActiveItem.iActiveTime = timeHelp.getNow() objNewActiveItem.iActiveTime = 0 objNewActiveItem.iActiveState = enumActiveState.stateGet objNewActiveData.dictActiveItem[ objNewActiveItem.iActiveId] = objNewActiveItem for var_active_type_id in g_activeTypeIdCfg: objNewActiveTypeItem = classActiveTypeItem() objNewActiveTypeItem.iActiveTypeId = var_active_type_id objNewActiveData.dictActiveTypeItem[ var_active_type_id] = objNewActiveTypeItem yield from classDataBaseMgr.getInstance().setActiveDataByLock( objNewActiveData, "", False, True)
def handleHttp(dict_param: dict): """ 后台添加新闻公告系统消息 """ objRsp = cResp() strAccountId = dict_param.get('accountId') iMsgType = int(dict_param.get("type", 0)) strMsgTitle = dict_param.get("title", "") strMsgDetail = dict_param.get("detail", "") strMsgId = dict_param.get("msgId", "") if not all([iMsgType, strMsgTitle, strMsgDetail]): raise exceptionLogic(errorLogic.client_param_invalid) if iMsgType == getMsgType.getNoticeType: iBroadcast = int(dict_param.get("broadcast", 0)) objNewMsg = addMsgInfo(strMsgTitle, strMsgDetail, iMsgType, strAccountId, strMsgId) objNewMsg.iBroadcast = iBroadcast yield from classDataBaseMgr.getInstance().addMsg( iMsgType, objNewMsg, strMsgId) # 构造回包 objRsp.data = cData(objNewMsg.strMsgId, objNewMsg.strMsgTitle, objNewMsg.strMsgDetail, objNewMsg.iMsgTime, iMsgType) objRsp.data.iBroadcast = iBroadcast yield from asyncio.sleep(1) return classJsonDump.dumps(objRsp) elif iMsgType == getMsgType.getNewsType: objNewMsg = addMsgInfo(strMsgTitle, strMsgDetail, iMsgType, strAccountId, strMsgId) yield from classDataBaseMgr.getInstance().addMsg( iMsgType, objNewMsg, strMsgId) # 构造回包 objRsp.data = cData(objNewMsg.strMsgId, objNewMsg.strMsgTitle, objNewMsg.strMsgDetail, objNewMsg.iMsgTime, iMsgType) yield from asyncio.sleep(1) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': dict_param.get('accountId', ''), 'action': "发送新闻公告", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "发送新闻公告Id:{},标题:{}".format(strMsgId, strMsgTitle), 'actionIp': dict_param.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRsp) else: logging.error("unknown msg type [{}]".format(iMsgType)) raise exceptionLogic(errorLogic.client_param_invalid)
def handleHttp(request: dict): """代理管理""" objRep = cResp() agentConfigs = yield from classDataBaseMgr.getInstance().getAgentConfig() for bytesAgent in agentConfigs: data = cData() data.name = bytesAgent.strName data.rate = bytesAgent.iRate data.kind = bytesAgent.iKind objRep.data.append(data) 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(objRep)
def updateMatchState(): objRedis = classDataBaseMgr.getInstance() iNowTime = timeHelp.getNow() # 获取当前比赛的数据 listMatchData = yield from objRedis.getMatchDataListByScore(0,-1,"all") iMatchIndex = 0 for iIndex in range(0, len(listMatchData)): try: var_match = listMatchData[iIndex] if var_match.iMatchState == 3: continue if iNowTime >= var_match.iMatchStartTimestamp: if var_match.iMatchState < 2: # 如果状态没有被 数据中心回调,这里继续增加竞猜延迟 objMatchData,objMatchLock = yield from objRedis.getMatchDataByLock(var_match.strMatchId) objMatchData.iMatchState = 2 yield from classDataBaseMgr.getInstance().setMatchDataByLock(objMatchData,objMatchLock) else: pass finally: iMatchIndex += 1
def updateActive(self, objPlayerData, iPayCoin, iOrderTime, objActiveTypeItem): if objActiveTypeItem is None: logging.error("accountId[{}] not have the payRebate active".format( objPlayerData.strAccountId)) return if objActiveTypeItem.iActiveState > enumActiveState.stateGet: # 活动已经完成,pass return # 获取上一次充值,活动充值的时间 iLastActivePayTime = objActiveTypeItem.dictParam.get("activePayNum", 0) if iLastActivePayTime == 0: # 上一次没有充值过 objActiveTypeItem.dictParam["activePayTime"] = iOrderTime if "activePayCoin" in objActiveTypeItem.dictParam: objActiveTypeItem.dictParam["activePayCoin"] += iPayCoin else: objActiveTypeItem.dictParam["activePayCoin"] = iPayCoin else: # 查看活动充值是否已经超过24小时 if (timeHelp.getNow() - iLastActivePayTime) > 24 * 3600: objActiveTypeItem.dictParam["activePayTime"] = iOrderTime objActiveTypeItem.dictParam["activePayCoin"] = iPayCoin else: if "activePayCoin" in objActiveTypeItem.dictParam: objActiveTypeItem.dictParam["activePayCoin"] += iPayCoin else: objActiveTypeItem.dictParam["activePayCoin"] = iPayCoin
def addCommissionBill(billId,agentId,year,month,newAccountNum,activelyAccountNum,probetWinLoss,pinboWinLoss,winLoss,probetRate,pingboRate,probetPlatformCost,pingboPlatformCost,platformCost,depositDrawingPoundage,backWater,activetyBonus,allWater,netProfit,preBalance,balance,proportion,commission,status): """生成佣金报表""" objAgentCommissionData = classAgentCommissionData() objAgentCommissionData.strBillId = billId objAgentCommissionData.strAgentId = agentId objAgentCommissionData.iTime = timeHelp.getNow() objAgentCommissionData.iYear = year objAgentCommissionData.iMonth = month objAgentCommissionData.iNewAccount = newAccountNum objAgentCommissionData.iActiveAccount = activelyAccountNum objAgentCommissionData.iProbetWinLoss = -probetWinLoss objAgentCommissionData.iPingboWinLoss = -pinboWinLoss objAgentCommissionData.iWinLoss = winLoss objAgentCommissionData.fProbetRate = probetRate objAgentCommissionData.fPingboRate = pingboRate objAgentCommissionData.iProbetCost = probetPlatformCost objAgentCommissionData.iPingboCost = pingboPlatformCost objAgentCommissionData.iPlatformCost = platformCost objAgentCommissionData.iDepositDrawingCost = depositDrawingPoundage objAgentCommissionData.iBackWater = backWater objAgentCommissionData.iBonus = activetyBonus objAgentCommissionData.iWater = allWater objAgentCommissionData.iNetProfit = netProfit objAgentCommissionData.iPreBalance = preBalance objAgentCommissionData.iBalance = balance objAgentCommissionData.fCommissionRate = proportion objAgentCommissionData.iCommission = commission objAgentCommissionData.iStatus = status return objAgentCommissionData
def handleHttp(request: dict): delId = request.get('id', '') if not delId: logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) try: conn = classSqlBaseMgr.getInstance() sql = "delete from dj_admin_account WHERE id={}".format(delId) yield from conn._exeCuteCommit(sql) sql = "select count(id) from dj_admin_account" listRest = yield from conn._exeCute(sql) count = yield from listRest.fetchone() sql = "select * from dj_admin_account order by dj_admin_account.id limit {}".format( MSG_PAGE_COUNT) listRest = yield from conn._exeCute(sql) accounts = yield from listRest.fetchall() resp = cResp() for x in accounts: data = cData() data.id = x['id'] data.accountId = x['accountId'] if x['role_id'] is None: data.role_name = '' else: sql = "select dj_admin_role.role_name from dj_admin_role WHERE dj_admin_role.id={}".format( x['role_id']) listRest = yield from conn._exeCute(sql) role_name = yield from listRest.fetchone() data.role_name = role_name[0] resp.data.append(data) resp.count = count[0] 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': "删除后台账号:{}".format(delId), 'actionIp': request.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(resp) except exceptionLogic as e: logging.error(repr(e)) raise e except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
def getVipPayRebate( strAccountId ,objActiveData, objActiveTypeItem): objData = cData() objActiveItem = objActiveData.getItemByTypeId(enumActiveType.activeVipPayRebate) objPlayerData = yield from classDataBaseMgr.getInstance().getPlayerData(strAccountId) if objPlayerData is None: raise exceptionLogic(errorLogic.player_data_not_found) objData.iCurrentVipLevel = objPlayerData.iLevel #跟进vip 等级 计算 iActiveId objData.iActiveId = getVipActiveId(objPlayerData.iLevel) if objActiveItem is None: # 还没有此类型的领取活动 objData.iCurrentPayCoin = objActiveTypeItem.dictParam.get("activePayCoin",0) objData.iActiveStatus = enumActiveState.stateGet # 如果activepaytime 还没有 lefttime = 0 iLeftTime = (24 * 3600 - (timeHelp.getNow() - objActiveTypeItem.dictParam.get("activePayTime",0))) if iLeftTime < 0: iLeftTime = 0 objData.iLeftSeconds = iLeftTime else: #活动开始到现在有效流水 validWater = yield from classSqlBaseMgr.getInstance().getValidWaterByTimeRange(objActiveItem.iActiveTime, timeHelp.getNow(), strAccountId) pingboValidWater = yield from classSqlBaseMgr.getInstance().getAccountPinboHistoryValidWater( objActiveItem.iActiveTime, timeHelp.getNow(), strAccountId) objData.iCurrentValidWater = validWater + pingboValidWater #当月的流水 iLastStartTs = timeHelp.lastMonthStartTimestamp() iNowStartTs = timeHelp.monthStartTimestamp() pinboMonthValidWater = yield from classSqlBaseMgr.getInstance().getOnePinboHistoryValidWater(strAccountId, iLastStartTs, iNowStartTs) monthValidWater = yield from classSqlBaseMgr.getInstance().getValidWaterMonthly(strAccountId) objData.iCurrentMonthValidWater = pinboMonthValidWater + monthValidWater objData.iActiveStatus = enumActiveState.stateAward return objData
def handleHttp(request: dict): """代理新增线下用户""" objRep = cResp() agentId = request.get('agentId', '') offlineUser = request.get('offlineUser', '') if not all([agentId, offlineUser]): raise exceptionLogic(errorLogic.client_param_invalid) try: agentData = yield from classDataBaseMgr.getInstance().getAgentData( agentId) if agentData is None: # 判断是否是代理 logging.debug(errorLogic.agent_data_not_found) raise exceptionLogic(errorLogic.agent_data_not_found) userIsAgent = yield from classDataBaseMgr.getInstance().getAgentData( offlineUser) if userIsAgent is not None: # 判断新增用户是否是代理 logging.debug(errorLogic.user_is_agent) raise exceptionLogic(errorLogic.user_is_agent) # 判断新增用户是否是有代理 userData, objPlayerLock = yield from classDataBaseMgr.getInstance( ).getPlayerDataByLock(offlineUser) if userData is None: logging.debug(errorLogic.player_data_not_found) raise exceptionLogic(errorLogic.player_data_not_found) if userData.strAgentId != '': logging.debug(errorLogic.user_has_agent) raise exceptionLogic(errorLogic.user_has_agent) userData.strAgentId = agentId yield from classDataBaseMgr.getInstance().setPlayerDataByLock( userData, objPlayerLock) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': request.get('accountId', ''), 'action': "代理新增下线用户", 'actionTime': getNow(), 'actionMethod': methodName, 'actionDetail': "给代理:{} 新增下线用户:{}".format(agentId, offlineUser), '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 welcomeMsg(strAccountId): SysMsgData = classMessageData() SysMsgData.iMsgTime = timeHelp.getNow() SysMsgData.strMsgId = str(uuid.uuid1()) SysMsgData.strAccountId = strAccountId SysMsgData.strMsgTitle = "欢迎加入probet!" SysMsgData.strMsgDetail = "尊敬的{},恭喜您已经成为Probet正式会员。我们将为您提供海量的电竞,体育赛事,同时我们提供便捷的存提款方式让您毫无后顾之忧," \ "probet是注册于菲律宾的合法博彩公司,我们会倾尽全力为您的资金保驾护航,再次欢迎您光临。".format(strAccountId) SysMsgData.strSendFrom = "Pro电竞" return SysMsgData
def handleHttp(request:dict): # 修改密码 accountId=request.get('accountId','') oldPassword=request.get('oldPassword','') password=request.get('password','') rePassword=request.get('rePassword','') if not all([accountId,password,rePassword]): logging.debug(errorLogic.client_param_invalid) raise exceptionLogic(errorLogic.client_param_invalid) if password!=rePassword: logging.debug(errorLogic.login_pwd_not_valid) raise exceptionLogic(errorLogic.login_pwd_not_valid) if len(password)<6 or len(password)>20: logging.debug(errorLogic.player_TradePwd_length_out_of_range) raise exceptionLogic(errorLogic.player_TradePwd_length_out_of_range) try: conn=classSqlBaseMgr.getInstance() sql="select passwordHash from dj_admin_account WHERE accountId='{}'".format(accountId) listRest=yield from conn._exeCute(sql) old_pwd=yield from listRest.fetchone() if not check_password(old_pwd['passwordHash'],oldPassword): logging.debug(errorLogic.login_only_old_pwd_not_valid) raise exceptionLogic(errorLogic.login_only_old_pwd_not_valid) sql="update dj_admin_account set passwordHash='{}' WHERE accountId='{}'".format(generate_password_hash(password),accountId) yield from conn._exeCuteCommit(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 exceptionLogic as e : raise e except Exception as e: logging.debug(e) raise exceptionLogic(errorLogic.db_error)
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 __init__(self): self.file_handle = None self.file_name = "" self.file_seek_pos = 0 self.file_seek_pos_change_flag = False self.init_state = False self.change_continue_flag = False self.last_change_time = 0 self.last_update_time = timeHelp.getNow()
def handleHttp(dict_param: dict): """ 后台添加代理消息 """ objRsp = cResp() sendTo = dict_param.get("agentIds", "") strMsgTitle = dict_param.get("msgTitle", "") strMsgDetail = dict_param.get("msgDetail", "") AccountId = dict_param.get("accountId", "") msgId = dict_param.get("msgId", "") if not all([strMsgTitle, strMsgDetail]): raise exceptionLogic(errorLogic.client_param_invalid) MsgId = str(uuid.uuid1()) if sendTo: agentIds = sendTo.split(',') for agentId in agentIds: objNewMsg = addMsgInfo(MsgId, strMsgTitle, strMsgDetail, agentId, AccountId) yield from classDataBaseMgr.getInstance().addAgentMsg( objNewMsg, msgId) # yield from pushPlayerMsg(agentId, MsgId, "broadCastPub") else: sql = "select agentId from dj_agent" listResult = yield from classSqlBaseMgr.getInstance()._exeCute(sql) result = yield from listResult.fetchall() if len(result) == 0: logging.info(" 没有账户 ") else: for var_row in result: agentId = var_row.agentId objNewMsg = addMsgInfo(MsgId, strMsgTitle, strMsgDetail, agentId, AccountId) yield from classDataBaseMgr.getInstance().addAgentMsg( objNewMsg, msgId) # yield from pushPlayerMsg(agentId, MsgId, "broadCastPub") yield from asyncio.sleep(1) fileName = __name__ nameList = fileName.split('.') methodName = nameList.pop() # 日志 dictActionBill = { 'billType': 'adminActionBill', 'accountId': dict_param.get('accountId', ''), 'action': "给代理发送消息", 'actionTime': timeHelp.getNow(), 'actionMethod': methodName, 'actionDetail': "给代理发送消息Id:{}".format(msgId), 'actionIp': dict_param.get('srcIp', ''), } logging.getLogger('bill').info(json.dumps(dictActionBill)) return classJsonDump.dumps(objRsp)