def __init__(self, account, password, Etype=1): self.log = Log('Employee') self.tool = Tool() self.request = Request() emp = EmployeeSession(account, password) self.password = emp.password self.token, self.deviceId = emp.token, emp.deviceId if Etype == 1: self.employee_info = self.tool.miaoshu_query_user_info_by_mobile( account, 2) # self.log.logger.debug("员工信息:%s" % self.employee_info) elif Etype == 2: self.employee_info = self.tool.miaoshu_query_user_info_by_email( account, 2) else: return if self.employee_info != (): self.employee_info = self.employee_info[0] self.employee_id = self.employee_info["id"] self.employee_real_name = self.employee_info["real_name"] self.employee_nickname = self.employee_info["nickname"] self.employee_sex = self.employee_info["sex"] self.employee_mobile = self.employee_info["mobile"] self.employee_email = self.employee_info["email"] self.employee_account_status = self.employee_info["account_status"] self.employee_account_type = self.employee_info["account_type"] self.employee_head_img = self.employee_info["head_img"] self.employee_register_time = self.employee_info["create_time"] self.employee_edit_time = self.employee_info["edit_time"] self.employee_channel_shop_id = None
def __init__(self, mobile): self.log = Log('User') self.tool = Tool() self.request = Request() # self.user_info = self.tool.miaoshu_query_user_info_by_mobile(mobile, 1) # if self.user_info != (): # self.user_info = self.user_info[0] # if self.user_info['channel_status'] is not None: # self.tool.ms_delete_user_by_mobile(mobile) us = UserSession(mobile) self.encryptedPwd = us.encrypted_password self.token, self.device_id = us.token, us.deviceId self.user_info = self.tool.miaoshu_query_user_info_by_mobile(mobile, 1) if self.user_info != (): self.user_info = self.user_info[0] self.user_id = self.user_info["id"] self.real_name = self.user_info["real_name"] self.nickname = self.user_info["nickname"] self.sex = self.user_info["sex"] self.mobile = self.user_info["mobile"] self.email = self.user_info["email"] self.account_status = self.user_info["account_status"] self.account_type = self.user_info["account_type"] self.head_img = self.user_info["head_img"] self.register_time = self.user_info["create_time"] self.edit_time = self.user_info["edit_time"] self.channel_shop_id = None self.supplier_shop_id = None
class Farmer(object): L = Log("Farmer") fake = Faker() heads = [ "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012058085.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012097899.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012131136.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012158702.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012174832.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012206259.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012246905.png" ] gender = {1: "男", 2: "女"} def __init__(self): self.head_img = self.heads[self.fake.random_int(0, 6)] self.L.logger.debug(u"农场主头像 为 %s " % str(self.head_img)) self.real_name = self.fake.name() self.L.logger.debug(u"农场主姓名 为 %s " % str(self.real_name)) self.birthday = self.fake.date_of_birth() self.L.logger.debug(u"农场主生日 为 %s " % str(self.birthday)) self.mobile = self.fake.random_int(610000000, 619999999) self.L.logger.debug(u"农场主手机 为 %s " % str(self.mobile)) self.farmer_address = self.fake.address().replace('\n', ' ') self.L.logger.debug(u"农场主住址 为 %s " % str(self.farmer_address)) self.sex = self.fake.random_int(1, 2) self.L.logger.debug("农场主性别 为 %s " % self.gender[self.sex]) self.owned_farmer_num = self.fake.random_int(1, 9) self.L.logger.debug(u"农场主拥有农场数 为 %s " % str(self.owned_farmer_num))
class Redis(object): L = Log("Redis") pool = redis.ConnectionPool(host='67.218.159.111', port=6699, db=7, password='******') r = redis.Redis(connection_pool=pool) def set(self, key, value): self.r.set(key, value) self.L.logger.debug('Set %s = %s' % (str(key), str(value))) def get(self, key): value = self.r.get(key) self.L.logger.debug('Get %s = %s' % (str(key), str(value))) return value.decode() def delete(self, key): self.r.delete(key) self.L.logger.debug('Delete %s' % str(key)) def exists(self, key): exist = self.r.exists(key) self.L.logger.debug('exist? %s' % str(exist)) return exist
def __init__(self, real_name, mobile, email, region, *roles): self.log = Log('User') self.log.logger.debug(type(roles)) self.tool = Tool() self.request = Request() self.mobile = mobile self.user_info = self.tool.query_user_info_by_mobile(self.mobile) self.role_list = self.tool.get_role_code(*roles) self.real_name = real_name self.email = email self.region = region data_uc = Config('uc').data employee_data = data_uc['http://dev.uc.worldfarm.com'][ '/admin/emp/add'] employee_data["mobile"] = self.mobile employee_data["realName"] = self.real_name employee_data["email"] = self.email employee_data["mobileRegion"] = self.region employee_data["roles"] = self.role_list admin = EmployeeSession('007', '123456') employee_data["_tk_"] = admin.token employee_data["_deviceId_"] = admin.deviceId add_employee = self.request.post( url="http://dev.uc.worldfarm.com/admin/emp/add", data=employee_data) self.log.logger.debug(add_employee)
def setUpClass(cls): cls.Log = Log() cls.logger = cls.Log.get_logger() cls.LoginExcel = DealExcelFile() _ = cls.LoginExcel.load(LoginExcelDir) cls.ContactExcel = DealExcelFile() _ = cls.ContactExcel.load(ContactExcelDir)
def __init__(self, supplier): self.log = Log('SupplierAction') self.supplier = supplier self.request = Request() self.tool = Tool() self.redis = Redis() self.db = DataBaseOperate() self.ps = 10
class Config(object): L = Log('Config') def __init__(self, name): self.name = name current_path = os.path.dirname(os.path.abspath(__file__)) settings = yaml.load( open(current_path + "/" + name + ".yaml", encoding='utf-8')) self.data = settings
def __init__(self, promoter): self.log = Log('PromoterAction') self.promoter = promoter self.data_sso = Config('sso').data self.data_trade = Config('trade').data self.data_sms = Config('sms').data self.request = Request() self.tool = Tool() self.ps = 10
def __init__(self, translator): self.log = Log('TranslatorAction') self.translator = translator self.data_sso = Config('sso').data self.data_trade = Config('trade').data self.data_sms = Config('sms').data self.data_base = DataBaseOperate() self.request = Request() self.tool = Tool()
def __init__(self, seller_agent): self.log = Log('sellerAgent') self.sellerAgent = seller_agent self.data_sso = Config('sso').data self.data_trade = Config('trade').data self.data_sms = Config('sms').data self.request = Request() self.tool = Tool() self.ps = 10
def createLog(self): """ Create the log of test. The log is created in the test folder """ self.createPath() TestCase = self.__class__.__name__ log_path = LOG_PATH.format(self.path, TestCase) self.log = Log(log_path) self.log = self.log.get_logger() self.log.info(MsgLog.MSG_CREATE_LOG.format(log_path))
class Shop(object): L = Log('Shop') fake = Faker('zh_CN') def __init__(self, user, shop_name='', shop_mobile='', shop_contact=''): """ 初始化一个店铺对象 :param user: 传一个用户对象 :param shop_name: 店铺名称 :param shop_mobile: 店铺手机号 :param shop_contact: 店铺联系人 """ da = DistributorAction(user) if shop_name == '': self.name = str(user.mobile[1:]) else: self.name = shop_name self.L.logger.debug("店铺名称为: %s" % str(self.name)) if shop_mobile == '': pre_list = [ "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "147", "150", "151", "152", "153", "155", "156", "157", "158", "159", "186", "187", "188" ] self.mobile = random.choice(pre_list) + "".join( random.choice("0123456789") for i in range(8)) else: self.mobile = shop_mobile self.L.logger.debug("店铺手机号为: %s" % str(self.mobile)) if shop_contact == '': shop_contact_name = self.fake.name() self.contact = shop_contact_name else: self.contact = shop_contact self.L.logger.debug("店铺联系人为: %s" % str(self.contact)) self.avatar = da.upload_avatar() self.L.logger.debug("头像链接为: %s" % str(self.avatar)) self.lat = round(random.uniform(30.5, 30.7), 4) self.L.logger.debug("纬度为: %s" % str(self.lat)) self.lng = round(random.uniform(103.9, 104.2), 3) self.L.logger.debug("经度为: %s" % str(self.lng)) self.province = 41 self.city = 4101 self.area = '高新区' self.address = self.fake.address() self.L.logger.debug("地址为: %s" % str(self.address)) self.shopId = user.channel_shop_id self.supplier_shop_id = user.supplier_shop_id
def __init__(self, buyer): """ 初始化方法的一个常用数据 :param buyer: 传的是一个用户对象 """ self.log = Log('buyer') self.buyer = buyer self.data_sso = Config('sso').data self.data_trade = Config('trade').data self.data_sms = Config('sms').data self.request = Request() self.tool = Tool() self.ps = 10
def __init__(self, account, password): gender = {'1': '男', '2': '女'} self.log = Log('Employee') self.tool = Tool() employee_info = self.tool.query_employee_info_by_account(account)[0] self.real_name = employee_info['real_name'] self.log.logger.debug("工号 %s 的 姓名 为 %s" % (str(account), self.real_name)) self.mobile = employee_info['mobile'] self.log.logger.debug("工号 %s 的 手机号 为 %s" % (str(account), self.mobile)) self.mobile_region = employee_info['mobile_region'] self.log.logger.debug("工号 %s 的 手机国际区号 为 %s" % (str(account), self.mobile_region)) self.account_status = employee_info['account_status'] self.log.logger.debug("工号 %s 的 账户状态 为 %s" % (str(account), self.account_status)) self.account_type = employee_info['account_type'] self.log.logger.debug("工号 %s 的 账户类型 为 %s" % (str(account), self.account_type)) self.email = employee_info['email'] self.log.logger.debug("工号 %s 的 邮箱 为 %s" % (str(account), self.email)) self.email_state = employee_info['email_state'] self.log.logger.debug("工号 %s 的 邮箱状态 为 %s" % (str(account), self.email_state)) self.user_id = employee_info['id'] self.log.logger.debug("工号 %s 的 用户id 为 %s" % (str(account), self.user_id)) self.register_time = employee_info['register_time'] self.log.logger.debug("工号 %s 的 注册时间 为 %s" % (str(account), self.register_time)) self.account = str(account) self.log.logger.debug("工号 %s 的 工号 为 %s" % (str(account), str(account))) self.birthday = employee_info['birthday'] self.log.logger.debug("工号 %s 的 生日 为 %s" % (str(account), self.birthday)) self.head_img = employee_info['head_img'] self.log.logger.debug("工号 %s 的 头像 为 %s" % (str(account), self.head_img)) # self.sex = employee_info['sex'] # self.log.logger.debug("工号 %s 的 性别 为 %s" % (str(account), gender[str(self.sex)])) self.request = Request() session = EmployeeSession(account, password) self.token = session.token self.log.logger.debug("工号 %s 的 token 为 %s" % (str(account), session.token)) self.device_id = session.deviceId self.log.logger.debug("工号 %s 的 deviceId 为 %s" % (str(account), session.deviceId))
class PotentialSellerAgent(object): L = Log("PotentialSellerAgent") data = Config('RegionAU').data state = {"1": "待开发", "2": "已开发"} gender = {1: "男", 2: "女"} fake = Faker() heads = [ "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012058085.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012097899.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012131136.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012158702.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012174832.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012206259.png", "https://zyp-farm-2.oss-ap-southeast-1.aliyuncs.com/data/farm/head/1530012246905.png" ] def __init__(self): state = list(self.data.keys())[self.fake.random_int(0, 7)] location = list(self.data[state][0].values())[0] self.image = self.heads[self.fake.random_int(0, 6)] self.L.logger.debug("待开发中介 头像 为 %s " % str(self.image)) self.real_name = self.fake.name() self.L.logger.debug("待开发中介 姓名 为 %s " % str(self.real_name)) self.status = "1" self.L.logger.debug("待开发中介 状态 为 %s " % self.state[self.status]) self.mobile = self.fake.random_int(610000000, 619999999) self.L.logger.debug("待开发中介 手机 为 %s " % str(self.mobile)) self.address = location['address'] self.L.logger.debug("待开发中介 住址 为 %s " % str(self.address)) self.lat = location['lat'] self.L.logger.debug("待开发中介 维度 为 %s " % str(self.lat)) self.lng = location['lng'] self.L.logger.debug("待开发中介 经度 为 %s " % str(self.lng)) self.sex = self.fake.random_int(1, 2) self.L.logger.debug("待开发中介 性别 为 %s " % self.gender[self.sex]) self.published_farm_num = self.fake.random_int(1, 9) self.L.logger.debug("待开发中介 发布农场数 为 %s " % str(self.published_farm_num)) def add(self): DataBaseOperate().operate( "39.104.28.40", "farm-trade", "INSERT INTO `farm-trade`.`t_out_seller_agency` " "(`real_name`,`image`,`sex`,`mobile`,`lng`,`lat`,`status`," "`published_farm_num`,`address`) " "VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s');" % (self.real_name, self.image, self.sex, self.mobile, self.lng, self.lat, self.status, self.published_farm_num, self.address))
class DataBaseOperate(object): L = Log("DataBaseOperate") def operate(self, host_ip, database_name, sql): if host_ip == "39.104.28.40": user, password, port = "root", "YYJNo$QsaaSjgb8U3JoigB", 3306 elif host_ip == "47.74.129.65": user, password, port = "farm_test", "r2rublBL4qJMc", 3306 elif host_ip == "67.218.159.111": user, password, port = "root", "Knight01", 3306 else: raise Exception('数据库IP地址错误: %s' % host_ip) try: db = pymysql.connect(host=host_ip, port=port, user=user, db=database_name, passwd=password) con = db.cursor(cursor=pymysql.cursors.DictCursor) con.execute(sql) results = con.fetchall() # print(results) for result in results: for fields in result: if isinstance(result[fields], datetime.datetime): result[fields] = str( result[fields].strftime('%Y-%m-%d %H:%M:%S')) elif isinstance(result[fields], datetime.date): result[fields] = str( result[fields].strftime('%Y-%m-%d')) elif isinstance(result[fields], decimal.Decimal): result[fields] = float(result[fields]) db.commit() con.close() # print(results) self.L.logger.debug("\n" + json.dumps(results, ensure_ascii=False, sort_keys=True, indent=2, separators=(',', ': '))) return results except Exception as e: self.L.logger.error(e)
class UiAutoShopping(TestCase): L = Log("UiAutoShopping") at = AndroidTool() def test0001(self): try: apk_path = '/Users/hengxin/Downloads/苗叔-20181130\(v1.0.24\).apk' self.at.launch_app_by_apk(apk_path) self.at.login_miaoshu("18602832572", "888888") self.at.enter_shop("自动化刷单勿删") self.at.pay_product() self.at.tear_down_miaoshu() Mail().send_html_email() self.L.logger.info("测试完成, 邮件发送成功") except Exception as e: self.at.get_screen_shot() self.L.logger.debug("错误信息: %s" % e) self.at.tear_down_miaoshu()
def init_log(self): time_source = lambda: self.simulation_state.curr_time log = Log() log.set_time_source(time_source) log.add_dataset("Inertial Position (m)", ["pn", "pe", "-pd"], [ self.aircraft_state.get_pn, self.aircraft_state.get_pe, lambda: -1 * self.aircraft_state.get_pd() ]) log.add_dataset("Attitude (rad)", ["ϕ", "ϴ", "ψ"], [ self.aircraft_state.get_phi, self.aircraft_state.get_theta, self.aircraft_state.get_psi ]) log.add_dataset("Attitude Rates (rad/s)", ["p", "q", "r"], [ self.aircraft_state.get_p, self.aircraft_state.get_q, self.aircraft_state.get_r ]) log.add_dataset("Body Velocity (m/s)", ["u", "v", "w"], [ self.aircraft_state.get_u, self.aircraft_state.get_v, self.aircraft_state.get_w ]) log.add_dataset("Airspeed (m/s)", ["ur", "vr", "wr"], [ self.aircraft_state.get_ur, self.aircraft_state.get_vr, self.aircraft_state.get_wr ]) log.add_dataset("Body Frame Forces (N)", ["fx", "fy", "fz"], [ self.aircraft_state.get_fx, self.aircraft_state.get_fy, self.aircraft_state.get_fz ]) log.add_dataset("Body Moments (Nm)", ["l", "m", "n"], [ self.aircraft_state.get_l, self.aircraft_state.get_m, self.aircraft_state.get_n ]) log.add_dataset("Wind (m/s)", ["wn", "we", "wd"], [ self.simulation_state.get_wn, self.simulation_state.get_we, self.simulation_state.get_wd ]) log.add_dataset( "Wind Triangle (m/s)", ["α", "β"], [self.aircraft_state.get_alpha, self.aircraft_state.get_beta]) self.log = log
class Redis(object): L = Log("Redis") pool = redis.ConnectionPool(host='39.104.28.40', port=6379, db=2, password='******') r = redis.Redis(connection_pool=pool) def set(self, key, value): self.r.set(key, value) self.L.logger.debug('Set %s = %s' % (str(key), str(value))) def get(self, key): value = self.r.get(key) self.L.logger.debug('Get %s = %s' % (str(key), str(value))) if value is not None: value = value.decode() return value def delete(self, key): self.r.delete(key) self.L.logger.debug('Delete %s' % str(key)) def exists(self, key): exist = self.r.exists(key) self.L.logger.debug('exist? %s' % str(exist)) return exist
class Tool(object): L = Log("Tool") def get_images(self, key='farm'): redis = Redis() # redis.set('get_index', 0) get_index = int(redis.get('get_index')) response = Request().get( 'https://www.pexels.com/search/%s/?page=%s&format=html' % (key, str((get_index / 15) + 1))) soup = BeautifulSoup(response) images = soup.findAll('a', attrs={'href': re.compile("(^https.*)\?")}) # list_start = get_index # list_end = list_start + 15 i = 0 for link in images: image_url = '%s&auto=compress\n' % link.get('href') self.L.logger.debug(image_url) image = Request().get(image_url) i += 1 with open('./Images/banner%s.jpg' % str(i), 'wb') as picture: picture.write(image) # redis.set('get_index', str(list_end)) def upload_image(self): redis = Redis() get_index = int(redis.get('get_index')) - 15 for i in range(1, 16): if round((os.path.getsize("./Images/banner" + str(i) + ".jpg")) / 1000.0 / 1000.0, 1) < 5: Request().post_file( url="http://39.104.28.40:9600/common/farm/upload-img", file_path="./Images/banner%s.jpg" % str(i), file_key='file') # zyp_url = json.loads(response)["content"] # redis.set("image%s" % str(get_index + i), zyp_url) self.L.logger.debug("image%s uploaded !" % str(get_index + i)) else: self.L.logger.debug("image%s exceed size !" % str(get_index + i)) @staticmethod def miaoshu_query_user_info_by_mobile(mobile, user_type): sql = 'SELECT * FROM `ms-user`.t_base_user tu ' \ 'WHERE tu.mobile = %s AND tu.is_delete = 0 AND tu.account_type = %s;' % (str(mobile), str(user_type)) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info def miaoshu_query_user_info_by_email(email, user_type): sql = 'SELECT * FROM t_user WHERE email = %s AND is_delete = 0 AND account_type = %s;' \ % (str(email), str(user_type)) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info def ms_delete_user_by_mobile(self, mobile): user_info = Tool.miaoshu_query_user_info_by_mobile(mobile, 1) if user_info: redis = RedisNew() user_index = int(redis.get('user_index')) DataBaseOperate().operate( host_ip, "ms-user", 'UPDATE t_user SET mobile = "%s" WHERE mobile = "%s";' % (str(user_index), str(mobile))) self.L.logger.debug('原手机号 %s 修改为 %s' % (str(mobile), str(user_index))) redis.set('user_index', user_index + 1) else: raise Exception('手机号输入错误: %s' % str(mobile)) @staticmethod def ms_query_user_address_by_user_id(user_id): sql = 'SELECT * FROM t_address WHERE user_id = %s AND is_delete = 0 order by is_default DESC,edit_time DESC;'\ % (str(user_id)) address_list_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return address_list_info @staticmethod def ms_query_user_address_by_address_id(address_id): sql = 'SELECT * FROM t_address WHERE id = %s;' % (str(address_id)) address_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return address_info @staticmethod def ms_query_channel_bill_id_by_trade_no(trade_no): sql = "SELECT * FROM t_channel_bill WHERE biz_num = %s AND is_delete = 0 order by edit_time;" % ( "'" + str(trade_no) + "'") pay_list_info = DataBaseOperate().operate(host_ip, "ms-pay", sql) return pay_list_info @staticmethod def ms_query_supplier_supp_update_by_user_id(user_id): sql = 'SELECT user_id, positive, negative FROM t_identity_supplier WHERE user_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_supplier_shop_get_by_user_id(user_id): sql = 'SELECT * FROM t_shop WHERE seller_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_update_shop_info_by_user_id(user_id): sql = 'SELECT name, mobile, contact, avatar FROM t_shop WHERE seller_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_update_address_by_shop_id(shop_id): sql = 'SELECT province,city,area,address FROM t_shop_ext_supplier WHERE shop_id = %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_switch_status_by_shop_id(shop_id): sql = 'SELECT status FROM t_shop WHERE id = %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_category_list_all_by_status(status): sql = 'SELECT count(*) FROM t_category WHERE `status` = %s;' % status user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_category_list_by_category_id(category_id): sql = 'SELECT count(*) FROM t_category WHERE `status` = 10 AND parent= %s;' % category_id user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_store_unit_list_by_is_delete(is_delete): sql = 'SELECT count(*) FROM t_store_unit WHERE is_delete= %s;' % is_delete user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_freight_template_all_by_shop_id(shop_id): sql = 'SELECT count(*) FROM t_freight_template WHERE shop_id= %s AND is_delete=0;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_add_by_freight_id(freight_id): sql = 'SELECT id, shop_id, title, freigh_per_km, free_price, free_distance, free_price_status, ' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_delete_by_freight_id(freight_id): sql = 'SELECT id, shop_id, is_delete FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_edit_by_freight_id(freight_id): sql = 'SELECT id, title, freigh_per_km, free_price, free_distance, free_price_status,' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_get_by_freight_id(freight_id): sql = 'SELECT id, title, freigh_per_km, free_price, free_distance, free_price_status,' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_status(status): sql = '''SELECT tus.mobile, tis.create_time,tis.id, tus.nickname, tis.`status`,tis.user_id, CASE tis.`status`WHEN 2 THEN '审核中'WHEN 3 THEN '未通过'END AS statusDesc FROM `ms-user`.t_user tus LEFT JOIN `ms-user`.t_identity_supplier tis ON tis.user_id = tus.id WHERE tis.`status` = %s order by tis.create_time DESC ''' % str( status) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_supplier_unaudited_detail(user_id): sql = '''SELECT tus.mobile,tis.create_time,tis.id, tis.last_time, tus.nickname, tis.positive, tis.negative, tis.`status`,tis.user_id, CASE tis.`status`WHEN 2 THEN '审核中'WHEN 3 THEN '未通过'END AS statusDesc FROM `ms-user`.t_user tus LEFT JOIN `ms-user`.t_identity_supplier tis ON tis.user_id = tus.id WHERE tis.`user_id` = %s''' % str(user_id) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_supplier_audit(user_id): sql = '''SELECT tis.id, tis.user_id, tis.`name`, tis.gender, tis.birthday, tis.province, tis.city,tis.address, tis.`status`, top.remark, CASE tis.`status`WHEN 2 THEN '审核中'WHEN 3 THEN '未通过'WHEN 4 THEN '审核通过'END AS statusDesc FROM `ms-user`.t_user tus LEFT JOIN `ms-user`.t_identity_supplier tis ON tis.user_id = tus.id LEFT JOIN `ms-user`.t_user_operate_log top ON top.user_id = tus.id WHERE tis.user_id = %s''' % str(user_id) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_supplier_detail(user_id): sql = '''SELECT tis.address, tis.birthday, tis.city, tis.create_time, tis.district, tis.gender, tis.id_num, tis.last_time, tus.mobile, tis.`name`, tis.negative, tus.nickname, tis.auth_time, tis.positive, tis.province, tsh.contact, tsh.id, tsh.mobile, tsh.`name`, tsh.`status`, tus.account_status, CASE tus.account_status WHEN 1 THEN '正常'WHEN 2 THEN '冻结'END AS statusDesc, CASE tsh.`status`WHEN 10 THEN '接单'WHEN 20 THEN '休息'END AS statusDesc FROM `ms-user`.t_user tus LEFT JOIN `ms-user`.t_identity_supplier tis ON tis.user_id = tus.id LEFT JOIN `ms-shop`.t_shop tsh ON tsh.seller_id = tus.id WHERE tis.user_id = %s''' % str(user_id) user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_channel_zz_by_user_id(user_id): sql = 'SELECT * FROM t_identity_channel WHERE user_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-user", sql) return user_info @staticmethod def ms_query_shop_info_by_seller_id(seller_id, current=True): if current: sql = 'SELECT ta.address, ta.area, ta.city, ta.lat, ta.lng, ta.province, ta.shop_id, ' \ 'ts.avatar, ts.contact, ts.mobile, ts.`name`, IFNULL(tpv.pv,0) pv, ts.seller_id, ts.`status`, ts.type ' \ 'FROM `ms-shop`.t_shop ts ' \ 'LEFT JOIN `ms-shop`.t_address ta ON ta.shop_id = ts.id ' \ 'LEFT JOIN t_page_view AS tpv ON tpv.shop_id = ts.id ' \ 'WHERE ta.`status`=10 and ts.seller_id = %s;' % seller_id else: sql = 'SELECT ta.address, ta.area, ta.city, ta.lat, ta.lng, ta.province, ta.shop_id, ' \ 'ts.avatar, ts.contact, ts.mobile, ts.`name`, IFNULL(tpv.pv,0) pv, ts.seller_id, ts.`status`, ts.type ' \ 'FROM `ms-shop`.t_shop ts ' \ 'LEFT JOIN `ms-shop`.t_address ta ON ta.shop_id = ts.id ' \ 'LEFT JOIN t_page_view AS tpv ON tpv.shop_id = ts.id ' \ 'WHERE ts.seller_id = %s;' % seller_id get_shop_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return get_shop_info @staticmethod def ms_query_update_shop_info_by_seller_id(seller_id): sql = 'SELECT mobile,contact,status,name FROM t_shop WHERE seller_id=%s;' % seller_id get_shop_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return get_shop_info @staticmethod def ms_query_latest_address_info_by_shop_id(shop_id): sql = 'SELECT id,shop_id, lng,lat,province,city,area,address FROM t_address WHERE shop_id=%s AND' \ '`status` = 10 ;' % shop_id get_address_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return get_address_info @staticmethod def ms_query_all_address_info_by_shop_id(shop_id): sql = 'SELECT id,shop_id, lng,lat,province,city,area,address,`status` FROM t_address WHERE shop_id=%s ' \ 'ORDER BY id DESC' % shop_id get_address_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return get_address_info @staticmethod def ms_query_channel_product_info_by_shop_id(shop_id): sql = 'SELECT tp.`name`, tp.shop_id,tp.price, tp.store_unit_id, tp.store,' \ ' tp.`status`, tp.service_type, tp.create_time, tpi.content ' \ 'FROM `ms-product`.t_product tp ' \ 'LEFT JOIN `ms-product`.t_product_info tpi ' \ 'ON tpi.product_id=tp.id WHERE tp.shop_id = %s ' \ 'ORDER BY tp.create_time desc' % shop_id add_product_info = DataBaseOperate().operate("39.104.28.40", "ms-product", sql) return add_product_info @staticmethod def ms_query_seller_order_info_by_order_no(order_no): sql = "SELECT o.content, o.door_address, unix_timestamp(o.door_time)*1000 door_time, oi.pay_status, " \ "oi.price_real, o.earnest_money_price, o.tail_money_price,"\ "oi.trade_no, oi.order_type,o.order_status, CASE o.order_status WHEN 10 THEN '待下单' WHEN 20 THEN '待上门'"\ " WHEN 30 THEN '待结款' WHEN 40 THEN '已完成' WHEN 50 THEN '已取消' END AS orderStatusDesc, u.mobile, " \ "o.service_type, CASE WHEN (oi.order_type = 10 AND oi.pay_status = 10) THEN 10 WHEN (oi.order_type = 10"\ " AND oi.pay_status = 20 ) THEN 20 END AS earnestMoneyPayStatus, CASE WHEN ( oi.order_type = 20 AND " \ "oi.pay_status = 10 ) THEN 10 WHEN ( oi.order_type = 20 AND oi.pay_status = 20) THEN 20 END AS " \ "tailMoneyPayStatus FROM `ms-order`.t_service_order o LEFT JOIN `ms-order`.t_service_order_item oi " \ "ON o.id = oi.order_id LEFT JOIN `ms-user`.t_base_user u ON u.id = o.buyer_id WHERE o.order_no = '%s' " \ "order by oi.create_time;" % order_no order_info = DataBaseOperate().operate(host_ip, "ms-order", sql) return order_info @staticmethod def ms_query_buyer_order_info_by_order_no(order_no): sql = "SELECT o.content, o.door_address, unix_timestamp(o.door_time)*1000 door_time, oi.pay_status, " \ "oi.price_real, o.earnest_money_price, o.tail_money_price,"\ "oi.trade_no, oi.order_type,o.order_status, CASE o.order_status WHEN 10 THEN '待下单' WHEN 20 THEN '待上门'"\ " WHEN 30 THEN '待结款' WHEN 40 THEN '已完成' WHEN 50 THEN '已取消' END AS orderStatusDesc, u.mobile, " \ "o.service_type, CASE WHEN (oi.order_type = 10 AND oi.pay_status = 10) THEN 10 WHEN (oi.order_type = 10"\ " AND oi.pay_status = 20 ) THEN 20 END AS earnestMoneyPayStatus, CASE WHEN ( oi.order_type = 20 AND " \ "oi.pay_status = 10 ) THEN 10 WHEN ( oi.order_type = 20 AND oi.pay_status = 20) THEN 20 END AS " \ "tailMoneyPayStatus FROM `ms-order`.t_service_order o LEFT JOIN `ms-order`.t_service_order_item oi " \ "ON o.id = oi.order_id LEFT JOIN `ms-user`.t_base_user u ON u.id = o.seller_id WHERE o.order_no = '%s' " \ "order by oi.create_time;" % order_no order_info = DataBaseOperate().operate(host_ip, "ms-order", sql) return order_info @staticmethod def ms_query_seller_id_order_list_by_user_id(user_id, order_status, ps, pn): sql = "SELECT o.order_no orderNo, o.order_status orderStatus, CASE o.order_status WHEN 10 THEN '待下单'" \ " WHEN 20 THEN '待上门' WHEN 30 THEN '待结款' WHEN 40 THEN '已完成' WHEN 50 THEN '已取消'" \ " END AS orderStatusDesc, CASE WHEN ( oi.order_type = 10 AND oi.pay_status = 10 ) THEN '未支付定金' " \ "WHEN ( oi.order_type = 10 AND oi.pay_status = 20 ) THEN '已支付定金' WHEN ( oi.order_type = 20 AND " \ "oi.pay_status = 20 ) THEN '未支付尾款' WHEN ( oi.order_type = 20 AND oi.pay_status = 20 ) " \ "THEN '已支付尾款' END AS payStatusDesc, o.earnest_money_price, o.tail_money_price, " \ "bu.mobile buyerMobile, CASE o.service_type WHEN 10 THEN '苗叔上门种植服务' " \ "WHEN 20 THEN '苗叔上门养护服务' END AS serviceTypeDesc, o.shop_name shopName FROM " \ "`ms-order`.t_service_order o LEFT JOIN `ms-order`.t_service_order_item oi ON o.id = oi.order_id " \ " LEFT JOIN `ms-user`.t_base_user u ON u.id = o.seller_id LEFT JOIN `ms-user`.t_base_user bu ON " \ "bu.id = o.buyer_id WHERE u.id = %s AND o.order_status = %s GROUP BY oi.order_id " \ "ORDER BY o.create_time DESC LIMIT %s, %s" % (user_id, order_status, (pn-1)*ps, ps) order_list = DataBaseOperate().operate(host_ip, "ms-order", sql) return order_list @staticmethod def ms_query_buyer_shop_order_detail_by_order_no(order_no): """ 张鹏飞:买家查看商品订单详情 :param order_no: 订单编号 :return: """ sql = "SELECT o.apply_status applyStatus, CASE o.apply_status WHEN 10 THEN '申诉' WHEN 20 THEN '已取消' " \ "WHEN 30 THEN '卖家拒绝取消订单' end as applyStatusDesc, o.order_no, tu.id buyerId, tu.head_img buyerHeadImg," \ " o.buyer_name, u.id 卖家ID, o.seller_name, unix_timestamp(o.create_time)* 1000 createTime, " \ "CASE o.order_status WHEN 10 THEN '待付款' WHEN 20 THEN '待收货' WHEN 30 THEN '待收货' WHEN 40 THEN '交易成功' " \ "WHEN 50 THEN '已取消' WHEN 70 THEN '已取消' END AS orderStatusDesc, o.order_status orderStatus, " \ "unix_timestamp(o.pay_time)* 1000 payTime, o.price_real priceReal, " \ "unix_timestamp(o.receive_time)* 1000 receiveTime, tsp.`name` shopName, tod.send_mobile sendMobile," \ "o.price_total priceTotal, o.freight, tos.product_id 商品ID, tps.price 商品单价, tos.sku_num 商品数量, " \ "tod.receive_address receiveAddress, tod.receive_lng receiveLng, tod.receive_lat receiveLat, " \ "tod.receive_mobile receiveMobile, tod.receive_name receiveName, tod.send_name sendName, " \ "tsp.contact shopContact, tsp.mobile shopContactMobile, unix_timestamp(o.valid_date)* 1000 validDate, " \ "o.trade_no tradeNo FROM `ms-order`.`t_order` o LEFT JOIN `ms-user`.`t_base_user` tu ON " \ "tu.id = o.buyer_id LEFT JOIN `ms-user`.`t_base_user` u ON u.id = o.seller_id " \ "LEFT JOIN `ms-order`.`t_order_item` tos ON tos.order_id = o.id " \ "LEFT JOIN `ms-product`.`t_product_snapshot` tps ON tos.snapshot_id = tps.id " \ "LEFT JOIN `ms-order`.`t_order_delivery` tod ON tod.order_id = o.id " \ "LEFT JOIN `ms-shop`.`t_shop` tsp ON tsp.id = o.shop_id WHERE o.order_no = '%s';" % order_no order_detail = DataBaseOperate().operate(host_ip, "ms-order", sql) return order_detail @staticmethod def ms_query_seller_shop_order_detail_by_order_no(order_no): """ 张鹏飞:卖家查看商品订单详情 :param order_no: 订单编号 :return: """ sql = "SELECT o.apply_status applyStatus, CASE o.apply_status WHEN 10 THEN '买家申请取消订单' WHEN 20 THEN '已取消' " \ "WHEN 30 THEN '已拒绝' end as applyStatusDesc, o.order_no, tu.id buyerId, tu.head_img buyerHeadImg, " \ "o.buyer_name, u.id 卖家ID, o.seller_name, unix_timestamp(o.create_time)* 1000 createTime, " \ "CASE o.order_status WHEN 10 THEN '等待买家待付款' WHEN 20 THEN '待处理' WHEN 30 THEN '等待买家确认收货' " \ "WHEN 40 THEN '已完成' WHEN 50 THEN '已取消' WHEN 70 THEN '已取消' END AS orderStatusDesc, " \ "o.order_status orderStatus, o.price_total priceTotal, unix_timestamp(o.pay_time)* 1000 payTime, " \ "o.price_real, o.freight, tos.product_id 商品ID, tps.price 商品单价, tos.sku_num 商品数量, " \ "tod.receive_address receiveAddress, tod.receive_lng receiveLng, tod.receive_lat receiveLat, " \ "tod.receive_mobile receiveMobile, tod.receive_name receiveName, unix_timestamp(o.receive_time)* 1000 " \ "receiveTime, tod.send_name sendName, tod.send_mobile sendMobile, tsp.contact shopContact, " \ "tsp.mobile shopContactMobile, tsp.`name` shopName, unix_timestamp(o.valid_date)* 1000 validDate, " \ "o.trade_no tradeNo FROM `ms-order`.`t_order` o " \ "LEFT JOIN `ms-user`.`t_base_user` tu ON tu.id = o.buyer_id " \ "LEFT JOIN `ms-user`.`t_base_user` u ON u.id = o.seller_id " \ "LEFT JOIN `ms-order`.`t_order_item` tos ON tos.order_id = o.id " \ "LEFT JOIN `ms-product`.`t_product_snapshot` tps ON tos.snapshot_id = tps.id " \ "LEFT JOIN `ms-order`.`t_order_delivery` tod ON tod.order_id = o.id " \ "LEFT JOIN `ms-shop`.`t_shop` tsp ON tsp.id = o.shop_id WHERE o.order_no = '%s'" % order_no order_detail = DataBaseOperate().operate(host_ip, "ms-order", sql) return order_detail @staticmethod def ms_query_channel_product_category_info_by_id_delete(is_delete): sql = 'SELECT id,`name`,parent FROM t_category WHERE is_delete=%s ORDER BY id DESC' % is_delete product_category_info = DataBaseOperate().operate( "39.104.28.40", "ms-product", sql) return product_category_info @staticmethod def ms_query_channel_search_product_by_product_code(pcode): sql = 'SELECT tp.pcode,tp.category_id,tp.full_name,tp.pcode,tp.price,tp.sales,tp.shop_id,tp.`status`,' \ 'tp.store,tp.store_unit_id,tc.parent,tc.name,tpi.content,tpi.freight_id,tpm.url ' \ 'FROM `ms-product`.t_product tp ' \ 'LEFT JOIN `ms-product`.t_category tc ON tp.category_id=tc.id ' \ 'LEFT JOIN `ms-product`.t_product_info tpi ON tp.id=tpi.product_id ' \ 'LEFT JOIN `ms-product`.t_product_img tpm ON tp.id=tpm.product_id ' \ 'LEFT JOIN `ms-product`.t_store_unit tsu ON tp.store_unit_id=tsu.id ' \ 'WHERE tp.pcode=%s;' % pcode product_info = DataBaseOperate().operate("39.104.28.40", "ms-product", sql) return product_info sql = 'SELECT id,shop_id, lng,lat,province,city,area,address,`status` FROM t_address WHERE shop_id=%s ' \ 'ORDER BY id DESC' % shop_id get_address_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return get_address_info @staticmethod def ms_query_supplier_shop_get_by_user_id(user_id): sql = 'SELECT * FROM t_shop WHERE seller_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_update_shop_info_by_user_id(user_id): sql = 'SELECT name, mobile, contact, avatar FROM t_shop WHERE seller_id = %s;' % user_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_update_address_by_shop_id(shop_id): sql = 'SELECT province,city,area,address FROM t_shop_ext_supplier WHERE shop_id = %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_switch_status_by_shop_id(shop_id): sql = 'SELECT status FROM t_shop WHERE id = %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_category_list_all_by_status(status): sql = 'SELECT count(*) FROM t_category WHERE `status` = %s;' % status user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_category_list_by_category_id(category_id): sql = 'SELECT count(*) FROM t_category WHERE `status` = 10 AND parent= %s;' % category_id user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_store_unit_list_by_is_delete(is_delete): sql = 'SELECT count(*) FROM t_store_unit WHERE is_delete= %s;' % is_delete user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_freight_template_all_by_shop_id(shop_id): sql = 'SELECT count(*) FROM t_freight_template WHERE shop_id= %s AND is_delete=0;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_add_by_freight_id(freight_id): sql = 'SELECT id, shop_id, title, freigh_per_km, free_price, free_distance, free_price_status, ' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_delete_by_freight_id(freight_id): sql = 'SELECT id, shop_id, is_delete FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_edit_by_freight_id(freight_id): sql = 'SELECT id, title, freigh_per_km, free_price, free_distance, free_price_status,' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_freight_template_get_by_freight_id(freight_id): sql = 'SELECT id, title, freigh_per_km, free_price, free_distance, free_price_status,' \ 'free_distance_status FROM t_freight_template WHERE id= %s;' % freight_id user_info = DataBaseOperate().operate(host_ip, "ms-shop", sql) return user_info @staticmethod def ms_query_supplier_product_save_by_shop_id(shop_id): sql = 'SELECT t_product.id, t_product.category_id, t_product.name, t_product.store_unit_id, ' \ 't_product_info.content, t_product.price, t_product.store, t_product_info.freight_id, ' \ 't_product.STATUS, t_product.service_type, t_product_img.url FROM t_product, t_product_info,' \ ' t_product_img WHERE t_product_info.product_id = t_product.id and ' \ 't_product_img.product_id = t_product.id and t_product.id=(select MAX(id) from t_product)' \ 'and t_product.shop_id=%s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_product_list_by_shop_id(shop_id): sql = 'SELECT count(*) FROM t_product WHERE shop_id= %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_status_update_by_product_pcode(product_pcode): sql = 'SELECT pcode, status, is_delete FROM t_product WHERE pcode= %s;' % product_pcode user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_product_update_by_pcode(pcode): sql = 'SELECT t_product.id, t_category.parent,t_product.category_id,t_product.name,t_product.store_unit_id, ' \ 't_product_info.content, t_product.price, t_product.store, t_product_info.freight_id, ' \ 't_product.STATUS, t_product.service_type, t_product_img.url FROM t_product, t_product_info,t_category,' \ ' t_product_img WHERE t_product_info.product_id = t_product.id AND ' \ 't_product_img.product_id = t_product.id AND t_category.id = t_product.category_id AND' \ ' t_product.pcode =%s;' % pcode user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_store_list_by_shop_id(shop_id): sql = 'SELECT count(*) FROM t_product WHERE shop_id= %s;' % shop_id user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_supplier_store_update_by_pcode(pcode_list): sql = 'SELECT pcode, store FROM t_product WHERE pcode in %s;' % pcode_list user_info = DataBaseOperate().operate(host_ip, "ms-product", sql) return user_info @staticmethod def ms_query_city_list_by_parent_id(parent_id=0): sql = 'SELECT `id`,`name` FROM `ms-kbms`.t_region te WHERE te.parent_id= %s' % str( parent_id) city_list = DataBaseOperate().operate("39.104.28.40", "ms-kbms", sql) return city_list @staticmethod def ms_shop_t_address_list_by_shop_id(shop_id): sql = 'SELECT * FROM `ms-shop`.t_address WHERE shop_id = %s and status=10' % str( shop_id) shop_list = DataBaseOperate().operate("39.104.28.40", "ms-shop", sql) return shop_list @staticmethod def ms_mobile_plant_add_by_room_id(room_id): sql = 'SELECT t_room.home_id,t_plant.room_id,t_plant.plant_wiki_id,t_plant.plant_name,t_plant.water_cycle_time,' \ 't_plant.img_url FROM `ms-plant`.t_room,`ms-plant`.t_plant WHERE t_plant.room_id=t_room.id AND ' \ 't_plant.room_id = %s ORDER BY t_plant.id DESC' % room_id plant_list = DataBaseOperate().operate("39.104.28.40", "ms-plant", sql) return plant_list[0] @staticmethod def test(): redis = Redis() for i in range(160): j = redis.get("image%s" % str(i)) if j is None: print("image%s" % str(i)) else: pass @staticmethod def get_short_massage_code(mobile): data_sso = Config('Sso').data data = data_sso['http://192.168.62.253:31007'][ '/mobile/sso/verify-code-get'] data["mobile"] = mobile code = Request().post( url="http://192.168.62.253:31007/mobile/sso/verify-code-get", data=data) Tool.L.logger.debug("手机号 %s 发送验证码成功" % str(mobile)) return Redis().get('VerifyCodeMobile: SmsVerifyCode:9_REGISTER_%s' % str(mobile)) @staticmethod def order_info_change(order_info): if order_info['status'] == 'OK': order = { "shopId": order_info['content'].get('shop').get('shopId'), "sellerId": order_info['content'].get('shop').get('sellerId'), "addressId": order_info['content'].get('shippingAddressDto').get('id'), "freight": order_info['content'].get('deliveryPrice'), "productPrice": order_info['content'].get('totalPrice'), "isCheck": 0 } products = [] for i in order_info["content"].get("products"): product = {} if i.get("cartId") is not None: product['cartId'] = i.get("cartId") if i.get("pcode") is not None: product["pCode"] = str(i.get("pcode")) product["num"] = str(i.get("amount")) if i.get("imgs") != [] and i.get("imgs") is not None: product['image'] = i.get("imgs")[0] if product != {}: products.append(product) products = urllib.parse.quote(str(products), safe=string.printable) order["product"] = products return order else: return False @staticmethod def get_cart_ids_by_cart_list(cart_list, shop_id): if cart_list['status'] == 'OK': shop_list = cart_list['content']['shopItem'] for j in shop_list: if j['shopId'] == shop_id: cart_id_list = [] for i in j['products']: cart_id_list.append(i['cartId']) return cart_id_list else: return False @staticmethod def get_pro_code_by_pro_list(pro_list): for i in pro_list: if i['productList'] != '[]': for j in i['productList']: if j['store'] != 0: return j['pcode'] return "未找到有库存的商品"
def __init__(self, kbms): self.log = Log('kbms') self.request = Request() self.kbms = kbms
class MessageMain(unittest.TestCase): """ 接口地址:http://dev.ms.user.sjnc.com/swagger-ui.html """ messageTest = userAction() faker_zh = Faker(locale='zh_CN') # faker_en = Faker(locale='en_GB') log = Log('MessageMain').logger log.info("开始执行服务咨询接口测试") invite_mobile = faker_zh.phone_number() def test001(self): """ 陈秀娟:获取自身IM账号 接口路径:POST /mobile/service/get-accid :return: """ self.log.info('获取自身的IM账号') # user = User('18382373185') self.messageTest.set_user('19982917912') self.messageTest._mobile_service_get_accid() def test002(self): """ 陈秀娟:获取商家的IM账号 接口路径:POST /mobile/service/get-seller-accid :return: """ self.log.info('获取商家的IM账号') self.messageTest.set_user('18582549167') self.messageTest._mobile_service_get_seller_accid(144) def test003(self): """ 陈秀娟:获取在线客服的IM账号 接口路径:POST /mobile/service/get-service-accid :return: """ self.log.info('获取在线客服的IM账号') # ser = User('13828898130') self.messageTest.set_user('18380581402') self.messageTest._mobile_service_get_service_accid() def test004(self): """ 陈秀娟:获取未读消息量 接口路径:POST /mobile/message/unread :return: """ self.log.info('获取未读消息量') self.messageTest.set_user('19982917912') self.messageTest._mobile_message_unread() def test005(self): """ 陈秀娟:更新未读为已读 接口路径:POST /mobile/message/read :return: """ self.log.info('更新未读为已读') self.messageTest.set_user('19982917912') self.messageTest._mobile_message_read() def test006(self): """ 陈秀娟:查询消息列表 接口路径:POST /mobile/message/list :return: """ self.log.info('查询消息列表') self.messageTest.set_user('19982917912') self.messageTest._mobile_message_list() def test007(self): """ 陈秀娟:删除消息 接口路径:POST /mobile/message/del :return: """ self.log.info('删除消息') self.messageTest.set_user('19982917912') self.messageTest._mobile_message_del()
from test.util.CeaterRunner import RunCaseAndCreateReport from test.util.CreateTestSuite import CreateTestSuite from utils.Log import Log from utils.Filepath import LOG_PATH from utils.SendMail import SendMail log = Log(LOG_PATH) suite = CreateTestSuite() suites = suite.choose_all_cases("test*.py") run = RunCaseAndCreateReport(suites) run.run() mail = SendMail() new_report = mail.new_report() mail.send_email(new_report)
def __init__(self, env='dev', log_path=None): all_settings=SettingsD8ImportRandosJour() self.settings=all_settings.options(env) self.champs_date=self.settings['getCrsfTokenRestAction']['url'] self.log_object=Log(log_path) self.rractions=RandoRestAction(self.settings, self.log_object)
import unittest, os, json from time import sleep import sys from utils.Logbug import LogBug from utils.Log import Log from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from Public_methods.PublicMethod import BasePage from utils.browser_engine import BrowserEngin from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select import time logger = Log() logbug = LogBug() log_path = os.path.dirname( os.path.abspath('.')) + "\\Element_methods\chandao.json" element = open(log_path, encoding='utf-8') elements = json.load(element) from configparser import ConfigParser config = ConfigParser() config_full_path = os.path.dirname( os.path.abspath('.')) + "\\configs\config.ini" config.read(config_full_path) url = config.get("testServer", "ChandaoURL") driver_dir = os.path.dirname(os.path.abspath('.')) chrome_driver_full_path = driver_dir + '\\tools\chromedriver.exe' """注意""" """注意"""
def __init__(self, Uc): self.log = Log('Uc') self.request = Request() self.Uc = Uc
class Main(unittest.TestCase): op_account = Config('config').data['User'][Config( 'config').data['run']]['op'] product_name = Config('productname').data['product_name'] L = Log('Main') toot = Tool() # 登录 buyer = User('18380581406') # 切换角色 pa = PurchaserAction(buyer) at = AndroidTool() distributor = User('18380581416') di = DistributorAction(distributor) supplier = User('18380581426') su = SupplierAction(supplier) operator = Employee(op_account['account'], op_account['password'], 1) op = OperatorAction(operator) def tearDown(self): pass def setUp(self): url = 'http://203.6.234.220:9660/download/attachments/1016059/user-avatar' resp = self.di._mobile_apply_channel_status() if resp.get('content') in (1, 2, 3): if resp.get('content') in (1, 3): self.di._mobile_apply_channel() resp = self.op._admin_audit_list(1, 10, 2, self.distributor.mobile, 2).get('content').get('datas')[0] self.op._admin_audit_pass(id=resp.get('id'), user_id=resp.get('userId'), positive=url, negative=url, name='Draven', gender=1, birthday='2018-11-11', id_num='513902199309091011', province=41, city=4140, district=1101104, address='领馆科技') resp = self.di._mobile_apply_channel_status() if resp.get('content') == 4: self.di._mobile_shop_server_server(10, 10) self.di._mobile_shop_server_server(20, 10) shop_info = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shop_info.get('content').get('shopId') self.distributor.channel_shop_id = shop_id self.L.logger.debug('客户端查询地址列表') address_list = self.pa._mobile_address_list() if len(address_list['content']) == 0: self.L.logger.debug('用户添加收货地址') self.pa._mobile_address_add('xiu', self.buyer.mobile, '41', '4101', '天府五街', 'E3-9', 104.069, 30.539, 1) def test0033(self): try: apk_path = '/Users/hengxin/Downloads/苗叔-20181130\(v1.0.24\).apk' self.at.launch_app_by_apk(apk_path) self.at.login_miaoshu("18602832572", "888888") self.at.enter_shop("自动化刷单勿删") self.at.pay_product() self.at.tear_down_miaoshu() Mail().send_html_email() self.L.logger.info("测试完成, 邮件发送成功") except Exception as e: self.at.get_screen_shot() self.L.logger.debug("错误信息: %s" % e) self.at.tear_down_miaoshu() def test0034(self): """ 服务订单的完整流程 :return: """ shopinfo = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shopinfo.get('content').get('shopId') self.distributor.channel_shop_id = shop_id shop = Shop(self.distributor) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=str(i)) self.di.product_save(p) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) order_no = self.di._mobile_channel_service_order_submit( buyerId=self.buyer.user_id, shopId=shop_id, serviceType=20, doorTime='2019-12-16 08:00', content='养猪', earnestMoneyPrice=1, doorAddress='ce', lng=103, lat=40) self.di._mobile_channel_service_order_detail(order_no['content']) order_info = self.pa._mobile_customer_service_order_detail( order_no['content']) caindex = self.pa.cashier_index( order_info['content']['earnestMoneyTradeNo']) self.pa.weipay_pay(order_info['content']['earnestMoneyTradeNo'], caindex['content']['channelList'][0]['id'], order_info['content']['earnestMoneyPrice']) self.pa.pay_callback(order_info['content']['earnestMoneyTradeNo'], order_info['content']['earnestMoneyPrice']) time.sleep(15) self.pa._mobile_customer_service_order_detail(order_no['content']) self.di._mobile_channel_service_order_detail(order_no['content']) self.di._mobile_channel_service_order_finish_door( order_no['content'], 10) order_info = self.pa._mobile_customer_service_order_detail( order_no['content']) caindex = self.pa.cashier_index( order_info['content']['tailMoneyTradeNo']) self.pa.weipay_pay(order_info['content']['tailMoneyTradeNo'], caindex['content']['channelList'][0]['id'], order_info['content']['tailMoneyPrice']) self.pa.pay_callback(order_info['content']['tailMoneyTradeNo'], order_info['content']['tailMoneyPrice']) time.sleep(15) self.pa._mobile_customer_service_order_detail(order_no['content']) self.di._mobile_channel_service_order_detail(order_no['content']) def test0035(self): """ 服务订单的取消流程 :return: """ shopinfo = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shopinfo.get('content').get('shopId') self.distributor.channel_shop_id = shop_id shop = Shop(self.distributor) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=str(i)) self.di.product_save(p) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) order_no = self.di._mobile_channel_service_order_submit( buyerId=self.buyer.user_id, shopId=shop_id, serviceType=10, doorTime='2019-12-16 08:00', content='养猪', earnestMoneyPrice=1, doorAddress='ce', lng=103, lat=40) self.di._mobile_channel_service_order_detail(order_no['content']) self.pa._mobile_customer_service_order_detail(order_no['content']) self.pa._mobile_customer_service_order_cancel(order_no['content']) self.pa._mobile_customer_service_order_detail(order_no['content']) self.di._mobile_channel_service_order_detail(order_no['content']) def test0036(self): """ 张鹏飞:服务订单列表 订单状态,10:待下单, 20:待上门, 30:已结款, 40:已完成, 50: 已取消 :return: """ self.L.logger.debug("卖家服务订单列表") self.di._mobile_channel_service_order_list(10) self.di._mobile_channel_service_order_list(20) self.di._mobile_channel_service_order_list(30) self.di._mobile_channel_service_order_list(40) self.di._mobile_channel_service_order_list(50) self.L.logger.debug("买家服务订单列表") self.pa._mobile_customer_service_order_list(10) self.pa._mobile_customer_service_order_list(20) self.pa._mobile_customer_service_order_list(30) self.pa._mobile_customer_service_order_list(40) self.pa._mobile_customer_service_order_list(50) def test0037(self): """ 张鹏飞:商品订单正向流程 :return: """ shop_info = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shop_info.get('content').get('shopId') self.distributor.channel_shop_id = shop_id self.L.logger.debug('苗叔查询运费模板列表') freight_list = self.di.all_freight() if len(freight_list['content']) <= 1: self.L.logger.debug('苗叔添加运费模板') self.di.freight_save_or_update(shop_id, '测试模板66', 500, 10000, 2000) self.L.logger.debug('更新店铺信息') shop = Shop(self.distributor) self.di.update_shop_info(shop) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=random.choice(self.product_name)) self.di.product_save(p) if i == 0: self.L.logger.debug('苗叔筛选查看库存商品列表') store_list = self.di.store_list_product(p) pro_code = store_list.get('content').get('datas')[0]['pcode'] self.L.logger.debug('苗叔更新商品库存') self.di.store_update_product(pro_code) self.L.logger.debug('苗叔筛选查看商品列表') pro_list = self.di.list_product(p) pro_code = pro_list.get('content').get('datas')[0]['pcode'] self.L.logger.debug('苗叔上架商品') self.di.status_update_product(pro_code) self.L.logger.debug('苗叔下架商品') self.di.status_update_product(pro_code, 20) self.L.logger.debug('苗叔删除商品') self.di.status_update_product(pro_code, 30) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) self.L.logger.debug('客户端查询地址列表') address_list = self.pa._mobile_address_list() address = address_list['content'][0] add_id = address['id'] self.L.logger.debug('客户端查询店铺信息') self.pa.get_shop_info_by_id(shop_id) self.L.logger.debug('店铺内商品列表') product_list = self.pa.get_shop_products_by_shop_id(shop_id) p_code = self.pa.tool.get_pro_code_by_pro_list(product_list['content']) self.L.logger.debug('添加购物车') self.pa.cart_add(p_code) self.L.logger.debug('购物车列表') cart_list = self.pa.get_cart_list() self.L.logger.debug('购物车结算') sure_order = self.pa.cart_balance( self.pa.tool.get_cart_ids_by_cart_list(cart_list, shop_id), add_id) self.L.logger.debug('确认提交订单') order = self.pa.submit_order( self.pa.tool.order_info_change(sure_order)) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('收银台') order_pay_info = self.pa.cashier_index(order['content']['tradeNo']) self.L.logger.debug('支付') self.pa.weipay_pay(order['content']['tradeNo'], order_pay_info['content']['channelList'][0]['id'], order_pay_info['content']['amount']) self.L.logger.debug('付款') self.pa.pay_callback(order['content']['tradeNo'], order_pay_info['content']['amount']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家未完成配送前取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔拒绝取消订单') self.di._mobile_channel_order_refuse(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('渠道商完成配送') self.di.finish_send_order(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家完成配送后取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔拒绝取消订单') self.di._mobile_channel_order_refuse(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('用户确认收货') self.pa.confirm_receive(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) def test0038(self): """ 张鹏飞:待付款订单取消 :return: """ shop_info = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shop_info.get('content').get('shopId') self.distributor.channel_shop_id = shop_id self.L.logger.debug('更新店铺信息') shop = Shop(self.distributor) self.di.update_shop_info(shop) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=str(i)) self.di.product_save(p) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) self.L.logger.debug('客户端查询地址列表') address_list = self.pa._mobile_address_list() address = address_list['content'][0] add_id = address['id'] self.L.logger.debug('客户端查询店铺信息') self.pa.get_shop_info_by_id(shop_id) self.L.logger.debug('店铺内商品列表') product_list = self.pa.get_shop_products_by_shop_id(shop_id) p_code = self.pa.tool.get_pro_code_by_pro_list(product_list['content']) self.L.logger.debug('添加购物车') self.pa.cart_add(p_code) self.L.logger.debug('购物车列表') cart_list = self.pa.get_cart_list() self.L.logger.debug('购物车结算') sure_order = self.pa.cart_balance( self.pa.tool.get_cart_ids_by_cart_list(cart_list, shop_id), add_id) self.L.logger.debug('确认提交订单') order = self.pa.submit_order( self.pa.tool.order_info_change(sure_order)) self.L.logger.debug('关闭订单') self.pa.order_close(order['content']['orderNo']) def test0039(self): """ 张鹏飞:待配送订单取消成功 :return: """ shop_info = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shop_info.get('content').get('shopId') self.distributor.channel_shop_id = shop_id self.L.logger.debug('更新店铺信息') shop = Shop(self.distributor) self.di.update_shop_info(shop) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=str(i)) self.di.product_save(p) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) # self.L.logger.debug('用户添加收货地址') # self.pa._mobile_address_add('xiu', 19982917912, '41', '4101', '天府五街', 'E3-9', 104.069, 30.539, 1) self.L.logger.debug('客户端查询地址列表') address_list = self.pa._mobile_address_list() address = address_list['content'][0] add_id = address['id'] self.L.logger.debug('客户端查询店铺信息') self.pa.get_shop_info_by_id(shop_id) self.L.logger.debug('店铺内商品列表') product_list = self.pa.get_shop_products_by_shop_id(shop_id) p_code = self.pa.tool.get_pro_code_by_pro_list(product_list['content']) self.L.logger.debug('添加购物车') self.pa.cart_add(p_code) self.L.logger.debug('购物车列表') cart_list = self.pa.get_cart_list() self.L.logger.debug('购物车结算') sure_order = self.pa.cart_balance( self.pa.tool.get_cart_ids_by_cart_list(cart_list, shop_id), add_id) self.L.logger.debug('确认提交订单') order = self.pa.submit_order( self.pa.tool.order_info_change(sure_order)) self.L.logger.debug('订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('收银台') order_pay_info = self.pa.cashier_index(order['content']['tradeNo']) self.L.logger.debug('支付') self.pa.weipay_pay(order['content']['tradeNo'], order_pay_info['content']['channelList'][0]['id'], order_pay_info['content']['amount']) self.L.logger.debug('付款') self.pa.pay_callback(order['content']['tradeNo'], order_pay_info['content']['amount']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家未完成配送前取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔拒绝取消订单') self.di._mobile_channel_order_refuse(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家未完成配送前取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔同意取消订单') self.di._mobile_channel_order_agree(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) def test0040(self): """ 张鹏飞:已配送完成的订单,买家取消订单,卖家同意 :return: """ shop_info = self.di.get_shop_id_by_type(self.distributor.user_id) shop_id = shop_info.get('content').get('shopId') self.distributor.channel_shop_id = shop_id self.L.logger.debug('更新店铺信息') shop = Shop(self.distributor) self.di.update_shop_info(shop) self.L.logger.debug('渠道商新增商品') for i in range(3): p = Product(user=self.distributor, product_name=str(i)) self.di.product_save(p) self.L.logger.debug('添加接单点') self.di.add_address(shop) self.L.logger.debug('开始接单') self.di.switch_status(shop_id=shop_id) # self.L.logger.debug('用户添加收货地址') # self.pa._mobile_address_add('xiu', 19982917912, '41', '4101', '天府五街', 'E3-9', 104.069, 30.539, 1) self.L.logger.debug('客户端查询地址列表') address_list = self.pa._mobile_address_list() address = address_list['content'][0] add_id = address['id'] self.L.logger.debug('客户端查询店铺信息') self.pa.get_shop_info_by_id(shop_id) self.L.logger.debug('店铺内商品列表') product_list = self.pa.get_shop_products_by_shop_id(shop_id) p_code = self.pa.tool.get_pro_code_by_pro_list(product_list['content']) self.L.logger.debug('添加购物车') self.pa.cart_add(p_code) self.L.logger.debug('购物车列表') cart_list = self.pa.get_cart_list() self.L.logger.debug('购物车结算') sure_order = self.pa.cart_balance( self.pa.tool.get_cart_ids_by_cart_list(cart_list, shop_id), add_id) self.L.logger.debug('确认提交订单') order = self.pa.submit_order( self.pa.tool.order_info_change(sure_order)) self.L.logger.debug('订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('收银台') order_pay_info = self.pa.cashier_index(order['content']['tradeNo']) self.L.logger.debug('支付') self.pa.weipay_pay(order['content']['tradeNo'], order_pay_info['content']['channelList'][0]['id'], order_pay_info['content']['amount']) self.L.logger.debug('付款') self.pa.pay_callback(order['content']['tradeNo'], order_pay_info['content']['amount']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家未完成配送前取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔拒绝取消订单') self.di._mobile_channel_order_refuse(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('渠道商完成配送') self.di.finish_send_order(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('买家完成配送后取消订单') self.pa._mobile_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) self.L.logger.debug('苗叔同意取消订单') self.di._mobile_channel_order_agree(order['content']['orderNo']) time.sleep(10) self.L.logger.debug('买家订单详情') self.pa.order_detail(order['content']['orderNo']) self.L.logger.debug('卖家订单详情') self.di.shopping_order_detail(order['content']['orderNo']) def test0041(self): """ 张鹏飞:商品订单列表 订单状态,10:待下单, 20:待上门, 30:已结款, 40:已完成, 50: 已取消 :return: """ self.L.logger.debug("卖家商品订单待处理列表") self.di.list_order(20) self.L.logger.debug("卖家商品订单待买家收货列表") self.di.list_order(30) self.L.logger.debug("卖家商品订单已完成列表") self.di.list_order(40) self.L.logger.debug("卖家商品订单已退款已取消列表") self.di.list_order(70) self.L.logger.debug("买家商品订单列表") self.pa.order_list(10) self.pa.order_list(20) self.pa.order_list(30) self.pa.order_list(40) self.pa.order_list((50, 70)) def test0042(self): """ baiying:苗叔向基地购买商品正向流程 :return: """ shop_info = self.su.get_shop_id_by_type(self.supplier.user_id) shop_id = shop_info.get('content').get('shopId') self.supplier.supplier_shop_id = shop_id self.L.logger.debug('更新店铺信息') shop = Shop(self.supplier) self.su.update_shop_info(shop) self.L.logger.debug('基地新增商品') for i in range(3): p = Product(user=self.supplier, product_name=str(i)) self.su.product_save(p) self.L.logger.debug('基地地址') address_list = self.su.history_address(shop_id) if len(address_list['content']) == 0: self.L.logger.debug('基地添加店铺地址') self.su._mobile_address_add('xiu', self.buyer.mobile, '41', '4101', '天府五街', 'E3-9', 104.069, 30.539, 1) self.L.logger.debug('开始接单') self.su.switch_status(shop_id=shop_id) self.L.logger.debug('客户端查询地址列表') address_list = self.di._mobile_address_list() address = address_list['content'][0] add_id = address['id'] self.L.logger.debug('客户端查询店铺信息') self.di.get_shop_info_by_id(shop_id) self.L.logger.debug('店铺内商品列表') product_list = self.pa.get_shop_products_by_shop_id(shop_id) p_code = self.pa.tool.get_pro_code_by_pro_list(product_list['content']) self.L.logger.debug('添加购物车') self.di.cart_add(p_code) self.L.logger.debug('购物车列表') cart_list = self.di.get_cart_list() self.L.logger.debug('购物车结算') sure_order = self.di.cart_balance( self.pa.tool.get_cart_ids_by_cart_list(cart_list, shop_id), add_id) self.L.logger.debug('确认提交订单') order = self.di.submit_order( self.pa.tool.order_info_change(sure_order)) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('收银台') order_pay_info = self.di.cashier_index(order['content']['tradeNo']) self.L.logger.debug('支付') self.di.weipay_pay(order['content']['tradeNo'], order_pay_info['content']['channelList'][0]['id'], order_pay_info['content']['amount']) self.L.logger.debug('付款') self.di.pay_callback(order['content']['tradeNo'], order_pay_info['content']['amount']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('苗叔未完成配送前取消订单') self.di._mobile_supply_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('苗叔未完成配送前取消订单') self.L.logger.debug('基地拒绝取消订单') self.su._mobile_supply_channel_order_refuse( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('基地完成配送') self.su._mobile_supply_channel_order_finish_send( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('苗叔完成配送后取消订单') self.di._mobile_supply_customer_order_apply_refund( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('基地拒绝取消订单') self.su._mobile_supply_channel_order_refuse( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) self.L.logger.debug('苗叔确认收货') self.di._mobile_supply_customer_order_confirm_receive( order['content']['orderNo']) time.sleep(10) self.L.logger.debug('苗叔订单详情') self.di._mobile_supply_customer_order_detail( order['content']['orderNo']) self.L.logger.debug('基地订单详情') self.su._mobile_supply_channel_order_detail( order['content']['orderNo']) def test0043(self): """ 张鹏飞:运营后台订单数据 :return: """ self.op._admin_report_order_pie_sta('2018-12-1', '2018-12-20') self.op._admin_report_order_summary_sta('2018-12-1', '2018-12-20') self.op._admin_report_service_order_service_data_card( '2018-12-1', '2018-12-20') self.op._admin_report_service_order_service_data_trend( '2018-12-1', '2018-12-20') self.op._admin_report_service_order_service_type_distribution( '2018-12-1', '2018-12-20')
def __init__(self): self.log = Log('user') self.request = Request()
def __init__(self, Report): self.log = Log('Report') self.request = Request() self.Report = Report