Beispiel #1
0
 def deposit(self):
     if 'member' not in self.context:
         return self.validateAndReturn(None, 3002, "存款余额失败,用户未登录")
     member = self.context['member']
     amount = self.context['amount']
     last_ce = self.context['last_ce']
     try:
         new_Member = Member.amountToMemberAccount(member.username, amount)
     except Exception as e:
         current_app.logger.exception(e)
         current_app.logger.error("%s向主账户存款失败,内部错误%s" %
                                  (member.username, e))
         current_app.logger.error(
             "%s从%s娱乐城取款%s已经完成,但是将金额存回主账户时错误,请查看详细日志。" %
             (member.username, self.context['last_ce'], amount))
         current_app.logger.error(
             {
                 "success": False,
                 'errorCode': 9001,
                 'errorMsg':
                 "%s从%s娱乐城取款%s已经完成,但是将金额存回主账户时错误,这是一个严重错误,需要人工存入"
             } % (member.username, self.context['last_ce'], amount))
         return {"success": False, 'errorCode': 3001, 'errorMsg': "转账失败"}
Beispiel #2
0
 def withdrawalToAccount(context, kargs):
     uid = context['member'].id
     username = context['member'].username
     isTsetPLay = context['member'].isTsetPLay
     actionTime = int(time.time())
     last_ce = None
     ecTradeDao = None
     if 'isDemo' in kargs:
         if kargs['isDemo'] == '1' or isTsetPLay == 1:
             current_app.logger.info('%s试玩账号不需要额度转换' % (username))
             return {"success": True}
     if 'fromEC' in kargs and kargs['fromEC'] is not None:
         last_ce = kargs['fromEC']
     else:
         #获取上一次用户登录的娱乐城
         ecLogDao = EntertainmentCityLog()
         last_ce = ecLogDao.getLastLogin(uid)
     if last_ce is None:
         return {"success": True}
     current_app.logger.info("%s本次娱乐城:%s" % (username, context['loginEC']))
     current_app.logger.info("%s上次娱乐城:%s" % (username, last_ce))
     #如果本次与上一次登录的是同一个娱乐城或者上一次在kk。则不用转账
     if (last_ce == "MAIN") or (last_ce == context['loginEC']):
         current_app.logger.info('%s不需要取款' % (username))
         return {"success": True}
     amount = None
     lastEC = EntertainmentCityFactory.getEntertainmentCity(last_ce)
     lastEC.context["member"] = context["member"]
     #去上一个娱乐城查询余额
     try:
         m_res = lastEC.balance(kargs)
         if m_res['success'] == False:
             current_app.logger.error("%s查询余额错误:%s" % (username, m_res))
             return {
                 "success": False,
                 'errorCode': 3001,
                 'errorMsg': "查询余额错误"
             }
     except Exception as e:
         current_app.logger.exception(format(e))
         current_app.logger.error("%s查询余额错误:%s" % (username, m_res))
         return {"success": False, 'errorCode': 3001, 'errorMsg': "查询余额错误"}
     #娱乐城的余额
     balance = float(m_res['data']['balance'])
     current_app.logger.info('%s在%s余额:%s' % (username, last_ce, balance))
     if 'amount' in kargs:
         amount = kargs['amount']
         current_app.logger.info('%s从%s取款:%s' % (username, last_ce, amount))
         if amount > balance:
             current_app.logger.info("%s取款金额大于娱乐城余额,余额是%s" %
                                     (username, balance))
             return {
                 "success": False,
                 'errorCode': 3001,
                 'errorMsg': "转账失败"
             }
         else:
             balance = amount
     lastEC.context["amount"] = balance
     orderid = createECOrderId(uid)
     lastEC.context['orderid'] = orderid
     wjorderId = None
     #取款
     if balance >= 1:
         current_app.logger.info('开始取款')
         #生成交易记录
         ecTradeDao = AmountTransfer.saveECTradeLog(uid, username, balance,
                                                    actionTime, 'MAIN',
                                                    last_ce, orderid, None,
                                                    context['real_ip'], 0,
                                                    0)
         try:
             m_res = lastEC.withdrawal(None)
         except Exception as e:
             current_app.logger.exception(e)
             current_app.logger.error('%s从%s取款失败' % (username, last_ce))
             AmountTransfer.updateECTradeLog(ecTradeDao, None, 0, 0, 0)
             #生成交易明细
             AmountTransfer.saveECTradeDetail(uid, username, actionTime,
                                              balance, orderid, last_ce,
                                              None, 0, '娱乐城取款失败,不用额度确认',
                                              None)
             #                 AmountTransfer.saveECTradeLog(uid, username, balance, actionTime, 'MAIN',last_ce, orderid, wjorderId, context['real_ip'],2,0,'娱乐城转账失败,余额已从娱乐城转出,需要人工审核结案')
             return {
                 "success": False,
                 'errorCode': 3001,
                 'errorMsg': "转账失败"
             }
         if m_res['success'] == False:
             current_app.logger.error('%s从%s取款失败:%s' %
                                      (username, last_ce, m_res))
             AmountTransfer.updateECTradeLog(ecTradeDao, None, 0, 0, 0)
             AmountTransfer.saveECTradeDetail(uid, username, actionTime,
                                              balance, orderid, last_ce,
                                              None, 0, '娱乐城取款失败,不用额度确认',
                                              None)
             return {
                 "success": False,
                 'errorCode': 3001,
                 'errorMsg': "转账失败"
             }
         wjorderId = AmountTransfer.getWjorderId(m_res, last_ce)
         AmountTransfer.updateECTradeLog(ecTradeDao, wjorderId, 0, 1, 2)
         AmountTransfer.saveECTradeDetail(uid, username, actionTime,
                                          balance, orderid, last_ce, None,
                                          1, '交易成功', None)
         current_app.logger.info('%s结束取款' % (username))
         current_app.logger.info('%s取出余额:%s' % (username, balance))
     else:
         current_app.logger.info('%s结束取款取款金额小于1元' % (username))
         return {"success": True}
     #将余额存回主账户
     current_app.logger.info("%s转回主账户开始" % (username))
     #如果钱已经从娱乐城取出,但是更新主账户金额时发生错误(例如数据库链接不上),需要日志记录,否前钱不回来
     try:
         member = Member.amountToMemberAccount(username, balance)
     except Exception as e:
         current_app.logger.exception(e)
         current_app.logger.error("%s转回主账户失败,内部错误%s" % (username, e))
         current_app.logger.error(
             "%s从%s娱乐城取款%s已经完成,但是将金额更新回主账户时错误,请查看详细日志。" %
             (username, last_ce, balance))
         current_app.logger.error({
             "success":
             False,
             'errorCode':
             9001,
             'errorMsg':
             "%s从%s娱乐城取款%s已经完成,但是将金额更新回主账户时错误,这是一个严重错误,需要人工存入" %
             (username, last_ce, balance)
         })
         AmountTransfer.updateECTradeLog(
             ecTradeDao, wjorderId, 0, 1, 2, 0,
             "%s从%s娱乐城取款%s已经完成,将余额存入回主账户的过程中发生错误,这是一个严重错误,需要人工存入" %
             (username, last_ce, balance),
             '确认转账状态与判断不符而造成掉额度,开始进行补额度 - [系統]')
         AmountTransfer.saveECTradeDetail(
             uid, username, actionTime, balance, orderid, 'MAIN', 1, 2,
             '交易失败', '确认转账状态与判断不符而造成掉额度,开始进行补额度 - [系統]')
         return {"success": False, 'errorCode': 3001, 'errorMsg': "转账失败"}
     current_app.logger.info("转回主账户完成")
     AmountTransfer.updateECTradeLog(ecTradeDao, wjorderId, 1, 1, 1, None,
                                     '转账成功', None)
     AmountTransfer.saveCoinlog(uid, balance, member, actionTime, orderid,
                                wjorderId, 'MAIN', last_ce, context['ip'],
                                400, '转回主账户完成')
     AmountTransfer.saveECTradeDetail(uid, username, actionTime, balance,
                                      orderid, 'MAIN', None, 1, '交易成功',
                                      None)
     return {"success": True}