-->
当前位置:首页 > DayDayUp > 正文内容

每刻报销,填写费用详细信息

Luz11个月前 (09-14)DayDayUp1522

每刻报销提交报销单的时候需要给每笔费用信息都补充完整,明明是一样的信息却不可以批量填写,非得一个个点开。

抓了个接口来完成这些工作


代码

import requests
import json
from selenium import webdriver
import time
login_url='https://auth.maycur.com/'
logged_url='https://www.maycur.com/web/'
#driver = webdriver.Chrome()
# 记得写完整的url 包括http和https
#driver.get(login_url)
# 延迟20秒
#time.sleep(20)
#cookies=# 获取当前标签页的全部cookie信息
#print(driver.get_cookies())
# 把cookie转化为字典
#cookies = {cookie['name']: cookie['value'] for cookie in driver.get_cookies()}
def convert_cookies_to_dict(cookies):
    cookies = dict([l.split("=", 1) for l in cookies.split("; ")])
    return cookies
def submit_fee():
    temp_cookie=""""""#cookie
    cookies = convert_cookies_to_dict(temp_cookie)
    #global cookies
    print(cookies)
    headers = {
        'Accept': 'application/json, text/plain, */*',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        'Connection': 'keep-alive',
        'Content-Type': 'application/json;charset=UTF-8',
        'Eagleeye-Sessionid': '', #补充完整
        'Eagleeye-Traceid': '',
        'Eagleeye-Pappname': '',
        'Origin': 'https://www.maycur.com',
        'Referer': 'https://www.maycur.com/web/',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'same-origin',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.48',
        'entCode': '',
        'lang': 'zh',
        'sec-ch-ua': '"Chromium";v="112", "Microsoft Edge";v="112", "Not:A-Brand";v="99"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'tokenId': '',
    }
    data={
          "draw": 6,
          "columns": [
            {
              "data": '',
              "name": "",
              "searchable": True,
              "orderable": False,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": '',
              "name": "consumeAmount",
              "searchable": True,
              "orderable": True,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": '',
              "name": "consumeTime",
              "searchable": True,
              "orderable": True,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": '',
              "name": "",
              "searchable": True,
              "orderable": False,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": "subsidiaryName",
              "name": "",
              "searchable": True,
              "orderable": False,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": '',
              "name": "",
              "searchable": True,
              "orderable": False,
              "search": {
                "value": "",
                "regex": False
              }
            },
            {
              "data": '',
              "name": "",
              "searchable": True,
              "orderable": False,
              "search": {
                "value": "",
                "regex": False
              }
            }
          ],
          "order": [
            {
              "column": 2,
              "dir": "desc"
            }
          ],
          "start": 0,
          "length": 100,#数量
          "search": {
            "value": "",
            "regex": False
          },
          "feeDataStatusArray": [
            "unreimbursed"
          ],
          "authorizer": "UI2107271IOTVBI8"
     }
    result=json.loads(requests.post(url="https://www.maycur.com/api/web/expense/list",headers=headers,json=data,cookies=cookies).text)
    print(result)
    total_fee=0
    for i in result['data']:
        #for j in i:
        #    print(j,'值:\t\t\t\t',i[j])
        fee_submit_data={  "reimburseDataCode": '',
              "reimburseStatus": "未报销",
              "showPersonalTag": False,
              "feeCode": str(i['feeCode']),
              "feeTypeCode": str(i["feeTypeCode"]),
              "feeTypeName": "差旅打车",
              "feeTypeParentCode": "2002",
              "feeTypeParentName": "交通类",
              "autoGenAllowance": False,
              "booking": True,
              "businessPurpose": "汽车",
              "children": [],
              "comments": "因公出行",##事由
              "consumeAmount": str(i["consumeAmount"]),
              "consumeCcyCode": "CNY",
              "consumeCcySymbol": "¥",
              "consumeLocation": "domestic-ZH32-ZH32_2",
              "consumeTime": str(i['consumeTime']),
              "collectionCcyCode": "",
              "costTrackings": [
                {
                  "required": False,
                  "costTrackingCode": "CT1609231GKGT0JK",
                  "costTrackingName": "项目(Project)",
                  "costTrackingItemCode": "CTI190107140CDA4G",
                  "costTrackingItemName": "无项目"
                },
                {
                  "required": False,
                  "costTrackingCode": "CT160924VTNKSG0",
                  "costTrackingName": "行业线(Industry line)",
                  "costTrackingItemCode": "CTI160927QXGJLKW",
                  "costTrackingItemName": "其他"
                }
              ],
              "createTime": str(i['createTime']),
              "currentUserCode": str(i['userCode']),
              "dynamicForms": i['dynamicForms'],
              "exchangeRate": '1',
              "feeAmount": str(i['feeAmount']),
              "feeCcyCode": "CNY",
              "feeCcySymbol": "¥",
              "feeTypeGroupTag": "Taxi",
              "freeInvoice": False,
              "feeAllocations": [
                {
                  "costTrackings": [
                    {
                      "required": False,
                      "costTrackingCode": "CT1609231GKYD8U8",
                      "costTrackingName": "客户(Customer)",
                      "linkedCostTrackingCode": "",
                      "costTrackingItemCode": "CTI180305191RCVB4",
                      "costTrackingItemName": "无客户",
                      "costTrackingItemBizCode": "GGKH000001"
                    }
                  ],
                  "allocatedRatio": 100,
                  "allocatedAmount": str(i['feeAmount'])
                }
              ],
              "invoiceList": '',
              "parentChild": "U",
              "sourceId": str(i['sourceId']),
              "sourceName": "差旅壹号",
              "sourceType": "travelno1",
              "statistic": True,
              "subsidiaryCode": str(i['subsidiaryCode']),
              "sysExchangeRate": '1',
              "userCode": str(i['userCode']),
              "invoiceCount": '0',
              "payMethod": "PERSONAL_PAY",
              "feeAllocated": False,
              "invoiceDataCodes": [],
              "deductionFlag": False,
              "consumeApplication": '',
              "accompaniedUserList": '',
              "customerObjectV2": {},
              "invoiceAndTaxDetails": [],
              "approvedAmount": str(i['feeAmount'])
            }
        #print(fee_submit_data)
        fee_submit=json.loads(requests.post(url='https://www.maycur.com/api/web/expense/edit',headers=headers,json=fee_submit_data,cookies=cookies).text)
        print(fee_submit['message'],i['feeAmount'],i['dynamicForms'])
        total_fee=total_fee+i['feeAmount']
    print("总计费用:",total_fee)
       
     
submit_fee()


运行截图

1694661705630.png

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。