def __init__(self):
        self.base_url = 'https://scmubpre.xiyunfin.com/'
        self.login_sevice = 'ub/user/login'
        self.login_url = os.path.join(self.base_url, self.login_sevice)
        self.data = {
            "account": "standard.ql.admin",
            "password": "******",
            "force": 1
        }

        self.login_data = json.dumps(self.data)
        self.header = {
            'User-Agent':
            "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }

        try:
            res = requests.post(url=self.login_url,
                                headers=self.header,
                                data=self.login_data).json()
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败', e)

        self.d = Data()
Beispiel #2
0
    def __init__(self):
        self.d=Data()
        self.baseurl='http://crouter.yunzongnet.com/scf-backstage/t5670/'
        self.loginservice='scf/user/login'
        self.loginurl=os.path.join(self.baseurl,self.loginservice)
        data={
            "account": "scfyangxue",
            "password": "******",
            "platform": 12,
            "force": 1
            }
        self.header={
            'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }
        self.logindata=json.dumps(data)

        try:
            res=requests.post(url=self.loginurl,data=self.logindata,headers=self.header).json()
            # print(res)
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败',e)
 def __init__(self):
     '''
     基础url 共用的在其他方式也可使用,根据项目跟改,自己url是本链接的url
     data 是请求的数据,force:0 非强制登陆,1:强制登陆
     登陆完成后把返回的token,赋值到header中的Authorization,供其他模块使用
     '''
     self.baseurl = 'https://scmubpre.xiyunfin.com/'
     self.url = os.path.join(self.baseurl, 'ub/user/login')
     print(self.url)
     data = {"account": "agent.ql.admin", "password": "******", "force": 1}
     self.data = json.dumps(data)
     self.header = {
         'User-Agent':
         "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
         'Content-Type': 'application/json'
     }
     try:
         res = requests.post(url=self.url,
                             headers=self.header,
                             data=self.data).json()
         self.header['Authorization'] = res['resultObject']['token']
     except Exception as e:
         print('登陆失败', e)
     self.d = Data()
class salepricecreate():
    def __init__(self):
        self.base_url = 'https://scmubpre.xiyunfin.com/'
        self.login_sevice = 'ub/user/login'
        self.login_url = os.path.join(self.base_url, self.login_sevice)
        self.data = {
            "account": "standard.ql.admin",
            "password": "******",
            "force": 1
        }

        self.login_data = json.dumps(self.data)
        self.header = {
            'User-Agent':
            "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }

        try:
            res = requests.post(url=self.login_url,
                                headers=self.header,
                                data=self.login_data).json()
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败', e)

        self.d = Data()

    def get_all_material(self):
        self.get_all_material_sever = ''
        self.get_all_material_url = os.path.join(self.base_url,
                                                 self.get_all_material_sever)

    def add_purches(self):
        self.add_purches_servier = ''
        self.add_purches_servier_url = os.path.join(self.base_url,
                                                    self.add_purches_servier)

    #获取一下仓库下已经新建得采购价目表
    def get_purches(self):
        self.get_purchesservice = 'ub/standardjc/base/purchasePrice/queryPurchasePricePaging?'
        self.get_purches_url = os.path.join(self.base_url,
                                            self.get_purchesservice)
        self.params = self.d.perchersedata()

        try:
            self.perchesrdatares = requests.get(url=self.get_purches_url,
                                                headers=self.header,
                                                params=self.params).json()
            print('获取成功')
        except Exception as e:
            print('获取失败,', e)

    def get_mentail(self, materialName):
        self.get_materialserver = 'ub/standardjc/base/material/list?'
        self.get_materialurl = os.path.join(self.base_url,
                                            self.get_materialserver)
        self.materialparams = self.d.get_material()
        self.materialparams['materialName'] = materialName
        try:
            res = requests.get(url=self.get_materialurl,
                               headers=self.header,
                               params=self.materialparams).json()
            return res['resultObject']['pageData'][0]['saleTaxRate']
        except Exception as e:
            print(e)

    def add_sale(self):
        self.add_service = 'ub/standardjc/base/salePrice/newSalePrice'
        self.add_url = os.path.join(self.base_url, self.add_service)
        self.data1 = self.d.saledata()
        self.get_purches()
        for item in self.perchesrdatares['resultObject']['pageData']:
            self.data1['salePriceDetailList'][0]['materialName'] = item[
                'materialName']
            self.data1['salePriceDetailList'][0]['materialNumber'] = item[
                'materialNumber']
            self.data1['salePriceDetailList'][0]['materialId'] = item[
                'materialId']
            self.data1['salePriceDetailList'][0]['materialUnitName'] = item[
                'materialUnitName']
            self.data1['salePriceDetailList'][0]['materialUnitNumber'] = item[
                'materialUnitNumber']
            self.data1['salePriceDetailList'][0][
                'materialSpecification'] = item['materialSpecification']
            self.data1['salePriceDetailList'][0][
                'saleTaxRate'] = self.get_mentail(item['materialName'])
            self.datap = json.dumps(self.data1)
            print(self.datap)

            try:
                res = requests.post(url=self.add_url,
                                    data=self.datap,
                                    headers=self.header).json()
                print(res)
            except Exception as e:
                print('新增失败', e)
Beispiel #5
0
class scfScript:
    '''
    金融产品管理
    '''
    def __init__(self):
        self.d=Data()
        self.baseurl='http://crouter.yunzongnet.com/scf-backstage/t5670/'
        self.loginservice='scf/user/login'
        self.loginurl=os.path.join(self.baseurl,self.loginservice)
        data={
            "account": "scfyangxue",
            "password": "******",
            "platform": 12,
            "force": 1
            }
        self.header={
            'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }
        self.logindata=json.dumps(data)

        try:
            res=requests.post(url=self.loginurl,data=self.logindata,headers=self.header).json()
            # print(res)
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败',e)

    def finacialProductsAdd(self):
        '''
        新增金融产品
        :return:
        '''
        self.addservice='scf/finance/fund/add'
        self.addurl=os.path.join(self.baseurl,self.addservice)
        self.adddata=self.d.finacaildata()
        orderForm={'0':'采购','1':'意向','2':'暂估'}
        gracein={'0':'单笔总额','1':'单笔未结算余额','2':'所有未收款余额','3':'所有未结清总额'}
        for i in (0,1,2):
            for j in (0,1,2,3):
                self.adddata['fundName']='%s-%s-yx'%(orderForm[str(i)],gracein[str(j)])
                self.adddata['orderForm']=i
                self.adddata['graceIn']=j
                self.fdata=json.dumps(self.adddata)
                try:
                    res=requests.post(url=self.addurl,headers=self.header,data=self.fdata).json()
                    print('增加金融产品成功  :',res)
                except Exception as e:
                    print('增加金融产品失败:',e)

    def finacialProductsget(self,pagesize,partname):
        '''
        获取金融产品
        :param pagesize:页面个数
        :param partname: 金融产品搜索词
        :return:
        '''
        self.getservice='scf/finance/fund/page'
        self.geturl=os.path.join(self.baseurl,self.getservice)
        params={
            'pageSize': pagesize,
            'currentPage': 1,
            'totalCount': '',
            'fundNo':'',
            'fundTypeNo':'',
            'fundName':partname,
            'payment':'',
            'settleAccount':'',
            'orderForm':'',
            'effectiveStatus':'',
            'status':''
        }
        try:
            self.getres=requests.get(url=self.geturl,headers=self.header,params=params).json()


        except Exception as e:
            print('获取金融产品失败',e)

    def finacialProductsexamine(self):
        '''
        金融产品审核
        :return:
        '''
        self.examineservice='scf/finance/fund/examine'
        self.examineurl=os.path.join(self.baseurl,self.examineservice)
        self.finacialProductsget(50,'na')  #修改名称和页数
        exdata=self.d.examinedata()
        self.waitexaminedata=[]
        for iterm in self.getres['resultObject']['pageData']:
            if iterm['status']==0:
                dict1={}
                dict1['id']=iterm['id']
                dict1['fundNo']=iterm['fundNo']
                self.waitexaminedata.append(dict1)
        # print(self.waitexaminedata)


        for item1 in self.waitexaminedata:
            exdata['id']=item1['id']
            exdata['fundNo']=item1['fundNo']
            # exdata['status']=item1['status']
            self.exdata=json.dumps(exdata)
            try:
                res=requests.post(url=self.examineurl,headers=self.header,data=self.exdata).json()
                print('审核成功:  ',exdata['fundNo'])
            except Exception as e:
                print('审核不成功:  ',exdata['fundNo'])
Beispiel #6
0
class enterpriseManagement:
    '''
    企业管理
    '''

    def __init__(self):
        self.d=Data()
        self.baseurl='http://crouter.yunzongnet.com/scf-backstage/t5670/'
        self.loginservice='scf/user/login'
        self.loginurl=os.path.join(self.baseurl,self.loginservice)
        data={
            "account": "scfyangxue",
            "password": "******",
            "platform": 12,
            "force": 1
            }
        self.header={
            'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }
        self.logindata=json.dumps(data)

        try:
            res=requests.post(url=self.loginurl,data=self.logindata,headers=self.header).json()
            # print(res)
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败',e)

    def getenterprise(self,keyword):
        '''
        获取企业列表
        :return:
        '''
        self.getenterpriseserver='scf/enterprise/page'
        self.getenterpriseurl=os.path.join(self.baseurl,self.getenterpriseserver)
        self.params={
            'pageSize': 50,
            'currentPage': 1,
            'totalCount': '',
            'enterpriseName': keyword,
            'enterpriseNo':'',
            'enterpriseBelong':1,
            'businessStatus':'',
            'effectiveStatus':'',
            'start': 'enterpriseDateStart',
            'end':' enterpriseDateEnd',
            'enterpriseDateStart':'',
            'enterpriseDateEnd':''
        }
        try:
            res=requests.get(url=self.getenterpriseurl,headers=self.header,params=self.params).json()
            # print(res)
        except Exception as e:
            print('获取客户失败',e)

        listdata=[]
        for item in res['resultObject']['pageData']:
            if item['businessStatus']=='0':
                dict1={}
                dict1['enterpriseId']=item['enterpriseId']
                dict1['enterpriseNo']=item['enterpriseNo']
                dict1['enterpriseName']=item['enterpriseName']
                listdata.append(dict1)
        print(listdata)
        return listdata


    def getenterpriseapproval(self):
        '''
        启动立项申请
        :return:
        '''
        self.getenterpriseapprovalservice='scf/enterprise/cAdd'
        self.getenterpriseapprovalurl=os.path.join(self.baseurl,self.getenterpriseapprovalservice)
        listdata=self.getenterprise('')
        self.approvaldata=self.d.apprdata()
        for item in listdata:
            self.approvaldata['enterpriseId']=item['enterpriseId']
            try:
                res=requests.post(url=self.getenterpriseapprovalurl,headers=self.header,data=self.approvaldata)
                print('企业立项申请申请成功',res)
            except Exception as e:
                print('企业立项申请申请失败')

    def requestDing(self):
        '''
        发起钉钉申请
        :return:
        '''
        pass

    def imagedo(self):
        '''
        处理图片信息函数
        主要处理图片上传后返回一个key
        role:钉钉申请:1 供应商:2
        :return:
        '''
        url = os.path.join(self.baseurl, 'scf/oss/file/upload')
        header = {
            'Authorization': '09091ca4b0534cbfb57ff6d49c115d83',
            'Accept-Encoding': 'gzip, deflate'
        }
        filename = '1.png'
        filepath = r'C:\Users\Think\Desktop\img\1.png'
        header['Authorization'] = self.header['Authorization']
        data = {}
        data['type'] = '1'
        data['file'] = (filename, open(filepath, 'rb').read())
        encode_data = encode_multipart_formdata(data)
        data = encode_data[0]
        header['Content-Type'] = encode_data[1]
        try:
            res = requests.post(url=url, headers=header, data=data).json()
            key = res['resultObject']['md5']
            print(key)
            return key
        except Exception as e:
            print('图片上传失败', e)
class customerAdd:
    def __init__(self):
        '''
        基础url 共用的在其他方式也可使用,根据项目跟改,自己url是本链接的url
        data 是请求的数据,force:0 非强制登陆,1:强制登陆
        登陆完成后把返回的token,赋值到header中的Authorization,供其他模块使用
        '''
        self.baseurl = 'https://scmubpre.xiyunfin.com/'
        self.url = os.path.join(self.baseurl, 'ub/user/login')
        print(self.url)
        data = {"account": "agent.ql.admin", "password": "******", "force": 1}
        self.data = json.dumps(data)
        self.header = {
            'User-Agent':
            "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            'Content-Type': 'application/json'
        }
        try:
            res = requests.post(url=self.url,
                                headers=self.header,
                                data=self.data).json()
            self.header['Authorization'] = res['resultObject']['token']
        except Exception as e:
            print('登陆失败', e)
        self.d = Data()

    def newwarehose(self, warehosename):
        '''
        新增仓库函数
        :param warehosename:仓名称参数
        :return:没有返回值,直接把请求返回放到了类中
        wdata:从数据源中取数据
        '''
        url = os.path.join(self.baseurl,
                           'ub/agent/base/warehouse/newWarehouse')
        wdata = self.d.wdata()
        wdata['warehouseName'] = warehosename
        self.wdata = json.dumps(wdata)
        try:
            self.warehoseres = requests.post(url=url,
                                             headers=self.header,
                                             data=self.wdata).json()
            print('新增仓库成功: ',
                  self.warehoseres['resultObject']['warehouseName'])
        except Exception as e:
            print('新建仓库失败', e)

    def addcustomer(self):
        '''
        新增客户函数
        data=self.d.cdata():从数据源中取数据
        dk = self.imagedo():从图片处理函数中获取图片上传后的key,用于图片的上传校验
        warehosename='仓库00%s-y'%i:设置仓库名称,可修改除了%s之外的命名
        customername='客户00%s-y'%i:设置客户名称,可修改除了%s之外的命名
        :return:
        '''
        self.url = os.path.join(self.baseurl, 'ub/agent/base/customer/add')
        data = self.d.cdata()
        for i in range(9):
            dk = self.imagedo('1')
            if dk:
                data['businessCommonFiles'][0]['key'] = dk['2']
                data['legalCommonFiles'][0]['key'] = dk['3']
                data['foodSafetyCommonFiles'][0]['key'] = dk['11']
                warehosename = '预发仓库%s' % i
                customername = '预发客户%s' % i
                self.newwarehose(warehosename)
                if self.warehoseres:
                    data['warehouseId'] = self.warehoseres['resultObject'][
                        'warehouseId']
                    data['warehouseNumber'] = self.warehoseres['resultObject'][
                        'warehouseNumber']
                    data['warehouseName'] = self.warehoseres['resultObject'][
                        'warehouseName']
                    data['customerName'] = customername
                    self.dataf = json.dumps(data)
                    try:
                        self.customerres = requests.post(
                            url=self.url, headers=self.header,
                            data=self.dataf).json()
                        print('新增客户成功', self.customerres)
                    except Exception as e:
                        print('新增客户失败', e)

    def supplieradd(self):
        '''
        供应商跟客户绑成一对一,通过客户名模糊搜索出来,列表里把客户名称提出来,供应商名称“客户名称+供应商”
        拿到客户对应得仓库编号再拿到仓库id,然后绑定到一起
        使用哦得时候修改一下customerlist=self.getcustomer(50,'模糊搜索客户名'),之前建了什么客户模糊搜索一下就好
        然后代码会自动建供应商,大致是这样名称得供应商‘客户名称供应商’
        :return:
        '''
        url = os.path.join(self.baseurl, 'ub/agent/base/supplier/submit')
        customerlist = self.getcustomer(50, '预发客户')
        listsupplier = []
        for itme in customerlist:
            dict = {}
            dict['cname'] = itme['customerName']
            dict['wid'] = itme['warehouseId']
            listsupplier.append(dict)

        sdata = self.d.supplier()

        for itme in listsupplier:
            dk = self.imagedo('2')
            if dk:
                sdata['businessCommonFiles'][0]['key'] = dk['2']
                sdata['legalCommonFiles'][0]['key'] = dk['3']
                sdata['foodSafetyCommonFiles'][0]['key'] = dk['11']
                sdata['transactionInvoice'][0]['key'] = dk['12']
                sdata['businessContract'][0]['key'] = dk['13']
                sdata['supplierName'] = (itme['cname'] + '供应商')
                sdata['warehouseIds'][0] = itme['wid']
                self.sdata = json.dumps(sdata)
                # print(self.sdata)
                try:
                    res = requests.post(url=url,
                                        headers=self.header,
                                        data=self.sdata).json()
                    print('新增供应商成功,编号:', res)
                except Exception as e:
                    print('新增失败:', e)

    #获取用户得接口
    def getcustomer(self, pagesize, customername):
        self.url = os.path.join(self.baseurl, 'ub/agent/base/customer/page')
        params = {
            'pageSize': pagesize,
            'currentPage': 1,
            'totalCount': 0,
            'customerName': customername,
            'status': '',
            'warehouseName': '',
            'companyType': ''
        }
        try:
            res = requests.get(url=self.url,
                               headers=self.header,
                               params=params).json()
            clist = res['resultObject']['pageData']
            # print(clist)
            return clist
        except Exception as e:
            print('获取客户失败:', e)

    def imagedo(self, role):
        '''
        处理图片信息函数
        主要处理图片上传后返回一个key
        role:客户:1 供应商:2
        :return:
        '''
        url = os.path.join(self.baseurl, 'ub/image/cache/upload')
        header = {
            'Authorization': '09091ca4b0534cbfb57ff6d49c115d83',
            'Accept-Encoding': 'gzip, deflate'
        }
        filename = '1.png'
        filepath = r'C:\Users\Think\Desktop\img\1.png'
        header['Authorization'] = self.header['Authorization']
        if role == '1':
            dictkey = {}
            for i in (2, 3, 11):
                data = {}
                data['type'] = i
                data['file'] = (filename, open(filepath, 'rb').read())
                encode_data = encode_multipart_formdata(data)
                data = encode_data[0]
                header['Content-Type'] = encode_data[1]
                try:
                    res = requests.post(url=url, headers=header,
                                        data=data).json()
                    dictkey['%s' % i] = res['resultObject']['key']
                except Exception as e:
                    print('图片上传失败', e)
            return dictkey

        elif role == '2':
            dictkey = {}
            for i in (2, 3, 11, 12, 13):
                data = {}
                data['type'] = i
                data['file'] = (filename, open(filepath, 'rb').read())
                encode_data = encode_multipart_formdata(data)
                data = encode_data[0]
                header['Content-Type'] = encode_data[1]
                try:
                    res = requests.post(url=url, headers=header,
                                        data=data).json()
                    dictkey['%s' % i] = res['resultObject']['key']
                except Exception as e:
                    print('图片上传失败', e)
            return dictkey
        else:
            print('未知的业务模式')