C++大作业 物流管理系统

课程作业,在设计上用到了前后端分离的思想,把业务层和逻辑交互层分开来写。本来想用qml实现前后端分离,时间问题没做图形界面,只写了个扣1扣2的cmd界面,谈不上前后端之分。前前后后写了三天,从最底层数据封装开始,到内存的自动管理,再到业务层,最后是扣1扣2的界面层,总体来说还是很累的,简单记录一下屎山x。其中交互层还有很多未知bug,但咱重点突出一个能跑就行好吧,也欢迎大家指正。

如果对你有帮助那真是太好了(目移)。

任务目标

总体来说是一个物流管理系统,大致内容都在下面了。

 

 如图↑,没什么好说的,具体直接看代码说吧。

程序结构

 总体上就是这几个文件

                                                      

 服务依赖↑                                                                                     交互窗口↑

 在服务依赖这几个类中把主要涉及的数据处理封装好,最终在Service_User以及Service_Admin里面只暴露出相应服务操作的接口函数以供前端交互窗口调用,把数据存储,内存管理等全部封装好,避免写业务逻辑时再去关心这些内容。使得整体的架构更清晰也更方便维护。

交互窗口主要是两部分组成,一是存放展示界面的windows,二是存放页面逻辑的cmdApp。同样分开来写,让结构清晰一点。

下面详细讲讲每个类的实现

前后端“通信”

因为涉及到前后端的理念,不得不说明下是如何通信的。

设计理念就是,在前端实例化服务类的对象来启动服务,调用对象里的函数来向后端发起”请求“。在这个对象里会有一个public的链表,用于储存需要展示的信息的指针,前端通过读取这个链表的全部内容将信息解析并展示,以次完成”通讯“。

后端服务依赖

config

#pragma once
#pragma warning(disable:4996)
#include <iostream>
#include <string>
#include <fstream> 
#include <ctime>
#include <cstring>
#include <random>
#include <cstdlib>
//数据大小
#define MAX_NOTE_NUM 200
#define MAX_PHONE_NUM 11
#define MAX_ACCONT_NUM 20
#define MAX_PASSWORD_NUM 20
#define MAX_NIKENAME_NUM 20

#define MAX_REALNAME_NUM 20
#define MAX_ADDRESS_NUM 50

#define MAX_ODERNUM_NUM 23 

#define MAX_DAY_NUM 8

#define MAX_TIME_NUM 6

#define USERINFOR_FILE "UserInfor.dat"
#define ADDRESSINFOR_FILE "AddressBook.dat"
#define ODERINFOR_FILE "Oders.dat"
#define ADMININFOR_FILE "Admin.dat"

#define FRAGILLE 1
#define FRAGILLE_PRICE 8
#define BOOK 2
#define BOOK_PRICE 2
#define NORMAL 3
#define NORMAL_PRICE 5

一些宏定义,一些include,并且将一些自定义数据的大小进行了指定,方便之后对存储的管理。

BaseData

BaseData.h

#pragma once
#include "config.h"

template<int Num>
class myArray;
template<int Num>
std::ostream& operator<< (std::ostream &outp,const myArray<Num> &item);

template<int Num>
class myArray
{
    public:
        char Infor[Num];

        myArray():Infor("*"){};
        myArray(const std::string str)
        {   int i = 0;
            for(i;i<Num-1&&i<str.length();i++)
            {
                Infor[i] = str[i];
            }
            for(i;i<Num;i++)
            {
                Infor[i] = 0;
            }
        };
        myArray(char const *str )
        {
            int i =0;
            for(i;i<Num-1&&i<strlen(str);i++)
            {
                Infor[i] = str[i];    
            }
            for(i;i<Num;i++)
            {
                Infor[i] = 0;
            }
        };
        myArray(const myArray<Num> &obj)
        {
            for(int i = 0;i<Num;i++)
            {
                Infor[i] = obj.Infor[i];
            }  
        };
        ~myArray(){};
        int len(){return Num;};

        friend std::ostream& operator<< <> (std::ostream &outp,const myArray<Num> &item);
        bool operator==(const myArray<Num>&obj)
        {
            if(strcmp(Infor,obj.Infor)==0)return true;
            else
            return false;
        };
        operator std::string()const{return Infor;};

};
//linklist to manage the data
template <class ELE>
class Node
{
    public:
        ELE data;
        Node<ELE> *next = NULL;
        Node(const ELE &data)
        {
            this->data = data;
        }
        Node(){};
};

template<class ELE>
class LinkList
{
    private:
        Node<ELE>* head;
        int len = 0;
    public:
        LinkList()
        {
            head = new Node<ELE>;
            head->next = NULL;
            head->data = {};
            len = 0;
        };
        ~LinkList()
        {
            Node<ELE>* p =head->next;
            Node<ELE>* del;
            while(p!=NULL)
            {
                del = p;
                p = p->next;
                delete del;
            }
        };
        bool isEmpty()
        {
            return(head->next==NULL);
        };
        void clear()
        {
            Node<ELE>*p = head->next;
            Node<ELE>*del = p;
            while(p!=NULL)
            {
                del = p;
                p=p->next;
                delete del;   
            }
            head->next = NULL;
            len = 0;
        };
        void PushFront(Node<ELE>* node)
        {
            node->next = head->next;
            head->next = node;
            len++;
        };
        
        void PushBack(Node<ELE>* node)
        {
            Node<ELE>* p = head;
            while (p->next!=NULL)
            {
                p = p->next;
            }
            p->next = node;
            len++;
        };
        void AddI(int i,Node<ELE>* node)//need to use a
        {
            std::cout<<"adding";
            if(i<=len+1)
            {
                Node<ELE>* temp = head;
                for(int j = 0;j<i-1;j++)
                {
                    temp = temp->next;
                }
                Node<ELE>* temp2 = temp->next;
                temp->next = node;
                node->next = temp2;
                len++;
                std::cout<<"add succeee"<<std::endl;
            }

        };
        void ChangeI(int i,Node<ELE>* node)//把第i个位置的结点替换成node
        {
            if(!this->isEmpty()&&i<=len)
            {
                Node<ELE>* temp = head;
                for(int j = 0;j<i-1;j++)
                {
                    temp = temp->next;
                }
                Node<ELE>* temp1 = temp->next;
                temp->next = node;
                node->next = temp1->next;
                delete temp1;
            }
        };
        void DelI(int i)// 删掉第i个
        {
            if(!this->isEmpty()&&i<=len)
            {
                Node<ELE>* temp = head;
                for(int j = 0;j<i-1;j++)
                {
                    temp = temp->next;
                }
                Node<ELE>* temp2 = temp->next;
                temp->next = temp2->next;
                len--;
                delete temp2;
            }
        };
        int Getindex(Node<ELE>* node)
        {
            int i = 0;
            Node<ELE> *temp = node;
            while(temp!=NULL)
            {
                i++;
                temp = temp->next;
            }
            int res = len-i+1;
            return res;
        }
        Node<ELE>* GetI(int i)//返回指向第i个结点的指针
        {
            if (!this->isEmpty() && i <= len)
            {
                Node<ELE>* temp = head;
                for (int j = 0; j < i; j++)
                {
                    temp = temp->next;
                }
                return temp;
            }
            else
                return head;
        };
        Node<ELE>* PopBack()
        {
            if(!this->isEmpty())
            {
                Node<ELE>* temp = head;
                for(int i = 0;i<this->len-1;i++)
                {
                    temp = temp->next;
                }
                Node<ELE>* temp1 = temp->next;
                temp->next = NULL;
                len--;
                return temp1;
            }
            else
            {
                std::cout<<"emptyLinkList"<<std::endl;
                return 0;
            }
        };
        Node<ELE>* PopFront()//把开头的弹出,同时返回指向被弹出结点的指针
        {
            if(!this->isEmpty())
            {
                Node<ELE>* node = head->next;
                head->next = head->next->next;
                return node;
            }
            else
            {
                std::cout<<"empty LinkList"<<std::endl;
                return 0;
            }
        };
        Node<ELE>* PopI(int i)
        {
            if(!this->isEmpty()&&i<=len)
            {
                Node<ELE>* temp = GetI(i-1);
               
                Node<ELE>* tem1 = temp->next;
                temp->next = tem1->next;
                len--;
                return tem1;
            }
            else
            {
                std::cout<<"emptyLinkList"<<std::endl;
                return 0;
            }

        };
        Node<ELE>* Gethead()
        {
            return head;
        };
        int getlen()
        {
            return len;
        };

};

template<int Num>
std::ostream& operator<< (std::ostream &outp,const myArray<Num> &item)
{
    std::cout<<item.Infor;
    return outp;
};
//封装数据结点
typedef myArray<MAX_PHONE_NUM+1> Phone;
typedef myArray<MAX_NOTE_NUM+1> Note;
typedef myArray<MAX_PHONE_NUM+1> Phone;
typedef myArray<MAX_ACCONT_NUM+1> Account;
typedef myArray<MAX_PASSWORD_NUM+1> PassWord;
typedef myArray<MAX_NIKENAME_NUM+1> NickName;
typedef myArray<MAX_REALNAME_NUM+1> RealName;
typedef myArray<MAX_ODERNUM_NUM+1> OderCode;
typedef myArray<MAX_DAY_NUM+1> DayYear;
typedef myArray<MAX_TIME_NUM+1> Time;
typedef myArray<MAX_ADDRESS_NUM+1> Address;

typedef struct UserInfor
{//用户信息
    Account Accont;//keyword
    Phone Phone;
    PassWord PassWord;
    NickName NickName;
    double money = 0;
    void display()
    {
        std::cout<<"|userinfor"<<std::endl;
        std::cout<<"-|Account :"<<Accont<<std::endl;
        std::cout<<"-|Phone   :"<<Phone<<std::endl;
        std::cout<<"-|Password:"<<PassWord<<std::endl;
        std::cout<<"-|NickName:"<<NickName<<std::endl;
        std::cout<<"-|money   :"<<money<<std::endl;
        std::cout<<"|end..."<<std::endl;
    };
}UserInfor;
typedef struct  AdministratorInfor
{
    Account Account;
    PassWord PassWord;
    NickName NickName;
    double money = 0;
     void display()
    {
        std::cout<<"|AdministratorInfor"<<std::endl;
        std::cout<<"-|Account :"<<Account<<std::endl;
        std::cout<<"-|Password:"<<PassWord<<std::endl;
        std::cout<<"-|NickName:"<<NickName<<std::endl;
        std::cout<<"-|money   :"<<money<<std::endl;
        std::cout<<"|end..."<<std::endl;
    };
}AdministratorInfor;
typedef struct AddressInfor
{//地址信息
    
    Account relateAccont;//keyword
    RealName name;
    Phone Phone;
    Address Address;
    void display()
    {
        std::cout<<"|AddressInfor"<<std::endl;
        std::cout<<"-|Realname:"<<name<<std::endl;
        std::cout<<"-|Phone   :"<<Phone<<std::endl;
        std::cout<<"-|Address :"<<Address<<std::endl;
        std::cout<<"|end..."<<std::endl;
    };
}AddressInfor;
typedef struct Timess
{
    int year = 0;
    int month = 0;
    int day = 0;
    int hour = 0;
    int minute = 0;
    int sec = 0;
    Timess(){};
    Timess(tm* ltm)
    {
        year = ltm->tm_year+1900;
        month = ltm->tm_mon+1;
        day = ltm->tm_mday;
        hour = ltm->tm_hour;
        minute = ltm->tm_min;
        sec = ltm->tm_sec;
    }

}Timess;
typedef struct Statu
{
    int num1=0;//为1代取件
    Timess time1;
    int num2=0;//为1:运输中
    Timess time2;
    int num3=0;//为1:运达,待取件
    Timess time3;
    int num4=0;//为1:确认收货
    Timess time4;
}Status;
typedef struct OderInfor
{//订单信息
    OderCode OderNum;
    Account relateAccont;
    AddressInfor Sender;
    AddressInfor Recevier;
    Status StatuCode;
    int Kinds;
    double Price;
    int hadRecharged = 0;
    Note notes;
    void display()
    {
        std::cout<<"|OderInfor"<<std::endl;
        std::cout<<"-|OderNum :"<<OderNum<<std::endl;
        std::cout<<"-|Sender  :"<<std::endl;
        Sender.display();
        std::cout<<"-|Recevier:"<<std::endl;
        Recevier.display();
        std::cout<<"-|Notes   :"<<notes<<std::endl;
        std::cout<<"|end..."<<std::endl;
    };
}OderInfor;

typedef Node<UserInfor> UserInfor_Node;
typedef Node<AddressInfor> AddressInfor_Node;
typedef Node<AddressInfor_Node*> AddressPointor_Node;
typedef Node<OderInfor> Oder_Node;
typedef Node<Oder_Node*> OderPointor_Node; 
typedef Node<AdministratorInfor> AdministratorInfor_Node;


typedef LinkList<UserInfor> UserInfor_list;
typedef LinkList<AddressInfor> AddressInfor_list;
typedef LinkList<AddressInfor_Node*> AddressDisplay_list;
typedef LinkList<OderInfor> Oderinfor_list;
typedef LinkList<Oder_Node*> OderDisplay_list;
typedef LinkList<AdministratorInfor> AdministratorInfor_list;

在这个头文件里,用模板类将之后业务常见的数据类型进行了封装和指定,并重载了一些基本的运算符,主要目的是string不能指定长度,会对之后数据的永久化储存产生困扰,干脆用指定长度的字符串进行存储。

又对一些关键的信息集用struct进行了封装,方便之后使用

同时还实现了一个简单的链表用于内存管理,这个链表有些方法后面没有用上,但它用起来真的很舒服,用链表进行内存管理极大程度上减轻了思考的负担。至于为什么自己写而没用std里的...因为懒得看)

然后就是利用typedef把模板类指定成一个个实例类,方便之后使用

这里实现和声明没有分开写是因为模板类分开写会报错,虽然一开始我分开写的时候并没有遇到问题但网上都这么建议,我也就都写在一个文件里了。

myDatabase

myDatabase.h

#pragma once
#include "BaseData.h"
//这一层的函数,参数全部使用引用的方式,把内存管理封死在这一层,提供给业务层接口
//所有业务操作有关于内存的均在此处完成,查询等功能也在此处完成

class myDatabase
{
    public:
        void saveUser();
        void saveAddress();
        void saveOder();
        void saveAdmin();
        //注意原本储存链表内有数据,不能直接load,会反复读取,需要对链表进行clear操作
        void loadUser();
        void loadAddress();
        void loadOder();
        void loadAdmin();
        
        void saveAll();//把链表内所有信息重新写入到文件中,并且刷新所有的信息覆盖
        void loadALL(); 
        UserInfor_list *Userlist_ALL_P;
        AddressInfor_list *Addreslist_ALL_P;
        Oderinfor_list *Oderlist_ALL_P;
        AdministratorInfor_list *adminlist_ALL_P;

        AdministratorInfor_Node* search_adminP_by_Accont(Account &act);
        UserInfor_Node* search_userP_by_Accont(Account &act);
        Oder_Node* search_OderP_by_OderCode(OderCode &code);

        
        myDatabase();
        myDatabase(UserInfor_list* UserP, AddressInfor_list* adres = NULL, Oderinfor_list* oder = NULL, AdministratorInfor_list* Admin = NULL)
        :Userlist_ALL_P(UserP),Addreslist_ALL_P(adres),Oderlist_ALL_P(oder),adminlist_ALL_P(Admin) {};//测试用
        ~myDatabase();


};

myDatabase.cpp

#include "myDatabase.h"

myDatabase::myDatabase()
{
    Userlist_ALL_P = new UserInfor_list;
    Addreslist_ALL_P = new AddressInfor_list;
    Oderlist_ALL_P = new Oderinfor_list;
    adminlist_ALL_P = new AdministratorInfor_list;
    loadALL();   
    std::cout<<"data service running..."<<std::endl;
}

myDatabase::~myDatabase()
{
    delete Userlist_ALL_P;
    delete Addreslist_ALL_P;
    delete Oderlist_ALL_P;
    delete adminlist_ALL_P;
    std::cout<<"data service closed..."<<std::endl;
}

void myDatabase::saveUser()
{
    std::ofstream dataFile(USERINFOR_FILE,std::ios::out|std::ios::binary);
    if(!dataFile)
    {
        std::cerr<<"file to load UserInfor type:SAVE"<<std::endl;
        return;
    };
    UserInfor_Node *temp = Userlist_ALL_P->Gethead();
    while(temp->next!=NULL)
    {   
        temp = temp->next;
        // dataFile.write((char*)&(temp->data.Accont),sizeof(Account));
        // dataFile.write((char*)&(temp->data.Phone),sizeof(Phone));
        // dataFile.write((char*)&(temp->data.PassWord),sizeof(PassWord));
        // dataFile.write((char*)&(temp->data.NickName),sizeof(NickName));
        // dataFile.write((char*)&(temp->data.money),sizeof(double));
        int watch = sizeof(UserInfor);

        dataFile.write((char*)&(temp->data),sizeof(UserInfor));
    }
    dataFile.close();
    
}
void myDatabase::saveAdmin()
{
    std::ofstream dataFile(ADMININFOR_FILE,std::ios::out|std::ios::binary);
    if(!dataFile)
    {
        std::cerr<<"file to load AdminInfor type:SAVE"<<std::endl;
        return;
    };
    AdministratorInfor_Node *temp = adminlist_ALL_P->Gethead();
    while(temp->next!=NULL)
    {   
        temp = temp->next;
        // dataFile.write((char*)&(temp->data.Accont),sizeof(Account));
        // dataFile.write((char*)&(temp->data.Phone),sizeof(Phone));
        // dataFile.write((char*)&(temp->data.PassWord),sizeof(PassWord));
        // dataFile.write((char*)&(temp->data.NickName),sizeof(NickName));
        // dataFile.write((char*)&(temp->data.money),sizeof(double));
        dataFile.write((char*)&(temp->data),sizeof(AdministratorInfor));
    }
    dataFile.close();
    
}
void myDatabase::saveAddress()
{
    std::ofstream dataFile(ADDRESSINFOR_FILE,std::ios::out|std::ios::binary);
    if(!dataFile)
    {
        std::cerr<<"file to load Address type:SAVE"<<std::endl;
        return;
    };
    AddressInfor_Node *temp = Addreslist_ALL_P->Gethead();
    while(temp->next!=NULL)
    {   
        temp = temp->next;
        // dataFile.write((char*)&(temp->data.relateAccont),sizeof(Account));
        // dataFile.write((char*)&(temp->data.name),sizeof(RealName));
        // dataFile.write((char*)&(temp->data.Phone),sizeof(Phone));
        // dataFile.write((char*)&(temp->data.Address),sizeof(Address));
        dataFile.write((char*)(&temp->data),sizeof(AddressInfor));
    }
    dataFile.close();
    
}
void myDatabase::saveOder()
{
    std::ofstream dataFile(ODERINFOR_FILE,std::ios::out|std::ios::binary);
    if(!dataFile)
    {
        std::cerr<<"file to load Oderifor type:SAVE"<<std::endl;
        return;
    };
    Oder_Node *temp = Oderlist_ALL_P->Gethead();
    while(temp->next!=NULL)
    {   
        temp = temp->next;
        dataFile.write((char*)(&temp->data),sizeof(OderInfor));
    }
    dataFile.close();
    
}
void myDatabase::loadUser()
{
    std::ifstream dataFile(USERINFOR_FILE,std::ios::ate|std::ios::binary);
    if(!dataFile)//打开错误处理
    {
        std::cerr<<"file to load UserInfor type:READ"<<std::endl;
        return;
    };
    int filesize;
    filesize = dataFile.tellg();//获取文件大小
    dataFile.seekg(0,std::ios::beg);//指针返回起始位置
    int filep = 0;
    while(filep<filesize)
    {
        UserInfor_Node* temp = new UserInfor_Node;
        dataFile.read((char*)(&temp->data),sizeof(UserInfor));
        filep = dataFile.tellg();
        Userlist_ALL_P->PushBack(temp);
    };
    dataFile.close();
}
void myDatabase::loadAdmin()
{
    std::ifstream dataFile(ADMININFOR_FILE,std::ios::ate|std::ios::binary);
    if(!dataFile)//打开错误处理
    {
        std::cerr<<"file to load UserInfor type:READ"<<std::endl;
        return;
    };
    int filesize;
    filesize = dataFile.tellg();//获取文件大小
    dataFile.seekg(0,std::ios::beg);//指针返回起始位置
    int filep = 0;
    while(filep<filesize)
    {
        AdministratorInfor_Node* temp = new AdministratorInfor_Node;
        dataFile.read((char*)(&temp->data),sizeof(AdministratorInfor));
        filep = dataFile.tellg();
        adminlist_ALL_P->PushBack(temp);
    };
    dataFile.close();
}
void myDatabase::loadAddress()
{
    std::ifstream dataFile(ADDRESSINFOR_FILE,std::ios::ate|std::ios::binary);
    if(!dataFile)//打开错误处理
    {
        std::cerr<<"file to load AddressInfor type:READ"<<std::endl;
        return;
    };
    int filesize;
    filesize = dataFile.tellg();//获取文件大小
    dataFile.seekg(0,std::ios::beg);//指针返回起始位置
    int filep = 0;
    while(filep<filesize)
    {
        AddressInfor_Node* temp = new AddressInfor_Node;
        dataFile.read((char*)(&temp->data),sizeof(AddressInfor));
        filep = dataFile.tellg();
        Addreslist_ALL_P->PushBack(temp);
    };
    dataFile.close();
}
void myDatabase::loadOder()
{
    std::ifstream dataFile(ODERINFOR_FILE,std::ios::ate|std::ios::binary);
    if(!dataFile)//打开错误处理
    {
        std::cerr<<"file to load OderInfor type:READ"<<std::endl;
        return;
    };
    int filesize;
    filesize = dataFile.tellg();//获取文件大小
    dataFile.seekg(0,std::ios::beg);//指针返回起始位置
    int filep = 0;
    while(filep<filesize)
    {
        Oder_Node* temp = new Oder_Node;
        dataFile.read((char*)(&temp->data),sizeof(OderInfor));
        filep = dataFile.tellg();
        Oderlist_ALL_P->PushBack(temp);
    };
    dataFile.close();
}

void myDatabase::saveAll()
{
    saveAddress();
    saveUser();
    saveOder();
    saveAdmin();
}

void myDatabase::loadALL()
{
    loadAddress();
    loadUser();
    loadOder();
    loadAdmin();
}

AdministratorInfor_Node* myDatabase::search_adminP_by_Accont(Account &act)
{
    AdministratorInfor_Node* p;
    int i = adminlist_ALL_P->getlen();
    for(int j = 1;j<i;j++)
    {
        p = adminlist_ALL_P->GetI(j);
        if(p->data.Account==act)
        {
            return p;
        }

    }
    p = adminlist_ALL_P->GetI(i);
    if(p->data.Account ==act)return p;
    p = NULL;
    return p;
};
UserInfor_Node* myDatabase::search_userP_by_Accont(Account &act)
{
    UserInfor_Node* p;
    int i = Userlist_ALL_P->getlen();
    for(int j =1;j<i;j++)
    {
        p = Userlist_ALL_P->GetI(j);
        if(p->data.Accont==act)
        {
            return p;
        }
    }
    p = Userlist_ALL_P->GetI(i);
    if(p->data.Accont==act)return p;
    p = NULL;
    return p;
};
Oder_Node* myDatabase::search_OderP_by_OderCode(OderCode &code)
{
    Oder_Node* p;
    int i = Oderlist_ALL_P->getlen();
    for(int j = 1;j<i;j++)
    {
        p = Oderlist_ALL_P->GetI(j);
        if(p->data.OderNum==code)
        {
            return p;
        }
    }
    p = Oderlist_ALL_P->GetI(i);
    if(p->data.OderNum ==code)return p;
    p = NULL;
    return p;
};

在这里,主要是为了实现数据的长久储存(吐槽一下为什么不让用数据库),这里偷懒,采用启动程序直接把数据读到内存里,处理完再覆盖上去的方式。没有考虑数据量太大怎么办,毕竟目的是能跑就行。

然后实现了一些查找功能,便于之后编写。

在这一层极力把对指针的操作封死在此处,减轻上层的思考负担,专注于业务的编写

Service

Service.h

#pragma once
#include "myDatabase.h"
class Service
{
    protected:
        
    public:
        myDatabase *DataBase;
        OderDisplay_list *Display_list_oder;//订单展示的链表
        //展示链表:一个记录了所需要展示的信息的指针的链表,信息还是存在database里的四个链表内,
        //相当于在database的链表内查询到要展示的结点,返回一个指向这些结点的指针储存在这个显示链表内
        //信息真实的存储地址还是database链表内的结点处
        
        Service();
        ~Service();
        //产生订单唯一订单号
        tm* TimeGetor();//获取当前时间信息集
        void add0(std::string &str,int n);//把字符串格式的数字修改成应该的n位
        Time time_tm2Time(tm *ltm);//把数字时间信息转成Time
        DayYear dayer_tm2Dayear(tm *ltm);//把数字年月转成Dayear
        int randomint();
        OderCode Creat_OderCode(const Time &tim, const DayYear &dyr);
        
        virtual void AllOder_Pushin()=0;//清空展示链表,同时把 所有订单信息|该账号相关的所有订单信息 压入展示链表
        virtual void searchOderbyOderCode_Pushiin(OderCode &code)=0;//按订单号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入展示链表
        virtual void searchOderbytime_Pushin(int year,int month)=0;//按年月在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入展示链表
        virtual void searchOderbySenderPhone_Pushin(Phone &pho)=0;//按发送者的手机号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入显示链栈
        virtual void searchOderbyReciverPhone_Pushin(Phone &pho)=0;//按接收者的手机号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入显示链栈
};
#include "Service.h"

Service::Service()
{
    DataBase = new myDatabase;
    Display_list_oder = new OderDisplay_list;
}
Service::~Service()
{
    delete DataBase;
    delete Display_list_oder;
}

tm* Service::TimeGetor()
{
    time_t now = time(0);
    tm*ltm = localtime(&now);
    return ltm;
};


Time Service::time_tm2Time(tm *ltm)
{   
    std::string hour = std::to_string(ltm->tm_hour);
    std::string min = std::to_string(ltm->tm_min);
    std::string sec = std::to_string(ltm->tm_sec);
    add0(hour,2);add0(min,2);add0(sec,2);
    std::string temp = hour+min+sec;
    Time res = temp;
    return res; 
};//把数字时间信息转成Time
        
DayYear Service::dayer_tm2Dayear(tm *ltm)
{   std::string year = std::to_string(ltm->tm_year+1900);
    std::string month =std::to_string(ltm->tm_mon+1);
    std::string day = std::to_string(ltm->tm_mday);
    add0(year,4);add0(month,2);add0(day,2);
    std::string temp = year+month+day;
    DayYear res = temp;
    return res;
};//把数字年月转成Dayear

void Service::add0(std::string &str,int n)
{
    int round = str.length();
    if(round>=n)return;
    if(round<n)
    {
        std::string tem = "0";
        for(round;round<n-1;round++)
        {
            tem+="0";
        }
        std::string res = tem+str;
        str = res;
    }
};
int Service::randomint()
{
    srand(unsigned(time(NULL)));
    int a = 1+(int)9999*rand()/(RAND_MAX+1);
    return a;
};
OderCode Service::Creat_OderCode(const Time &tim,const DayYear &dyr)
{
    std::string radomnum = std::to_string(randomint());
    add0(radomnum,4);
    std::string time = tim;
    std::string dyrear = dyr;
    std::string res = "FURRY"+dyrear+time+radomnum;
    OderCode odco = res;
    return odco;
}

这一层是服务类的抽象类,用纯虚函数把这一层指定成接口类,用来写User和Admin共有的一些方法。

Service_User

Service_User.h

#pragma once
#include "Service.h"
class Service_User :
    public Service
{
    public:
        UserInfor_Node* User;
        //特有的一个展示队列
        AddressDisplay_list* Display_list_address;
        Service_User();
        ~Service_User();
        //账号相关操作
        bool login(Account &act,PassWord &psw);
        bool regist(Account &act,PassWord &psw,NickName &nic,Phone &pho);
        void changePassword(PassWord &newPsw);
        void changeNickname(NickName &newNic);
        void Recharge(double money);
        //地址簿相关操作
        void Refresh_Display_list_address();//对地址信息展示栈的操作,刷新并展示此账号关联的地址信息
        void Add_Address(RealName &name,Phone &pho,Address &Address);
        void Del_Address(AddressInfor_Node* p);
        void Change_Address(AddressInfor_Node* p,AddressInfor &ifor);
        //订单相关操作
        double culculator(int kinds,double weight);
        Oder_Node* Add_Oder(AddressInfor_Node* sender,AddressInfor_Node* recevier,int kinds,Note notes,double price);//下订单
        void Confirm_Oder(Oder_Node* p);
            //订单查询业务
        void AllOder_Pushin();//清空展示链表,同时把该账号相关的所有订单信息 压入展示链表
        void searchOderbyOderCode_Pushiin(OderCode &code);//按订单号在该账号相关的所有订单信息 中查询记录并压入展示链表
        void searchOderbytime_Pushin(int year,int month);//按年月在该账号相关的所有订单信息 中查询记录并压入展示链表
        void searchOderbySenderPhone_Pushin(Phone &pho);//按发送者的手机号在该账号相关的所有订单信息 中查询记录并压入显示链栈
        void searchOderbyReciverPhone_Pushin(Phone &pho);//按接收者的手机号在该账号相关的所有订单信息 中查询记录并压入显示链栈
};

Service_User.cpp

#include "Service_User.h"
Service_User::Service_User()
{   
    Display_list_address = new AddressDisplay_list;
    User = NULL;
};
Service_User::~Service_User()
{
    delete Display_list_address;
    User = NULL;
}
bool Service_User::login(Account &act,PassWord &psw)
{
    UserInfor_Node *p = DataBase->search_userP_by_Accont(act);
    if(p!=NULL)
    {
        if(p->data.PassWord==psw)
        {
            this->User = p;
            return true;
        }
        else 
        return false;
    }
    else 
    return false;
};
bool Service_User::regist(Account &act,PassWord &psw,NickName &nic,Phone &pho)
{
    UserInfor_Node *p = DataBase->search_userP_by_Accont(act);
    if(p!=NULL)return false;
    UserInfor userdata = {act,pho,psw,nic,0};
    UserInfor_Node* res = new UserInfor_Node(userdata);
    DataBase->Userlist_ALL_P->PushBack(res);
    return true; 
};
void Service_User::changePassword(PassWord &newPsw)
{
    User->data.PassWord = newPsw;
};        
void Service_User::changeNickname(NickName &newNic)
{
    User->data.NickName = newNic;
};
void Service_User::Recharge(double money)
{
    User->data.money+=money;
};

void Service_User::Refresh_Display_list_address()
{
    Display_list_address->clear();//清空显示栈
    AddressInfor_Node* p;
    int len = DataBase->Addreslist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Addreslist_ALL_P->GetI(i);
        if(p->data.relateAccont == User->data.Accont)
        {
            AddressPointor_Node *pt = new AddressPointor_Node(p);
            Display_list_address->PushBack(pt);//压入显示栈
        }
    }
};

void Service_User::Add_Address(RealName &name,Phone &pho,Address &Address)
{
    AddressInfor adinfo = {User->data.Accont,name,pho,Address};
    AddressInfor_Node *adrNode = new AddressInfor_Node(adinfo);
    DataBase->Addreslist_ALL_P->PushBack(adrNode);
}

void Service_User::Del_Address(AddressInfor_Node* p)
{
    int index = DataBase->Addreslist_ALL_P->Getindex(p);
    DataBase->Addreslist_ALL_P->DelI(index);
};

void Service_User::Change_Address(AddressInfor_Node* p,AddressInfor &ifor)
{
    p->data = ifor;
};

double Service_User::culculator(int kinds,double weight)//1:FRAGILLE 2:BOOK 3:NOMALL
{
    if (kinds == FRAGILLE)
    {
        return weight * FRAGILLE_PRICE;
    }
    else if (kinds == BOOK)
    {
        return weight * BOOK_PRICE;
    }
    else if (kinds == NORMAL)
    {
        return weight * NORMAL_PRICE;
    }
    else
        return 0;
}
Oder_Node* Service_User::Add_Oder(AddressInfor_Node* sender,AddressInfor_Node* recevier,int kinds,Note notes,double price)
{
    tm* ltm = TimeGetor();
    Time time_mine = time_tm2Time(ltm);
    DayYear dayer = dayer_tm2Dayear(ltm);
    OderCode code = Creat_OderCode(time_mine,dayer);
    Timess timess(ltm);
    Status statucode;
    statucode.num1 = 1;
    statucode.time1 = timess;
    OderInfor data;
    data.OderNum = code;
    data.relateAccont = User->data.Accont;
    data.Sender = sender->data;
    data.Recevier = recevier->data;
    data.StatuCode = statucode;
    data.Kinds = kinds;
    data.Price = price;
    data.hadRecharged = 0;
    data.notes = notes;

    Oder_Node *Node = new Oder_Node(data);
    DataBase->Oderlist_ALL_P->PushBack(Node);//把新的数据压入数据库
    return Node;
};

void Service_User::Confirm_Oder(Oder_Node* p)
{
    tm* ltm = TimeGetor();
    p->data.StatuCode.num4 = 1;
    p->data.StatuCode.time4.year = ltm->tm_year+1900;
    p->data.StatuCode.time4.month = ltm->tm_mon+1;
    p->data.StatuCode.time4.day = ltm->tm_mday;
    p->data.StatuCode.time4.hour = ltm->tm_hour;
    p->data.StatuCode.time4.minute = ltm->tm_min;
    p->data.StatuCode.time4.sec = ltm->tm_sec;
};

void Service_User::AllOder_Pushin()
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {   
        p = DataBase->Oderlist_ALL_P->GetI(i);
        if(p->data.relateAccont==User->data.Accont)
        {
            OderPointor_Node *pt = new OderPointor_Node(p);
            Display_list_oder->PushBack(pt);
        }
    }
}

void Service_User::searchOderbyOderCode_Pushiin(OderCode &code)
{
    Display_list_oder->clear();
    Oder_Node* p=DataBase->search_OderP_by_OderCode(code);
    if(p!= NULL&&p->data.relateAccont==User->data.Accont)
    {   
        OderPointor_Node *pt = new OderPointor_Node(p);
        Display_list_oder->PushBack(pt);   
    }
};

void Service_User::searchOderbytime_Pushin(int year,int month)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        if(p->data.relateAccont==User->data.Accont)
        {
            int ye = p->data.StatuCode.time1.year;
            int mo = p->data.StatuCode.time1.month;
            if(ye==year&&mo==month)
            {
                OderPointor_Node *pt = new OderPointor_Node(p);
                Display_list_oder->PushBack(pt);
            }
        }
    }
};

void Service_User::searchOderbySenderPhone_Pushin(Phone &pho)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        if(p->data.relateAccont==User->data.Accont)
        {
            Phone phone = p->data.Sender.Phone;
            if(phone == pho)
            {
                OderPointor_Node *pt = new OderPointor_Node(p);
                Display_list_oder->PushBack(pt);
            }
        }
    }
};

void Service_User::searchOderbyReciverPhone_Pushin(Phone &pho)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        if(p->data.relateAccont==User->data.Accont)
        {
            Phone phone = p->data.Recevier.Phone;
            if(phone == pho)
            {
                OderPointor_Node *pt = new OderPointor_Node(p);
                Display_list_oder->PushBack(pt);
            }
        }
    }
};

对于User能干的事情进行了详细的编写,最终前端调用只创建Service_User对象并调用其中函数即可。

Service_Admin

Service_Admin.h

#pragma once
#include "Service.h"
class Service_Admin :
    public Service
{
    public:
        AdministratorInfor_Node* Admin;
   
        Service_Admin();
        ~Service_Admin();
        bool login(Account &act,PassWord &psw);
        void RecivedGoods(Oder_Node* p);
        void ArrivedGoods(Oder_Node* p);
        void getmoney();

        void AllOder_Pushin();//清空展示链表,同时把 所有订单信息|该账号相关的所有订单信息 压入展示链表
        void searchOderbyOderCode_Pushiin(OderCode &code);//按订单号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入展示链表
        void searchOderbytime_Pushin(int year,int month);//按年月在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入展示链表
        void searchOderbySenderPhone_Pushin(Phone &pho);//按发送者的手机号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入显示链栈
        void searchOderbyReciverPhone_Pushin(Phone &pho);//按接收者的手机号在 所有订单信息|该账号相关的所有订单信息 中查询记录并压入显示链栈

};

Service_Admin.cpp

#include "Service_Admin.h"
Service_Admin::Service_Admin()
{
    Admin = NULL;
};
Service_Admin::~Service_Admin()
{
    Admin = NULL;
}
bool Service_Admin::login(Account &act,PassWord &psw)
{
    AdministratorInfor_Node* p = DataBase->search_adminP_by_Accont(act);
    if(p!=NULL)
    {
        if(p->data.PassWord==psw)
        {
            this->Admin = p;
            return true;
        }
        else 
        return false;
    }
    else 
    return false;
}

void Service_Admin::RecivedGoods(Oder_Node* p)
{
    tm* ltm = TimeGetor();
    p->data.StatuCode.num2 = 1;
    p->data.StatuCode.time2.year = ltm->tm_year+1900;
    p->data.StatuCode.time2.month = ltm->tm_mon+1;
    p->data.StatuCode.time2.day = ltm->tm_mday;
    p->data.StatuCode.time2.hour = ltm->tm_hour;
    p->data.StatuCode.time2.minute = ltm->tm_min;
    p->data.StatuCode.time2.sec = ltm->tm_sec;
};

void Service_Admin::ArrivedGoods(Oder_Node* p)
{
    tm* ltm = TimeGetor();
    p->data.StatuCode.num3 = 1;
    p->data.StatuCode.time3.year = ltm->tm_year+1900;
    p->data.StatuCode.time3.month = ltm->tm_mon+1;
    p->data.StatuCode.time3.day = ltm->tm_mday;
    p->data.StatuCode.time3.hour = ltm->tm_hour;
    p->data.StatuCode.time3.minute = ltm->tm_min;
    p->data.StatuCode.time3.sec = ltm->tm_sec;
};
void Service_Admin::getmoney()
{   
    if(Admin==NULL)return;
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    double money  = 0;
    for(int i =1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        int a = p->data.hadRecharged;
        int b = p->data.StatuCode.num4;
        if(a==0&&b==1)
        {
            p->data.hadRecharged = 1;
            money+=p->data.Price;
        }
    }
    Admin->data.money+=money;
}

//查询操作
void Service_Admin::AllOder_Pushin()
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        OderPointor_Node *pt = new OderPointor_Node(p);
        Display_list_oder->PushBack(pt);
    }
}

void Service_Admin::searchOderbyOderCode_Pushiin(OderCode &code)
{
    Display_list_oder->clear();
    Oder_Node* p=DataBase->search_OderP_by_OderCode(code);
    if(p!= NULL)
    {   
        OderPointor_Node *pt = new OderPointor_Node(p);
        Display_list_oder->PushBack(pt);   
    }
};

void Service_Admin::searchOderbytime_Pushin(int year,int month)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        int ye = p->data.StatuCode.time1.year;
        int mo = p->data.StatuCode.time1.month;
        if(ye==year&&mo==month)
        {
            OderPointor_Node *pt = new OderPointor_Node(p);
            Display_list_oder->PushBack(pt);
        }
    }
};

void Service_Admin::searchOderbySenderPhone_Pushin(Phone &pho)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        Phone phone = p->data.Sender.Phone;
        if(phone == pho)
        {
            OderPointor_Node *pt = new OderPointor_Node(p);
            Display_list_oder->PushBack(pt);
        }
    }
};

void Service_Admin::searchOderbyReciverPhone_Pushin(Phone &pho)
{
    Display_list_oder->clear();
    Oder_Node* p;
    int len = DataBase->Oderlist_ALL_P->getlen();
    for(int i = 1;i<=len;i++)
    {
        p = DataBase->Oderlist_ALL_P->GetI(i);
        Phone phone = p->data.Recevier.Phone;
        if(phone == pho)
        {
            OderPointor_Node *pt = new OderPointor_Node(p);
            Display_list_oder->PushBack(pt);
        }
    }
};

对于Admin能干的事情进行了详细的编写,最终前端调用只创建Service_Admin对象并调用其中函数即可。

前端交互

在这里面,主要是对展示链表内数据的解析以及调用后端暴露出的接口函数,并把一些简单的判错逻辑实现掉。还有就是界面的展示。

windows

windows.h

#pragma once
#include "config.h"
#include "Service_User.h"
#include "Service_Admin.h"
using namespace std;
void window_welcome();
void window_Userlogin();
void window_Adminlogin();
void window_Regist();

void window_UserPlatform(Service_User &ser_user);
void window_AdminPlatform(Service_Admin &ser_adim);


void window_OderManage(Service_Admin &ser_adim,int now);
void window_OderManage(Service_User &ser_user,int now);

void frame_DisplayOder(OderPointor_Node *oderP,int ind);
void Detail_DisplayOder(Oder_Node* p);

void window_addressManage(Service_User &ser_user,int now);
void frame_DisplayAddress(AddressInfor_Node *adrsP,int ind);

#include "windows.h"
void window_welcome()
{
    cout<<"             ======================FURRYTMS========================="<<endl;
    cout<<"             =                欢迎使用物流管理系统                   ="<<endl;
    cout<<"             =                   用户登录请扣1                      ="<<endl;
    cout<<"             =                  管理员登录请扣2                     ="<<endl;
    cout<<"             =                     注册请扣3                        ="<<endl;
    cout<<"             =                     退出请扣0                        ="<<endl;
    cout<<"             ======================FURRYTMS========================="<<endl;
}


void window_Userlogin()
{
    cout<<"             ======================FURRYTMS========================="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             =                     用户登录                         ="<<endl;
    cout<<"             =                     继续请扣1                        ="<<endl;
    cout<<"             =                     返回请扣0                        ="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             ======================FURRYTMS========================="<<endl;
}
void window_Adminlogin()
{
    cout<<"             ======================FURRYTMS========================="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             =                     管理员登录                       ="<<endl;
    cout<<"             =                     继续请扣1                        ="<<endl;
    cout<<"             =                     返回请扣0                        ="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             ======================FURRYTMS========================="<<endl;
};
void window_Regist()
{
    cout<<"             ======================FURRYTMS========================="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             =                 欢迎使用FURRYTMS!                   ="<<endl;
    cout<<"             =                  即将为您注册账号                     ="<<endl;
    cout<<"             =                     继续请扣1                        ="<<endl;
    cout<<"             =                     返回请扣0                        ="<<endl;
    cout<<"             =                                                     ="<<endl;
    cout<<"             ======================FURRYTMS========================="<<endl;
};
void window_UserPlatform(Service_User &ser_user)
{
    NickName n = ser_user.User->data.NickName;
    double m = ser_user.User->data.money;
    cout<<"===================================FURRYTMS==================================="<<endl;
    cout<<" 你好,"<<n<<"!"<<"         ~( ̄▽ ̄~)(~ ̄▽ ̄)~              账户余额:"<<m<<endl;        
    cout<<"=             我的快递[1]                               下订单[2]              ="<<endl;
    cout<<"=             我的地址簿[3]                              充值[4]               ="<<endl;
    cout<<"=             修改密码[5]                               修改昵称[6]            ="<<endl;
    cout<<"=                                 退出程序[0]                                 ="<<endl;
    cout<<"===================================FURRYTMS==================================="<<endl;
};

void window_AdminPlatform(Service_Admin &ser_adim)
{
    NickName n = ser_adim.Admin->data.NickName;
    double m = ser_adim.Admin->data.money;
    cout<<"===================================FURRYTMS==================================="<<endl;
    cout<<" 你好,"<<n<<"!"<<"                                           账户余额:"<<m<<endl;        
    cout<<"=                                                                            "<<endl;
    cout<<"=            管理快递[1]                                                                 "<<endl;
    cout<<"=                                              ヽ(`д´)ノ                              "<<endl;
    cout<<"=            退出系统[0]                                                                "<<endl;
    cout<<"=                                                                            "<<endl;
    cout<<"=                                                                         @管理员平台 "<<endl;
    cout<<"===================================FURRYTMS==================================="<<endl;
};


void frame_DisplayOder(OderPointor_Node *oderP,int ind)
{   OderCode odcod = oderP->data->data.OderNum;
    RealName senNa = oderP->data->data.Sender.name;
    RealName recNa = oderP->data->data.Recevier.name;
    string   statu;
    Status st = oderP->data->data.StatuCode;
    if(st.num1==1&&st.num2==0&&st.num3==0&&st.num4==0){statu = "代取件";}
    else if (st.num1==1&&st.num2==1&&st.num3==0&&st.num4==0){statu = "运输中";}
    else if (st.num1==1&&st.num2==1&&st.num3==1&&st.num4==0){statu = "代取件";}
    else if (st.num1==1&&st.num2==1&&st.num3==1&&st.num4==1){statu = "已完成";}
    else {statu = "未知";}
    int year = st.time1.year;
    cout<<"------------------------------------Oder-------------------------------------"<<endl;
    cout<<"|"<<ind<<"、                                                                        "<<endl;
    cout<<"|订单号:"<<odcod<<"                                                                    "<<endl;
    cout<<"|发件人:"<<senNa<<"                                                                           "<<endl;
    cout<<"|收件人:"<<recNa<<"                                                                       ="<<endl;
    cout<<"|当前状态:"<<statu<<"                                                                      @管理员平台 ="<<endl;
    cout<<"|下单时间:"<<st.time1.year<<st.time1.month<<st.time1.day<<st.time1.hour<<st.time1.minute<<"                                                                      @管理员平台 ="<<endl;
    cout<<"------------------------------------FURRYTMS--------------------------------"<<endl;
};
void frame_DisplayAddress(AddressInfor_Node *adrsP,int ind)
{  
    
    cout<<"-"<<ind<<"----------------------------------Address-------------------------------------"<<endl;
    cout<<"|姓名:"<<adrsP->data.name<<endl;
    cout<<"|手机号:"<<adrsP->data.Phone<<endl;
    cout<<"|地址:"<<adrsP->data.Address<<endl;
    cout<<"------------------------------------FURRYTMS--------------------------------"<<endl;
};
void window_OderManage(Service_Admin &ser_adim,int now)
{
    int len = ser_adim.Display_list_oder->getlen();
    int allPage = len/4+1;
    int round = 0;
    if(allPage>now)round = 4;
    else round = len%4;
    cout<<"===================================FURRYTMS==================================="<<endl;
    if(ser_adim.Display_list_oder->isEmpty())
    {
    cout<<"===================================Fund Nothing==================================="<<endl;
    }
    else
    {
        for(int i  = 1;i<=round;i++)
    {
        int index = (now-1)*4+i;
        OderPointor_Node *p = ser_adim.Display_list_oder->GetI(index);
        frame_DisplayOder(p,i);   
    }
    }
    cout<<"                                                                          "<<now<<"/"<<allPage<<endl;
    cout<<"===================================FURRYTMS==================================="<<endl;
    cout<<"1~4查看订单详情并操作 5 展示全部订单信息 6 按订单号查找订单 7 按时间查找订单 8 按发件人手机号查找 "<<endl;
    cout<<"9 按收件人手机号查找订单信息 0 返回上一级 11 向前翻页 22 向后翻页"<<endl;
};
void window_OderManage(Service_User &ser_user,int now)
{
    int len = ser_user.Display_list_oder->getlen();
    int allPage = len/4+1;
    int round = 0;
    if(allPage>now)round = 4;
    else round = len%4;
    cout<<"===================================FURRYTMS==================================="<<endl;
    if(ser_user.Display_list_oder->isEmpty())
    {
    cout<<"===================================Fund Nothing==================================="<<endl;
    }
    else
    {
        for(int i  = 1;i<=round;i++)
    {
        int index = (now-1)*4+i;
        OderPointor_Node *p = ser_user.Display_list_oder->GetI(index);
        frame_DisplayOder(p,i);   
    }
    }
    cout<<"                                                                          "<<now<<"/"<<allPage<<endl;
    cout<<"===================================FURRYTMS==================================="<<endl;
    cout<<"1~4查看订单详情并操作 5 展示全部订单信息 6 按订单号查找订单 7 按时间查找订单 8 按发件人手机号查找 "<<endl;
    cout<<"9 按收件人手机号查找订单信息 0 返回上一级 11 向前翻页 22 向后翻页"<<endl;
};
void window_addressManage(Service_User &ser_user,int now)
{
    int len = ser_user.Display_list_address->getlen();
    int allPage = len/4+1;
    int round = 0;
    if(allPage>now)round = 4;
    else round = len%4;
    cout<<"===================================FURRYTMS==================================="<<endl;
    if(ser_user.Display_list_address->isEmpty())
    {
    cout<<"===================================Fund Nothing==================================="<<endl;
    }
    else
    {
        for(int i  = 1;i<=round;i++)
    {
        int index = (now-1)*4+i;
        AddressInfor_Node *p = ser_user.Display_list_address->GetI(index)->data;
        
        frame_DisplayAddress(p,index);   
    }
    }
    cout<<"                                                                          "<<now<<"/"<<allPage<<endl;
    cout<<"===================================FURRYTMS==================================="<<endl;
    cout<<"扣1新建地址           扣2删除地址                扣3修改地址             扣0返回上一级"<<endl;
    cout<<"          扣4上一页                                          扣5下一页             "<<endl;
};
void Detail_DisplayOder(Oder_Node *oderP)
{
    OderCode odcod = oderP->data.OderNum;
    RealName senNa = oderP->data.Sender.name;
    RealName recNa = oderP->data.Recevier.name;
    string   statu;
    Status st = oderP->data.StatuCode;
    if(st.num1==1&&st.num2==0&&st.num3==0&&st.num4==0){statu = "代取件";}
    else if (st.num1==1&&st.num2==1&&st.num3==0&&st.num4==0){statu = "运输中";}
    else if (st.num1==1&&st.num2==1&&st.num3==1&&st.num4==0){statu = "代取件";}
    else if (st.num1==1&&st.num2==1&&st.num3==1&&st.num4==1){statu = "已完成";}
    else {statu = "未知";}
    string kinddds;
    int kinds = oderP->data.Kinds;
    if (kinds == FRAGILLE)
    {
        kinddds = "易碎品";
    }
    else if (kinds == BOOK)
    {
        kinddds = "书籍";
    }
    else if (kinds == NORMAL)
    {
        kinddds = "普通货物";
    }
    int year = st.time1.year;
    cout<<"------------------------------------Oder-------------------------------------"<<endl;
    cout<<"|订单号:"<<odcod<<"                                                                    "<<endl;
    cout<<"|关联账户:"<<oderP->data.relateAccont<<"                                                                           "<<endl;
    cout<<"|发件人:"<<senNa<<"                                                                           "<<endl;
    cout<<"|发件人手机号:"<<oderP->data.Sender.Phone<<"                                                                           "<<endl;
    cout<<"|收件人:"<<recNa<<"                                                                       ="<<endl;
    cout<<"|收件人手机号:"<<oderP->data.Recevier.Phone<<"                                                                           "<<endl;
    cout<<"|当前状态:"<<statu<<"                                                                       ="<<endl;
    cout<<"|下单时间:"<<st.time1.year<<st.time1.month<<st.time1.day<<st.time1.hour<<st.time1.minute<<"     ="<<endl;
    cout<<"|种类:"<<kinddds<<"                                                                       ="<<endl;
    cout<<"|运费:"<<oderP->data.Price<<"                                                                      "<<endl;
    cout<<"|备注:"<<oderP->data.notes<<"                                                         @管理员平台 ="<<endl;
    cout<<"------------------------------------FURRYTMS--------------------------------"<<endl;
    
};

数据的最终解析与展示,还有界面

cmdApp

cmdApp.h

#pragma once
#include "Service_User.h"
#include "Service_Admin.h"
#include "windows.h"
using namespace std;

void run();
void welcome(Service_Admin &ser_adim,Service_User &ser_user,int &wh);
bool Userlogin(Service_Admin &ser_adim,Service_User &ser_user,int &wh);
bool Adminlogin(Service_Admin &ser_adim,Service_User &ser_user,int &wh);
bool UserRegist(Service_User &ser_user);



void Oderdetail(Service_Admin &ser_adim,Oder_Node *node);//admin用的订单查询

void Oderdetail(Service_User &ser_user,Oder_Node *node);//admin用的订单查询

void userPlatform(Service_User &ser_user);
void UserOderManage(Service_User &ser_user);
void UserAdresManage(Service_User &ser_user);

void adminPlatform(Service_Admin &ser_adim);
void AdminOderManage(Service_Admin &ser_adim);

void showAddress_simple(Service_User &ser_user);
void addOder(Service_User& ser_user);
#include "cmdApp.h"

void run()
{
    Service_Admin service_Admin;
    Service_User service_User;
    int who = 0;
    welcome(service_Admin,service_User,who);
    if(who ==1)//进到用户界面
    {
        userPlatform(service_User);
        service_User.DataBase->saveAll();
        return;

    }
    else if (who ==2)//进到管理员界面
    {
        adminPlatform(service_Admin);
        service_Admin.DataBase->saveAll();
        return;
    }

}
void welcome(Service_Admin &ser_adim,Service_User &ser_user,int& wh)
{
    window_welcome();//界面
    cout<<"请输入0-3:";
    int input = 0;//操作数
    while(cin>>input)
    {   
        if(input<0||input>3)
        {
            cout<<"错误输入,请重新输入0-3"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {
                bool t = Userlogin(ser_adim,ser_user,wh);
                if(t)return;
                break;
            }
            case 2:
            {
                bool t = Adminlogin(ser_adim,ser_user,wh);
                if(t)return;
                break;
            }
            case 3:
            {
                bool t = UserRegist(ser_user);
                break;
            }
            case 0:
            {
                cout<<"byebye~"<<endl;
                return;
            }
        }
        window_welcome();//界面
        cout<<"请输入0-3:";
    }

}

bool UserRegist(Service_User &ser_user)
{
    window_Regist();
    int input = 0;//操作数
    cout<<"请输入0-1:";
    while(cin>>input)
    {   
        if(input<0||input>1)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {   
                string actt;
                string psww;
                string nic;
                string pho;
                cout<<"请输入账号:";cin>>actt;cout<<endl;
                cout<<"请输入密码:";cin>>psww;cout<<endl;
                cout<<"请输入昵称:";cin>>nic;cout<<endl;
                cout<<"请输入手机号:";cin>>pho;cout<<endl;
                Account act(actt);PassWord psw(psww);NickName niic(nic);Phone ph(pho);
                int res = ser_user.regist(act,psw,niic,ph);
                if(res == 1)
                {   
                    cout<<"注册成功!欢迎您 "<<endl;
                    ser_user.DataBase->saveAll();
                    return true;
                }
                else if (res==0)
                {
                    cout<<"此账号已被注册,请试试别的账号!"<<endl;
                    cout<<"请输入0-1:";
                    break;   
                }
            }
            
            case 0:
            {
                return false;
            }
        }
        window_Regist();//界面
        cout<<"请输入0-1"<<endl;
    }
}

bool Userlogin(Service_Admin &ser_adim,Service_User &ser_user,int &wh)
{
    window_Userlogin();
    int input = 0;//操作数
    cout<<"请输入0-1:";
    while(cin>>input)
    {   
        if(input<0||input>1)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {   
                string actt;
                string psww;
                cout<<"请输入账号:";cin>>actt;cout<<endl;
                cout<<"请输入密码:";cin>>psww;cout<<endl;
                Account act(actt);PassWord psw(psww);
                int res = ser_user.login(act,psw);
                if(res == 1)
                {   
                    cout<<"登录成功!欢迎您 "<<ser_user.User->data.NickName<<endl;
                    wh = 1;
                    return true;
                }
                else if (res==0)
                {
                    cout<<"账号或密码错误,请重新输入!"<<endl;
                    cout<<"请输入0-1:";   
                }
                break;
            }
            
            case 0:
            {
                return false;
            }
        }
        window_Userlogin();//界面
        cout<<"请输入0-1";
    }
}
bool Adminlogin(Service_Admin &ser_adim,Service_User &ser_user,int &wh)
{
    window_Adminlogin();
    int input = 0;//操作数
    cout<<"请输入0-1:";
    while(cin>>input)
    {   
        if(input<0||input>2)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {   
                string actt;
                string psww;
                cout<<"请输入管理员账号:";cin>>actt;cout<<endl;
                cout<<"请输入密码:";cin>>psww;cout<<endl;
                Account act(actt);PassWord psw(psww);
                int res = ser_adim.login(act,psw);
                if(res == 1)
                {   
                    cout<<"登录成功!欢迎您 "<<ser_adim.Admin->data.NickName<<endl;
                    wh = 2;
                    return true;
                }
                else if (res==0)
                {
                    cout<<"账号或密码错误,请重新输入!"<<endl;
                    cout<<"请输入0-1:";   
                }
                break;
            }
            
            case 0:
            {
                return false;
            }
        }
        window_Adminlogin();//界面
        cout<<"请输入0-1";
    }
}

void userPlatform(Service_User &ser_user)
{
    window_UserPlatform(ser_user);//界面
    cout<<"请输入0~6:";
    int input = 0;//操作数
    while(cin>>input)
    {   
        if(input<0||input>6)
        {
            cout<<"错误输入,请重新输入0-6"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {
                UserOderManage(ser_user);
                break;
            }
            case 2:
            {   
                
                addOder(ser_user);
                break;
            }
            case 3:
            {

                UserAdresManage(ser_user);
                break;
            }
            case 4:
            {
                double money;
                cout<<"请输入你要充值的金额:";
                cin>>money;
                ser_user.Recharge(money);
                cout<<"充值完成!"<<endl;
                break;
            }
            case 5:
            {
                string pasw;
                cout<<"请输入您的新密码:";
                cin>>pasw;
                PassWord psw(pasw);
                ser_user.changePassword(psw);
                cout<<"密码修改完成!您的新密码是:"<<ser_user.User->data.PassWord<<endl;
                break;
            }
            case 6:
            {
                string newni;
                cout<<"请输入您的新昵称";
                cin>>newni;
                NickName nick(newni);
                ser_user.changeNickname(nick);
                cout<<"昵称修改完成,你好,"<<ser_user.User->data.NickName<<"!"<<endl;
                break;
            }
            case 0:
            {
                cout<<"byebye~"<<endl;
                return;
            }
        }
        window_UserPlatform(ser_user);//界面
        cout<<"请输入0-6:";
    }
};
void adminPlatform(Service_Admin &ser_adim)
{
    window_AdminPlatform(ser_adim);//界面
    cout<<"请输入0~1:";
    int input = 0;//操作数
    while(cin>>input)
    {   
        if(input<0||input>1)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {
                AdminOderManage(ser_adim);
                break;
            }
            case 0:
            {
                cout<<"byebye~"<<endl;
                return;
            }
        }
        window_AdminPlatform(ser_adim);//界面
        cout<<"请输入0-1:";
    }
};
void AdminOderManage(Service_Admin &ser_adim)
{
    // int lenth;
    // int alPage;
    // int lenth = ser_adim.Display_list_oder->getlen();
    // int alPage = lenth/4 +1;
    // int now;
    int now = 1;
    ser_adim.AllOder_Pushin();
    window_OderManage(ser_adim,now);//界面
    cout<<"请输入0~9,11 or 22:";
    int input = 0;//操作数
    while(cin>>input)
    {  
        if(input<0||input>9)
        {   
            if (input!=11||input!=22)
            {
                cout<<"错误输入,请重新输入0-9"<<endl;
                continue;
            }
        }
        switch (input)
        {
            case 1:
            {
                Oder_Node* p = ser_adim.Display_list_oder->GetI((now-1)*4+1)->data;
                Oderdetail(ser_adim,p);
                break;
            }
            case 2:
            {
                Oder_Node* p = ser_adim.Display_list_oder->GetI((now-1)*4+2)->data;
                Oderdetail(ser_adim,p);
                break;
            }
            case 3:
            {
                Oder_Node* p = ser_adim.Display_list_oder->GetI((now-1)*4+3)->data;
                Oderdetail(ser_adim,p);
                break;
            }
            case 4:
            {
                Oder_Node* p = ser_adim.Display_list_oder->GetI((now-1)*4+4)->data;
                Oderdetail(ser_adim,p);
                break;
            }
            case 5:
            {
                now = 1;
                ser_adim.AllOder_Pushin();
                break;
            }
            case 6:
            {
                now = 1;
                cout<<"请输入订单号:";
                string tem;
                cin>>tem;
                cout<<endl;
                OderCode odc(tem);
                ser_adim.searchOderbyOderCode_Pushiin(odc);
                break;
            }
            case 7:
            {
                
                now = 1;
                int year;int month;
                cout<<"请输入年份:";
                cin>>year;
                cout<<"请输入月份:";
                cin>>month;
                ser_adim.searchOderbytime_Pushin(year,month);
                break;
            }
            case 8:
            {
                now = 1;
                string ph;
                cout<<"请输入发件人的手机号";
                cin>>ph;
                Phone phon(ph);
                ser_adim.searchOderbySenderPhone_Pushin(phon);
                break;
            }
            case 9:
            {
                
                string ph;
                now = 1;
                cout<<"请输入收件人的手机号";
                cin>>ph;
                Phone phon(ph);
                ser_adim.searchOderbyReciverPhone_Pushin(phon);
                break;
            }
            case 11:
            {   if(now-1>0)
                    now--;
                else
                cout<<"已经是第一页啦~"<<endl;
                break;
            }
            case 22:
            {
                if(now+1>ser_adim.Display_list_oder->getlen()/4+1)
                    now++;
                else
                cout<<"已经是最后一页啦~"<<endl;
                break;
            }
            case 0:
            {
                return;
            }
        }
        window_OderManage(ser_adim,now);//界面
        cout<<"请输入0-9,11or12:";
    }
};
void UserOderManage(Service_User &ser_user)
{
    // int lenth;
    // int alPage;
    // int lenth = ser_adim.Display_list_oder->getlen();
    // int alPage = lenth/4 +1;
    // int now;
    int now = 1;
    ser_user.AllOder_Pushin();
    window_OderManage(ser_user,now);//界面
    cout<<"请输入0~9,11 or 22:";
    int input = 0;//操作数
    while(cin>>input)
    {  
        if(input<0||input>9)
        {   
            if (input!=11||input!=22)
            {
                cout<<"错误输入,请重新输入0-9"<<endl;
                continue;
            }
        }
        switch (input)
        {
            case 1:
            {
                Oder_Node* p = ser_user.Display_list_oder->GetI((now-1)*4+1)->data;
                Oderdetail(ser_user,p);
                break;
            }
            case 2:
            {
                Oder_Node* p = ser_user.Display_list_oder->GetI((now-1)*4+2)->data;
                Oderdetail(ser_user,p);
                break;
            }
            case 3:
            {
                Oder_Node* p = ser_user.Display_list_oder->GetI((now-1)*4+3)->data;
                Oderdetail(ser_user,p);
                break;
            }
            case 4:
            {
                Oder_Node* p = ser_user.Display_list_oder->GetI((now-1)*4+4)->data;
                Oderdetail(ser_user,p);
                break;
            }
            case 5:
            {
                now = 1;
                ser_user.AllOder_Pushin();
                break;
            }
            case 6:
            {
                now = 1;
                cout<<"请输入订单号:";
                string tem;
                cin>>tem;
                cout<<endl;
                OderCode odc(tem);
                ser_user.searchOderbyOderCode_Pushiin(odc);
                break;
            }
            case 7:
            {
                
                now = 1;
                int year;int month;
                cout<<"请输入年份:";
                cin>>year;
                cout<<"请输入月份:";
                cin>>month;
                ser_user.searchOderbytime_Pushin(year,month);
                break;
            }
            case 8:
            {
                now = 1;
                string ph;
                cout<<"请输入发件人的手机号";
                cin>>ph;
                Phone phon(ph);
                ser_user.searchOderbySenderPhone_Pushin(phon);
                break;
            }
            case 9:
            {
                
                string ph;
                now = 1;
                cout<<"请输入收件人的手机号";
                cin>>ph;
                Phone phon(ph);
                ser_user.searchOderbyReciverPhone_Pushin(phon);
                break;
            }
            case 11:
            {   if(now-1>0)
                    now--;
                else
                cout<<"已经是第一页啦~"<<endl;
                break;
            }
            case 22:
            {
                if(now+1>ser_user.Display_list_oder->getlen()/4+1)
                    now++;
                else
                cout<<"已经是最后一页啦~"<<endl;
                break;
            }
            case 0:
            {
                return;
            }
        }
        window_OderManage(ser_user,now);//界面
        cout<<"请输入0-9,11or12:";
    }
};
//
void UserAdresManage(Service_User &ser_user)
{
    int now = 1;
    ser_user.Refresh_Display_list_address();
    window_addressManage(ser_user,now);//界面
    cout<<"请输入0~9,11 or 22:";
    int input = 0;//操作数
    while(cin>>input)
    {  
        if(input<0||input>9)
        {   
            if (input!=11||input!=22)
            {
                cout<<"错误输入,请重新输入0-9"<<endl;
                continue;
            }
        }
        switch (input)
        {
            case 1:
            {
                string nam;
                string pho;
                string add;
                cout<<"请输入姓名:";cin>>nam;cout<<endl;
                cout<<"请输入手机号:";cin>>pho;cout<<endl;
                cout<<"请输入地址:";cin>>add;cout<<endl;
                RealName name(nam);
                Phone phone(pho);
                Address adres(add);
                ser_user.Add_Address(name,phone,adres);
                cout<<"新建地址信息完成";
                ser_user.Refresh_Display_list_address();
                now = 1;
                break;
            }
            case 2:
            {
                int index = 0;
                cout<<"请输入要删除的地址信息序号:";cin>>index;cout<<endl;
                if(index<1||index>ser_user.Display_list_address->getlen())
                {
                    cout<<"请输入正确的序号!"<<endl;
                    break;
                }
                AddressInfor_Node* p = ser_user.Display_list_address->GetI(index)->data;
                ser_user.Del_Address(p);
                cout<<"完成删除"<<endl;
                ser_user.Refresh_Display_list_address();
                now = 1;
                break;
            }
            case 3:
            {
                int index = 0;
                cout<<"请输入要修改的地址信息序号:";cin>>index;cout<<endl;
                if(index<1||index>ser_user.Display_list_address->getlen())
                {
                    cout<<"请输入正确的序号!"<<endl;
                    break;
                }
                AddressInfor_Node* p = ser_user.Display_list_address->GetI(index)->data;
                
                string nam;
                string pho;
                string add;
                cout<<"请输入姓名:";cin>>nam;cout<<endl;
                cout<<"请输入手机号:";cin>>pho;cout<<endl;
                cout<<"请输入地址:";cin>>add;cout<<endl;
                RealName name(nam);
                Phone phone(pho);
                Address adres(add);
                AddressInfor adrsif = {ser_user.User->data.Accont,name,phone,adres};
                ser_user.Change_Address(p,adrsif);
                cout<<"修改完成!" ;
                ser_user.Refresh_Display_list_address();
                now = 1;
                break;
            }
            case 4:
            {
                if(now-1>0)
                    now--;
                else
                cout<<"已经是第一页啦~"<<endl;
                break;
            }
            case 5:
            {
                if(now+1>ser_user.Display_list_oder->getlen()/4+1)
                    now++;
                else
                cout<<"已经是最后一页啦~"<<endl;
                break;
            }
            case 0:
            {
                return;
            }
        }
        window_addressManage(ser_user,now);//界面
        cout<<"请输入0-5:";
    }

};


void Oderdetail(Service_Admin &ser_adim,Oder_Node *node)
{
    Detail_DisplayOder(node);
    cout<<"[1]我已收到此货物                 [2]此货物已送达                  [0]返回上一级"<<endl;
    cout<<"请输入0~2:";
    int input = 0;//操作数
    while(cin>>input)
    {   
        if(input<0||input>2)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {
                int ket = 0;
                cout<<"确认操作? 1 or 0:";cin>>ket;
                if(ket)
                {ser_adim.RecivedGoods(node);
                cout<<"订单状态已修改"<<endl;
                }
                break;
            }
            case 2:
            {
                int ket = 0;
                cout<<"确认操作? 1 or 0:";cin>>ket;
                if(ket)
                {
                ser_adim.ArrivedGoods(node);
                cout<<"订单状态已修改"<<endl;
                }
                break; 
            }
            case 0:
            { 
                return;
            }
        }
        Detail_DisplayOder(node);
        cout<<"[1]我已收到此货物                 [2]此货物已送达                  [0]返回上一级"<<endl;
        cout<<"请输入0-2:";
    }
};

void Oderdetail(Service_User &ser_user,Oder_Node *node)//用户界面的订单详情
{
    Detail_DisplayOder(node);
    cout<<"[1]我已收到此货物                                                      [0]返回上一级"<<endl;
    cout<<"请输入0~1:";
    int input = 0;//操作数
    while(cin>>input)
    {   
        if(input<0||input>1)
        {
            cout<<"错误输入,请重新输入0-1"<<endl;
            continue;
        }
        switch (input)
        {
            case 1:
            {   int ket = 0;
                cout<<"确认操作? 1 or 0:";cin>>ket;
                if(ket)
                {
                cout<<"已确认收货,感谢您的信赖"<<endl;
                ser_user.Confirm_Oder(node);
                }
                break;
            }
            
            case 0:
            { 
                return;
            }
        }
        Detail_DisplayOder(node);
        cout<<"[1]我已收到此货物                 [2]此货物已送达                  [0]返回上一级"<<endl;
        cout<<"请输入0-2:";
    }
};

void showAddress_simple(Service_User &ser_user)
{
    ser_user.Refresh_Display_list_address();
    int i = ser_user.Display_list_address->getlen();
    for(int j = 1;j<=i;j++)
    {
        AddressInfor_Node *p = ser_user.Display_list_address->GetI(j)->data;

        cout<<j<<"、"<<"姓名:"<<p->data.name<<" 手机号:"<<p->data.Phone<<" 地址:"<<p->data.Address<<endl;
    }
};

void addOder(Service_User &ser_user)
{
    int kin;
    double weight;
    string notes;
    cout<<"请填写以下表单"<<endl;
    cout<<"请选择货物的类型: [1]易碎品 [2]书籍 [3]普通货物"<<endl;
    while(cin>>kin)
    {
        if(kin<1||kin>3)
        {   
            cout<<"请选择正确的货物种类"<<endl;
            cout<<"请选择货物的类型: [1]易碎品 [2]书籍 [3]普通货物"<<endl;
        }
        else
        break;
    }
    cout<<"请输入货物的重量/件数:";cin>>weight;
    int index1 = 0,index2 = 0;
    showAddress_simple(ser_user);
    cout<<"请选择发件人的地址信息:";
    while(cin>>index1)
    {
        if(index1>0&&index1<ser_user.Display_list_address->getlen())break;
        else
        {
            cout<<"请按地址簿序号正确填写"<<endl;
        }
    };
    showAddress_simple(ser_user);
    cout<<"请选择收件人的地址信息:";
    while(cin>>index2)
    {
        if(index2>0&&index2<ser_user.Display_list_address->getlen())break;
        else
        {
            cout<<"请按地址簿序号正确填写"<<endl;
        }
    };
    cout<<"请输入备注:"<<endl;cin>>notes;
    Note nots(notes);
    cout<<"正在生成订单..."<<endl;
    AddressInfor_Node* sender = ser_user.Display_list_address->GetI(index1)->data;    
    AddressInfor_Node* reciver = ser_user.Display_list_address->GetI(index2)->data;    

    double price = ser_user.culculator(kin,weight);
    Oder_Node* p = ser_user.Add_Oder(sender,reciver,kin,notes,price);
    cout<<"您的订单已生成,订单号是:"<<p->data.OderNum<<endl;
    cout<<"您稍后可在【我的订单】选项中查看订单状态"<<endl;
}

最长也是最shit山的一个,写完不想看第二眼。主要实现了页面跳转逻辑以及一些业务逻辑的处理。

在这里还实现了一个简单的分页功能,可以把展示链表里的内容分页展示,支持翻页,还是挺有趣的

总结

写的很shit,还是以记录为主。

记录下大二上学期的结束,记录下菜鸡的自己。

随便用,如果能帮到你留个言让我感动一下)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值