Esempio n. 1
0
class HomeLogic(object):
    def __init__(self):
        self.dao = MongoDataModel()

    def get_banner_config_info(self):
        banner_config_info = self.dao.find('banner_config_info', {"status": 1},
                                           sort=[('sort', -1)])
        return banner_config_info

    def get_mian_lottery_info(self):
        lottery_config_info = self.dao.find('lottery_config_info', {},
                                            sort=[('sort', -1)])
        return lottery_config_info

    def get_main_focus_matches_info(self):
        matches = self.dao.find_one('focus_matches_info', {"status": 1},
                                    sort=[('endtime', -1)])
        return matches

    def get_operation_config_info(self):
        operation_config = self.dao.find('operation_config_info',
                                         {"status": "1"},
                                         sort=[('sort', -1)])
        return operation_config

    def get_bulletin_list(self, pn=1, rn=10):
        pn = (pn - 1) * rn
        bulletin_info = self.dao.find('bulletin_info', {"status": "1"},
                                      sort=[('crtime', -1)],
                                      pn=pn,
                                      rn=rn)
        return bulletin_info
Esempio n. 2
0
    def __init__(self, lotid):

        TABLE_MAP = {
            3: "lottery_ssq_expect_info",
            28: "lottery_dlt_expect_info",
            44: "lottery_gx11x5_expect_info"
        }

        self.dao = MongoDataModel()
        self.lotid = lotid
        self.table = TABLE_MAP.get(int(self.lotid), "")
Esempio n. 3
0
    def __init__(self, lotid):

        TABLE_MAP = {
            46: "lottery_ticket_jczq_match_info",
            47: "lottery_ticket_jclq_match_info"

        }

        self.dao = MongoDataModel()
        self.lotid = lotid
        self.table = TABLE_MAP.get(int(self.lotid), "")
Esempio n. 4
0
 def __init__(self, lotid):
     super(BaseDraw, self).__init__()
     TABLE_MAP = {
         3: "lottery_ssq_open_info",
         28: "lottery_dlt_open_info",
         44: "lottery_gx11x5_expect_info",
         46: "lottery_ticket_jczq_match_result",
         47: "lottery_ticket_jclq_match_result"
     }
     self.lotid = lotid
     self.table = TABLE_MAP.get(int(self.lotid), "")
     self.dao = MongoDataModel()
Esempio n. 5
0
class InfoLogic(object):
    def __init__(self):
        self.dao = MongoDataModel()

    def get_info_list(self, tabid, pagesize, pageno):
        pn = int(pageno) - 1
        articles = self.dao.find('dongqiudi_articles', {"tabid": int(tabid)}, projection={"body": 0, "_id": 0},
                                 count=True, rn=int(pagesize), pn=pn, sort=[('display_time', -1)])
        return articles

    def get_info_detail(self, tabid, id):
        articles = self.dao.find_one('dongqiudi_articles', {"tabid": int(tabid), "id": int(id)})
        return articles
Esempio n. 6
0
 def __init__(self):
     self.conn_r = db_pool.get_mysql("nncp_ro")
     self.conn_w = db_pool.get_mysql("nncp_wr")
     self.conn = db_pool.get_mysql("nncp")
     self.cursor = self.conn.cursor(MySQLdb.cursors.DictCursor)
     self.rds = db_pool.get_redis("msgbus")
     self.mongo = MongoDataModel()
Esempio n. 7
0
 def __init__(self):
     self.conn_r = db_pool.get_mysql("betblock_r")
     self.conn_w = db_pool.get_mysql("betblock_w")
     self.conn = None
     self.cursor = None
     self.dao = MongoDataModel()
     self.state = False
     self.lazy_commit = False
Esempio n. 8
0
class BaseJc(object):

    def __init__(self, lotid):

        TABLE_MAP = {
            46: "lottery_ticket_jczq_match_info",
            47: "lottery_ticket_jclq_match_info"

        }

        self.dao = MongoDataModel()
        self.lotid = lotid
        self.table = TABLE_MAP.get(int(self.lotid), "")

    def get_jc_on_sale_matches(self):
        """ 获取竞彩对阵
        :param pn:
        :param rn:
        :return:
        """
        curtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
        matches_info = self.dao.find(self.table, {"endTime": {"$gt": curtime}})

        return matches_info

    def get_matches_by_matchid(self, matchid):
        """
            通过matchid 获取对阵数据
        :return:
        """
        matches_info = self.dao.find_one(self.table, {"matchId": matchid})
        return matches_info

    def get_matches_by_matchids(self, matchids):
        """
            通过matchids 批量获取对阵数据
        :return:
        """
        matches_info = self.dao.find(self.table, {"matchId": {"$in": matchids}})
        return matches_info
Esempio n. 9
0
class BaseExpect(object):

    def __init__(self, lotid):

        TABLE_MAP = {
            3: "lottery_ssq_expect_info",
            28: "lottery_dlt_expect_info",
            44: "lottery_gx11x5_expect_info"
        }

        self.dao = MongoDataModel()
        self.lotid = lotid
        self.table = TABLE_MAP.get(int(self.lotid), "")

    def get_expect_info_list(self, pn=1, rn=10):
        """ 获取期号列表
        :param pn:
        :param rn:
        :return:
        """
        pn = (pn-1)*10
        expect_info = self.dao.find(self.table, {}, sort=[('expect', -1)], rn=rn, pn=pn)

        return expect_info

    def get_current_expect(self):
        """
        获取当前期
        :return:
        """
        curr_expect = self.dao.find_one(self.table, {"isCurrent": "1"})
        return curr_expect.get("expect") if curr_expect else ""

    def get_current_expect_info(self):
        """当前期号信息
        :return:
        """
        curr_expect = self.dao.find_one(self.table, {"isCurrent": "1"})
        return curr_expect
Esempio n. 10
0
class BaseDraw(object):

    def __init__(self, lotid):
        super(BaseDraw, self).__init__()
        TABLE_MAP = {
            3: "lottery_ssq_open_info",
            28: "lottery_dlt_open_info",
            44: "lottery_gx11x5_expect_info",
            46: "lottery_ticket_jczq_match_result",
            47: "lottery_ticket_jclq_match_result"
        }
        self.lotid = lotid
        self.table = TABLE_MAP.get(int(self.lotid), "")
        self.dao = MongoDataModel()

    def get_opencode_by_expects(self, expects):
        """通过期号获取开奖信息
        """

        opencode = self.dao.find(self.table, {"expect": {"$in": expects}}, sort=[('expect', -1)])
        return opencode

    def get_opencode_by_expect(self, expect):
        opencode = self.dao.find_one(self.table, {'expect': expect})
        return opencode

    def get_newest_opencode(self):
        opencode = self.dao.find_one(self.table, {"openCode": {"$ne": ""}}, sort=[('expect', -1)])
        return opencode

    def get_history_opencode_list(self, pn=1, rn=10):
        pn = (pn-1) * 10
        opencode = self.dao.find(self.table, {"openCode": {"$ne": ""}}, sort=[('expect', -1)], pn=pn, rn=rn)
        return opencode

    def get_latest_matchscore(self):
        match = self.dao.find_one(self.table, {}, sort=[('matchId', -1)])
        return match
Esempio n. 11
0
 def check_beishu(self, beishu):
     config = MongoDataModel().find_one('lottery_config_info', {'lotid': str(self.lotid)})
     beishulimit = int(config.get('beishulimit', -1))
     if int(beishu) < beishulimit:
         raise ews.EwsError(ews.STATUS_LOTTOCHECK_ERROR, '体彩中心通知【世界杯期间每单投注倍数不得小于{}倍】'.format(beishulimit))
Esempio n. 12
0
 def check_switch(self):
     config = MongoDataModel().find_one('lottery_config_info', {'lotid': str(self.lotid)})
     if int(config.get('status', -1)) == -1:
         raise ews.EwsError(ews.STATUS_LOTTOCHECK_ERROR, '暂停销售')
Esempio n. 13
0
 def __init__(self):
     self.dao = MongoDataModel()
Esempio n. 14
0
    def continue_chasenumber(self, params):
        """追号计划继续
        """
        cid = params.get("cid")
        getmoney = params.get("getmoney")
        pid = None
        try:
            sql = "SELECT * FROM t_chasenumber WHERE f_cid=%s AND f_chasestatus=%s FOR UPDATE"
            self.cursor.execute(sql, (cid, define.CHASE_STATUS_SUCC))
            chasenumber = self.cursor.fetchone() or {}
            if not chasenumber:
                raise Exception("追号计划不存在或已完成! lotid={}|chaseid={}".format(
                    self.lotid, cid))

            #命中中奖停止条件
            stopprize = chasenumber.get("f_stopprize")
            expecttotal = chasenumber.get("f_expecttotal")
            expectnum = chasenumber.get("f_expectnum")
            lastexpect = chasenumber.get("f_lastexpect")
            allmoney = chasenumber.get("f_allmoney")
            lotid = chasenumber.get("f_lotid")
            uid = chasenumber.get("f_uid")

            if stopprize > 0 and getmoney > stopprize:
                #追号方案退款
                sql = "SELECT * FROM t_account_info WHERE f_uid=%s"
                self.cursor.execute(sql, (uid, ))
                uinfo = self.cursor.fetchone() or {}
                returnmoney = allmoney * (expecttotal - expectnum)
                balance_recharge = uinfo.get("f_balance_recharge")
                balance_draw = uinfo.get("f_balance_draw")
                freeze = uinfo.get("f_freeze")
                balance_draw = balance_draw + returnmoney
                sql = "UPDATE t_account_info SET f_balance_draw=%s WHERE f_uid=%s"
                self.cursor.execute(sql, (balance_draw, uid))

                #更新追号状态
                sql = "UPDATE t_chasenumber SET f_chasestatus=%s, f_stopreturnmoney=%s WHERE f_cid=%s"
                self.cursor.execute(
                    sql, (define.CHASE_STATUS_PRIZESTOP, returnmoney, cid))

                #流水日志
                sql = """INSERT INTO t_account_log(
                            f_uid,
                            f_oid,
                            f_lotid,
                            f_inout,
                            f_money,
                            f_balance_recharge,
                            f_balance_draw,
                            f_freeze)
                        VALUES(%s,%s,%s,%s,%s,%s,%s,%s)
                    """
                self.cursor.execute(
                    sql, (uid, cid, lotid, define.ACCOUNT_LOG_TYPE_CHASECANCEL,
                          returnmoney, balance_recharge, balance_draw, freeze))
                self.conn.commit()
                return {}
            else:
                #查询当前期号
                curr_expect = ""
                try:
                    if int(self.lotid) in [28, 3]:
                        curr_expect = MongoDataModel().find_one(
                            self.expecttable, {"isCurrent": "1"})
                        curr_expect = curr_expect.get(
                            "expect") if curr_expect else ""
                    elif int(self.lotid) in [44]:
                        curtime = time.strftime('%Y-%m-%d %H:%M:%S',
                                                time.localtime())
                        curr_expect = MongoDataModel().find_one(
                            self.expecttable, {
                                "startTime": {
                                    "$lte": curtime
                                },
                                "stopTime": {
                                    "$gt": curtime
                                }
                            },
                            sort=[('expect', -1)],
                            rn=10)
                        curr_expect = curr_expect.get(
                            "expect") if curr_expect else ""
                except:
                    logger.error(traceback.format_exc())
                if not curr_expect:
                    raise Exception("追号获取当前期号失败! lotid={}|chaseid={}".format(
                        self.lotid, cid))
                if curr_expect == lastexpect:
                    raise Exception(
                        "当前期重复追号拦截! lotid={}|chaseid={}|expect={}".format(
                            self.lotid, cid, lastexpect))

                #更新追号进度
                israndom = chasenumber.get("israndom")
                expectnum += 1
                chasestatus = define.CHASE_STATUS_SUCC if expectnum < expecttotal else define.CHASE_STATUS_FINISHSTOP
                sql = "UPDATE t_chasenumber SET f_expectnum=%s, f_chasestatus=%s, f_lastexpect=%s WHERE f_cid=%s"
                self.cursor.execute(sql,
                                    (expectnum, chasestatus, curr_expect, cid))

                #投注下单
                uid = chasenumber.get("f_uid")
                lotid = chasenumber.get("f_lotid")
                wtype = chasenumber.get("f_wtype")
                fileorcode = chasenumber.get("f_fileorcode")
                selecttype = chasenumber.get("f_selecttype")
                zhushu = chasenumber.get("f_zhushu")
                beishu = chasenumber.get("f_beishu")
                couponid = 0
                sql = """
                    INSERT INTO {}(
                        f_uid,
                        f_chaseid,
                        f_lotid,
                        f_wtype,
                        f_beishu,
                        f_zhushu,
                        f_expect,
                        f_allmoney,
                        f_couponid,
                        f_fileorcode,
                        f_selecttype,
                        f_placetime,
                        f_orderstatus)
                    VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
                """
                sql = sql.format(self.table)
                self.cursor.execute(
                    sql, (uid, cid, lotid, wtype, beishu, zhushu, curr_expect,
                          allmoney, couponid, fileorcode, selecttype,
                          datetime.datetime.now(), define.ORDER_STATUS_SUCC))

                pid = self.cursor.lastrowid
                #同步插入方案汇总表
                self._insert_project_union(pid)
                self.conn.commit()

                logger.debug(
                    "[TRADE SVR]Continue chasenumber! uid=%s|lotid=%s|cid=%s|pid=%s",
                    uid, lotid, cid, pid)
                return {
                    "uid": uid,
                    "pid": pid,
                    "cid": cid,
                    "lotid": lotid,
                    "allmoney": allmoney,
                    "couponid": couponid
                }
        except Exception as ex:
            logger.error(traceback.format_exc())
            self.conn.rollback()
            return {}