Beispiel #1
0
def _getExchangeRecords(gameId, userId):
    records = []
    datas = daobase._executePayDataCmd('HGETALL', daoconst.PAY_KEY_CTY % (gameId, userId))
    if datas:
        for i in xrange(len(datas) / 2):
            try:
                jstr = datas[i * 2 + 1]
                record = json.loads(jstr)
                dt = datetime.strptime(record['rtime'], '%Y%m%d%H%M%S')
                record['rtime'] = dt.strftime('%Y-%m-%d %H:%M')
                records.append(record)
            except:
                ftlog.error()
    return records
Beispiel #2
0
def _getExchangeRecords(gameId, userId):
    records = []
    datas = daobase._executePayDataCmd('HGETALL',
                                       daoconst.PAY_KEY_CTY % (gameId, userId))
    if datas:
        for i in xrange(len(datas) / 2):
            try:
                jstr = datas[i * 2 + 1]
                record = json.loads(jstr)
                dt = datetime.strptime(record['rtime'], '%Y%m%d%H%M%S')
                record['rtime'] = dt.strftime('%Y-%m-%d %H:%M')
                records.append(record)
            except:
                ftlog.error()
    return records
Beispiel #3
0
def _getGameOrderInfo(orderId):
    values = daobase._executePayDataCmd('HMGET', GameOrderSchema.mkey(orderId), *GameOrderSchema.FIELDS_ALL)
    return GameOrderSchema.checkDataDict(GameOrderSchema.FIELDS_ALL, values)
Beispiel #4
0
def _setGameOrderInfo(userId, orderId, datas):
    params = GameOrderSchema.paramsDict2List(datas)
    return daobase._executePayDataCmd('HMSET', GameOrderSchema.mkey(orderId), *params)
Beispiel #5
0
def _makeGameOrderId(gameId, userId, productId):
    orderId = daobase._executePayDataCmd('INCR', daoconst.PAY_KEY_GAME_ORDER_ID)
    ct = datetime.now()
    orderId = 'GO%s%s' % (ct.strftime('%Y%m%d%H%M%S'), orderId)
    return orderId
Beispiel #6
0
def _makeExchangeId():
    exchangeId = daobase._executePayDataCmd('INCR', daoconst.PAY_KEY_EXCHANGE_ID)
    ct = datetime.now()
    exchangeId = 'EO%s%s' % (ct.strftime('%Y%m%d%H%M%S'), exchangeId)
    return exchangeId
Beispiel #7
0
def _main():
    from freetime.entity.msg import MsgPack
    from freetime.util import log as ftlog
    from poker.util import webpage, strutil
    from poker.util.constants import CLIENT_SYS_H5
    from poker.entity.dao import daobase, sessiondata
    from poker.entity.configure import gdata
    from poker.protocol import router
    from hall.entity import hallstore, hallconf
    # 开始支付
    serverUrl = gdata.httpGame()
    product = hallstore.findProduct(gameId, userId, productId)
    appId = 9999
    appKey = hallconf.getAppKeyInfo(appId).get("key", "")
    clientId = sessiondata.getClientId(userId)
    clientOs = sessiondata.getClientIdSys(userId)
    if clientOs == CLIENT_SYS_H5:
        # 发起支付请求
        httpUrl = serverUrl + "/open/v4/pay/order"
        datas = {
            "userId": userId,
            "appId": appId,
            "wxAppId": "wx30efe34580243475",
            "clientId": clientId,
            "imei": "null",
            "uuid": "9503fcb2e234423081a13010cd401554",
            "prodId": productId,
            "prodName": product.displayName,
            "prodCount": 1,
            "prodPrice": product.price,
            "chargeType": "wxapp.iap",
            "gameId": gameId,
            "appInfo": "",
            "mustcharge": 1
        }
        ret, _ = webpage.webgetJson(httpUrl, datas)
        if ret.get("result").get("code") != 0:
            ftlog.error("pay test error", ret, datas)
            return
        platformOrder = ret.get("result").get("chargeInfo").get("platformOrderId")
        chargeData = daobase._executePayDataCmd("HGET", "sdk.charge:%s" % platformOrder, "consume")
        orderId = strutil.loads(chargeData, False, True, {}).get("prodOrderId")
        # SDK通知游戏服钻石变更
        httpUrl = serverUrl + "/v2/game/charge/notify"
        datas = {
            "appId": appId,
            "clientId": clientId,
            "userId": userId,
            "buttonId": productId,
            "diamonds": int(product.priceDiamond),
            "rmbs": float(product.price)
        }
        ret = webpage.webget(httpUrl, datas)
        print ret
        # SDK通知游戏服发货
        httpUrl = serverUrl + "/v2/game/consume/delivery"
        datas = {
            "apiver": 2,
            "appId": appId,
            "appInfo": "1",
            "chargeType": "wxwap",
            "chargedDiamonds": int(product.priceDiamond),
            "chargedRmbs": float(product.price),
            "clientId": clientId,
            "consumeCoin": product.priceDiamond,
            "consumeId": orderId,
            "orderId": orderId,
            "platformOrder": platformOrder,
            "prodCount": 1,
            "prodId": productId,
            "prodPrice": product.price,
            "userId": userId
        }
        webpage.webget(httpUrl, datas, appKey)
    else:
        # SDK通知游戏服钻石变更
        httpUrl = serverUrl + "/api/hall5/store/charge/notify"
        datas = {
            "appId": appId,
            "userId": userId,
            "chargedDiamonds": int(product.priceDiamond),
            "chargedRmbs": float(product.price),
            "clientId": clientId,
            "prodId": productId,
            "realGameId": 9998
        }
        ret = webpage.webget(httpUrl, datas, appKey)
        print ret
Beispiel #8
0
def _getGameOrderInfo(orderId):
    values = daobase._executePayDataCmd('HMGET', GameOrderSchema.mkey(orderId),
                                        *GameOrderSchema.FIELDS_ALL)
    return GameOrderSchema.checkDataDict(GameOrderSchema.FIELDS_ALL, values)
Beispiel #9
0
def _setGameOrderInfo(userId, orderId, datas):
    params = GameOrderSchema.paramsDict2List(datas)
    return daobase._executePayDataCmd('HMSET', GameOrderSchema.mkey(orderId),
                                      *params)
Beispiel #10
0
def _makeGameOrderId(gameId, userId, productId):
    orderId = daobase._executePayDataCmd('INCR',
                                         daoconst.PAY_KEY_GAME_ORDER_ID)
    ct = datetime.now()
    orderId = 'GO%s%s' % (ct.strftime('%Y%m%d%H%M%S'), orderId)
    return orderId
Beispiel #11
0
def _makeExchangeId():
    exchangeId = daobase._executePayDataCmd('INCR',
                                            daoconst.PAY_KEY_EXCHANGE_ID)
    ct = datetime.now()
    exchangeId = 'EO%s%s' % (ct.strftime('%Y%m%d%H%M%S'), exchangeId)
    return exchangeId