示例#1
0
def accountHomeRse(taid,time):
    ta = tasver.AccountHomeReq()
    ta.investorid = taid
    ta.reqday = time
    header = tasver.Header()
    header.cmd = 104
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)

    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.AccountHomeRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
        print json.loads(oAccountJon)
        return json.loads(oAccountJon)

    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
示例#2
0
def report_create(request):
    ta = tasver.FundReportReq()
    ta.reportid = int(request.GET['reportid'])
    header = tasver.Header()
    header.cmd = 108
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url, headdata, headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0:
        oAccountRsp = tasver.FundReportRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        REPORT_ROOT = os.path.join(BASE_DIR, 'gaoyicrm/static/reports')
        WriteFileData = open(
            REPORT_ROOT + '/' + (oAccountRsp.reportname).encode('utf-8'), 'wb')
        WriteFileData.write(oAccountRsp.content)
        WriteFileData.close()
        # 修复基金报告导出问题
        # print oAccountRsp
        return oAccountRsp
    else:
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
示例#3
0
def webFundAssetReq(taid):
    ta = tasver.WebFundAssetReq()
    ta.fundid = "S33180"
    ta.investorid = "DI1042"
    header = tasver.Header()
    header.cmd = 106
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.WebFundAssetRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
        return json.loads(oAccountJon)
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
示例#4
0
def get_TAID(idtype, idno, name, moblie):
    ta = tasver.WebVerifyIdReq()
    ta.idtype = int(idtype)
    ta.idno = idno
    ta.name = unicode(name, "utf-8")
    ta.phone = moblie
    header = tasver.Header()
    header.cmd = 101
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)
    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)

    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.WebVerifyIdRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
        return json.loads(oAccountJon)['id']
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
        return "_"
示例#5
0
def fund_info(request):
    ta = tasver.WebFundDetailReq()
    ta.fundid = request.GET['fundid']
    print ta.fundid
    header = tasver.Header()
    header.cmd = 107
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)

    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        print headerRes.errCode
        oAccountRsp = tasver.WebFundDetailRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
        content = {'fundinfo':json.loads(oAccountJon)}
        return JsonResponse(content)
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
示例#6
0
def get_records(ta_id):
    ta = tasver.WebOpRecordReq()
    ta.investorid = ta_id
    header = tasver.Header()
    header.cmd = 103
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.WebOpRecordRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
    records =  json.loads(oAccountJon)
    funds = []
    for item in records['op']:
        if {'fundname':item['fundname'],'fundid':item['fundid']} not in funds:
            fund = {'fundname':item['fundname'],'fundid':item['fundid']}
            funds.append(fund)
    content = {'funds':funds,'fundsCount':len(funds),'recordsList':records['op'],'len':len(records['op'])}
    return content
示例#7
0
def get_all_product():
    ta = tasver.ProductListReq()
    header = tasver.Header()
    header.cmd = 102
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)
    headers = {'content-type': 'application/json'}
    print '!!!!!!!begin',time.time()
    r = requests.post(url,headdata,headers=headers)
    print '!!!!!!!end',time.time()
    headerRes = tasver.WebRspHeader()
    print '____________step1',time.time()
    headerRes.ParseFromString(r.content)
    print '____________step2',time.time()
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.ProductListRsp()
        print '____________step3',time.time()
        oAccountRsp.ParseFromString(headerRes.content)
        print '____________step4',time.time()
        oAccountJon = pbjson.pb2json(oAccountRsp)
        print '____________step5',time.time()
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")
    print '____________step6',time.time()
    alllist = json.loads(oAccountJon)['productlist']
    print alllist
    print '____________step7',time.time()
    return alllist
示例#8
0
def weixininfo(request):
    result = requests.get(request.GET['weixinUrl'])
    resultJson = result.json()
    openid = resultJson['openid']
    print openid

    userInfoUrl = 'https://api.weixin.qq.com/sns/userinfo?access_token=' + resultJson[
        'access_token'] + '&openid=' + resultJson['openid']
    userInfoResult = requests.get(userInfoUrl)
    userInfoResultJson = userInfoResult.json()
    content = {
        'usernickname': userInfoResultJson['nickname'],
        'headimgurl': userInfoResultJson['headimgurl']
    }

    if Investor.objects.filter(openid=openid).exists():
        investor = Investor.objects.get(openid=openid)
        request.session['userID'] = investor.id
        content.update({'success': 0})
    else:
        ta = tasver.WechatIdCheckReq()
        ta.wechatid = resultJson['openid']
        # ta.wechatid = 'o3zFCuLQfGhhwdaenalaIr8R9aQs'
        header = tasver.Header()
        header.cmd = 109
        header.ver = 0
        header.platform = 3
        header.content = pbjson.pb2json(ta)
        headdata = pbjson.pb2json(header)

        headers = {'content-type': 'application/json'}
        r = requests.post(url, headdata, headers=headers)
        headerRes = tasver.WebRspHeader()
        headerRes.ParseFromString(r.content)
        if headerRes.errCode == 0:
            oAccountRsp = tasver.WechatIdCheckRsp()
            oAccountRsp.ParseFromString(headerRes.content)
            oAccountJon = pbjson.pb2json(oAccountRsp)
            if json.loads(oAccountJon)['investorid'] == '':
                request.session['openid'] = openid
            else:
                request.session['openid'] = json.loads(
                    oAccountJon)['investorid']
            content.update({'success': 1})
            # print json.loads(oAccountJon)
        else:
            print "ErrCode:"
            print headerRes.errCode
            print "ErrMsg:"
            # print headerRes.errMsg.encode("utf-8")

    return JsonResponse(content)
示例#9
0
def fund_details_chart(request):
    page = request.GET['page']
    ta = tasver.WebFundDetailReq()
    ta.fundid = request.GET['fundid']
    header = tasver.Header()
    header.cmd = 107
    header.ver = 0
    header.platform = 3
    header.content = pbjson.pb2json(ta)
    headdata = pbjson.pb2json(header)

    headers = {'content-type': 'application/json'}
    r = requests.post(url,headdata,headers=headers)
    headerRes = tasver.WebRspHeader()
    headerRes.ParseFromString(r.content)
    if headerRes.errCode == 0 :
        oAccountRsp = tasver.WebFundDetailRsp()
        oAccountRsp.ParseFromString(headerRes.content)
        oAccountJon = pbjson.pb2json(oAccountRsp)
        detailInfo = json.loads(oAccountJon)

        nav_paginator = Paginator(detailInfo['fundNavlist'],10)
        # print detailInfo['fundNavlist']
        # totalnav_paginator = Paginator(detailInfo['totalnav'],10)
        # print totalnav_paginator
        sh300_paginator = Paginator(detailInfo['sh300'],10)
        gem_paginator = Paginator(detailInfo['gem'],10)
        subNavPaginatorList = []
        totalNavPaginatorList = []
        subsh300PaginatorList = []
        subgemPaginatorList = []
        for item in nav_paginator.page(int(page)):
            subNavPaginatorList.append(item)
        # for item in totalnav_paginator.page(int(page)):
        #     totalNavPaginatorList.append(item)
        for item in sh300_paginator.page(int(page)):
            subsh300PaginatorList.append(item)
        for item in gem_paginator.page(int(page)):
            subgemPaginatorList.append(item)
        paginatorlist = [subNavPaginatorList,subsh300PaginatorList,subgemPaginatorList]
        print paginatorlist
        content = {'detailInfo':detailInfo,'paginatorList':paginatorlist,'len':len(nav_paginator.page(int(page))),'pageCount':nav_paginator.num_pages}
        return JsonResponse(content)
    else :
        print "ErrCode:"
        print headerRes.errCode
        print "ErrMsg:"
        print headerRes.errMsg.encode("utf-8")