def post(self): parser = RequestParser() parser.add_argument('toEC', type=str, required=True) parser.add_argument('fromEC', type=str, required=True) kargs = parser.parse_args() shijianchuo = int(time.time()) actiontime = shijianchuo - 2592000 users = db.session.query( distinct(EntertainmentCityTradeLog.username), EntertainmentCityTradeLog.uid).filter( EntertainmentCityTradeLog.ec == kargs['fromEC'], EntertainmentCityTradeLog.state == 1, EntertainmentCityTradeLog.actionTime > actiontime).all() if not users: return {"errorMsg": "目前没有会员创建该娱乐城钱包"} r_data = {} for user in users: name = list(user) t_name = name[0] mContext = {} duixiang = Member.query.filter(Member.username == t_name).first() mContext["member"] = duixiang mContext['loginEC'] = kargs['toEC'] mContext["ip"] = host_to_value(request.remote_addr) mContext["real_ip"] = request.remote_addr current_app.logger.info('---------%s从%s取回会员钱包到主账户开始------------' % (g.current_user.username, kargs['fromEC'])) r_data = AmountTransfer.withdrawalToAccount(mContext, kargs) current_app.logger.info('---------%s从%s取回会员钱包到主账户结束------------' % (g.current_user.username, kargs['fromEC'])) history = OperationalRecord() history.username = g.current_user.username history.creatTime = time_to_value() history.remark = "取回%s所有钱包" % kargs['fromEC'] history.ylc = kargs['fromEC'] try: db.session.add(history) db.session.commit() except: db.session.rollback() db.session.remove() return r_data
def post(self, id): parser = RequestParser(trim=True) parser.add_argument('amount', type=float) parser.add_argument('pay_type', type=int) parser.add_argument('bank_type', type=str) m_args = parser.parse_args(strict=True) if not hasattr(g, 'current_member'): return {'errorCode': "9999", 'errorMsg': "用戶未登录", 'success': False} uid = g.current_member.id member = Member.query.filter(Member.id == uid).first() status = member.status if status == 2: m_html = ''' <body class="notfound"> <div class="wrapper"> <div class="big">页面不见了!</div> <div>该用户钱包已经被冻结</div> <div> </body> ''' if status == 0: m_html = ''' <body class="notfound"> <div class="wrapper"> <div class="big">页面不见了!</div> <div>该用户已被禁用</div> <div> </body> ''' m_response = make_response(m_html) m_response.headers["Content-type"] = "text/html;charset=UTF-8" return m_response paylogger.info("%s用户使用线上支付%s" % (g.current_member.id, m_args['amount'])) realIp = request.remote_addr ip = utils.host_to_value(realIp) m_res = Payment().pay(id, m_args, g.current_member.id, g.current_member.username, ip, realIp) paylogger.info("请求html------------------------") paylogger.info(m_res) paylogger.info("请求html------------------------") m_response = make_response(m_res) m_response.headers["Content-type"] = "text/html;charset=UTF-8" return m_response
def post(self, id): parser = RequestParser(trim=True) parser.add_argument('amount', type=float) parser.add_argument('remitter', type=str) parser.add_argument('msg', type=str) parser.add_argument('income_type', type=int) parser.add_argument('pay_type', type=int) parser.add_argument('bankId', type=int) parser.add_argument('accountName', type=int) m_args = parser.parse_args(strict=True) if not hasattr(g, 'current_member'): return {'errorCode': "9999", 'errorMsg': "用戶未登录", 'success': False} paylogger.info("%s用户公司入款 args:%s" % (g.current_member.username, m_args)) uid = g.current_member.id member = Member.query.filter(Member.id == uid).first() status = member.status if status == 2: return { 'errorCode': "9999", 'errorMsg': "该用户已被冻结", 'success': False } if status == 0: return { 'errorCode': "9999", 'errorMsg': "该用户已被禁用", 'success': False } if m_args['amount'] == None or m_args['pay_type'] == None: return {"success": False, 'errorCode': "1010", 'errorMsg': "充值失败"} m_amount = m_args['amount'] if m_amount <= 0: return { "success": False, 'errorCode': "1010", 'errorMsg': "充值失败,充值金额不正确" } ip = utils.host_to_value(request.remote_addr) m_res = Payment().recharge(id, m_args, g.current_member.id, g.current_member.username, ip) if m_res: return {"success": True} else: return {"success": False, 'errorCode': "1010", 'errorMsg': "充值失败"}
def post(self): if not hasattr(g, 'current_member'): return {'errorCode': "9999", 'errorMsg': "用戶未登录", 'success': False} parser = RequestParser(trim=True) parser.add_argument('fromEC', type=str, required=True) #源娱乐城 parser.add_argument('toEC', type=str, required=True) #目标娱乐城 parser.add_argument('amount', type=float, required=True) #金额 parser.add_argument('isDemo', type=int, default=0) #金额 kargs = parser.parse_args(strict=True) if g.current_member.username not in tempUser: return {"success": False, 'errorCode': 3000, 'errorMsg': "没有权限"} amount = kargs['amount'] if amount < 1: return {"success": False, 'errorCode': 3001, 'errorMsg': "转账发生错误"} fromEC = kargs['fromEC'] toEC = kargs['toEC'] mContext = {} mContext["member"] = g.current_member mContext["ip"] = host_to_value(request.remote_addr) mContext["real_ip"] = request.remote_addr mContext["loginEC"] = toEC #选择登录的娱乐城 current_app.logger.info('---------%s从%s转账到%s 开始------------' % (g.current_member.username, fromEC, toEC)) m_data = {'success': True} if fromEC == 'MAIN': ce = EntertainmentCityFactory.getEntertainmentCity(toEC) ce.context["member"] = g.current_member ce.register() m_data = AmountTransfer.accountToEntertainmentCity( mContext, kargs, ce) elif toEC == 'MAIN': m_data = AmountTransfer.withdrawalToAccount(mContext, kargs) # else: # m_data = AmountTransfer.withdrawalToAccount(mContext,kargs) # ce = EntertainmentCityFactory.getEntertainmentCity(toEC); # ce.context["member"] = g.current_member # m_data = AmountTransfer.accountToEntertainmentCity(mContext,kargs,ce) #AmountTransfer.saveECLog(g.current_member.id, g.current_member.username, int(time.time()), toEC, mContext['ip']) current_app.logger.info('---------%s从%s转账到%s 结束------------' % (g.current_member.username, fromEC, toEC)) return m_data
def put(self): parser = RequestParser(trim=True) parser.add_argument('orderid', type=int, required=True) parser.add_argument('state', type=int, required=True) parser.add_argument('amount', type=float, required=True) parser.add_argument('username', type=str, required=True) parser.add_argument('uid', type=int, required=True) args = parser.parse_args() user = User.query.get(g.current_user.id) # if user.systemDepositLimitOnce is not None: # if args['amount'] > user.systemDepositLimitOnce: # return jsonify({ # 'success': False, # 'errorCode': 403, # 'errorMsg': '超出单次存款上限' # }) # if user.systemDepositLimitCount is not None: # if user.systemDepositLimitTotal == None: # user.systemDepositLimitTotal = 0 # if args['amount'] > user.systemDepositLimitCount - user.systemDepositLimitTotal: # return jsonify({ # 'success': False, # 'errorCode': 403, # 'errorMsg': '超出您的总存入限额' # }) try: member = Member.query.get(args['uid']) if member: # 会员加钱 member.balance += args['amount'] db.session.add(member) # db.session.commit() # # 管理员-总存款限额 # if user.systemDepositLimitTotal == None: # user.systemDepositLimitTotal = 0 # user.systemDepositLimitTotal += args['amount'] # db.session.add(user) # 会员存款记录 deposit = Deposit() if 'uid' in args and args['uid'] is not None: deposit.memberId = args['uid'] if 'amount' in args and args['amount'] is not None: deposit.depositAmount = args['amount'] if 'orderid' in args and args['orderid'] is not None: deposit.number = str(args['orderid']) deposit.auditUser = user.id deposit.auditTime = time_to_value() deposit.auditHost = host_to_value(request.remote_addr) deposit.isAcdemen = 0 deposit.type = 900011 if 'username' in args and args['username'] is not None: deposit.username = args['username'] deposit.applicationAmount = args['amount'] deposit.applicationTime = time_to_value() deposit.applicationHost = host_to_value(request.remote_addr) deposit.status = 2 deposit.isDelete = 0 deposit.flag = 0 db.session.add(deposit) # db.session.commit() # # 账变信息 cion = MemberAccountChangeRecord() cion.memberId = args['uid'] cion.amount = args['amount'] cion.orderId = args['orderid'] cion.accountChangeType = 900011 cion.actionUID = user.id cion.OperatorName = user.username cion.time = time_to_value() cion.host = host_to_value(request.remote_addr) cion.isAcdemen = 0 cion.memberBalance = member.balance + deposit.depositAmount cion.memberFrozenBalance = member.frozenBalance cion.info = '额度转账确认' db.session.add(cion) # db.session.commit() # 管理员操作记录 optionhistory = OperationHistory() optionhistory.uid = member.id optionhistory.info = '转账额度确认%f' % args['amount'] optionhistory.username = member.username optionhistory.auditime = time_to_value() optionhistory.makeUser = g.current_user.id optionhistory.makeUserName = user.username optionhistory.ip = host_to_value(request.remote_addr) db.session.add(optionhistory) # db.session.commit() result = db.session.query(EntertainmentCityTradeLog).filter( EntertainmentCityTradeLog.orderid == args['orderid']).first() if 'state' in args and args['state'] is not None: # 修改转账额度确认状态 result.state = args['state'] result.operator = g.current_user.username result.actionTime = time_to_value() db.session.add(result) db.session.commit() except: db.session.rollback() db.session.remove() abort(500) return {'success': True, 'message': '手动补全额度成功'}
def post(self, code): if not hasattr(g, 'current_member'): return {'errorCode': "9999", 'errorMsg': "用戶未登录", 'success': False} parser = RequestParser(trim=True) parser.add_argument('deviceTypeCode', type=str) # 電腦版: PC, 手機版: Mobile parser.add_argument('gameCode', type=str) #游戏代码 parser.add_argument('isDemo', type=str, default=0) #是否试玩,默认否 kargs = parser.parse_args(strict=True) current_app.logger.info("%s用户登录%s娱乐城" % (g.current_member.username, code)) if g.current_member.username not in tempUser: return {"success": False, 'errorCode': 3000, 'errorMsg': "没有权限"} try: mContext = {} mContext["member"] = g.current_member mContext["ip"] = host_to_value(request.remote_addr) mContext["real_ip"] = request.remote_addr mContext["loginEC"] = code #选择登录的娱乐城 m_data = {'success': True} ce = EntertainmentCityFactory.getEntertainmentCity(code) if ce is None: current_app.logger.error({ "success": False, 'errorCode': 3000, 'errorMsg': "没有中找到娱乐城" }) return { "success": False, 'errorCode': 3000, 'errorMsg': "登录失败" } ce.context["member"] = g.current_member if code != 'MAIN': m_data = ce.register() if 'success' not in m_data or m_data['success'] == False: return { "success": False, 'errorCode': 3000, 'errorMsg': "登录失败" } if g.current_member.auto_change == 1: current_app.logger.info('---------额度转换开始------------') AmountTransfer.withdrawalToAccount(mContext, kargs) if code != 'MAIN': AmountTransfer.accountToEntertainmentCity( mContext, kargs, ce) current_app.logger.info('---------额度转换结束------------') if code != 'MAIN': m_data = ce.login(kargs) if 'success' not in m_data or m_data['success'] == False: return { "success": False, 'errorCode': 3000, 'errorMsg': "登录失败" } AmountTransfer.saveECLog(g.current_member.id, g.current_member.username, int(time.time()), code, mContext['ip']) except RuntimeError as e: return {"success": False, 'errorCode': 3000, 'errorMsg': "登录失败"} return m_data
def validate(self, parser): # 按文档的要求拼拼接符串 m_str = '''CreateTime=%s&Coin=%s&CoinAmount=%s&LegalAmount=%s&OrderId=%s&OrderNum=%s&Price=%s&Remark=%s&State1=%s&State2=%s&Token=%s&Type=%s&UserName=%s''' % ( parser['CreateTime'], parser['Coin'], parser['CoinAmount'], parser['LegalAmount'], parser['OrderId'], parser['OrderNum'], parser['Price'], parser['Remark'], parser['State1'], parser['State2'], parser['Token'], parser['Type'], parser['UserName']) #生成加密数据 m_sign = self.getSign(m_str, parser['OrderNum'], True) print( '**********************************加密数据*************************************' ) print(m_sign) print( '***********************************加密数据************************************' ) self.orderid = parser['OrderNum'] self.amount = float(parser['CoinAmount']) self.porderid = parser['OrderNum'] if parser['Sign'] == m_sign and parser['State1'] == 2 and parser[ 'State2'] == 2: deposit = Deposit.query.filter( Deposit.number == parser['OrderNum']).first() mid = OperationHistory().getMemberAll(deposit.memberId) if mid.status == 2: return {"success": False, "errorMsg": "该用户已被冻结"} GW = GsrkGW() h_GW = GW.setContext(parser['OrderNum']) GW.orderid = parser['OrderNum'] if deposit.pOrderid: GW.porderid = deposit.pOrderid else: GW.porderid = parser['OrderNum'] GW.amount = parser['CoinAmount'] try: if parser['State1'] == 2: h_sign = GW.accountChange(100004, 0, 0) if h_sign: OperationHistory().PublicData(100004, deposit) return {'messages': '充值成功', 'success': True} else: return {'errorMsg': '充值失败', 'success': False} else: deposit = Deposit.query.filter( Deposit.number == parser['OrderNum']).first() deposit_status = deposit.status if deposit_status != 1: return {'errorMsg': '状态错误', 'success': False} else: deposit.auditUser = g.current_user.id deposit.auditTime = time_to_value() deposit.auditHost = host_to_value(request.remote_addr) deposit.status = parser['State1'] db.session.add(deposit) db.session.commit() except: db.session.rollback() db.session.remove() else: return False