|
@@ -162,171 +162,40 @@ public:
|
|
|
|
|
|
|
|
std::string m_total_price_show;
|
|
std::string m_total_price_show;
|
|
|
|
|
|
|
|
- int getItemNum()
|
|
|
|
|
- {
|
|
|
|
|
- return m_items.size();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- std::string getTotalPriceShow()
|
|
|
|
|
- {
|
|
|
|
|
- return m_total_price_show;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- CDiandanOrderItem getDiandanOrderItem(int index)
|
|
|
|
|
- {
|
|
|
|
|
- return m_items[index];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //这个函数的逻辑是选择一个新商品的时候,与已有商品进行对比,看看是加一个新的商品,还是对已有商品增加数量
|
|
|
|
|
- //返回值是表示新加的item,在第几个元素,方便刷新显示
|
|
|
|
|
- int AddItem(CDiandanOrderItem newitem, bool& is_add_new)
|
|
|
|
|
- {
|
|
|
|
|
- int index = 0;
|
|
|
|
|
- bool is_found = false;
|
|
|
|
|
-
|
|
|
|
|
- for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
|
|
|
|
|
- {
|
|
|
|
|
- CDiandanOrderItem curItem = *it;
|
|
|
|
|
-
|
|
|
|
|
- if (curItem == newitem)
|
|
|
|
|
- {
|
|
|
|
|
- is_found = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- index++;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //如果找到了,更新数量
|
|
|
|
|
- if (is_found)
|
|
|
|
|
- {
|
|
|
|
|
- std::string old_num = m_items[index].num;
|
|
|
|
|
-
|
|
|
|
|
- double d_old_num = std::stod(old_num);
|
|
|
|
|
- double d_new_num = d_old_num + 1;
|
|
|
|
|
-
|
|
|
|
|
- //如果新的数量是一个整数,那么展示的时候就把小数去掉
|
|
|
|
|
- if (d_new_num - (int)d_new_num < 0.0001)
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = std::to_string((int)d_new_num);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = CLewaimaiString::DoubleToString(d_new_num, 3);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_items[index].UpdateShowPrice();
|
|
|
|
|
-
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
-
|
|
|
|
|
- is_add_new = false;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- //如果没找到,直接加一个新的item
|
|
|
|
|
- m_items.push_back(newitem);
|
|
|
|
|
-
|
|
|
|
|
- m_items[index].UpdateShowPrice();
|
|
|
|
|
-
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
|
|
+private:
|
|
|
|
|
+ //订单的整单备注
|
|
|
|
|
+ std::string m_memo;
|
|
|
|
|
|
|
|
- is_add_new = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+public:
|
|
|
|
|
|
|
|
- return index;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ int getItemNum();
|
|
|
|
|
|
|
|
- void UpdateItemGuige(int index, std::vector<FoodNatureSelectValue>& natureSelectedArray)
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].natureSelectedArray = natureSelectedArray;
|
|
|
|
|
|
|
+ std::string getTotalPriceShow();
|
|
|
|
|
|
|
|
- this->UpdateGuigePrice(index);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CDiandanOrderItem getDiandanOrderItem(int index);
|
|
|
|
|
|
|
|
- void UpdateTotalPriceShow()
|
|
|
|
|
- {
|
|
|
|
|
- double total_price_show = 0;
|
|
|
|
|
|
|
+ //这个函数的逻辑是选择一个新商品的时候,与已有商品进行对比,看看是加一个新的商品,还是对已有商品增加数量
|
|
|
|
|
+ //返回值是表示新加的item,在第几个元素,方便刷新显示
|
|
|
|
|
+ int AddItem(CDiandanOrderItem newitem, bool& is_add_new);
|
|
|
|
|
|
|
|
- for (std::vector<CDiandanOrderItem>::iterator it = m_items.begin(); it != m_items.end(); it++)
|
|
|
|
|
- {
|
|
|
|
|
- total_price_show += std::stod((*it).show_price);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void UpdateItemGuige(int index, std::vector<FoodNatureSelectValue>& natureSelectedArray);
|
|
|
|
|
|
|
|
- m_total_price_show = CLewaimaiString::DoubleToString(total_price_show, 2);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void UpdateTotalPriceShow();
|
|
|
|
|
|
|
|
//给某一项添加一个数量
|
|
//给某一项添加一个数量
|
|
|
- void AddNum(int index)
|
|
|
|
|
- {
|
|
|
|
|
- std::string old_num = m_items[index].num;
|
|
|
|
|
-
|
|
|
|
|
- double d_old_num = std::stod(old_num);
|
|
|
|
|
- double d_new_num = d_old_num + 1;
|
|
|
|
|
-
|
|
|
|
|
- //如果新的数量是一个整数,那么展示的时候就把小数去掉
|
|
|
|
|
- if (d_new_num - (int)d_new_num < 0.0001)
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = std::to_string((int)d_new_num);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = CLewaimaiString::DoubleToString(d_new_num, 3);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_items[index].UpdateShowPrice();
|
|
|
|
|
-
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void AddNum(int index);
|
|
|
|
|
|
|
|
//给某一项减少一个数量,返回值为true表示商品本删掉了,也就是为0份;如果为false表示没被删掉
|
|
//给某一项减少一个数量,返回值为true表示商品本删掉了,也就是为0份;如果为false表示没被删掉
|
|
|
- bool DelNum(int index)
|
|
|
|
|
- {
|
|
|
|
|
- std::string old_num = m_items[index].num;
|
|
|
|
|
-
|
|
|
|
|
- double d_old_num = std::stod(old_num);
|
|
|
|
|
- double d_new_num = d_old_num - 1;
|
|
|
|
|
-
|
|
|
|
|
- if (d_new_num < 0.0001)
|
|
|
|
|
- {
|
|
|
|
|
- //已经减为0了,那么就删掉这个item
|
|
|
|
|
- m_items.erase(m_items.begin() + index);
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
-
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- //如果新的数量是一个整数,那么展示的时候就把小数去掉
|
|
|
|
|
- if (d_new_num - (int)d_new_num < 0.0001)
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = std::to_string((int)d_new_num);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].num = CLewaimaiString::DoubleToString(d_new_num, 3);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_items[index].UpdateShowPrice();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ bool DelNum(int index);
|
|
|
|
|
|
|
|
//删除某一项
|
|
//删除某一项
|
|
|
- void Remove(int index)
|
|
|
|
|
- {
|
|
|
|
|
- //已经减为0了,那么就删掉这个item
|
|
|
|
|
- m_items.erase(m_items.begin() + index);
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void Remove(int index);
|
|
|
|
|
|
|
|
//更新了某项的规格,那么重新刷新显示和价格
|
|
//更新了某项的规格,那么重新刷新显示和价格
|
|
|
- void UpdateGuigePrice(int index)
|
|
|
|
|
- {
|
|
|
|
|
- m_items[index].UpdateShowPrice();
|
|
|
|
|
|
|
+ void UpdateGuigePrice(int index);
|
|
|
|
|
|
|
|
- UpdateTotalPriceShow();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //清空商品
|
|
|
|
|
+ void Clear();
|
|
|
|
|
+
|
|
|
|
|
+ void SetMemo(std::string memo);
|
|
|
};
|
|
};
|