def tuikuan001(self, ketuikuandingdan): '''执行退款,并把退款数据写入到表格''' for i in ketuikuandingdan: if self.stop001: return try: self.driver.get(i) time.sleep(random.uniform(2, 3)) ym1 = self.driver.find_element_by_css_selector('body').text tytk = "//div[contains(@class,'button')]/span[contains(text(),'同意退款')]" self.driver.find_element_by_xpath(tytk).click() time.sleep(random.uniform(2, 3)) b1 = self.driver.find_elements_by_xpath(tytk) b1[1].click() time.sleep(random.uniform(2, 3)) self.driver.refresh() if self.driver.find_elements_by_xpath( "//span[contains(text(),'退款成功')]" ) and '***已退款[tiqianchuli]' not in re.findall( r'\n修改备注\n(.*?)\n', ym1)[0]: #备注内容 self.driver.find_element_by_xpath( "//span[text()='修改备注']").click() #点击修改备注 time.sleep(random.uniform(2, 3)) tuikuanshijian = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) beizhu = '***已退款[tiqianchuli]----伟' + tuikuanshijian self.driver.find_element_by_css_selector( 'textarea[placeholder="主订单备忘"]').send_keys( beizhu) #输入备注 time.sleep(1) self.driver.find_element_by_css_selector( 'label[data-reactid$="@1.1.0:$4"]').click() #点击选择紫旗 time.sleep(1) self.driver.find_element_by_xpath( "//span[text()='确定']").click() #点击确认备注 time.sleep(random.uniform(1, 2)) li001 = [ re.findall(r'\n订单编号:\n(.*?)\n', ym1)[0], #订单编号 tuikuanshijian, #退款时间 re.findall('买家已退货:(.*)((.*)\)查看物流详情', ym1)[0][0], #物流单号 re.findall('买家已退货:(.*)((.*)\)查看物流详情', ym1)[0][1], #物流公司 ] #['订单编号','退货物流','退货单号','退款时间'] print('%s\n*******************退款成功' % li001) filename = tong1yong4.pei4zhi4('peizhi.ini').read( 'DEFAULT', 'excelname') #数据保存文件名 sheet_nanm = '退货提前退款' #表名 title = ['订单编号', '退款时间', '退货物流', '退货单号'] #表头 tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) except: pass
def start002(self): print('start001') checkb = { 'checkBox': self.checkBox, 'checkBox_2': self.checkBox_2, 'checkBox_3': self.checkBox_3, 'checkBox_4': self.checkBox_4, 'checkBox_5': self.checkBox_5 } for i in checkb: tong1yong4.pei4zhi4('peizhi.ini').change( 'appMain', {i: str(checkb[i].isChecked())}) tong1yong4.pei4zhi4('peizhi.ini').change( 'cuoduobu', {'time': self.lineEdit.text()}) linee = { 'user': self.lineEdit_4, 'excelName': self.lineEdit_2, 'riZhiName': self.lineEdit_3 } for i in linee: tong1yong4.pei4zhi4('peizhi.ini').change('DEFAULT', {i: linee[i].text()})
def cuodb(self): '''错拍多拍不想要退款处理''' self.driver.implicitly_wait(3) #等待网页元素加载20秒,针对此句后的所有网页元素 self.driver.get( r'https://refund2.tmall.com/dispute/sellerDisputeList.htm') time.sleep(1) yuanycdb1 = 'div#disputelist > div > div > div > div > div > label:nth-child(2) > span' self.driver.find_elements_by_css_selector( yuanycdb1)[0].click() #退款页面退款原因错多不 time.sleep(2) #错拍多拍不想要,筛选出错拍多拍不想要退款,等待操作 li = [] while True: if self.stop001: return dingdbh = r'div> div.mod-dispute-body-col.brand>a' tuiktd = self.driver.find_elements_by_css_selector( dingdbh) #定位退款入口 for td in tuiktd: li.append(td.get_attribute('href')) try: driver.find_element_by_css_selector( 'li[title="下一页"][class=" rc-pagination-next"][aria-disabled="false"]' ).click() time.sleep(random.uniform(2, 3)) except: break if li: for tk in li: if self.stop001: return self.driver.get(tk) time.sleep(1) ym1 = self.driver.find_element_by_css_selector('body').text li001 = [ ''.join(re.findall(r'\n买家:\n(.*?)\n', ym1)), #网名 ''.join(re.findall(r'\n订单编号:\n(.*?)\n', ym1)), #订单编号 ''.join(re.findall(r'\n原因:\n(.*?)\n', ym1)), #退款原因 ''.join(re.findall(r'\n退款金额:\n(.*?)\n', ym1)), #退款金额 ''.join(re.findall(r'\n成交时间:\n(.*?)\n', ym1)), #付款时间 ''.join(re.findall(r'\n修改备注\n(.*?)\n', ym1)) #备注内容 ] print(li001) shqshij = ''.join(re.findall(r'\)于(.*?)创建了退款申请', ym1)) shijiancha = time.mktime( time.strptime(shqshij, "%Y-%m-%d %H:%M:%S")) - time.mktime( time.strptime(li001[4], "%Y-%m-%d %H:%M:%S")) shijch = float( tong1yong4.pei4zhi4('peizhi.ini').read( 'cuoduobu', 'time')) #配置文件中的time if (li001[2] == '多拍/拍错/不想要') and (shijiancha / 60 < shijch): tytk = "//div[contains(@class,'button')]/span[contains(text(),'同意退款')]" self.driver.find_element_by_xpath(tytk).click() time.sleep(random.uniform(2, 3)) b1 = self.driver.find_elements_by_xpath(tytk) b1[1].click() time.sleep(random.uniform(2, 3)) self.driver.refresh() if self.driver.find_elements_by_xpath( "//span[contains(text(),'退款成功')]"): filename = tong1yong4.pei4zhi4('peizhi.ini').read( 'DEFAULT', 'excelname') #数据保存文件名 sheet_nanm = '错拍多拍' #表名 title = [ '旺旺ID', '订单编号', '退款原因', '退款金额', '付款时间', '备注内容', '是否多笔' ] #表头 if '***已退款[' in li001[5]: li001 = li001 + ['此订单存在多个退款'] tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) continue tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) self.driver.find_element_by_xpath( "//span[text()='修改备注']").click() #点击修改备注 time.sleep(random.uniform(2, 3)) beizhu = '***已退款[cuodb]----伟' + time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())) self.driver.find_element_by_css_selector( 'textarea[placeholder="主订单备忘"]').send_keys( beizhu) #输入备注 time.sleep(1) self.driver.find_element_by_css_selector( 'label[data-reactid$="@1.1.0:$4"]').click( ) #点击选择紫旗 time.sleep(1) self.driver.find_element_by_xpath( "//span[text()='确定']").click() #点击确认备注 time.sleep(random.uniform(1, 2))
def setupUi(self, Form): #界面位置 Form.setObjectName("Form") Form.resize(413, 181) label = QtWidgets.QLabel(Form) label.setGeometry(QtCore.QRect(140, 20, 201, 16)) label.setObjectName("label") label_2 = QtWidgets.QLabel(Form) label_2.setGeometry(QtCore.QRect(140, 50, 81, 16)) label_2.setObjectName("label_2") label_3 = QtWidgets.QLabel(Form) label_3.setGeometry(QtCore.QRect(140, 80, 81, 16)) label_3.setObjectName("label_3") label_4 = QtWidgets.QLabel(Form) label_4.setGeometry(QtCore.QRect(140, 110, 111, 16)) label_4.setObjectName("label_4") self.lineEdit = QtWidgets.QLineEdit(Form) self.lineEdit.setGeometry(QtCore.QRect(341, 19, 51, 20)) self.lineEdit.setObjectName("lineEdit") self.lineEdit_2 = QtWidgets.QLineEdit(Form) self.lineEdit_2.setGeometry(QtCore.QRect(222, 49, 171, 20)) self.lineEdit_2.setObjectName("lineEdit_2") self.lineEdit_3 = QtWidgets.QLineEdit(Form) self.lineEdit_3.setGeometry(QtCore.QRect(222, 79, 171, 20)) self.lineEdit_3.setObjectName("lineEdit_3") self.lineEdit_4 = QtWidgets.QLineEdit(Form) self.lineEdit_4.setGeometry(QtCore.QRect(242, 109, 151, 20)) self.lineEdit_4.setObjectName("lineEdit_4") self.checkBox = QtWidgets.QCheckBox(Form) self.checkBox.setGeometry(QtCore.QRect(20, 20, 101, 16)) self.checkBox.setObjectName("checkBox") self.checkBox_2 = QtWidgets.QCheckBox(Form) self.checkBox_2.setGeometry(QtCore.QRect(20, 50, 101, 16)) self.checkBox_2.setObjectName("checkBox_2") self.checkBox_3 = QtWidgets.QCheckBox(Form) self.checkBox_3.setGeometry(QtCore.QRect(20, 80, 101, 16)) self.checkBox_3.setObjectName("checkBox_3") self.checkBox_4 = QtWidgets.QCheckBox(Form) self.checkBox_4.setGeometry(QtCore.QRect(20, 110, 81, 16)) self.checkBox_4.setObjectName("checkBox_4") self.checkBox_5 = QtWidgets.QCheckBox(Form) self.checkBox_5.setGeometry(QtCore.QRect(20, 140, 91, 16)) self.checkBox_5.setObjectName("checkBox_5") pushButton = QtWidgets.QPushButton(Form) pushButton.setGeometry(QtCore.QRect(140, 140, 75, 23)) pushButton.setObjectName("pushButton") pushButton_2 = QtWidgets.QPushButton(Form) pushButton_2.setGeometry(QtCore.QRect(320, 140, 75, 23)) pushButton_2.setObjectName("pushButton_2") checkb = { 'checkBox': self.checkBox, 'checkBox_2': self.checkBox_2, 'checkBox_3': self.checkBox_3, 'checkBox_4': self.checkBox_4, 'checkBox_5': self.checkBox_5 } for i in checkb: checkb[i].setChecked( eval(tong1yong4.pei4zhi4('peizhi.ini').read('appMain', i))) #界面文字 Form.setWindowTitle( QtWidgets.QApplication.translate("Form", "自动退款规蜜", None, -1)) label.setText( QtWidgets.QApplication.translate("Form", "错拍多拍付款到退款的时长(分钟):", None, -1)) label_2.setText( QtWidgets.QApplication.translate("Form", "导出表格名称:", None, -1)) label_3.setText( QtWidgets.QApplication.translate("Form", "日志文件名称:", None, -1)) label_4.setText( QtWidgets.QApplication.translate("Form", "退款使用的旺旺号:", None, -1)) self.lineEdit.setText( QtWidgets.QApplication.translate( "Form", tong1yong4.pei4zhi4('peizhi.ini').read('cuoduobu', 'time'), None, -1)) self.lineEdit_2.setText( QtWidgets.QApplication.translate( "Form", tong1yong4.pei4zhi4('peizhi.ini').read('DEFAULT', 'excelName'), None, -1)) self.lineEdit_3.setText( QtWidgets.QApplication.translate( "Form", tong1yong4.pei4zhi4('peizhi.ini').read('DEFAULT', 'riZhiName'), None, -1)) self.lineEdit_4.setText( QtWidgets.QApplication.translate( "Form", tong1yong4.pei4zhi4('peizhi.ini').read('DEFAULT', 'user'), None, -1)) self.checkBox.setText( QtWidgets.QApplication.translate("Form", "错拍多拍退款", None, -1)) self.checkBox_2.setText( QtWidgets.QApplication.translate("Form", "审核订单退款", None, -1)) self.checkBox_3.setText( QtWidgets.QApplication.translate("Form", "退运费", None, -1)) self.checkBox_4.setText( QtWidgets.QApplication.translate("Form", "规蜜处理", None, -1)) self.checkBox_5.setText( QtWidgets.QApplication.translate("Form", "退货提前退", None, -1)) pushButton.setText( QtWidgets.QApplication.translate("Form", "开始", None, -1)) pushButton_2.setText( QtWidgets.QApplication.translate("Form", "暂停", None, -1)) QtCore.QObject.connect(pushButton, QtCore.SIGNAL("clicked()"), self.start002) QtCore.QObject.connect(pushButton_2, QtCore.SIGNAL("clicked()"), self.stop002) QtCore.QMetaObject.connectSlotsByName(Form)
def shenghedd(self): '''已审核订单退款处理''' self.driver.implicitly_wait(3) #等待网页元素加载3秒,针对此句后的所有网页元素 self.driver.get( r'https://refund2.tmall.com/dispute/sellerDisputeList.htm') time.sleep(1) yuanycdb1 = self.driver.find_elements_by_xpath( '//span[contains(text(),"已审核(")]') #退款页面已审核订单筛选 yuanycdb1[0].click() time.sleep(random.uniform(0.5, 1)) yuanycdb1[1].click() time.sleep(random.uniform(2, 3)) #筛选出已审核订单退款,等待操作 li = [] dingdbh = r'div> div.mod-dispute-body-col.brand>a' tuiktd = self.driver.find_elements_by_css_selector(dingdbh) #定位退款入口 if tuiktd: for td in tuiktd: li.append(td.get_attribute('href')) if li: for tk in li: if self.stop001: return self.driver.get(tk) time.sleep(1) ym1 = self.driver.find_element_by_css_selector('body').text li001 = [ ''.join(re.findall(r'\n买家:\n(.*?)\n', ym1)), #网名 ''.join(re.findall(r'\n订单编号:\n(.*?)\n', ym1)), #订单编号 ''.join(re.findall(r'\n原因:\n(.*?)\n', ym1)), #退款原因 ''.join(re.findall(r'\n退款金额:\n(.*?)\n', ym1)), #退款金额 ''.join(re.findall(r'\n成交时间:\n(.*?)\n', ym1)), #付款时间 ''.join(re.findall(r'\n修改备注\n(.*?)\n', ym1)) #备注内容 ] print(li001) if re.findall(r'\n该笔订单已(.*?),审核员', ym1): if re.findall(r'\n该笔订单已(.*?),审核员', ym1)[0] == '通过同意退款审核': tytk = "//div[contains(@class,'button')]/span[contains(text(),'同意退款')]" self.driver.find_element_by_xpath(tytk).click() time.sleep(random.uniform(2, 3)) b1 = self.driver.find_elements_by_xpath(tytk) b1[1].click() time.sleep(random.uniform(2, 3)) self.driver.refresh() if self.driver.find_elements_by_xpath( "//span[contains(text(),'退款成功')]"): filename = tong1yong4.pei4zhi4('peizhi.ini').read( 'DEFAULT', 'excelname') #数据保存文件名 sheet_nanm = '审核退款' #表名 title = [ '旺旺ID', '订单编号', '退款原因', '退款金额', '付款时间', '备注内容', '是否多笔' ] #表头 if '***已退款[' in li001[5]: li001 = li001 + ['此订单存在多个退款'] tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) continue tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) self.driver.find_element_by_xpath( "//span[text()='修改备注']").click() #点击修改备注 time.sleep(random.uniform(2, 3)) beizhu = '***已退款[shenghedd]----伟' + time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime( time.time())) self.driver.find_element_by_css_selector( 'textarea[placeholder="主订单备忘"]').send_keys( beizhu) #输入备注 time.sleep(1) self.driver.find_element_by_css_selector( 'label[data-reactid$="@1.1.0:$4"]').click( ) #点击选择紫旗 time.sleep(1) self.driver.find_element_by_xpath( "//span[text()='确定']").click() #点击确认备注 time.sleep(random.uniform(1, 2))
def tuiyunfei(self): '''仅退款,退运费处理''' self.driver.implicitly_wait(3) #等待网页元素加载20秒,针对此句后的所有网页元素 self.driver.get( r'https://refund2.tmall.com/dispute/sellerDisputeList.htm') time.sleep(random.uniform(1, 2)) self.driver.find_element_by_xpath( r'//*[@id="sellerGridQueryContainer_1@3"]/div[2]/span').click( ) #退款页面退款原因 time.sleep(1) self.driver.find_element_by_xpath( "//div/div/span[text()='退运费']").click() #退款页面退款原因里的退运费 time.sleep(2) self.driver.find_element_by_xpath( "//span[text()='仅退款(已发货)']").click() #退款页面仅退款(已发货) time.sleep(2) #退运费,筛选出退运费仅退款,等待操作 li = [] while True: if self.stop001: return dingdbh = r'div> div.mod-dispute-body-col.brand>a' tuiktd = self.driver.find_elements_by_css_selector( dingdbh) #定位退款入口 for td in tuiktd: li.append(td.get_attribute('href')) try: driver.find_element_by_css_selector( 'li[title="下一页"][class=" rc-pagination-next"][aria-disabled="false"]' ).click() time.sleep(random.uniform(2, 3)) except: break if li: for tk in li: if self.stop001: return self.driver.get(tk) time.sleep(random.uniform(1, 2)) ym1 = self.driver.find_element_by_css_selector('body').text li001 = [ ''.join(re.findall(r'\n买家:\n(.*?)\n', ym1)), #网名 ''.join(re.findall(r'\n订单编号:\n(.*?)\n', ym1)), #订单编号 ''.join(re.findall(r'\n原因:\n(.*?)\n', ym1)), #退款原因 ''.join(re.findall(r'\n退款金额:\n(.*?)\n', ym1)), #退款金额 ''.join(re.findall(r'\n成交时间:\n(.*?)\n', ym1)), #付款时间 ''.join(re.findall(r'\n修改备注\n(.*?)\n', ym1)) #备注内容 ] print(li001) if (li001[3][:-3] in li001[5]) and (li001[2] == '退运费') and ( '已退款' not in li001[5]): tytk = "//div[contains(@class,'button')]/span[contains(text(),'同意退款')]" self.driver.find_element_by_xpath(tytk).click() time.sleep(random.uniform(2, 3)) b1 = self.driver.find_elements_by_xpath(tytk) b1[1].click() time.sleep(random.uniform(2, 3)) self.driver.refresh() if self.driver.find_elements_by_xpath( "//span[contains(text(),'退款成功')]"): filename = tong1yong4.pei4zhi4('peizhi.ini').read( 'DEFAULT', 'excelname') #数据保存文件名 sheet_nanm = '退运费' #表名 title = [ '旺旺ID', '订单编号', '退款原因', '退款金额', '付款时间', '备注内容' ] #表头 tong1yong4.biao3ge2xie3ru4.excelwrite( filename, sheet_nanm, li001, title) self.driver.find_element_by_xpath( "//span[text()='修改备注']").click() #点击修改备注 time.sleep(random.uniform(2, 3)) beizhu = '***已退款[tuiyunfei]----伟' + time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())) self.driver.find_element_by_css_selector( 'textarea[placeholder="主订单备忘"]').send_keys( beizhu) #输入备注 time.sleep(1) self.driver.find_element_by_css_selector( 'label[data-reactid$="@1.1.0:$4"]').click( ) #点击选择紫旗 time.sleep(1) self.driver.find_element_by_xpath( "//span[text()='确定']").click() #点击确认备注 time.sleep(random.uniform(1, 2))