Ejemplo n.º 1
0
    def getPassengerTicketStrListAndOldPassengerStr(self, secretStr,
                                                    secretList):
        """
        获取提交车次人内容格式
        passengerTicketStr	O,0,1,文贤平,1,43052419950223XXXX,15618715583,N_O,0,1,梁敏,1,43052719920118XXXX,,N
        oldPassengerStr	文贤平,1,43052719920118XXXX,1_梁敏,1,43052719920118XXXX,1
        ps: 如果is_more_ticket打开了的话,那就是读取联系人列表里面前符合车次数量的前几个联系人
        :return:
        """
        passengerTicketStrList = []
        oldPassengerStr = []
        tickers = []
        set_type = ""
        if wrapcache.get("user_info"):  # 如果缓存中有联系人方式,则读取缓存中的联系人
            user_info = wrapcache.get("user_info")
            print(u"使用缓存中查找的联系人信息")
        else:
            user_info = self.sendGetPassengerDTOs()
            wrapcache.set("user_info", user_info, timeout=9999999)
        if not user_info:
            raise PassengerUserException(ticket.DTO_NOT_IN_LIST)
        if len(
                user_info
        ) < self.is_more_ticket_num:  # 如果乘车人填错了导致没有这个乘车人的话,可能乘车人数会小于自动乘车人
            self.is_more_ticket_num = len(user_info)
        if secretStr:
            set_type = self.getPassengerTicketStr(self.set_type)
            if self.is_more_ticket_num is 1:
                passengerTicketStrList.append(
                    '0,' + user_info[0]['passenger_type'] + "," +
                    user_info[0]["passenger_name"] + "," +
                    user_info[0]['passenger_id_type_code'] + "," +
                    user_info[0]['passenger_id_no'] + "," +
                    user_info[0]['mobile_no'] + ',N,' +
                    user_info[0]["allEncStr"])
                oldPassengerStr.append(user_info[0]['passenger_name'] + "," +
                                       user_info[0]['passenger_id_type_code'] +
                                       "," + user_info[0]['passenger_id_no'] +
                                       "," + user_info[0]['passenger_type'] +
                                       '_')
            else:
                for i in range(self.is_more_ticket_num):
                    passengerTicketStrList.append(
                        '0,' + user_info[i]['passenger_type'] + "," +
                        user_info[i]["passenger_name"] + "," +
                        user_info[i]['passenger_id_type_code'] + "," +
                        user_info[i]['passenger_id_no'] + "," +
                        user_info[i]['mobile_no'] + ',N,' +
                        user_info[i]["allEncStr"] + '_' + set_type)
                    oldPassengerStr.append(
                        user_info[i]['passenger_name'] + "," +
                        user_info[i]['passenger_id_type_code'] + "," +
                        user_info[i]['passenger_id_no'] + "," +
                        user_info[i]['passenger_type'] + '_')
        elif secretList:
            """
            候补订单有多少个联系人,就候补多少个联系人了,没有优先提交之说
            1#XXXX#1#***************77X#bf6ae40d3655ae7eff005ee21d95876b38ab97a8031b464bc2f74a067e3ec957;
            """
            for user in user_info:
                tickers.append(
                    f"1#{user['passenger_name']}#1#{user['passenger_id_no']}#{user['allEncStr']};"
                )

        return {
            "passengerTicketStrList":
            set_type + "," + ",".join(passengerTicketStrList),
            "passengerTicketStrByAfterLate":
            "".join(tickers),
            "oldPassengerStr":
            "".join(oldPassengerStr),
            "code":
            ticket.SUCCESS_CODE,
            "set_type":
            set_type,
            "status":
            True,
            "user_info":
            user_info,
        }
Ejemplo n.º 2
0
 def getPassengerTicketStrListAndOldPassengerStr(self):
     """
     获取提交车次人内容格式
     passengerTicketStr	O,0,1,文贤平,1,43052419950223XXXX,15618715583,N_O,0,1,梁敏,1,43052719920118XXXX,,N
     oldPassengerStr	文贤平,1,43052719920118XXXX,1_梁敏,1,43052719920118XXXX,1
     ps: 如果is_more_ticket打开了的话,那就是读取联系人列表里面前符合车次数量的前几个联系人
     :return:
     """
     passengerTicketStrList = []
     oldPassengerStr = []
     if wrapcache.get("user_info"):  # 如果缓存中有联系人方式,则读取缓存中的联系人
         user_info = wrapcache.get("user_info")
         print(u"使用缓存中查找的联系人信息")
     else:
         user_info = self.sendGetPassengerDTOs()
         wrapcache.set("user_info", user_info, timeout=9999999)
     set_type = self.getPassengerTicketStr(self.set_type)
     if not user_info:
         raise PassengerUserException(ticket.DTO_NOT_IN_LIST)
     if len(
             user_info
     ) < self.is_more_ticket_num:  # 如果乘车人填错了导致没有这个乘车人的话,可能乘车人数会小于自动乘车人
         self.is_more_ticket_num = len(user_info)
     if self.is_more_ticket_num is 1:
         passengerTicketStrList.append(
             '0,' + user_info[0]['passenger_type'] + "," +
             user_info[0]["passenger_name"] + "," +
             user_info[0]['passenger_id_type_code'] + "," +
             user_info[0]['passenger_id_no'] + "," +
             user_info[0]['mobile_no'] + ',N,' + user_info[0]["allEncStr"])
         oldPassengerStr.append(user_info[0]['passenger_name'] + "," +
                                user_info[0]['passenger_id_type_code'] +
                                "," + user_info[0]['passenger_id_no'] +
                                "," + user_info[0]['passenger_type'] + '_')
     else:
         for i in xrange(self.is_more_ticket_num):
             passengerTicketStrList.append(
                 '0,' + user_info[i]['passenger_type'] + "," +
                 user_info[i]["passenger_name"] + "," +
                 user_info[i]['passenger_id_type_code'] + "," +
                 user_info[i]['passenger_id_no'] + "," +
                 user_info[i]['mobile_no'] + ',N,' +
                 user_info[i]["allEncStr"] + '_' + set_type)
             oldPassengerStr.append(user_info[i]['passenger_name'] + "," +
                                    user_info[i]['passenger_id_type_code'] +
                                    "," + user_info[i]['passenger_id_no'] +
                                    "," + user_info[i]['passenger_type'] +
                                    '_')
     return {
         "passengerTicketStrList":
         set_type + "," + ",".join(passengerTicketStrList),
         "oldPassengerStr":
         "".join(oldPassengerStr),
         "code":
         ticket.SUCCESS_CODE,
         "set_type":
         set_type,
         "status":
         True,
         "user_info":
         user_info,
     }