def build_message(nshead, in_param_dict): request = price_service_pb2.PsRequest() # search_type request.service_type = 1 # search_id request.search_id = "987654321static" # version_id request.version_id = 2 # user_info request.user_info.user_ip = "127.0.0.1" request.user_info.customer_level = 0 request.user_info.order_from = 0 request.user_info.booking_channel = 2 # list_req - query_info for hid in in_param_dict["hotel_id"].split(','): if hid != '': request.list_request.query_info.hotel_id.append(int(hid)) request.list_request.query_info.filter_ota = 982958 request.list_request.query_info.cashpay_booking_channel_mask = 0 room = request.list_request.query_info.room_person.add() room.adult_num = 2 timeArray = time.strptime(in_param_dict["checkin"], "%Y-%m-%d") request.list_request.query_info.check_in_date = int( time.mktime(timeArray)) + 1000 timeArray = time.strptime(in_param_dict["checkout"], "%Y-%m-%d") request.list_request.query_info.check_out_date = int( time.mktime(timeArray)) + 1000 # list_query_flag # 1 0001 : ORIGIN_PRICE - 列表页检索接口 # 3 0011 : ORIGIN_PRICE | ELONG_PRICE - 列表页批量接口 # 15 1111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION | DIGEST - 列表页批量接口 # 7 0111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION - 列表页检索接口 request.list_request.query_info.list_query_flag = 1 return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): region_id = in_param_dict["region_id"] hotel_id_list = in_param_dict["hotel_id_list"] filter_ota = in_param_dict["filter_ota"] checkin = in_param_dict["checkin"] checkout = in_param_dict["checkout"] request_type = in_param_dict["request_type"] booking_channel = in_param_dict["booking_channel"] list_query_flag = in_param_dict["list_query_flag"] request = price_service_pb2.PsRequest() # search_id request.search_id = "12345678910"; # version_id request.version_id = 1 # user_info request.user_info.user_ip = "192.168.21.1" request.user_info.customer_level = 1 request.user_info.order_from = 50 request.user_info.booking_channel = booking_channel request.user_info.request_type = request_type # coupon info #request.user_info.activity_id_list.append(2015081441); #request.user_info.activity_id_list.append(2015081432); #request.user_info.activity_id_list.append(2015081457); #request.user_info.activity_id_list.append(2015081452); #request.user_info.activity_id_list.append(2015081460); #request.user_info.activity_id_list.append(2015081451); #request.user_info.activity_id_list.append(2015081513); # search_type request.service_type = 1 # detail_req - query_info request.list_request.query_info.region_id = region_id for hid in hotel_id_list: request.list_request.query_info.hotel_id.append(hid) request.list_request.query_info.filter_ota = filter_ota request.list_request.query_info.cashpay_booking_channel_mask = 0 room = request.list_request.query_info.room_person.add() room.adult_num = 2 # room.child_age_list.append(4) # room.child_age_list.append(2) # room.child_age_list.append(7) timeArray = time.strptime(checkin, "%Y-%m-%d") request.list_request.query_info.check_in_date = int(time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.list_request.query_info.check_out_date = int(time.mktime(timeArray)) + 1000 # request.list_request.query_info.check_in_date = 1477929600 # request.list_request.query_info.check_out_date = 1478016000 # list_query_flag # as请求ps可能的参数: # 3 0011 : ORIGIN_PRICE | ELONG_PRICE - 列表页批量接口 # 15 1111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION | DIGEST - 列表页批量接口 # 1 0001 : ORIGIN_PRICE - 列表页检索接口 # 7 0111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION - 列表页检索接口 request.list_request.query_info.list_query_flag = list_query_flag return request, request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param booking_channel = in_param_dict["booking_channel"] hotel_id = in_param_dict["hotel_id"] filter_ota = in_param_dict["filter_ota"] checkin = in_param_dict["checkin"] checkout = in_param_dict["checkout"] request_type = in_param_dict["request_type"] request = price_service_pb2.PsRequest() request.search_id = "12345678910_2" request.version_id = 2 request.service_type = 2 # user_info request.user_info.user_ip = "127.0.0.1" request.user_info.customer_level = 0 request.user_info.order_from = 0 request.user_info.booking_channel = booking_channel request.user_info.request_type = request_type # query_info request.detail_request.query_info.hotel_id.append(hotel_id) request.detail_request.query_info.filter_ota = filter_ota room = request.detail_request.query_info.room_person.add() room.adult_num = 2 timeArray = time.strptime(checkin, "%Y-%m-%d") request.detail_request.query_info.check_in_date = int( time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.detail_request.query_info.check_out_date = int( time.mktime(timeArray)) + 1000 # request.detail_request.query_info.cache_time = 1000 # request.detail_request.query_info.timeout = 3000 # 不参与优选 request.detail_request.query_info.preferred_product = True return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param try: booking_channel = 0 if in_param_dict["booking_channel"] == '' else int(in_param_dict["booking_channel"]) # order_from = 0 if in_param_dict["order_from"] == '' else int(in_param_dict["order_from"]) # customer_level = 0 if in_param_dict["customer_level"] == '' else int(in_param_dict["customer_level"]) # user_ip = in_param_dict["user_ip"] hotel_id = in_param_dict["hotel_id"] filter_ota = 0 if in_param_dict["filter_ota"] == '' else int(in_param_dict["filter_ota"]) checkin = '2018-1-1' if in_param_dict["checkin"] == '' else in_param_dict["checkin"] checkout = '2018-1-2' if in_param_dict["checkout"] == '' else in_param_dict["checkout"] adult_num = 0 if in_param_dict["adult_num"] == '' else int(in_param_dict["adult_num"]) children = in_param_dict["children"] search_id = in_param_dict["search_id"] list_query_flag = 0 if in_param_dict["list_query_flag"] == '' else int(in_param_dict["list_query_flag"]) activity_id = in_param_dict["activity_id"] user_id = in_param_dict["user_id"] except Exception as e: print e return "", 0 request = price_service_pb2.PsRequest() # search_type request.service_type = 1 # search_id request.search_id = search_id; # version_id request.version_id = 2 # user_info request.user_info.user_ip = "127.0.0.1" # request.user_info.customer_level = customer_level # request.user_info.order_from = order_from request.user_info.booking_channel = booking_channel request.user_info.user_id = user_id # coupon info #request.user_info.activity_id_list.append(2015081441); #request.user_info.activity_id_list.append(2015081432); #request.user_info.activity_id_list.append(2015081457); #request.user_info.activity_id_list.append(2015081452); # detail_req - query_info # request.list_request.query_info.region_id = 178308 for ai in activity_id.split(','): if ai != '': request.user_info.activity_id_list.append(int(ai)) for hid in hotel_id.split(','): if hid != '': request.list_request.query_info.hotel_id.append(int(hid)) request.list_request.query_info.filter_ota = filter_ota request.list_request.query_info.cashpay_booking_channel_mask = 0 room = request.list_request.query_info.room_person.add() room.adult_num = adult_num for c in children.split(','): if c != '': room.child_age_list.append(int(c)) timeArray = time.strptime(checkin, "%Y-%m-%d") request.list_request.query_info.check_in_date = int(time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.list_request.query_info.check_out_date = int(time.mktime(timeArray)) + 1000 # list_query_flag # as请求ps可能的参数: # 3 0011 : ORIGIN_PRICE | ELONG_PRICE - 列表页批量接口 # 15 1111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION | DIGEST - 列表页批量接口 # 1 0001 : ORIGIN_PRICE - 列表页检索接口 # 7 0111 : ORIGIN_PRICE | ELONG_PRICE | PROMOTION - 列表页检索接口 request.list_request.query_info.list_query_flag = list_query_flag return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param try: booking_channel = 0 if in_param_dict["booking_channel"] == '' else int( in_param_dict["booking_channel"]) order_from = 0 if in_param_dict["order_from"] == '' else int( in_param_dict["order_from"]) customer_level = 0 if in_param_dict["customer_level"] == '' else int( in_param_dict["customer_level"]) # user_ip = in_param_dict["user_ip"] hotel_id = in_param_dict["hotel_id"] otaid = 0 if in_param_dict["otaid"] == '' else int( in_param_dict["otaid"]) src_otaid = -1 if in_param_dict["src_otaid"] == '' else int( in_param_dict["src_otaid"]) checkin = '2018-1-1' if in_param_dict[ "checkin"] == '' else in_param_dict["checkin"] checkout = '2018-1-2' if in_param_dict[ "checkout"] == '' else in_param_dict["checkout"] adult_num = 0 if in_param_dict["adult_num"] == '' else int( in_param_dict["adult_num"]) children = in_param_dict["children"] search_id = in_param_dict["search_id"] elong_pid = 0 if in_param_dict["elong_pid"] == '' else long( in_param_dict["elong_pid"]) ota_sign = 0 if in_param_dict["ota_sign"] == '' else long( in_param_dict["ota_sign"]) room_num = 0 if in_param_dict["room_num"] == '' else int( in_param_dict["room_num"]) elong_pname = in_param_dict["elong_pname"] user_id = in_param_dict["user_id"] except Exception as e: print e return "", 0 request = price_service_pb2.PsRequest() # search_type request.service_type = 3 # search_id request.search_id = search_id # version_id request.version_id = 2 # user_info # request.user_info.user_ip = user_ip request.user_info.customer_level = customer_level request.user_info.order_from = order_from request.user_info.booking_channel = booking_channel request.user_info.user_id = user_id # booking_req - query_info # request.booking_request.query_info.region_id = 178308 for hid in hotel_id.split(','): if hid != '': request.booking_request.query_info.hotel_id.append(int(hid)) for i in range(0, room_num): room = request.booking_request.query_info.room_person.add() room.adult_num = adult_num for c in children.split(','): if c != '': room.child_age_list.append(int(c)) timeArray = time.strptime(checkin, "%Y-%m-%d") request.booking_request.query_info.check_in_date = int( time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.booking_request.query_info.check_out_date = int( time.mktime(timeArray)) + 1000 # detail_ota --- ota if hotel_id.split(',')[0] != '': request.booking_request.detail_ota.base_hotel_id = int( hotel_id.split(',')[0]) request.booking_request.detail_ota.ota_id = otaid # request.booking_request.detail_ota.ota_sign = request.booking_request.detail_ota.hotel_status = 1 # detail_ota --- room room = request.booking_request.detail_ota.room_list.add() room.room_id = 0 room.room_name_cn = "default" room.room_status = 1 # detail_ota --- product product = room.product_list.add() product.elong_pid = elong_pid product.ota_sign = ota_sign product.room_num = room_num product.source_ota_id = src_otaid product.elong_pname = elong_pname # product.attachment = """{"rateKey": "4eff9a1e-23e6-4062-837c-b12d0cb74559-5208", "couponCode": "", "grossProfitOffline": 165.00999999999999, "hotelId": "419913", "rateCode": "201788267", "grossProfitOnline": 165.00999999999999, "isMobileChannel": "false", "elongPid": -5782743778810829706, "roomTypeCode": 200217206, "eSearchId": "1464761654"}""" return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param try: hotel_id = int(in_param_dict["hotel_id"]) otaid = int(in_param_dict["otaid"]) checkin = '2018-1-1' if in_param_dict["checkin"] == '' else in_param_dict["checkin"] checkout = '2018-1-2' if in_param_dict["checkout"] == '' else in_param_dict["checkout"] booking_channel = 0 if in_param_dict["booking_channel"] == '' else int(in_param_dict["booking_channel"]) adult_num = 0 if in_param_dict["adult_num"] == '' else int(in_param_dict["adult_num"]) search_id = in_param_dict["search_id"] children = in_param_dict["children"] list_only = False if in_param_dict["list_only"] == '0' else True hotel_status = int(in_param_dict["hotel_status"]) # room1 room1 = False if in_param_dict["room1"] == '0' else True roomId1 = long(in_param_dict["roomId1"]) roomNameCn1 = in_param_dict["roomNameCn1"].encode('utf-8') roomStatus1 = int(in_param_dict["roomStatus1"]) # product11 product11 = False if in_param_dict["product11"] == '0' else True elongPid11 = long(in_param_dict["elongPid11"]) productNameCn11 = in_param_dict["productNameCn11"].encode('utf-8') mobile11 = 0 if in_param_dict["mobile11"] == '0' else 1 cashPay11 = 1 if in_param_dict["cashPay11"] == '0' else 2 averRoomPrice11 = long(in_param_dict["averRoomPrice11"]) averPrice11 = long(in_param_dict["averPrice11"]) # product12 product12 = False if in_param_dict["product12"] == '0' else True elongPid12 = long(in_param_dict["elongPid12"]) productNameCn12 = in_param_dict["productNameCn12"].encode('utf-8') mobile12 = 0 if in_param_dict["mobile12"] == '0' else 1 cashPay12 = 1 if in_param_dict["cashPay12"] == '0' else 2 averRoomPrice12 = long(in_param_dict["averRoomPrice12"]) averPrice12 = long(in_param_dict["averPrice12"]) # room2 room2 = False if in_param_dict["room2"] == '0' else True roomId2 = long(in_param_dict["roomId2"]) roomNameCn2 = in_param_dict["roomNameCn2"].encode('utf-8') roomStatus2 = int(in_param_dict["roomStatus2"]) # product21 product21 = False if in_param_dict["product21"] == '0' else True elongPid21 = long(in_param_dict["elongPid21"]) productNameCn21 = in_param_dict["productNameCn21"].encode('utf-8') mobile21 = 0 if in_param_dict["mobile21"] == '0' else 1 cashPay21 = 1 if in_param_dict["cashPay21"] == '0' else 2 averRoomPrice21 = long(in_param_dict["averRoomPrice21"]) averPrice21 = long(in_param_dict["averPrice21"]) # product22 product22 = False if in_param_dict["product22"] == '0' else True elongPid22 = long(in_param_dict["elongPid22"]) productNameCn22 = in_param_dict["productNameCn22"].encode('utf-8') mobile22 = 0 if in_param_dict["mobile22"] == '0' else 1 cashPay22 = 1 if in_param_dict["cashPay22"] == '0' else 2 averRoomPrice22 = long(in_param_dict["averRoomPrice22"]) averPrice22 = long(in_param_dict["averPrice22"]) except Exception as e: # print e return "", 0 request = price_service_pb2.PsRequest() # search_id request.search_id = search_id; # version_id request.version_id = 1 # user_info request.user_info.user_ip = "192.168.21.1" request.user_info.customer_level = 2 request.user_info.order_from = 2 request.user_info.booking_channel = booking_channel # search_type request.service_type = 4 # update_req - query_info request.price_update_request.query_info.hotel_id.append(hotel_id) room = request.price_update_request.query_info.room_person.add() room.adult_num = 2 # room1 = request.price_update_request.query_info.room_person.add() # room1.adult_num = 2 #room.child_ages = "10" for c in children.split(','): if c != '': room.child_age_list.append(int(c)) timeArray = time.strptime(checkin, "%Y-%m-%d") request.price_update_request.query_info.check_in_date = int(time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.price_update_request.query_info.check_out_date = int(time.mktime(timeArray)) + 1000 # update_list_only request.price_update_request.query_info.update_list_only = list_only # DetailOta - 1 detail_ota1 = request.price_update_request.detail_ota.add() detail_ota1.base_hotel_id = hotel_id detail_ota1.ota_id = otaid detail_ota1.hotel_status = hotel_status # 2-SUCCESS_STOCK detail_ota1.crawl_time = int(time.time()) # room - 1 if room1: croom1 = detail_ota1.room_list.add() croom1.room_id = roomId1 croom1.room_name_cn = roomNameCn1 croom1.room_status = roomStatus1 # 1-open # product - 1.1 if product11: cproduct11 = croom1.product_list.add() cproduct11.elong_pid = elongPid11 cproduct11.product_name_cn = productNameCn11 cproduct11.room_num = 3 cproduct11.rateplan.ota_promo_type = mobile11 # 1-手机专享; 0-非手机专享 cproduct11.rateplan.pay_type = cashPay11 # 1-预付; 2-现付 # origin_price(分) cproduct11.origin_price.average_room_price.amount = averRoomPrice11 cproduct11.origin_price.average_room_price.currency = "CNY" cproduct11.origin_price.average_price.amount = averPrice11 cproduct11.origin_price.average_price.currency = "CNY" # product - 1.2 if product12: cproduct12 = croom1.product_list.add() cproduct12.elong_pid = elongPid12 cproduct12.product_name_cn = productNameCn12 cproduct12.room_num = 3 cproduct12.rateplan.ota_promo_type = mobile12 # 1-手机专享; 0-非手机专享 cproduct12.rateplan.pay_type = cashPay12 # 1-预付; 2-现付 # origin_price(分) cproduct12.origin_price.average_room_price.amount = averRoomPrice12 cproduct12.origin_price.average_room_price.currency = "CNY" cproduct12.origin_price.average_price.amount = averPrice12 cproduct12.origin_price.average_price.currency = "CNY" # room - 2 if room2: croom2 = detail_ota1.room_list.add() croom2.room_id = roomId2 croom2.room_name_cn = roomNameCn2 croom2.room_status = roomStatus2 # 1-open # product - 2.1 if product21: cproduct21 = croom2.product_list.add() cproduct21.elong_pid = elongPid21 cproduct21.product_name_cn = productNameCn21 cproduct21.room_num = 3 cproduct21.rateplan.ota_promo_type = mobile21 # 1-手机专享; 0-非手机专享 cproduct21.rateplan.pay_type = cashPay21 # 1-预付; 2-现付 # origin_price(分) cproduct21.origin_price.average_room_price.amount = averRoomPrice21 cproduct21.origin_price.average_room_price.currency = "CNY" cproduct21.origin_price.average_price.amount = averPrice21 cproduct21.origin_price.average_price.currency = "CNY" # product - 2.2 if product22: cproduct22 = croom2.product_list.add() cproduct22.elong_pid = elongPid22 cproduct22.product_name_cn = productNameCn22 cproduct22.room_num = 3 cproduct22.rateplan.ota_promo_type = mobile22 # 1-手机专享; 0-非手机专享 cproduct22.rateplan.pay_type = cashPay22 # 1-预付; 2-现付 # origin_price(分) cproduct22.origin_price.average_room_price.amount = averRoomPrice22 cproduct22.origin_price.average_room_price.currency = "CNY" cproduct22.origin_price.average_price.amount = averPrice22 cproduct22.origin_price.average_price.currency = "CNY" return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param try: booking_channel = 0 if in_param_dict["booking_channel"] == '' else int(in_param_dict["booking_channel"]) order_from = 0 if in_param_dict["order_from"] == '' else int(in_param_dict["order_from"]) customer_level = 0 if in_param_dict["customer_level"] == '' else int(in_param_dict["customer_level"]) # user_ip = in_param_dict["user_ip"] hotel_id = in_param_dict["hotel_id"] filter_ota = 0 if in_param_dict["filter_ota"] == '' else int(in_param_dict["filter_ota"]) checkin = '2018-1-1' if in_param_dict["checkin"] == '' else in_param_dict["checkin"] checkout = '2018-1-2' if in_param_dict["checkout"] == '' else in_param_dict["checkout"] adult_num = 0 if in_param_dict["adult_num"] == '' else int(in_param_dict["adult_num"]) children = in_param_dict["children"] search_id = in_param_dict["search_id"] activity_id = in_param_dict["activity_id"] user_id = in_param_dict["user_id"] except Exception as e: print e return "", 0 request = price_service_pb2.PsRequest() # search_id request.search_id = search_id; # version_id request.version_id = 2 # user_info request.user_info.user_ip = "127.0.0.1" request.user_info.customer_level = customer_level request.user_info.order_from = order_from request.user_info.booking_channel = booking_channel request.user_info.user_id = user_id # coupon info # request.user_info.activity_id_list.append(1); # request.user_info.activity_id_list.append(2); # request.user_info.activity_id_list.append(3); # request.user_info.activity_id_list.append(4); for ai in activity_id.split(','): if ai != '': request.user_info.activity_id_list.append(int(ai)) # search_type request.service_type = 2 # detail_req - query_info # request.detail_request.query_info.region_id = 178308 for hid in hotel_id.split(','): if hid != '': request.detail_request.query_info.hotel_id.append(int(hid)) request.detail_request.query_info.filter_ota = filter_ota # request.detail_request.query_info.cache_time = 1000 # request.detail_request.query_info.timeout = 3000 request.detail_request.query_info.cashpay_booking_channel_mask = 0 room = request.detail_request.query_info.room_person.add() room.adult_num = adult_num for c in children.split(','): if c != '': room.child_age_list.append(int(c)) timeArray = time.strptime(checkin, "%Y-%m-%d") request.detail_request.query_info.check_in_date = int(time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.detail_request.query_info.check_out_date = int(time.mktime(timeArray)) + 1000 return request.SerializeToString(), request.ByteSize()
def build_message(nshead, in_param_dict): # get param booking_channel = in_param_dict["booking_channel"] hotel_id = in_param_dict["hotel_id"] filter_ota = in_param_dict["filter_ota"] checkin = in_param_dict["checkin"] checkout = in_param_dict["checkout"] request_type = in_param_dict["request_type"] ota_id = in_param_dict["ota_id"] source_ota_id = in_param_dict["source_ota_id"] elong_pname = in_param_dict["elong_pname"] elong_pid = in_param_dict["elong_pid"] ota_sign = in_param_dict["ota_sign"] request = price_service_pb2.PsRequest() # search_id request.search_id = "12345678910" # version_id request.version_id = 2 # user_info request.user_info.user_ip = "192.168.21.1" request.user_info.customer_level = 2 request.user_info.order_from = 2 request.user_info.booking_channel = booking_channel request.user_info.request_type = request_type # search_type request.service_type = 3 #booking_req - query_info request.booking_request.query_info.hotel_id.append(hotel_id) request.booking_request.query_info.filter_ota = filter_ota room = request.booking_request.query_info.room_person.add() room.adult_num = 2 # room.child_age_list.append(4) # room.child_age_list.append(2) # room.child_age_list.append(7) timeArray = time.strptime(checkin, "%Y-%m-%d") request.booking_request.query_info.check_in_date = int( time.mktime(timeArray)) + 1000 timeArray = time.strptime(checkout, "%Y-%m-%d") request.booking_request.query_info.check_out_date = int( time.mktime(timeArray)) + 1000 # detail_ota --- ota request.booking_request.detail_ota.base_hotel_id = hotel_id request.booking_request.detail_ota.ota_id = ota_id request.booking_request.detail_ota.hotel_status = 1 # detail_ota --- room room = request.booking_request.detail_ota.room_list.add() room.room_id = 40239018 room.room_name_cn = "标准双人房" room.room_status = 1 # detail_ota --- product product = room.product_list.add() product.room_num = 1 product.elong_pid = elong_pid product.ota_sign = ota_sign product.source_ota_id = source_ota_id product.elong_pname = elong_pname return request, request.SerializeToString(), request.ByteSize()