CDiandanOrderItem.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "../zhipuzi/CFood.h"
  3. #include "../zhipuzi/CFoodpackage.h"
  4. #include "../control/CDiandanNatureItemUI.h"
  5. class MemberPrice
  6. {
  7. public:
  8. std::string id;
  9. std::string level;
  10. std::string price;
  11. };
  12. /**
  13. * 订单中的一个商品
  14. */
  15. class CDiandanOrderItem
  16. {
  17. public:
  18. //是否套餐的Item,因为目前套餐和普通商品都是用同一个Item类
  19. bool m_is_taocan = false;
  20. //普通商品才有的信息
  21. std::string food_id;
  22. std::string food_name;
  23. std::string type_id;
  24. bool is_weight = false;
  25. bool is_nature = false;
  26. //会员价
  27. bool is_member_price_used;
  28. std::vector<MemberPrice> m_member_price;
  29. //套餐才有的信息
  30. std::string foodpackage_id;
  31. std::string foodpackage_name;
  32. //这个是套餐和普通商品共有的信息
  33. std::string price;
  34. bool is_dabao = false;
  35. std::string dabao_money;
  36. std::string num;
  37. //这个用来存储所有属性选择的信息,每个属性选择的是第几个,什么价格等等
  38. std::vector<FoodNatureSelectValue> natureSelectedArray;
  39. //这个是商品对外展示的价格,根据数量和属性来计算的,不包含打包费
  40. std::string show_price;
  41. private:
  42. CFood m_foodinfo;
  43. CFoodpackage m_foodpackageinfo;
  44. public:
  45. bool operator==(CDiandanOrderItem& t);
  46. void SetFoodInfo(CFood info);
  47. void SetFoodpackageInfo(CFoodpackage info);
  48. void SetIsTaocan(bool is_taocan);
  49. void SetDabao();
  50. CFood GetFoodInfo();
  51. CFoodpackage GetFoodpackageInfo();
  52. bool GetIsTaocan();
  53. //根据当前选中的商品属性、份数,计算商品的展示价格
  54. void UpdateShowPrice();
  55. //这个是单价,包含属性价格,不考虑数量,也就是“1份”的价格
  56. std::string getSinglePrice();
  57. //获取用户展示的商品名字,如果有打包会在前面显示【打包】,不包含商品属性
  58. std::string getNameShow();
  59. //获取用于展示的属性名字,仅仅是属性名字,如“热、多糖、大杯”
  60. std::string getNatureShow();
  61. //获取用于完整展示的商品名字,包含商品本身的名字和属性,例如“【打包】珍珠奶茶【大杯、热、多糖】”
  62. std::string getNameWanzhengShow();
  63. //根据当前会员等级,计算该商品的会员优惠金额
  64. double getMemberYouhui(std::string member_level);
  65. //计算当前这个商品的打包费
  66. double getDabaoMoney();
  67. //获取点单相关的参数(仅用于非套餐)
  68. std::map<string, string> getDiandanParam();
  69. //获取点单相关的套餐参数(仅用于套餐)
  70. rapidjson::Document getDiandanTaocanParam(rapidjson::Document::AllocatorType &allocator);
  71. };