|
|
@@ -79,14 +79,92 @@ void CShopinfo::InitShopinfoByLogin(rapidjson::Value& v_data)
|
|
|
this->m_is_meishicheng = v_authority["is_meishicheng"].GetString();
|
|
|
}
|
|
|
|
|
|
-//处理登录成功后,通过获取店铺信息接口获取的信息并保存
|
|
|
-void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
+std::wstring CShopinfo::GetMachineLogoPath()
|
|
|
+{
|
|
|
+ string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image\\";
|
|
|
+ std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
|
|
|
+ if (!CSystem::IsDirExist(ws_folderPath))
|
|
|
+ {
|
|
|
+ LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
|
|
|
+ CSystem::CreateMultiLevel(folderPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //纯文件名
|
|
|
+ std::string file_name = CLewaimaiString::GetPathOrURLShortName(m_machine_logo_url);
|
|
|
+
|
|
|
+ //根据文件名,计算文件临时路径
|
|
|
+ wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
|
|
|
+
|
|
|
+ return imagePath;
|
|
|
+}
|
|
|
+
|
|
|
+bool CShopinfo::UpdateOneShopinfo(std::wstring& errmsg)
|
|
|
{
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+ bool ret = CZhipuziHttpClient::GetInstance()->Request("/shop/getoneshopinfo", params, response);
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ errmsg = _T("网络请求出错");
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ errmsg = _T("服务器返回数据格式错误");
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("data"))
|
|
|
+ {
|
|
|
+ errmsg = _T("服务器返回数据格式错误");
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (document.HasMember("error_code"))
|
|
|
+ {
|
|
|
+ rapidjson::Value& v_errcode = document["error_code"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string s_errmsg = "response failed! message:" + string(document["error_msg"].GetString());
|
|
|
+ errmsg = CLewaimaiString::UTF8ToUnicode(s_errmsg);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string s_errmsg = "response failed! message:" + string(document["errmsg"].GetString());
|
|
|
+ errmsg = CLewaimaiString::UTF8ToUnicode(s_errmsg);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获得数据成功
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+
|
|
|
+ //把获取到的数据保存起来
|
|
|
m_is_discount = data["is_discount"].GetString();
|
|
|
m_discount_value = data["discount_value"].GetString();
|
|
|
m_discountlimitmember = data["discountlimitmember"].GetString();
|
|
|
m_open_addservice = data["open_addservice"].GetString();
|
|
|
|
|
|
+ //开始处理增值服务
|
|
|
+ m_addservice.clear();
|
|
|
+
|
|
|
rapidjson::Value& addservice = data["addservice"];
|
|
|
for (rapidjson::SizeType i = 0; i < addservice.Size(); ++i)
|
|
|
{
|
|
|
@@ -101,6 +179,9 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
m_addservice.push_back(newAddService);
|
|
|
}
|
|
|
|
|
|
+ //开始处理满减
|
|
|
+ m_promotion.clear();
|
|
|
+
|
|
|
m_open_promotion = data["open_promotion"].GetString();
|
|
|
|
|
|
rapidjson::Value& promotion = data["promotion"];
|
|
|
@@ -137,12 +218,14 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
m_eq_card_discount_value = data["eq_card_discount_value"].GetString();
|
|
|
|
|
|
//处理会员折扣
|
|
|
+ m_discount_info.clear();
|
|
|
+
|
|
|
std::string s_discount_info = data["discount_info"].GetString();
|
|
|
|
|
|
- rapidjson::Document document;
|
|
|
- document.Parse(s_discount_info.c_str());
|
|
|
+ rapidjson::Document document_2;
|
|
|
+ document_2.Parse(s_discount_info.c_str());
|
|
|
|
|
|
- rapidjson::Value& discount = document;
|
|
|
+ rapidjson::Value& discount = document_2;
|
|
|
for (rapidjson::SizeType i = 0; i < discount.Size(); ++i)
|
|
|
{
|
|
|
rapidjson::Value& discountinfo = discount[i];
|
|
|
@@ -189,6 +272,8 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
m_machinecode_logo = data["machinecode_logo"].GetString();
|
|
|
|
|
|
//开始处理自定义支付
|
|
|
+ m_self_pay.clear();
|
|
|
+
|
|
|
rapidjson::Value& self_pay = data["self_pay"];
|
|
|
for (rapidjson::SizeType i = 0; i < self_pay.Size(); ++i)
|
|
|
{
|
|
|
@@ -216,7 +301,7 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
{
|
|
|
m_is_cash_pay_open = to_string(data["default_pay_open"]["is_cash_pay_open"].GetInt());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (data["default_pay_open"]["is_online_pay_open"].IsString())
|
|
|
{
|
|
|
m_is_online_pay_open = data["default_pay_open"]["is_online_pay_open"].GetString();
|
|
|
@@ -268,7 +353,7 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
{
|
|
|
m_is_open_fulika_pay = "0";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//开始下载小票打印的logo图
|
|
|
std::string logo_url = "http://img.zhipuzi.com" + m_machine_logo_url + "!max400"; //下载小图
|
|
|
|
|
|
@@ -279,30 +364,12 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
|
|
|
if (URLDownloadToFile(NULL, CLewaimaiString::UTF8ToUnicode(logo_url).c_str(), imagePath.c_str(), 0, NULL) == S_OK)
|
|
|
{
|
|
|
//图片下载成功了,发个消息,更新图片
|
|
|
- int a = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
LOG_INFO("URLDownloadToFile Fail,Error" << GetLastError());
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-std::wstring CShopinfo::GetMachineLogoPath()
|
|
|
-{
|
|
|
- string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image\\";
|
|
|
- std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
|
|
|
- if (!CSystem::IsDirExist(ws_folderPath))
|
|
|
- {
|
|
|
- LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
|
|
|
- CSystem::CreateMultiLevel(folderPath);
|
|
|
- }
|
|
|
-
|
|
|
- //纯文件名
|
|
|
- std::string file_name = CLewaimaiString::GetPathOrURLShortName(m_machine_logo_url);
|
|
|
|
|
|
- //根据文件名,计算文件临时路径
|
|
|
- wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
|
|
|
-
|
|
|
- return imagePath;
|
|
|
+ return true;
|
|
|
}
|