예제 #1
0
    def callback(self):
        # print ('start...')
        # self.api.
        try:
            self.conn = conn(self.config['db'])
            # 判断是否开启
            statusResult = api.getLoginInfo(self.conn,
                                            self.conf['serviceCode'])
            # 关闭同步功能
            if not statusResult or statusResult['status'] == 0:
                print('coco:autotask:stoped', statusResult['status'])
                self.api.stopBuyinWork()
                return

            # 开启带入提案审批任务
            self.api.startBuyinWork()
            self.settlement()
            # print('status = 1')
            # self.memberInfo = statusResult
            # self.cursor = self.conn.cursor()
            # self.settlement()
            # self.cursor.close()
            # self.conn.commit()
        except Exception as e:
            print "rollback"
            traceback.print_exc()
            # self.cursor.close()
            self.conn.rollback()
        finally:
            self.conn.close()
예제 #2
0
    def callback(self):
        try:
            self.conn = conn(self.config['db'])
            # 判断是否开启
            statusResult = api.getLoginInfo(self.conn,
                                            self.conf['serviceCode'])
            # 关闭同步功能
            if not statusResult or statusResult['status'] == 0:
                print('status = 0')
                return

            self.memberInfo = statusResult
            self.cursor = self.conn.cursor()
            # 手动汇入(从本地excel中结算)
            self.localSettlement()
            # 自动汇入(从接口查询结算)
            self.settlement()
            self.cursor.close()
            self.conn.commit()
        except Exception as e:
            print "rollback"
            traceback.print_exc()
            self.cursor.close()
            self.conn.rollback()
        finally:
            self.conn.close()
예제 #3
0
 def __init__(self, conf, dbconf):
     """
 初始化
 """
     self.conn = conn(dbconf)
     apiUser = api.getLoginInfo(self.conn, conf['serviceCode'])
     self.apiUsername = apiUser['username']
     self.apiPwd = apiUser['pw']
     self.apiBack = apiUser['back']  #特殊战局
     self.clubId = apiUser['clubid']
     self.conf = conf
     self.conn.close()
예제 #4
0
    def callback(self):
        self.conn = conn(self.config['db'])
        # 判断是否开启
        statusResult = api.getLoginInfo(
            self.conn, self.config['bzl-provider']['serviceCode'])
        # 关闭同步功能
        if not statusResult or statusResult['status'] == 0:
            return

        list = self.api.getBuyin()
        # list = [{u'status': 2, u'room_name': u'248\U0001f30d123\u9650', u'acc_id': 23, u'agent_balance': 10004098, u'pccname': u'tatacaca', u'total_buyin': 124400, u'firstagent_ps': u'', u'club_name': u'\u7ef4\u591a\u5229\u4e9a\u7684\u79d8\u5bc6', u'room_uuid': 34721208, u'amounts': 400, u'firstagent_balance': 20000596, u'acc_ps': u'2589370531', u'pccid': u'2589370531', u'rake_amounts': 400, u'suggest': -1, u'balance': 221, u'user_uuid': 1068464, u'stack': 400, u'total_result': None, u'operat': 0}, {u'status': 2, u'room_name': u'\U0001f43c24\u9650-151', u'acc_id': None, u'agent_balance': None, u'pccname': u'\u4e0b\u96ea\u6e56', u'total_buyin': 290600, u'firstagent_ps': None, u'club_name': u'\u7ef4\u591a\u5229\u4e9a\u7684\u79d8\u5bc6', u'room_uuid': 34726887, u'amounts': 800, u'firstagent_balance': None, u'acc_ps': None, u'pccid': u'2557331287', u'rake_amounts': 800, u'suggest': -2, u'balance': None, u'user_uuid': 1055336, u'stack': 800, u'total_result': None, u'operat': 0}, {u'status': 2, u'room_name': u'1240\u266679\u965025', u'acc_id': None, u'agent_balance': None, u'pccname': u'\u84dd\u8272\u7684\u77f3\u5934', u'total_buyin': 356000, u'firstagent_ps': None, u'club_name': u'\U0001f30a\u9ed1\u6843\u4ff1\u4e50\u90e8', u'room_uuid': 34723608, u'amounts': 2000, u'firstagent_balance': None, u'acc_ps': None, u'pccid': u'2838728644', u'rake_amounts': 2000, u'suggest': -2, u'balance': None, u'user_uuid': 1170025, u'stack': 2000, u'total_result': None, u'operat': 0}, {u'status': 2, u'room_name': u'512\u266682\u965025', u'acc_id': None, u'agent_balance': None, u'pccname': u'\u7eaa\u5ff5\u7eaa\u5ff5', u'total_buyin': 203500, u'firstagent_ps': None, u'club_name': u'\U0001f30a\u9ed1\u6843\u4ff1\u4e50\u90e8', u'room_uuid': 34724289, u'amounts': 1000, u'firstagent_balance': None, u'acc_ps': None, u'pccid': u'2622565341', u'rake_amounts': 1000, u'suggest': -2, u'balance': None, u'user_uuid': 1081932, u'stack': 1000, u'total_result': None, u'operat': 0}]
        for item in list:
            print item
            if int(item['suggest']) > -2 and int(item['pccid']) == 2525717358:
                purseInfo = purse.getPurseInfoByGameId(self.conn,
                                                       item['pccid'])
                data = {
                    'club_name': item["club_name"],
                    'pccid': item["pccid"],
                    'pccname': item["pccname"],
                    'room_uuid': item["room_uuid"],
                    'stack': item["stack"],
                    'amounts': item["amounts"]
                }
                if purseInfo:
                    if int(purseInfo['cash']) >= int(item['amounts']):
                        code = self.api.acceptBuyin(data)
                        print "审核成功" + str(code)
                        if code == 200:
                            try:
                                purse.syncBuyin(self.conn, purseInfo, item,
                                                -int(item['amounts']))
                            except Exception as e:
                                print e
                            continue
                    else:
                        code = self.api.denyBuyin(data)
                        if code == 200:
                            buyin.addBuyinLog(self.conn, purseInfo, item,
                                              'deny')
                            self.conn.commit()

                # else:
                #     code = self.api.denyBuyin(data)
                #     if code == 200:
                #         purseInfo = {}
                #         purseInfo['frontend_user_id'] = 'no purse'
                #         purseInfo['frontend_user_auth'] = 'no purse'
                #         purseInfo['game_vid'] = item["pccid"]
                #         buyin.addBuyinLog(self.conn, purseInfo, item, 'deny')
                #         self.conn.commit()
        self.conn.close()
예제 #5
0
  def settlement(self):
    try:
      # 判断是否开启
      statusResult = api.getLoginInfo(self.conn, self.conf['serviceCode'])
      # 关闭同步功能
      if not statusResult or statusResult['status'] == 0:
        return
    except Exception as e:
      traceback.print_exc()
      return
    
    now = datetime.datetime.now()
    nowStr = now.strftime('%Y-%m-%d %H:%M:%S')
    lastTimeStr = False

    if os.path.exists(self.tempFile):
      try:
        tempfileReader = open(self.tempFile, 'r')
        lastTimeStr = json.loads(tempfileReader.read())['lastTime']
        lastTime = datetime.datetime.strptime(lastTimeStr,'%Y-%m-%d %H:%M:%S')
        lastTimeStr = (lastTime + datetime.timedelta(minutes = -60)).strftime('%Y-%m-%d %H:%M:%S')
      except Exception as e:
        traceback.print_exc()
    if not lastTimeStr:
      lastTimeStr = (now + datetime.timedelta(days = -3)).strftime('%Y-%m-%d %H:%M:%S')

    try:
      data = self.queryUserBoardList(
        lastTimeStr,
        nowStr
      )
      if not data or data['err'] != False:
        return

      dataList = data['data']
      print(dataList)

      if dataList:
        print(('fetch:', len(dataList)))

        for record in dataList:
          self.settleRecord(record)
      else:
        print(('no records'))

      tempfile = open(self.tempFile, 'w+')
      tempfile.write(json.dumps({ 'lastTime': nowStr }))
    except Exception as e:
      traceback.print_exc()
예제 #6
0
    def callback(self):
        try:
            self.conn = conn(self.config['db'])
            # 判断是否开启
            statusResult = api.getLoginInfo(self.conn, self.config[self.providerName]['serviceCode'])
            # 关闭同步功能
            if not statusResult or statusResult['status'] == 0:
                return

            print ('-------------------------------whill get data')

            rel =  self.api.getBuyin()
            print(rel)
            if not 'result' in rel:
                return
            list = rel['result']
            # list = [{u'totalGames': 8, u'gameRoomName': u'\u53d1\u53d1\u53d1', u'totalProfit': 1485, u'uuid': 774478, u'gameRoomId': 35047501, u'strNick': u'\u4e5f\u8bb8\u4f1a\u53d8', u'poolRate': 0, u'showId': u'1868828686', u'strSmallCover': u'http://upyun.pokermate.net/images/male_head.png', u'buyStack': 200, u'leagueId': 0, u'totalBuyin': 1100, u'totalHands': 10, u'leagueName': u'', u'clubId': 0}]
            for item in list:
                print item
                uid = item['showId']
                if int(uid) > 0:
                    purseInfo = purse.getPurseInfoByGameId(self.conn, uid)
                    data = {
                        'uuid':item['uuid'], 
                        'gameRoomId':item["gameRoomId"],
                    }
                    print purseInfo
                    if purseInfo:
                        if int(purseInfo['cash']) >= int(item['buyStack']):
                            resp = self.api.acceptBuyin(data)
                            print "审核结果", resp
                            if resp['iErrCode'] == 0:
                                try:
                                    cms.syncCmsBuyin(self.conn, purseInfo, item, -int(item['buyStack']))
                                except Exception as e:
                                    print e
                        else:               
                            resp = self.api.denyBuyin(data)
                            if resp['iErrCode'] == 0:
                                cms.addBuyinLog(self.conn, purseInfo, item, 'deny')
            self.conn.commit()
        except Exception as e:
            traceback.print_exc()
        finally:
            try:
                self.conn.close()
            except Exception as e:
                traceback.print_exc()
예제 #7
0
    def __login__(self):
        """
        登录
        """

        try:
            self.conn = conn(self.dbconf)
            # 判断是否开启
            statusResult = api.getLoginInfo(self.conn,
                                            self.conf['serviceCode'])
        except Exception as e:
            traceback.print_exc()
            return
        finally:
            self.conn.close()

        loginAuth = base64.b64encode(
            '%s:%s' % (statusResult['username'], statusResult['pw']))

        try:
            loginResponse = requests.post('%s/login_admin' %
                                          self.conf['apiUrl'],
                                          data={'authorization': loginAuth})
            try:
                self.conn = conn(self.dbconf)
                api.updateChingApiStatus(self.conn, 'login_status', 'OK')
            except Exception as e:
                traceback.print_exc()
            finally:
                self.conn.close()
            loginResult = loginResponse.json()

            if 'name' in loginResult and loginResult['name'] == statusResult[
                    'username']:
                self.authCookie = loginResponse.cookies.get_dict()
                tempfile = open(self.tempFile, 'w+')
                tempfile.write(json.dumps(self.authCookie))
                return
            else:
                print(loginResult)
        except Exception as e:
            try:
                self.conn = conn(self.dbconf)
                api.updateChingApiStatus(self.conn, 'login_status', 'FAILED')
            except Exception as e:
                traceback.print_exc()
            finally:
                self.conn.close()
예제 #8
0
    def __login__(self):
        try:
            self.conn = conn(self.dbconf)
            statusResult = api.getLoginInfo(self.conn,
                                            self.conf['serviceCode'])
        except Exception as e:
            traceback.print_exc()
            return
        finally:
            self.conn.close()

        try:
            loginResponse = requests.post(
                '%s/auth/login' % self.conf['apiUrl'],
                data={
                    'username': statusResult['username'],
                    'password': statusResult['pw']
                })

            loginResult = loginResponse.json()

            if 'errCode' in loginResult:
                if loginResult['errCode'] == 0:
                    self.authCookie = loginResponse.cookies.get_dict()
                    tempfile = open(self.tempFile, 'w+')
                    tempfile.write(json.dumps(self.authCookie))
                    print('coco:login:success:', loginResponse)
                if loginResult['errCode'] == 1:
                    print('coco:login:password error:', loginResponse)
                if loginResult['errCode'] == 2:
                    print('coco:login:server result error:', loginResponse)
            else:
                print('coco:login:server result error:no errCode:',
                      loginResponse)

        except Exception as e:
            print('coco:login:fail:', e)
            traceback.print_exc()