|
|
@@ -1254,31 +1254,84 @@ bool CSqlite3::GetFoodtypeById(std::string foodtype_id, CFoodType& newFoodType)
|
|
|
return is_found;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 如果type_id为0,表示读取所有商品,否则只读取当前type_id的商品
|
|
|
- */
|
|
|
-std::vector<CFood> CSqlite3::GetFoodByTypeid(std::string type_id, bool is_shouyinji_show)
|
|
|
+std::vector<CFood> CSqlite3::GetAllFood()
|
|
|
{
|
|
|
- type_id = CLewaimaiString::SqlZhuanyi(type_id);
|
|
|
-
|
|
|
std::vector<CFood> data;
|
|
|
|
|
|
- std::string sql;
|
|
|
+ std::string sql = "SELECT * FROM pos_food WHERE is_shouyinji_show = '1' ORDER BY tag ASC";
|
|
|
|
|
|
- if (is_shouyinji_show)
|
|
|
+ sqlite3_stmt* stmt = NULL;
|
|
|
+
|
|
|
+ if (sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
|
|
|
{
|
|
|
- sql = "SELECT * FROM pos_food WHERE status='NORMAL' and is_shouyinji_show = '1'";
|
|
|
+ while (sqlite3_step(stmt) == SQLITE_ROW)
|
|
|
+ {
|
|
|
+ CFood newFood;
|
|
|
+
|
|
|
+ newFood.id = (char*)sqlite3_column_text(stmt, 0);
|
|
|
+ newFood.shop_id = (char*)sqlite3_column_text(stmt, 1);
|
|
|
+ newFood.name = (char*)sqlite3_column_text(stmt, 2);
|
|
|
+ newFood.price = (char*)sqlite3_column_text(stmt, 3);
|
|
|
+ newFood.tag = (char*)sqlite3_column_text(stmt, 4);
|
|
|
+ newFood.status = (char*)sqlite3_column_text(stmt, 5);
|
|
|
+ newFood.type_id = (char*)sqlite3_column_text(stmt, 6);
|
|
|
+ newFood.is_dabao = (char*)sqlite3_column_text(stmt, 7);
|
|
|
+ newFood.dabao_money = (char*)sqlite3_column_text(stmt, 8);
|
|
|
+ newFood.is_nature = (char*)sqlite3_column_text(stmt, 9);
|
|
|
+ newFood.nature = (char*)sqlite3_column_text(stmt, 10);
|
|
|
+ newFood.autostocknum = (char*)sqlite3_column_text(stmt, 11);
|
|
|
+ newFood.goods_img = (char*)sqlite3_column_text(stmt, 12);
|
|
|
+ newFood.unit = (char*)sqlite3_column_text(stmt, 13);
|
|
|
+ newFood.barcode = (char*)sqlite3_column_text(stmt, 14);
|
|
|
+ newFood.member_price_used = (char*)sqlite3_column_text(stmt, 15);
|
|
|
+ newFood.member_price = (char*)sqlite3_column_text(stmt, 16);
|
|
|
+ newFood.buying_price = (char*)sqlite3_column_text(stmt, 17);
|
|
|
+ newFood.stock = (char*)sqlite3_column_text(stmt, 18);
|
|
|
+ newFood.stockvalid = (char*)sqlite3_column_text(stmt, 19);
|
|
|
+ newFood.stock_warning = (char*)sqlite3_column_text(stmt, 20);
|
|
|
+ newFood.is_shouyinji_show = (char*)sqlite3_column_text(stmt, 21);
|
|
|
+ newFood.is_waimai_show = (char*)sqlite3_column_text(stmt, 22);
|
|
|
+ newFood.is_tangshi_show = (char*)sqlite3_column_text(stmt, 23);
|
|
|
+ newFood.is_zhengcan_show = (char*)sqlite3_column_text(stmt, 24);
|
|
|
+ newFood.expiration_date = (char*)sqlite3_column_text(stmt, 25);
|
|
|
+ newFood.is_weight = (char*)sqlite3_column_text(stmt, 26);
|
|
|
+ newFood.weight_plu_code = (char*)sqlite3_column_text(stmt, 27);
|
|
|
+ newFood.weight_food_code = (char*)sqlite3_column_text(stmt, 28);
|
|
|
+ newFood.jiagong_type = (char*)sqlite3_column_text(stmt, 29);
|
|
|
+ newFood.cost_mode = (char*)sqlite3_column_text(stmt, 30);
|
|
|
+ newFood.member_price_json = (char*)sqlite3_column_text(stmt, 31);
|
|
|
+
|
|
|
+ data.push_back(newFood);
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_finalize(stmt);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- sql = "SELECT * FROM pos_food WHERE status='NORMAL'";
|
|
|
+ //异常情况
|
|
|
+ sqlite3_finalize(stmt);
|
|
|
}
|
|
|
|
|
|
- if (type_id != "0")
|
|
|
+ return data;
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<CFood> CSqlite3::GetFoodByTypeid(std::string type_id, bool is_show_closed)
|
|
|
+{
|
|
|
+ type_id = CLewaimaiString::SqlZhuanyi(type_id);
|
|
|
+
|
|
|
+ std::vector<CFood> data;
|
|
|
+
|
|
|
+ std::string sql;
|
|
|
+
|
|
|
+ if (is_show_closed == true)
|
|
|
{
|
|
|
- sql += " AND type_id = '" + type_id + "'";
|
|
|
+ sql = "SELECT * FROM pos_food WHERE type_id = '" + type_id + "'";
|
|
|
}
|
|
|
-
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql = "SELECT * FROM pos_food WHERE status='NORMAL' AND is_shouyinji_show = '1' AND type_id = '" + type_id + "'";
|
|
|
+ }
|
|
|
+
|
|
|
sql += " ORDER BY tag ASC";
|
|
|
|
|
|
sqlite3_stmt * stmt = NULL;
|
|
|
@@ -1342,7 +1395,7 @@ std::vector<CFood> CSqlite3::GetFoodForTiaomacheng()
|
|
|
|
|
|
std::string sql;
|
|
|
|
|
|
- sql = "SELECT * FROM pos_food WHERE is_weight = '1' AND weight_plu_code != '' AND weight_food_code != ''";
|
|
|
+ sql = "SELECT * FROM pos_food WHERE is_weight = '1' AND weight_plu_code != ''";
|
|
|
|
|
|
sqlite3_stmt * stmt = NULL;
|
|
|
|
|
|
@@ -1760,4 +1813,4 @@ void CSqlite3::UpdateFoodStock(std::string food_id, std::string stock)
|
|
|
result = sqlite3_exec(m_db, sql.c_str(), 0, 0, 0);
|
|
|
|
|
|
result = sqlite3_exec(m_db, "COMMIT;", 0, 0, 0);
|
|
|
-}
|
|
|
+}
|