Пример #1
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()
Пример #2
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
Пример #3
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), "")
Пример #4
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), "")
Пример #5
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()
Пример #6
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))
Пример #7
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, '暂停销售')
Пример #8
0
 def __init__(self):
     self.dao = MongoDataModel()
Пример #9
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 {}