|
|
@@ -1,5 +1,6 @@
|
|
|
#include "pch.h"
|
|
|
#include "CHuiyuanInfoShowWnd.h"
|
|
|
+#include "CHuiyuanChongzhiWnd.h"
|
|
|
|
|
|
LRESULT CHuiyuanInfoShowWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
|
@@ -132,12 +133,20 @@ void CHuiyuanInfoShowWnd::Notify(TNotifyUI& msg)
|
|
|
{
|
|
|
DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
|
|
|
- if (senderName == _T("closebtn"))
|
|
|
+ if (senderName == _T("closebtn") || senderName == _T("huiyuan_info_close_btn"))
|
|
|
{
|
|
|
- Close(IDCANCEL);
|
|
|
+ //发生过充值,则以 IDOK 结束,调用方据此刷新会员余额
|
|
|
+ Close(m_is_chongzhi_success ? IDOK : IDCANCEL);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (senderName == _T("huiyuan_info_chongzhi_btn"))
|
|
|
+ {
|
|
|
+ this->StartHuiyuanChongzhi();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ CModalWnd::Notify(msg);
|
|
|
}
|
|
|
|
|
|
void CHuiyuanInfoShowWnd::Init()
|
|
|
@@ -145,43 +154,339 @@ void CHuiyuanInfoShowWnd::Init()
|
|
|
|
|
|
}
|
|
|
|
|
|
-void CHuiyuanInfoShowWnd::SetHuiyuanInfo(std::string m_member_name, std::string m_member_level, std::string m_member_level_name, std::string m_card_no, std::string m_balance, std::string m_phone, \
|
|
|
+void CHuiyuanInfoShowWnd::SetHuiyuanInfo(std::string m_member_id, std::string m_member_name, std::string m_member_level, std::string m_member_level_name, std::string m_card_no, std::string m_balance, std::string m_phone, \
|
|
|
std::string m_birthday, std::string m_sex, std::string m_address, std::string m_is_card, std::string m_point, std::string m_open_no_card_payment, std::string m_pay_password, std::string m_freeze, std::string m_card_identify)
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_num")->SetText((L"会员卡号:" + CLewaimaiString::UTF8ToUnicode(m_card_no)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_phone")->SetText((L"手机号:" + CLewaimaiString::UTF8ToUnicode(m_phone)).c_str());
|
|
|
+ this->m_member_id = m_member_id;
|
|
|
+ this->m_name = m_member_name;
|
|
|
+ this->m_level_name = m_member_level_name;
|
|
|
+ this->m_card_no = m_card_no;
|
|
|
+ this->m_balance = m_balance;
|
|
|
+ this->m_phone = m_phone;
|
|
|
+ this->m_birthday = m_birthday;
|
|
|
+ this->m_sex = m_sex;
|
|
|
+ this->m_address = m_address;
|
|
|
+ this->m_point = m_point;
|
|
|
+ this->m_open_no_card_payment = m_open_no_card_payment;
|
|
|
+ this->m_pay_password = m_pay_password;
|
|
|
+ this->m_freeze = m_freeze;
|
|
|
+ this->m_card_identify = m_card_identify;
|
|
|
+
|
|
|
+ this->UpdateHuiyuanInfo();
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanInfoShowWnd::UpdateHuiyuanInfo()
|
|
|
+{
|
|
|
+ //是否冻结:m_freeze 为 "0" 表示正常,其余("1")为已冻结
|
|
|
+ bool is_frozen = (!m_freeze.empty() && m_freeze != "0");
|
|
|
+
|
|
|
+ //头像:姓氏首字
|
|
|
+ std::wstring wname = CLewaimaiString::UTF8ToUnicode(m_name);
|
|
|
+ std::wstring first_char = L"";
|
|
|
+ if (wname.empty() == false)
|
|
|
+ {
|
|
|
+ first_char = wname.substr(0, 1);
|
|
|
+ }
|
|
|
+ static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_avatar"))->SetText(first_char.c_str());
|
|
|
+
|
|
|
+ //姓名(脱敏)
|
|
|
+ static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_name"))->SetText(this->GetMinganziName(m_name).c_str());
|
|
|
+
|
|
|
+ //等级:为空时兜底显示「普通会员」
|
|
|
+ CLabelUI* pLevel = static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_level"));
|
|
|
+ std::wstring level = CLewaimaiString::UTF8ToUnicode(m_level_name);
|
|
|
+ if (level.empty())
|
|
|
+ {
|
|
|
+ level = L"普通会员";
|
|
|
+ }
|
|
|
+ pLevel->SetText(level.c_str());
|
|
|
|
|
|
- if (m_open_no_card_payment == "1")
|
|
|
+ //状态:正常绿字 / 已冻结红字
|
|
|
+ CLabelUI* pStatus = static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_status"));
|
|
|
+ if (is_frozen)
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_mimazhifu")->SetText(L"密码支付:已开启");
|
|
|
+ pStatus->SetText(L"已冻结");
|
|
|
+ pStatus->SetTextColor(0xFFFF4500);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_mimazhifu")->SetText(L"密码支付:未开启");
|
|
|
+ pStatus->SetText(L"正常");
|
|
|
+ pStatus->SetTextColor(0xFF3CB371);
|
|
|
+ }
|
|
|
+
|
|
|
+ //头部背景:正常纯绿 #3CB371,冻结置灰 #9AA0A6
|
|
|
+ CControlUI* pHead = m_pm.FindControl(L"huiyuan_info_head");
|
|
|
+ if (pHead != NULL)
|
|
|
+ {
|
|
|
+ pHead->SetBkColor(is_frozen ? 0xFF9AA0A6 : 0xFF3CB371);
|
|
|
+ }
|
|
|
+
|
|
|
+ //手机号(脱敏)
|
|
|
+ static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_phone"))->SetText(this->GetMinganziPhone(m_phone).c_str());
|
|
|
+
|
|
|
+ //信息栅格
|
|
|
+ this->SetInfoText(L"huiyuan_info_sex", m_sex);
|
|
|
+ this->SetInfoText(L"huiyuan_info_birthday", m_birthday);
|
|
|
+ this->SetInfoText(L"huiyuan_info_card_no", m_card_no);
|
|
|
+ this->SetInfoText(L"huiyuan_info_address", m_address);
|
|
|
+ this->SetInfoTag(L"huiyuan_info_pay_password", (m_open_no_card_payment == "1"), L"已开启", L"未开启");
|
|
|
+ this->SetInfoTag(L"huiyuan_info_shitika", (!m_card_identify.empty()), L"已绑定", L"未绑定");
|
|
|
+
|
|
|
+ //余额 / 积分:冻结时置灰
|
|
|
+ CLabelUI* pBalance = static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_balance"));
|
|
|
+ pBalance->SetText(this->FormatMoney(m_balance).c_str());
|
|
|
+ pBalance->SetTextColor(is_frozen ? 0xFFA8ADB3 : 0xFFFF8910);
|
|
|
+
|
|
|
+ CLabelUI* pPoint = static_cast<CLabelUI*>(m_pm.FindControl(L"huiyuan_info_point"));
|
|
|
+ pPoint->SetText(this->FormatPoint(m_point).c_str());
|
|
|
+ pPoint->SetTextColor(is_frozen ? 0xFFA8ADB3 : 0xFF3CB371);
|
|
|
+
|
|
|
+ //冻结提示:正常态隐藏提示条并缩小窗口;冻结态显示提示条并使用较大窗口
|
|
|
+ //内容区高度:正常 392 = 16+92+14+190+16+44+20;冻结 432 = 正常 + 40
|
|
|
+ const int BODY_HEIGHT_NORMAL = 392;
|
|
|
+ const int BODY_HEIGHT_FROZEN = 432;
|
|
|
+ const int WINDOW_WIDTH = 520;
|
|
|
+ const int HEAD_HEIGHT = 132;
|
|
|
+
|
|
|
+ CControlUI* pBody = m_pm.FindControl(L"huiyuan_info_body");
|
|
|
+ CControlUI* pFrozenTip = m_pm.FindControl(L"huiyuan_info_frozen_tip");
|
|
|
+ if (pFrozenTip != NULL)
|
|
|
+ {
|
|
|
+ pFrozenTip->SetVisible(is_frozen);
|
|
|
+ }
|
|
|
+ if (pBody != NULL)
|
|
|
+ {
|
|
|
+ pBody->SetFixedHeight(is_frozen ? BODY_HEIGHT_FROZEN : BODY_HEIGHT_NORMAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ //窗口尚未显示前(ShowModal 之前)根据状态调整窗口高度并重新居中;
|
|
|
+ //充值回调里窗口已可见,此时状态不会变化,不再调整尺寸避免跳动。
|
|
|
+ if (m_hWnd != NULL && !::IsWindowVisible(m_hWnd))
|
|
|
+ {
|
|
|
+ int targetHeight = HEAD_HEIGHT + (is_frozen ? BODY_HEIGHT_FROZEN : BODY_HEIGHT_NORMAL);
|
|
|
+ ::SetWindowPos(m_hWnd, NULL, 0, 0, WINDOW_WIDTH, targetHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
+ this->CenterWindow();
|
|
|
+ }
|
|
|
+
|
|
|
+ m_pm.NeedUpdate();
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanInfoShowWnd::StartHuiyuanChongzhi()
|
|
|
+{
|
|
|
+ CHuiyuanChongzhiWnd* pChongzhiWnd = new CHuiyuanChongzhiWnd();
|
|
|
+ if (pChongzhiWnd == NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pChongzhiWnd->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
|
|
|
+ pChongzhiWnd->SetIcon(IDI_ICON_DUILIB);
|
|
|
+ pChongzhiWnd->CenterWindow();
|
|
|
+
|
|
|
+ pChongzhiWnd->SetCurBalance(m_balance);
|
|
|
+ pChongzhiWnd->m_member_id = m_member_id;
|
|
|
+ pChongzhiWnd->m_member_card_no = m_card_no;
|
|
|
+
|
|
|
+ UINT ret = pChongzhiWnd->ShowModal();
|
|
|
+
|
|
|
+ if (ret == IDOK)
|
|
|
+ {
|
|
|
+ //充值成功:新余额 = 原余额 + 充值金额 + 赠送金额
|
|
|
+ double cur = atof(m_balance.c_str());
|
|
|
+ double chongzhi = atof(pChongzhiWnd->m_chongzhi.c_str());
|
|
|
+ double zengsong = atof(pChongzhiWnd->m_zengsong.c_str());
|
|
|
+
|
|
|
+ m_balance = CLewaimaiString::DoubleToString(cur + chongzhi + zengsong, 2);
|
|
|
+ m_new_balance = m_balance;
|
|
|
+ m_is_chongzhi_success = true;
|
|
|
+
|
|
|
+ this->UpdateHuiyuanInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+ delete pChongzhiWnd;
|
|
|
+}
|
|
|
+
|
|
|
+std::wstring CHuiyuanInfoShowWnd::GetMinganziName(const std::string& name)
|
|
|
+{
|
|
|
+ std::wstring wname = CLewaimaiString::UTF8ToUnicode(name);
|
|
|
+
|
|
|
+ if (wname.empty())
|
|
|
+ {
|
|
|
+ return L"";
|
|
|
+ }
|
|
|
+ if (wname.length() == 1)
|
|
|
+ {
|
|
|
+ return wname;
|
|
|
+ }
|
|
|
+ if (wname.length() == 2)
|
|
|
+ {
|
|
|
+ return wname.substr(0, 1) + L"*";
|
|
|
+ }
|
|
|
+
|
|
|
+ return wname.substr(0, 1) + L"**";
|
|
|
+}
|
|
|
+
|
|
|
+std::wstring CHuiyuanInfoShowWnd::GetMinganziPhone(const std::string& phone)
|
|
|
+{
|
|
|
+ //只保留数字,兼容带空格 / +86 前缀的号码
|
|
|
+ std::string digits;
|
|
|
+ for (size_t i = 0; i < phone.length(); i++)
|
|
|
+ {
|
|
|
+ if (phone[i] >= '0' && phone[i] <= '9')
|
|
|
+ {
|
|
|
+ digits += phone[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (digits.empty())
|
|
|
+ {
|
|
|
+ return L"未绑定手机号";
|
|
|
+ }
|
|
|
+
|
|
|
+ //非 11 位不做脱敏,原样展示
|
|
|
+ if (digits.length() != 11)
|
|
|
+ {
|
|
|
+ return CLewaimaiString::UTF8ToUnicode(phone);
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string masked = digits.substr(0, 3) + "****" + digits.substr(7, 4);
|
|
|
+ return CLewaimaiString::UTF8ToUnicode(masked);
|
|
|
+}
|
|
|
+
|
|
|
+std::wstring CHuiyuanInfoShowWnd::FormatMoney(const std::string& value)
|
|
|
+{
|
|
|
+ std::string v = value;
|
|
|
+ if (v.empty())
|
|
|
+ {
|
|
|
+ v = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ bool negative = false;
|
|
|
+ if (v[0] == '-')
|
|
|
+ {
|
|
|
+ negative = true;
|
|
|
+ v = v.substr(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string int_part = v;
|
|
|
+ std::string dec_part = "00";
|
|
|
+
|
|
|
+ size_t dot = v.find('.');
|
|
|
+ if (dot != std::string::npos)
|
|
|
+ {
|
|
|
+ int_part = v.substr(0, dot);
|
|
|
+ dec_part = v.substr(dot + 1);
|
|
|
+ if (dec_part.length() > 2)
|
|
|
+ {
|
|
|
+ dec_part = dec_part.substr(0, 2);
|
|
|
+ }
|
|
|
+ while (dec_part.length() < 2)
|
|
|
+ {
|
|
|
+ dec_part += "0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (int_part.empty())
|
|
|
+ {
|
|
|
+ int_part = "0";
|
|
|
}
|
|
|
|
|
|
- m_pm.FindControl(L"huiyuan_name")->SetText((L"会员姓名:" + CLewaimaiString::UTF8ToUnicode(m_member_name)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_sex")->SetText((L"性别:" + CLewaimaiString::UTF8ToUnicode(m_sex)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_address")->SetText((L"地址:" + CLewaimaiString::UTF8ToUnicode(m_address)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_birthday")->SetText((L"生日:" + CLewaimaiString::UTF8ToUnicode(m_birthday)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_levelname")->SetText((L"会员级别:" + CLewaimaiString::UTF8ToUnicode(m_member_level_name)).c_str());
|
|
|
- m_pm.FindControl(L"huiyuan_yue")->SetText((L"当前余额:" + CLewaimaiString::UTF8ToUnicode(m_balance)).c_str());
|
|
|
+ //千分位
|
|
|
+ std::string out;
|
|
|
+ int count = 0;
|
|
|
+ for (int i = (int)int_part.length() - 1; i >= 0; i--)
|
|
|
+ {
|
|
|
+ out.insert(out.begin(), int_part[i]);
|
|
|
+ count++;
|
|
|
+ if (count % 3 == 0 && i > 0)
|
|
|
+ {
|
|
|
+ out.insert(out.begin(), ',');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (m_card_identify != "")
|
|
|
+ std::wstring ret = L"¥";
|
|
|
+ if (negative)
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_shitika")->SetText(L"实体会员卡:已绑定");
|
|
|
+ ret += L"-";
|
|
|
+ }
|
|
|
+ ret += CLewaimaiString::UTF8ToUnicode(out + "." + dec_part);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+std::wstring CHuiyuanInfoShowWnd::FormatPoint(const std::string& value)
|
|
|
+{
|
|
|
+ std::string v = value;
|
|
|
+ if (v.empty())
|
|
|
+ {
|
|
|
+ return L"0";
|
|
|
+ }
|
|
|
+
|
|
|
+ //去掉小数部分
|
|
|
+ size_t dot = v.find('.');
|
|
|
+ if (dot != std::string::npos)
|
|
|
+ {
|
|
|
+ v = v.substr(0, dot);
|
|
|
+ }
|
|
|
+ if (v.empty())
|
|
|
+ {
|
|
|
+ return L"0";
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string out;
|
|
|
+ int count = 0;
|
|
|
+ for (int i = (int)v.length() - 1; i >= 0; i--)
|
|
|
+ {
|
|
|
+ out.insert(out.begin(), v[i]);
|
|
|
+ count++;
|
|
|
+ if (count % 3 == 0 && i > 0)
|
|
|
+ {
|
|
|
+ out.insert(out.begin(), ',');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return CLewaimaiString::UTF8ToUnicode(out);
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanInfoShowWnd::SetInfoText(LPCTSTR control_name, const std::string& value)
|
|
|
+{
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(control_name));
|
|
|
+ if (pLabel == NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::wstring text = CLewaimaiString::UTF8ToUnicode(value);
|
|
|
+ if (text.empty())
|
|
|
+ {
|
|
|
+ pLabel->SetText(L"未填写");
|
|
|
+ pLabel->SetTextColor(0xFFA8ADB3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_shitika")->SetText(L"实体会员卡:未绑定");
|
|
|
+ pLabel->SetText(text.c_str());
|
|
|
+ pLabel->SetTextColor(0xFF1F2329);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- if (m_freeze == "0")
|
|
|
+void CHuiyuanInfoShowWnd::SetInfoTag(LPCTSTR control_name, bool is_on, LPCTSTR on_text, LPCTSTR off_text)
|
|
|
+{
|
|
|
+ CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(control_name));
|
|
|
+ if (pLabel == NULL)
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_status")->SetText(L"会员状态:正常");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (is_on)
|
|
|
+ {
|
|
|
+ pLabel->SetText(on_text);
|
|
|
+ pLabel->SetTextColor(0xFF3CB371);
|
|
|
+ pLabel->SetAttribute(L"bkimage", L"file='hyinfo_tag_on.png'");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_pm.FindControl(L"huiyuan_status")->SetText(L"会员状态:已冻结");
|
|
|
+ pLabel->SetText(off_text);
|
|
|
+ pLabel->SetTextColor(0xFFA8ADB3);
|
|
|
+ pLabel->SetAttribute(L"bkimage", L"file='hyinfo_tag_off.png'");
|
|
|
}
|
|
|
-}
|
|
|
+}
|