CSaomashouyinPageUI.cpp 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788
  1. #include "pch.h"
  2. #include "CSaomashouyinPageUI.h"
  3. #include "../control/ControlEx.h"
  4. #include "../tool/CSqlite3.h"
  5. #include "../wnd/CDiandanNatureWnd.h"
  6. #include "../wnd/CMemoWnd.h"
  7. #include "../wnd/CYouhuiShowWnd.h"
  8. #include "../wnd/CMemberLoginWnd.h"
  9. #include "../wnd/CSaomaYouhuiquanWnd.h"
  10. #include "../wnd/CSaomaShangpinquanWnd.h"
  11. #include "../wnd/CSaomaCikaWnd.h"
  12. #include "../wnd/CSaomaQuanyikaWnd.h"
  13. #include "../wnd/CWeixinzhifuShoukuanWnd.h"
  14. #include "../wnd/CHuiyuanShoukuanWnd.h"
  15. #include "../wnd/CXianjinShoukuanWnd.h"
  16. #include "../wnd/CFulikaShoukuanWnd.h"
  17. #include "../wnd/CZidingyiShoukuanWnd.h"
  18. #include "../wnd/CChengzhongWnd.h"
  19. #include "../wnd/CGuadanWnd.h"
  20. #include "../wnd/CNumInputWnd.h"
  21. #include "../wnd/CHuiyuanInfoShowWnd.h"
  22. #include "../wnd/CHuiyuanChongzhiWnd.h"
  23. #include "../print/CPosPrinter.h"
  24. #include "../tool/CShuangpingTool.h"
  25. #include "../worker/CChengzhongWorker.h"
  26. #include "../worker/CDiandanAIShibieWorker.h"
  27. CSaomashouyinPageUI::CSaomashouyinPageUI()
  28. {
  29. }
  30. CSaomashouyinPageUI::~CSaomashouyinPageUI()
  31. {
  32. }
  33. void CSaomashouyinPageUI::InitControl()
  34. {
  35. }
  36. //初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
  37. void CSaomashouyinPageUI::InitShow()
  38. {
  39. //初始化结算页面相关的展示,把所有活动清零
  40. this->InitJiesuanShow();
  41. //计算所有活动优惠,并且调整所有与价格相关的展示
  42. this->UpdateJiesuanInfo();
  43. if (m_is_zidingyizhifu_init == false)
  44. {
  45. //初始化结算页面的支付方式
  46. this->InitJiesuanZhifu();
  47. m_is_zidingyizhifu_init = true;
  48. }
  49. }
  50. void CSaomashouyinPageUI::RefreshShow()
  51. {
  52. //清空当前订单的信息
  53. m_cur_diandan_order.RefreshDiandanInfo();
  54. //初始化结算页面相关的展示,把所有活动清零
  55. this->InitJiesuanShow();
  56. //渲染左侧购物车(包含了调用UpdateJiesuanInfo重新计算价格)
  57. this->UpdateShopcartShow();
  58. }
  59. void CSaomashouyinPageUI::InitFoodShow()
  60. {
  61. std::string setting_xianshi_is_youtu = CSetting::GetInstance()->GetParam("setting_xianshi_is_youtu");
  62. m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("saomashouyin_foodlist")));
  63. m_foodLayout->RemoveAll();
  64. std::wstring xml_name;
  65. if (setting_xianshi_is_youtu == "1")
  66. {
  67. //样式① 图上文下:148x172(与 diandan_fooditem_youtu.xml 卡片一致)
  68. SIZE itemsize;
  69. itemsize.cx = 148;
  70. itemsize.cy = 172;
  71. m_foodLayout->SetItemSize(itemsize);
  72. xml_name = _T("diandan_fooditem_youtu.xml");
  73. }
  74. else if (setting_xianshi_is_youtu == "2")
  75. {
  76. //样式② 图左文右:250x82(与 diandan_fooditem_youtu_2.xml 卡片一致)
  77. SIZE itemsize;
  78. itemsize.cx = 250;
  79. itemsize.cy = 82;
  80. m_foodLayout->SetItemSize(itemsize);
  81. xml_name = _T("diandan_fooditem_youtu_2.xml");
  82. }
  83. else if (setting_xianshi_is_youtu == "3")
  84. {
  85. //样式③ 名字价格压图:148x150(与 diandan_fooditem_youtu_3.xml 卡片一致)
  86. SIZE itemsize;
  87. itemsize.cx = 148;
  88. itemsize.cy = 150;
  89. m_foodLayout->SetItemSize(itemsize);
  90. xml_name = _T("diandan_fooditem_youtu_3.xml");
  91. }
  92. else
  93. {
  94. //样式④ 纯文字:148x96(与 diandan_fooditem_wutu.xml 卡片一致)
  95. SIZE itemsize;
  96. itemsize.cx = 148;
  97. itemsize.cy = 96;
  98. m_foodLayout->SetItemSize(itemsize);
  99. xml_name = _T("diandan_fooditem_wutu.xml");
  100. }
  101. //如果当前一个分类都没有,那么就不处理了
  102. if (m_cur_type_id == "")
  103. {
  104. return;
  105. }
  106. else if (m_cur_type_id == "sousuo")
  107. {
  108. if (CLewaimaiString::is_only_number(m_sousuo_foodname))
  109. {
  110. //说明是纯数字,按商品条码来搜索
  111. CSqlite3 sqlite;
  112. CFood food;
  113. bool ret = sqlite.GetFoodByBarcode(m_sousuo_foodname, food);
  114. if (ret)
  115. {
  116. CDialogBuilder builder;
  117. CDialogBuilderCallbackEx cb;
  118. CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
  119. m_foodLayout->Add(pItem);
  120. pItem->SetYoutuModel(setting_xianshi_is_youtu);
  121. pItem->SetFoodInfo(food);
  122. pItem->UpdateShow();
  123. }
  124. }
  125. else
  126. {
  127. //当商品名字来搜索
  128. CSqlite3 sqlite;
  129. std::vector<CFood> foodlist = sqlite.GetFoodByFoodname(m_sousuo_foodname);
  130. for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
  131. {
  132. CFood food = *it;
  133. CDialogBuilder builder;
  134. CDialogBuilderCallbackEx cb;
  135. CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
  136. m_foodLayout->Add(pItem);
  137. pItem->SetYoutuModel(setting_xianshi_is_youtu);
  138. pItem->SetFoodInfo(food);
  139. pItem->UpdateShow();
  140. }
  141. }
  142. }
  143. }
  144. //仅仅初始化结算相关的显示(比如折扣、优惠、价格等)
  145. void CSaomashouyinPageUI::InitJiesuanShow()
  146. {
  147. //先清空会员登录状态
  148. this->ClickMemberLogout();
  149. m_is_member_zhekou = false;
  150. m_member_zhekou_value = 10;
  151. //再初始化取单数量
  152. RefreshGuadanNum();
  153. //先初始化折扣值
  154. CEditUI* pZhekouEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhekou_value")));
  155. pZhekouEdit->SetText(L"100");
  156. //再初始化加价
  157. m_jiajia = 0;
  158. CEditUI* pJiajiaEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_jiajia_value")));
  159. pJiajiaEdit->SetText(L"0");
  160. //初始化优惠
  161. m_rengong_youhui = 0;
  162. CEditUI* pYouhuiEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhui_value")));
  163. pYouhuiEdit->SetText(L"0");
  164. //优惠券
  165. m_is_youhuiquan = false;
  166. CLabelUI* pYouhuiquanEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_status")));
  167. pYouhuiquanEdit->SetText(L"未使用");
  168. CButtonUI* pYouhuiquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_btn_cancel")));
  169. pYouhuiquanCancel->SetVisible(false);
  170. //商品券
  171. m_is_shangpinquan = false;
  172. CLabelUI* pShangpinEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_status")));
  173. pShangpinEdit->SetText(L"未使用");
  174. CButtonUI* pShangpinquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_btn_cancel")));
  175. pShangpinquanCancel->SetVisible(false);
  176. //次卡
  177. m_is_cika = false;
  178. CLabelUI* pCikaEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_status")));
  179. pCikaEdit->SetText(L"未使用");
  180. CButtonUI* pCikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_btn_cancel")));
  181. pCikaCancel->SetVisible(false);
  182. //权益卡
  183. m_is_quanyika = false;
  184. CLabelUI* pQuanyikaEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_status")));
  185. pQuanyikaEdit->SetText(L"未使用");
  186. CButtonUI* pQuanyikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_btn_cancel")));
  187. pQuanyikaCancel->SetVisible(false);
  188. //抹零
  189. std::string diandan_moling_type = CSetting::GetInstance()->GetParam("saomashouyin_moling_type");
  190. m_moling_type = atoi(diandan_moling_type.c_str());
  191. if (m_moling_type == 0)
  192. {
  193. CCheckBoxUI* pMolingCheck = static_cast<CCheckBoxUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_moling_bumoling")));
  194. pMolingCheck->Selected(true, false);
  195. }
  196. else if (m_moling_type == 1)
  197. {
  198. CCheckBoxUI* pMolingCheck = static_cast<CCheckBoxUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_moling_molingdaojiao")));
  199. pMolingCheck->Selected(true, false);
  200. }
  201. else if (m_moling_type == 2)
  202. {
  203. CCheckBoxUI* pMolingCheck = static_cast<CCheckBoxUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_moling_molingdaoyuan")));
  204. pMolingCheck->Selected(true, false);
  205. }
  206. }
  207. void CSaomashouyinPageUI::InitJiesuanZhifu()
  208. {
  209. CHorizontalLayoutUI* pZhifufangshiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_layout")));
  210. int num = 0;
  211. CHorizontalLayoutUI* pWeixinLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_weixinzhifu")));
  212. if (CShopinfo::GetInstance()->m_is_online_pay_open == "1")
  213. {
  214. //展示微信支付,并且调整位置
  215. pWeixinLayout->SetVisible(true);
  216. num++;
  217. }
  218. else
  219. {
  220. pZhifufangshiLayout->RemoveAt(num);
  221. }
  222. //会员支付
  223. CHorizontalLayoutUI* pHuiyuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_huiyuan")));
  224. if (CShopinfo::GetInstance()->m_is_vip_pay_open == "1")
  225. {
  226. pHuiyuanLayout->SetVisible(true);
  227. num++;
  228. }
  229. else
  230. {
  231. pZhifufangshiLayout->RemoveAt(num);
  232. }
  233. //现金支付
  234. CHorizontalLayoutUI* pXianjinLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_xianjin")));
  235. if (CShopinfo::GetInstance()->m_is_cash_pay_open == "1")
  236. {
  237. pXianjinLayout->SetVisible(true);
  238. num++;
  239. }
  240. else
  241. {
  242. pZhifufangshiLayout->RemoveAt(num);
  243. }
  244. /*
  245. //购物卡
  246. CHorizontalLayoutUI* pGouwukaLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_gouwuka")));
  247. if (CShopinfo::GetInstance()->m_is_giftcard_pay_open == "1")
  248. {
  249. pGouwukaLayout->SetVisible(true);
  250. num++;
  251. }
  252. else
  253. {
  254. pGouwukaLayout->SetVisible(false);
  255. }
  256. //美食城临时卡
  257. CHorizontalLayoutUI* pMeishichengLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_meishicheng")));
  258. if (CShopinfo::GetInstance()->m_is_food_town_card_pay_open == "1")
  259. {
  260. pMeishichengLayout->SetVisible(true);
  261. num++;
  262. }
  263. else
  264. {
  265. pMeishichengLayout->SetVisible(false);
  266. }
  267. */
  268. //福利卡
  269. CHorizontalLayoutUI* pFulikaLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_fulika")));
  270. if (CShopinfo::GetInstance()->m_is_open_fulika_pay == "1")
  271. {
  272. pFulikaLayout->SetVisible(true);
  273. num++;
  274. }
  275. else
  276. {
  277. pZhifufangshiLayout->RemoveAt(num);
  278. }
  279. //接着添加自定义支付的
  280. for (std::vector<SelfPay>::iterator it = CShopinfo::GetInstance()->m_self_pay.begin(); it != CShopinfo::GetInstance()->m_self_pay.end(); it++)
  281. {
  282. SelfPay selfpay = *it;
  283. if (selfpay.is_open == "1")
  284. {
  285. CButtonUI* newButton = new CButtonUI();
  286. newButton->SetFixedWidth(120);
  287. newButton->SetFixedHeight(54);
  288. newButton->SetText(CLewaimaiString::UTF8ToUnicode(selfpay.name).c_str());
  289. //与固定支付方式统一:白色圆角按钮(pay_more 三态图),文字深灰
  290. newButton->SetAttribute(L"normalimage", L"file='pay_more_n.png' corner='8,8,8,8'");
  291. newButton->SetAttribute(L"hotimage", L"file='pay_more_h.png' corner='8,8,8,8'");
  292. newButton->SetAttribute(L"pushedimage", L"file='pay_more_p.png' corner='8,8,8,8'");
  293. newButton->SetAttribute(L"textcolor", L"#FF5F6368");
  294. newButton->SetAttribute(L"font", L"13");
  295. //设置定义属性,在点击按钮的时候好区分
  296. newButton->SetAttribute(L"name", L"saomashouyin_jiesuan_zhifufangshi_zidingyi_btn");
  297. newButton->AddCustomAttribute(L"selfpay_id", CLewaimaiString::UTF8ToUnicode(selfpay.id).c_str());
  298. newButton->SetAttribute(L"float", L"true");
  299. //必须先Add,才能调用下面的SetPos,否则无效
  300. pZhifufangshiLayout->Add(newButton);
  301. num++;
  302. }
  303. }
  304. m_nZhiufuNum = num;
  305. }
  306. void CSaomashouyinPageUI::UpdateJiesuanZhifuPos()
  307. {
  308. //添加支付方式
  309. int nWidth = m_nPageWidth;
  310. if (nWidth == 0)
  311. {
  312. return;
  313. }
  314. int nZhangdanWidth;
  315. if (m_is_yincangyouhui == true)
  316. {
  317. nZhangdanWidth = nWidth - 647 - 13; // 隐藏优惠后只剩账单卡;13=右侧 inset12 + 余量1
  318. }
  319. else
  320. {
  321. nZhangdanWidth = nWidth - 647 - 330 - 12 - 13; // 优惠卡330 + 卡间距12;13=右侧 inset12 + 余量1
  322. }
  323. if (nZhangdanWidth < 292)
  324. {
  325. nZhangdanWidth = 292; // 2 个支付按钮(20+132+120=272)+ 右边距 20
  326. }
  327. CVerticalLayoutUI* pZhangdanLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(L"saomashouyin_page_jiesuan_zhangdan_layout"));
  328. pZhangdanLayout->SetFixedWidth(nZhangdanWidth);
  329. //根据宽度计算每行显示的数量(扫码收银页按需求固定每行 2 个支付方式)
  330. int nMeihangNum = (nZhangdanWidth) / 132;
  331. if (nMeihangNum < 1)
  332. {
  333. nMeihangNum = 1;
  334. }
  335. if (nMeihangNum > 2)
  336. {
  337. nMeihangNum = 2;
  338. }
  339. int num = 0;
  340. CHorizontalLayoutUI* pZhifufangshiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhifufangshi_layout")));
  341. for (int i = 0; i < m_nZhiufuNum; i++)
  342. {
  343. CButtonUI* curItem = static_cast<CButtonUI*>(pZhifufangshiLayout->GetItemAt(i));
  344. int curRow = num / nMeihangNum + 1;
  345. int curCol = num % nMeihangNum + 1;
  346. RECT rect;
  347. rect.left = (curCol - 1) * 132 + 20;
  348. rect.right = rect.left + 120;
  349. rect.top = (curRow - 1) * 64 + 6;
  350. rect.bottom = rect.top + 54;
  351. // 强制设置固定大小和位置
  352. SIZE size;
  353. size.cx = rect.left;
  354. size.cy = rect.top;
  355. curItem->SetFixedXY(size);
  356. curItem->SetFixedWidth(rect.right - rect.left);
  357. curItem->SetFixedHeight(rect.bottom - rect.top);
  358. num++;
  359. }
  360. //调整区域高度
  361. int lastRow = (num - 1) / nMeihangNum + 1;
  362. pZhifufangshiLayout->SetFixedHeight((lastRow - 1) * 64 + 60);
  363. }
  364. //展示结算页面,隐藏选购页面
  365. void CSaomashouyinPageUI::ShowJiesuanPage()
  366. {
  367. //先隐藏商品页面
  368. CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("saomashouyin_food_layout")));
  369. pFoodLayout->SetVisible(false);
  370. //再展示结算页面
  371. CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_layout")));
  372. pJiesuanLayout->SetVisible(true);
  373. //更新结算按钮位置
  374. UpdateJiesuanZhifuPos();
  375. }
  376. //展示选购页面,隐藏结算页面
  377. void CSaomashouyinPageUI::ShowXuangouPage()
  378. {
  379. //先展示商品页面
  380. CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("saomashouyin_food_layout")));
  381. pFoodLayout->SetVisible(true);
  382. //再隐藏结算页面
  383. CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_layout")));
  384. pJiesuanLayout->SetVisible(false);
  385. }
  386. //只是刷新取单数量
  387. void CSaomashouyinPageUI::RefreshGuadanNum()
  388. {
  389. size_t guadan_num = m_guadan_orders.size();
  390. CLabelUI* pNum = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_page_qudan_num")));
  391. if (guadan_num > 0)
  392. {
  393. //有挂单的
  394. pNum->SetText(std::to_wstring(guadan_num).c_str());
  395. pNum->SetVisible(true);
  396. }
  397. else
  398. {
  399. //没有挂单的
  400. pNum->SetVisible(false);
  401. }
  402. }
  403. //处理按钮点击类事件
  404. void CSaomashouyinPageUI::HandleClickMsg(TNotifyUI& msg)
  405. {
  406. CDuiString name = msg.pSender->GetName();
  407. if (name == L"diandan_fooditem")
  408. {
  409. CDiandanFoodItemUI* fooditemUI = static_cast<CDiandanFoodItemUI*>(msg.pSender);
  410. m_cur_click_food_item = fooditemUI;
  411. this->ClickFoodAction();
  412. }
  413. else if (name == L"btn_saomashouyin_jia")
  414. {
  415. this->ClickAdd();
  416. }
  417. else if (name == L"btn_saomashouyin_jian")
  418. {
  419. this->ClickDel();
  420. }
  421. else if (name == L"btn_saomashouyin_shanchu")
  422. {
  423. this->ClickRemove();
  424. }
  425. else if (name == L"btn_saomashouyin_guige")
  426. {
  427. this->ClickGuige();
  428. }
  429. else if (name == L"btn_saomashouyin_qingkong")
  430. {
  431. //纯粹用于调试物理键盘
  432. //CSystem::ShowKeyboardDeviceNames();
  433. this->ClickQingkong();
  434. }
  435. else if (name == L"btn_saomashouyin_gengduozhifu_pay")
  436. {
  437. //点击更多支付
  438. this->ClickGengduoPay();
  439. }
  440. else if (name == L"btn_saomashouyin_jixujiacai")
  441. {
  442. }
  443. else if (name == L"btn_saomashouyin_dabao")
  444. {
  445. //点击打包
  446. this->ClickDabao();
  447. }
  448. else if (name == L"btn_saomashouyin_member_login")
  449. {
  450. //点击会员登录
  451. this->ClickMemberLogin();
  452. }
  453. else if (name == L"btn_saomashouyin_member_chongzhi")
  454. {
  455. //点击会员充值
  456. this->ClickMemberChongzhi();
  457. }
  458. else if (name == L"saomashouyin_cart_item")
  459. {
  460. //购物车行被选中:选中行名字绿色,其余恢复黑色(底色由 List 的 itemselectedbkcolor 处理)
  461. this->RefreshCartItemSelectedColor();
  462. return;
  463. }
  464. else if (name == L"saomashouyin_jiesuan_zhekou_value")
  465. {
  466. //点击整单折扣
  467. this->ClickZhekou();
  468. }
  469. else if (name == L"saomashouyin_jiesuan_jiajia_value")
  470. {
  471. //点击加价
  472. this->ClickJiajia();
  473. }
  474. else if (name == L"saomashouyin_jiesuan_youhui_value")
  475. {
  476. //点击人工优惠
  477. this->ClickRengongyouhui();
  478. }
  479. else if (name == L"saomashouyin_jiesuan_youhuiquan_btn")
  480. {
  481. //点击扫码优惠券
  482. this->ClickSaomaYouhuiquan();
  483. }
  484. else if (name == L"saomashouyin_jiesuan_shangpinquan_btn")
  485. {
  486. //点击扫码商品券
  487. this->ClickSaomaShangpinquan();
  488. }
  489. else if (name == L"saomashouyin_jiesuan_cika_btn")
  490. {
  491. //点击扫码次卡
  492. this->ClickSaomaCika();
  493. }
  494. else if (name == L"saomashouyin_jiesuan_quanyika_btn")
  495. {
  496. //点击扫码权益卡
  497. this->ClickSaomaQuanyika();
  498. }
  499. else if (name == L"btn_saomashouyin_weixinzhifu_pay" || name == L"saomashouyin_jiesuan_zhifufangshi_weixinzhifu_btn")
  500. {
  501. //点击微信支付
  502. this->StartWeixinzhifuShoukuan();
  503. }
  504. else if (name == L"btn_saomashouyin_huiyuanzhifu_pay" || name == L"saomashouyin_jiesuan_zhifufangshi_huiyuan_btn")
  505. {
  506. //点击会员收款
  507. this->StartHuiyuanShoukuan();
  508. }
  509. else if (name == L"btn_saomashouyin_xianjinzhifu_pay" || name == L"saomashouyin_jiesuan_zhifufangshi_xianjin_btn")
  510. {
  511. //点击现金收款
  512. this->StartXianjinShoukuan();
  513. }
  514. else if (name == L"saomashouyin_jiesuan_zhifufangshi_fulika_btn")
  515. {
  516. //福利卡收款
  517. this->StartFulikaShoukuan();
  518. }
  519. else if (name == L"saomashouyin_jiesuan_zhifufangshi_zidingyi_btn")
  520. {
  521. //自定义支付
  522. std::wstring name = msg.pSender->GetText();
  523. std::wstring selfpay_id = msg.pSender->GetCustomAttribute(L"selfpay_id");
  524. this->StartZidingyiShoukuan(name, selfpay_id);
  525. }
  526. else if (name == L"saomashouyin_food_search_clear")
  527. {
  528. CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("saomashouyin_food_search_edit")));
  529. m_pEdit->SetText(L"");
  530. StopSerachFood();
  531. }
  532. else if (name == L"btn_saomashouyin_cundan")
  533. {
  534. this->ClickCundan();
  535. }
  536. else if (name == L"btn_saomashouyin_qudan")
  537. {
  538. this->ClickQudan();
  539. }
  540. else if (name == L"btn_saomashouyin_qianxiang")
  541. {
  542. CPosPrinter printer;
  543. printer.OpenQianxiang();
  544. }
  545. else if (name == L"saomashouyin_jiesuan_youhuiquan_btn_cancel")
  546. {
  547. this->ClickQuxiaoYouhuiquan();
  548. }
  549. else if (name == L"saomashouyin_jiesuan_shangpinquan_btn_cancel")
  550. {
  551. this->ClickQuxiaoShangpinquan();
  552. }
  553. else if (name == L"saomashouyin_jiesuan_quanyika_btn_cancel")
  554. {
  555. this->ClickQuxiaoQuanyika();
  556. }
  557. else if (name == L"saomashouyin_jiesuan_cika_btn_cancel")
  558. {
  559. this->ClickQuxiaoCika();
  560. }
  561. else if (name == L"saomashouyin_jiesuan_yincangyouhui_btn")
  562. {
  563. this->YincangYouhui();
  564. }
  565. else if (name == L"saomashouyin_jiesuan_xianshiyouhui_btn")
  566. {
  567. this->XianshiYouhui();
  568. }
  569. else if (name == L"saomashouyin_page_member_out_btn")
  570. {
  571. this->ClickMemberLogout();
  572. }
  573. else if (name == L"saomashouyin_page_member_info_btn")
  574. {
  575. this->ClickMemberInfoShow();
  576. }
  577. else if (name == L"saomashouyin_page_aixuexi_btn")
  578. {
  579. this->ClickAixuexi();
  580. }
  581. else if (name == L"saomashouyin_page_chengzhong_zhiling")
  582. {
  583. this->ZhiLing();
  584. }
  585. else if (name == L"saomashouyin_page_chengzhong_qupi")
  586. {
  587. this->Qupi();
  588. }
  589. }
  590. //处理option切换事件
  591. void CSaomashouyinPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
  592. {
  593. CDuiString name = msg.pSender->GetName();
  594. COptionUI* curOption = static_cast<COptionUI*>(msg.pSender);
  595. std::wstring groupname = curOption->GetGroup();
  596. if (groupname == L"saomashouyin_jiesuan_moling")
  597. {
  598. if (name == _T("saomashouyin_jiesuan_moling_bumoling"))
  599. {
  600. m_moling_type = 0;
  601. CSetting::GetInstance()->SetParam("saomashouyin_moling_type", "0");
  602. UpdateJiesuanInfo();
  603. }
  604. else if (name == _T("saomashouyin_jiesuan_moling_molingdaojiao"))
  605. {
  606. m_moling_type = 1;
  607. CSetting::GetInstance()->SetParam("saomashouyin_moling_type", "1");
  608. UpdateJiesuanInfo();
  609. }
  610. else if (name == _T("saomashouyin_jiesuan_moling_molingdaoyuan"))
  611. {
  612. m_moling_type = 2;
  613. CSetting::GetInstance()->SetParam("saomashouyin_moling_type", "2");
  614. UpdateJiesuanInfo();
  615. }
  616. }
  617. }
  618. //处理下拉框、radio的切换事件
  619. void CSaomashouyinPageUI::HandleItemSelectMsg(TNotifyUI& msg)
  620. {
  621. }
  622. //处理编辑框输入内容改变事件
  623. void CSaomashouyinPageUI::HandleTextChangedMsg(TNotifyUI& msg)
  624. {
  625. CDuiString name = msg.pSender->GetName();
  626. if (name == L"saomashouyin_food_search_edit")
  627. {
  628. //商品搜索框的输入事件
  629. CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("saomashouyin_food_search_edit")));
  630. std::wstring ws_Value = m_pEdit->GetText();
  631. std::string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
  632. if (strValue.length() == 0)
  633. {
  634. //搜索词被清空了,退出搜索
  635. this->StopSerachFood();
  636. }
  637. else
  638. {
  639. //搜索词没清空,进入搜索
  640. this->StartSearchFood(strValue);
  641. }
  642. }
  643. }
  644. //处理扫码枪捕捉到的扫码信息
  645. void CSaomashouyinPageUI::HandleTextCapture(std::string content)
  646. {
  647. if (m_is_show_modal_wnd == true)
  648. {
  649. m_curModalWnd->HandleTextCapture(content);
  650. return;
  651. }
  652. //没有任何弹框,那么就是按扫描商品条码来处理
  653. bool ret = this->SaomiaoBarcode(content);
  654. if (ret == true)
  655. {
  656. //已经找到了条码,那么就处理完了
  657. return;
  658. }
  659. if (content.length() != 12 && content.length() != 13 && content.length() != 17 && content.length() != 18)
  660. {
  661. //位数不对,那肯定不是称重条码
  662. }
  663. else
  664. {
  665. //如果没有找到条码,就找一下是不是称重的标签秤的码,这个时候要对码进行各种分析了
  666. ret = this->BiaoqianchengSaomaBarcode(content);
  667. if (ret == true)
  668. {
  669. return;
  670. }
  671. }
  672. //代码走到这里,肯定不是条码了,也不是称重码,判断是不是付款码
  673. std::string s_Fukuanma = content;
  674. int length = s_Fukuanma.size();
  675. if (length != 18 && length != 19)
  676. {
  677. //肯定不是付款码
  678. m_pMainWnd->ShowToast(L"无效的条码!");
  679. return;
  680. }
  681. for (int i = 0; i < length; i++)
  682. {
  683. char c = *(s_Fukuanma.c_str() + i);
  684. if (isdigit(c) == 0)
  685. {
  686. //不是数字
  687. m_pMainWnd->ShowToast(L"无效的条码!");
  688. return;
  689. }
  690. }
  691. if (s_Fukuanma.find("10") == 0 \
  692. || s_Fukuanma.find("11") == 0 \
  693. || s_Fukuanma.find("12") == 0 \
  694. || s_Fukuanma.find("13") == 0 \
  695. || s_Fukuanma.find("14") == 0 \
  696. || s_Fukuanma.find("15") == 0)
  697. {
  698. //微信付款码
  699. }
  700. else if (s_Fukuanma.find("25") == 0 \
  701. || s_Fukuanma.find("26") == 0 \
  702. || s_Fukuanma.find("27") == 0 \
  703. || s_Fukuanma.find("28") == 0 \
  704. || s_Fukuanma.find("29") == 0 \
  705. || s_Fukuanma.find("30") == 0)
  706. {
  707. //支付宝付款码
  708. }
  709. else if (s_Fukuanma.find("62") == 0)
  710. {
  711. //云闪付付款码
  712. }
  713. else
  714. {
  715. m_pMainWnd->ShowToast(L"无效的条码!");
  716. return;
  717. }
  718. //代码能走到这里,说明肯定就是付款码了,默认唤起支付
  719. this->StartWeixinzhifuShoukuan(content);
  720. }
  721. bool CSaomashouyinPageUI::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  722. {
  723. if (uMsg == WM_MYHOTKEY_WEIXIN_SHOUKUAN)
  724. {
  725. StartWeixinzhifuShoukuan();
  726. return true;
  727. }
  728. else if (uMsg == WM_MYHOTKEY_HUIYUAN_DENGLU)
  729. {
  730. ClickMemberLogin();
  731. return true;
  732. }
  733. else if (uMsg == WM_MYHOTKEY_HUIYUAN_SHOUKUAN)
  734. {
  735. StartHuiyuanShoukuan();
  736. return true;
  737. }
  738. else if (uMsg == WM_MYHOTKEY_XIANJIN_SHOUKUAN)
  739. {
  740. StartXianjinShoukuan();
  741. return true;
  742. }
  743. return false;
  744. }
  745. //刷新购物车行选中文字色(选中行名字绿色 #2E9B5C,其余恢复默认 #1F2329)
  746. void CSaomashouyinPageUI::RefreshCartItemSelectedColor()
  747. {
  748. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  749. if (pList == NULL)
  750. {
  751. return;
  752. }
  753. for (int i = 0; i < pList->GetCount(); i++)
  754. {
  755. CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(pList->GetItemAt(i));
  756. if (pEle == NULL)
  757. {
  758. continue;
  759. }
  760. CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_name")));
  761. if (pName == NULL)
  762. {
  763. continue;
  764. }
  765. pName->SetTextColor(pEle->IsSelected() ? 0xFF2E9B5C : 0xFF1F2329);
  766. //序号同步高亮,选中行更容易辨认
  767. CLabelUI* pXuhao = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_xuhao")));
  768. if (pXuhao != NULL)
  769. {
  770. pXuhao->SetTextColor(pEle->IsSelected() ? 0xFF2E9B5C : 0xFF1F2329);
  771. }
  772. }
  773. }
  774. void CSaomashouyinPageUI::UpdateShopcartShow(bool is_add_new)
  775. {
  776. //先保留选中
  777. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  778. int nIndex = pList->GetCurSel();
  779. //保留滚动条位置
  780. SIZE ScrollPos = pList->GetScrollPos();
  781. //先清空
  782. pList->RemoveAll();
  783. int nItemNum = m_cur_diandan_order.getItemNum();
  784. for (int i = 0; i < nItemNum; i++)
  785. {
  786. CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(i);
  787. CDialogBuilder builder;
  788. CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("saomashouyin_cart_item.xml"), (UINT)0, NULL, m_pManager));
  789. pList->Add(pEle);
  790. CLabelUI* pXuhao = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_xuhao")));
  791. pXuhao->SetText(std::to_wstring(i + 1).c_str());
  792. if (item.m_is_taocan)
  793. {
  794. CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_name")));
  795. pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
  796. CLabelUI* pTiaoma = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_tiaoma")));
  797. pTiaoma->SetText(L"");
  798. CLabelUI* pDanjia = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_danjia")));
  799. pDanjia->SetText(CLewaimaiString::UTF8ToUnicode(item.price).c_str());
  800. CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_num")));
  801. pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
  802. CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_price")));
  803. pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
  804. CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_nature")));
  805. pEle->SetFixedHeight(84);
  806. pNature->SetVisible(true);
  807. pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
  808. }
  809. else
  810. {
  811. CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_name")));
  812. pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
  813. CLabelUI* pTiaoma = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_tiaoma")));
  814. pTiaoma->SetText(CLewaimaiString::UTF8ToUnicode(item.barcode).c_str());
  815. CLabelUI* pDanjia = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_danjia")));
  816. pDanjia->SetText(CLewaimaiString::UTF8ToUnicode(item.price).c_str());
  817. CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_num")));
  818. pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
  819. CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_price")));
  820. pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
  821. CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("saomashouyin_cart_item_nature")));
  822. if (item.is_nature)
  823. {
  824. pEle->SetFixedHeight(84);
  825. pNature->SetVisible(true);
  826. pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
  827. }
  828. else
  829. {
  830. pEle->SetFixedHeight(42);
  831. pNature->SetVisible(false);
  832. }
  833. }
  834. }
  835. if (is_add_new == true)
  836. {
  837. //必须先刷新重绘,再获取range才准
  838. pList->NeedUpdate();
  839. pList->Invalidate();
  840. m_pManager->Invalidate();
  841. //这个是同步阻塞重绘
  842. ::UpdateWindow(m_pManager->GetPaintWindow());
  843. //增加新商品,选中最后一个
  844. pList->SelectItem(nItemNum - 1, false);
  845. pList->EnsureVisible(nItemNum - 1);
  846. }
  847. else
  848. {
  849. //保留选中
  850. if (nIndex != -1 && pList->GetCount() > 0)
  851. {
  852. if (nIndex <= pList->GetCount() - 1)
  853. {
  854. pList->SelectItem(nIndex, false);
  855. }
  856. else
  857. {
  858. pList->SelectItem(pList->GetCount() - 1, false);
  859. }
  860. }
  861. //恢复滚动条位置
  862. pList->SetScrollPos(ScrollPos);
  863. }
  864. //更新选中行文字色 + 结算信息
  865. RefreshCartItemSelectedColor();
  866. UpdateJiesuanInfo();
  867. }
  868. void CSaomashouyinPageUI::UpdateJiesuanInfo()
  869. {
  870. //先按所有的价格公式规则,计算一次价格
  871. //(基础商品价格+属性价格-商品券-次卡(抵扣金额、抵扣商品)-会员商品优惠)*店铺折扣*分等级会员折扣*权益卡折扣*次卡折扣-满减优惠-次卡满减-优惠券+加价-优惠-抹零+开台费+打包费+茶位费
  872. //先计算基础商品价格(不包含任何优惠活动等情况下的实际金额,已包含商品属性价格)
  873. double jichu_price = m_cur_diandan_order.getTotalPrice();
  874. //这个是临时变量,表示每次优惠过后的实时价格
  875. double cur_price = jichu_price;
  876. double total_youhui = 0;
  877. //判断是否有商品券,如果有的话把金额抵扣掉
  878. m_shangpinquan_youhui = 0;
  879. if (m_is_shangpinquan)
  880. {
  881. //判断当前购物车商品,是否有满足对应商品券使用要求的
  882. bool ret = m_cur_diandan_order.UseShangpinquan(m_shangpinquan_foodid, m_shangpinquan_youhui);
  883. total_youhui += m_shangpinquan_youhui;
  884. }
  885. //判断次卡
  886. m_cika_youhui = 0;
  887. if (m_is_cika)
  888. {
  889. //对次卡进行处理
  890. if (m_cika_deduct_type == "0")
  891. {
  892. }
  893. else if (m_cika_deduct_type == "1")
  894. {
  895. }
  896. else if (m_cika_deduct_type == "2")
  897. {
  898. m_cika_youhui = atof(m_cika_offer_value.c_str());
  899. }
  900. else if (m_cika_deduct_type == "3")
  901. {
  902. //这种情况是次卡跟商品券一样抵扣商品\
  903. bool ret;
  904. if (m_is_shangpinquan && m_shangpinquan_foodid == m_cika_bind_foods_id)
  905. {
  906. ret = m_cur_diandan_order.UseCikaDikou(m_cika_bind_foods_id, m_cika_youhui, true);
  907. }
  908. else
  909. {
  910. ret = m_cur_diandan_order.UseCikaDikou(m_cika_bind_foods_id, m_cika_youhui, false);
  911. }
  912. }
  913. total_youhui += m_cika_youhui;
  914. }
  915. //判断会员商品优惠
  916. m_total_member_youhui = 0;
  917. if (m_is_member)
  918. {
  919. m_total_member_youhui = m_cur_diandan_order.getTotalMemberYouhui(m_member_level);
  920. }
  921. total_youhui += m_total_member_youhui;
  922. cur_price = jichu_price - total_youhui;
  923. //再判断整单折扣
  924. CEditUI* pZhekouEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhekou_value")));
  925. std::wstring ws_zhekou = pZhekouEdit->GetText();
  926. int zhekouValue = atoi(CLewaimaiString::UnicodeToUTF8(ws_zhekou).c_str());
  927. m_zhekou_value = zhekouValue;
  928. if (zhekouValue == 100)
  929. {
  930. m_zhekou_youhui = 0;
  931. }
  932. else
  933. {
  934. m_zhekou_youhui = (100 - zhekouValue) * cur_price / 100.00;
  935. total_youhui += m_zhekou_youhui;
  936. cur_price = cur_price - m_zhekou_youhui;
  937. }
  938. //再判断分等级会员折扣
  939. m_member_zhekou_youhui = 0;
  940. std::vector<DiscountInfo> member_discount_info = CShopinfo::GetInstance()->m_discount_info;
  941. for (std::vector<DiscountInfo>::iterator it = member_discount_info.begin(); it != member_discount_info.end(); it++)
  942. {
  943. DiscountInfo info = *it;
  944. if (info.member_level == m_member_level)
  945. {
  946. if (info.is_discount == "1")
  947. {
  948. m_is_member_zhekou = true;
  949. m_member_zhekou_value = info.discount_value;
  950. double member_discount = atof(info.discount_value.c_str());
  951. if (abs(member_discount - 10) < 0.0001)
  952. {
  953. m_member_zhekou_youhui = 0;
  954. }
  955. else
  956. {
  957. m_member_zhekou_youhui = (10 - member_discount) * cur_price / 10.00;
  958. total_youhui += m_member_zhekou_youhui;
  959. cur_price -= m_member_zhekou_youhui;
  960. }
  961. break;
  962. }
  963. }
  964. }
  965. //再判断权益卡折扣
  966. m_quanyika_youhui = 0;
  967. if (m_is_quanyika == true)
  968. {
  969. double quanyika_zhekou = atof(m_quanyika_discount.c_str());
  970. if (abs(quanyika_zhekou - 10) < 0.0001)
  971. {
  972. m_quanyika_youhui = 0;
  973. }
  974. else
  975. {
  976. m_quanyika_youhui = (10 - quanyika_zhekou) * cur_price / 10.00;
  977. total_youhui += m_quanyika_youhui;
  978. cur_price -= m_quanyika_youhui;
  979. }
  980. }
  981. //次卡折扣
  982. if (m_is_cika)
  983. {
  984. //对次卡进行处理
  985. if (m_cika_deduct_type == "0")
  986. {
  987. double cika_zhekou = atof(m_cika_discount_value.c_str());
  988. if (abs(cika_zhekou - 10) < 0.0001)
  989. {
  990. m_cika_youhui = 0;
  991. }
  992. else
  993. {
  994. m_cika_youhui = (10 - cika_zhekou) * cur_price / 10.00;
  995. total_youhui += m_cika_youhui;
  996. cur_price -= m_cika_youhui;
  997. }
  998. }
  999. }
  1000. //满减优惠
  1001. m_manjian_youhui = 0;
  1002. if (CShopinfo::GetInstance()->m_open_promotion == "1")
  1003. {
  1004. //开启了满减,进行判断
  1005. std::vector<Promotion> promotion = CShopinfo::GetInstance()->m_promotion;
  1006. for (std::vector<Promotion>::iterator it = promotion.begin(); it != promotion.end(); it++)
  1007. {
  1008. Promotion cur = *it;
  1009. if (jichu_price >= cur.amount)
  1010. {
  1011. m_manjian_youhui = cur.discount;
  1012. total_youhui += m_manjian_youhui;
  1013. cur_price -= m_manjian_youhui;
  1014. break;
  1015. }
  1016. }
  1017. }
  1018. //次卡满减
  1019. if (m_is_cika)
  1020. {
  1021. //对次卡进行处理
  1022. if (m_cika_deduct_type == "1")
  1023. {
  1024. std::vector<std::string> manjian = CLewaimaiString::Split(m_cika_full_reduce_value, ",");
  1025. double amount = atof(manjian[0].c_str());
  1026. double value = atof(manjian[1].c_str());
  1027. if (jichu_price >= amount)
  1028. {
  1029. m_cika_youhui = value;
  1030. total_youhui += m_cika_youhui;
  1031. cur_price -= m_cika_youhui;
  1032. }
  1033. }
  1034. }
  1035. //优惠券
  1036. m_youhuiquan_youhui = 0;
  1037. if (m_is_youhuiquan)
  1038. {
  1039. time_t deadline = CLewaimaiTime::StringToDatetime(m_coupon_deadline);
  1040. time_t now = time(NULL);
  1041. if (deadline > now)
  1042. {
  1043. if (jichu_price >= atof(m_coupon_basic_price.c_str()))
  1044. {
  1045. m_youhuiquan_youhui = atof(m_coupon_value.c_str());
  1046. total_youhui += m_youhuiquan_youhui;
  1047. cur_price -= m_youhuiquan_youhui;
  1048. }
  1049. }
  1050. }
  1051. //加价
  1052. m_jiajia = 0;
  1053. CEditUI* pJiajiaEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_jiajia_value")));
  1054. std::wstring ws_jiajia = pJiajiaEdit->GetText();
  1055. m_jiajia = atof(CLewaimaiString::UnicodeToUTF8(ws_jiajia).c_str());
  1056. cur_price += m_jiajia;
  1057. //人工优惠
  1058. m_rengong_youhui = 0;
  1059. CEditUI* pYouhuiEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhui_value")));
  1060. std::wstring ws_rengong_youhui = pYouhuiEdit->GetText();
  1061. m_rengong_youhui = atof(CLewaimaiString::UnicodeToUTF8(ws_rengong_youhui).c_str());
  1062. total_youhui += m_rengong_youhui;
  1063. cur_price -= m_rengong_youhui;
  1064. //开台费
  1065. m_kaitai = 0;
  1066. //打包费
  1067. m_dabao = m_cur_diandan_order.getDabaoMoney();
  1068. cur_price += m_dabao;
  1069. //茶位费
  1070. m_chawei = 0;
  1071. //抹零
  1072. m_moling_youhui = 0;
  1073. if (m_moling_type == 0)
  1074. {
  1075. }
  1076. else if (m_moling_type == 1)
  1077. {
  1078. double new_price = (int)(cur_price * 10) / 10.0;
  1079. m_moling_youhui = cur_price - new_price;
  1080. total_youhui += m_moling_youhui;
  1081. cur_price = new_price;
  1082. }
  1083. else if (m_moling_type == 2)
  1084. {
  1085. double new_price = (int)(cur_price);
  1086. m_moling_youhui = cur_price - new_price;
  1087. total_youhui += m_moling_youhui;
  1088. cur_price = new_price;
  1089. }
  1090. if (cur_price < 0)
  1091. {
  1092. cur_price = 0;
  1093. }
  1094. m_cur_total_price = cur_price;
  1095. m_total_youhui = total_youhui;
  1096. //至此优惠全部处理完了,开始刷新各个地方的展示
  1097. //再刷新份数显示
  1098. CLabelUI* pFenshuLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_page_fenshu")));
  1099. if (m_cur_diandan_order.getItemNum() > 0)
  1100. {
  1101. std::wstring ws_fenshu = L"共计<b><c #E14B4A>" + std::to_wstring(m_cur_diandan_order.getItemNum()) + L"</c></b>行,<b><c #E14B4A>" + std::to_wstring(m_cur_diandan_order.getTotalNum()) + L"</c></b>件商品";
  1102. pFenshuLabel->SetText(ws_fenshu.c_str());
  1103. }
  1104. else
  1105. {
  1106. pFenshuLabel->SetText(L"共<b><c #E14B4A>0</c></b>行,<b><c #E14B4A>0</c></b>件商品");
  1107. }
  1108. //再刷新账单明细展示
  1109. CVerticalLayoutUI* pmingxiLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhangdanmingxi_jiage_layout")));
  1110. pmingxiLayout->RemoveAll();
  1111. //账单卡偏窄时,明细行的 name/value 宽度按容器实际可用宽自适应,避免右侧金额被裁掉
  1112. int nMingxiContainerW = pmingxiLayout->GetWidth();
  1113. if (nMingxiContainerW <= 28)
  1114. {
  1115. //首帧尚未布局时 GetWidth() 可能为 0,退回用账单卡宽兜底
  1116. CVerticalLayoutUI* pZhangdan = static_cast<CVerticalLayoutUI*>(this->FindSubControl(L"saomashouyin_page_jiesuan_zhangdan_layout"));
  1117. if (pZhangdan != NULL)
  1118. {
  1119. nMingxiContainerW = pZhangdan->GetWidth();
  1120. }
  1121. }
  1122. int nMingxiAvail = nMingxiContainerW - 28; //28 = 容器左右 padding 14+14
  1123. if (nMingxiAvail < 200)
  1124. {
  1125. nMingxiAvail = 200;
  1126. }
  1127. int nMingxiValueW = nMingxiAvail / 2; //金额列占一半
  1128. if (nMingxiValueW < 110) { nMingxiValueW = 110; }
  1129. int nMingxiNameW = nMingxiAvail - nMingxiValueW;
  1130. if (nMingxiNameW < 90) { nMingxiNameW = 90; }
  1131. int item_num = 0;
  1132. //先显示基础价格
  1133. if (true)
  1134. {
  1135. CDialogBuilder builder;
  1136. CDialogBuilderCallbackEx cb;
  1137. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1138. pmingxiLayout->Add(pItem);
  1139. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1140. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1141. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1142. pName->SetFixedWidth(nMingxiNameW);
  1143. pValue->SetFixedWidth(nMingxiValueW);
  1144. pName->SetText(L"商品原价:");
  1145. pValue->SetText((CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(jichu_price, 2)) + L"元").c_str());
  1146. item_num++;
  1147. }
  1148. //开始展示各种优惠
  1149. if (m_shangpinquan_youhui > 0)
  1150. {
  1151. CDialogBuilder builder;
  1152. CDialogBuilderCallbackEx cb;
  1153. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1154. pmingxiLayout->Add(pItem);
  1155. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1156. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1157. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1158. pName->SetFixedWidth(nMingxiNameW);
  1159. pValue->SetFixedWidth(nMingxiValueW);
  1160. pName->SetText(L"商品券优惠:");
  1161. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_shangpinquan_youhui, 2)) + L"元").c_str());
  1162. pValue->SetTextColor(0xFFE14B4A);
  1163. item_num++;
  1164. }
  1165. if (m_cika_youhui > 0)
  1166. {
  1167. CDialogBuilder builder;
  1168. CDialogBuilderCallbackEx cb;
  1169. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1170. pmingxiLayout->Add(pItem);
  1171. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1172. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1173. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1174. pName->SetFixedWidth(nMingxiNameW);
  1175. pValue->SetFixedWidth(nMingxiValueW);
  1176. pName->SetText(L"次卡优惠:");
  1177. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_cika_youhui, 2)) + L"元").c_str());
  1178. pValue->SetTextColor(0xFFE14B4A);
  1179. item_num++;
  1180. }
  1181. if (m_total_member_youhui > 0)
  1182. {
  1183. CDialogBuilder builder;
  1184. CDialogBuilderCallbackEx cb;
  1185. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1186. pmingxiLayout->Add(pItem);
  1187. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1188. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1189. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1190. pName->SetFixedWidth(nMingxiNameW);
  1191. pValue->SetFixedWidth(nMingxiValueW);
  1192. pName->SetText(L"商品会员价优惠:");
  1193. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_total_member_youhui, 2)) + L"元").c_str());
  1194. pValue->SetTextColor(0xFFE14B4A);
  1195. item_num++;
  1196. }
  1197. if (m_zhekou_youhui > 0)
  1198. {
  1199. CDialogBuilder builder;
  1200. CDialogBuilderCallbackEx cb;
  1201. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1202. pmingxiLayout->Add(pItem);
  1203. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1204. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1205. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1206. pName->SetFixedWidth(nMingxiNameW);
  1207. pValue->SetFixedWidth(nMingxiValueW);
  1208. pName->SetText(L"整单折扣优惠:");
  1209. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_zhekou_youhui, 2)) + L"元").c_str());
  1210. pValue->SetTextColor(0xFFE14B4A);
  1211. item_num++;
  1212. }
  1213. if (m_member_zhekou_youhui > 0)
  1214. {
  1215. CDialogBuilder builder;
  1216. CDialogBuilderCallbackEx cb;
  1217. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1218. pmingxiLayout->Add(pItem);
  1219. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1220. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1221. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1222. pName->SetFixedWidth(nMingxiNameW);
  1223. pValue->SetFixedWidth(nMingxiValueW);
  1224. pName->SetText(L"会员整单折扣优惠:");
  1225. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_member_zhekou_youhui, 2)) + L"元").c_str());
  1226. pValue->SetTextColor(0xFFE14B4A);
  1227. item_num++;
  1228. }
  1229. if (m_quanyika_youhui > 0)
  1230. {
  1231. CDialogBuilder builder;
  1232. CDialogBuilderCallbackEx cb;
  1233. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1234. pmingxiLayout->Add(pItem);
  1235. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1236. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1237. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1238. pName->SetFixedWidth(nMingxiNameW);
  1239. pValue->SetFixedWidth(nMingxiValueW);
  1240. pName->SetText(L"权益卡优惠:");
  1241. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_quanyika_youhui, 2)) + L"元").c_str());
  1242. pValue->SetTextColor(0xFFE14B4A);
  1243. item_num++;
  1244. }
  1245. if (m_manjian_youhui > 0)
  1246. {
  1247. CDialogBuilder builder;
  1248. CDialogBuilderCallbackEx cb;
  1249. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1250. pmingxiLayout->Add(pItem);
  1251. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1252. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1253. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1254. pName->SetFixedWidth(nMingxiNameW);
  1255. pValue->SetFixedWidth(nMingxiValueW);
  1256. pName->SetText(L"满减优惠:");
  1257. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_manjian_youhui, 2)) + L"元").c_str());
  1258. pValue->SetTextColor(0xFFE14B4A);
  1259. item_num++;
  1260. }
  1261. if (m_youhuiquan_youhui > 0)
  1262. {
  1263. CDialogBuilder builder;
  1264. CDialogBuilderCallbackEx cb;
  1265. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1266. pmingxiLayout->Add(pItem);
  1267. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1268. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1269. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1270. pName->SetFixedWidth(nMingxiNameW);
  1271. pValue->SetFixedWidth(nMingxiValueW);
  1272. pName->SetText(L"优惠券优惠:");
  1273. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_youhuiquan_youhui, 2)) + L"元").c_str());
  1274. pValue->SetTextColor(0xFFE14B4A);
  1275. item_num++;
  1276. }
  1277. if (m_rengong_youhui > 0)
  1278. {
  1279. CDialogBuilder builder;
  1280. CDialogBuilderCallbackEx cb;
  1281. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1282. pmingxiLayout->Add(pItem);
  1283. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1284. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1285. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1286. pName->SetFixedWidth(nMingxiNameW);
  1287. pValue->SetFixedWidth(nMingxiValueW);
  1288. pName->SetText(L"人工优惠:");
  1289. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_rengong_youhui, 2)) + L"元").c_str());
  1290. pValue->SetTextColor(0xFFE14B4A);
  1291. item_num++;
  1292. }
  1293. if (m_moling_youhui > 0)
  1294. {
  1295. CDialogBuilder builder;
  1296. CDialogBuilderCallbackEx cb;
  1297. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1298. pmingxiLayout->Add(pItem);
  1299. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1300. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1301. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1302. pName->SetFixedWidth(nMingxiNameW);
  1303. pValue->SetFixedWidth(nMingxiValueW);
  1304. pName->SetText(L"抹零优惠:");
  1305. pValue->SetText((L"-" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_moling_youhui, 2)) + L"元").c_str());
  1306. pValue->SetTextColor(0xFFE14B4A);
  1307. item_num++;
  1308. }
  1309. //然后处理加价的各种
  1310. if (m_dabao > 0)
  1311. {
  1312. CDialogBuilder builder;
  1313. CDialogBuilderCallbackEx cb;
  1314. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1315. pmingxiLayout->Add(pItem);
  1316. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1317. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1318. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1319. pName->SetFixedWidth(nMingxiNameW);
  1320. pValue->SetFixedWidth(nMingxiValueW);
  1321. pName->SetText(L"打包费:");
  1322. pValue->SetText((L"+" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_dabao, 2)) + L"元").c_str());
  1323. item_num++;
  1324. }
  1325. if (m_jiajia > 0)
  1326. {
  1327. CDialogBuilder builder;
  1328. CDialogBuilderCallbackEx cb;
  1329. CHorizontalLayoutUI* pItem = static_cast<CHorizontalLayoutUI*>(builder.Create(_T("diandan_zhangdanmingxi_item.xml"), (UINT)0, &cb, m_pManager));
  1330. pmingxiLayout->Add(pItem);
  1331. CLabelUI* pName = static_cast<CLabelUI*>(pItem->FindSubControl(_T("name")));
  1332. CLabelUI* pValue = static_cast<CLabelUI*>(pItem->FindSubControl(_T("value")));
  1333. //按容器可用宽重设明细行宽度(防止窄卡截断)
  1334. pName->SetFixedWidth(nMingxiNameW);
  1335. pValue->SetFixedWidth(nMingxiValueW);
  1336. pName->SetText(L"人工加价:");
  1337. pValue->SetText((L"+" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(m_jiajia, 2)) + L"元").c_str());
  1338. item_num++;
  1339. }
  1340. pmingxiLayout->SetFixedHeight(item_num * 32);
  1341. CLabelUI* pYingshou = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_total_yingshou")));
  1342. pYingshou->SetText((L"应收金额:<f 117><c #3CB371>" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(cur_price, 2)) + L" 元</c>").c_str());
  1343. //同步更新副屏的显示内容
  1344. CShuangpingTool::GetInstance()->UpdateShow(m_cur_diandan_order, total_youhui, cur_price, m_dabao);
  1345. }
  1346. void CSaomashouyinPageUI::ClickFoodAction()
  1347. {
  1348. bool is_taocan = m_cur_click_food_item->GetIsTaocan();
  1349. if (is_taocan)
  1350. {
  1351. //点击套餐之后的处理逻辑
  1352. CFoodpackage foodpackageinfo = m_cur_click_food_item->GetFoodpackageInfo();
  1353. CDiandanOrderItem clickItem;
  1354. clickItem.foodpackage_id = foodpackageinfo.id;
  1355. clickItem.foodpackage_name = foodpackageinfo.name;
  1356. clickItem.price = foodpackageinfo.price;
  1357. clickItem.is_dabao = false;
  1358. clickItem.dabao_money = foodpackageinfo.dabao_money;
  1359. clickItem.num = "1";
  1360. //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
  1361. clickItem.SetFoodpackageInfo(m_cur_click_food_item->GetFoodpackageInfo());
  1362. clickItem.SetIsTaocan(true);
  1363. if (m_is_show_modal_wnd == true)
  1364. {
  1365. return;
  1366. }
  1367. //先弹框进行选择属性
  1368. CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
  1369. pNatureFrame->SetFoodItemUI(m_cur_click_food_item);
  1370. if (pNatureFrame != NULL)
  1371. {
  1372. m_is_show_modal_wnd = true;
  1373. m_curModalWnd = pNatureFrame;
  1374. pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1375. pNatureFrame->SetIcon(IDI_ICON_DUILIB);
  1376. pNatureFrame->CenterWindow();
  1377. UINT ret = pNatureFrame->ShowModal();
  1378. if (ret == IDOK)
  1379. {
  1380. //保存选择的属性
  1381. std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
  1382. clickItem.natureSelectedArray = natureSelectedArray;
  1383. m_is_show_modal_wnd = false;
  1384. delete pNatureFrame;
  1385. }
  1386. else
  1387. {
  1388. m_is_show_modal_wnd = false;
  1389. delete pNatureFrame;
  1390. return;
  1391. }
  1392. }
  1393. //商品没有商品属性
  1394. bool is_add_new = false;
  1395. int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
  1396. this->UpdateShopcartShow(is_add_new);
  1397. }
  1398. else
  1399. {
  1400. //点击普通商品之后的处理逻辑
  1401. CFood foodinfo = m_cur_click_food_item->GetFoodInfo();
  1402. if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < 0.001)
  1403. {
  1404. //库存为0了,不做任何处理
  1405. m_pMainWnd->ShowToast(L"该商品已售完");
  1406. return;
  1407. }
  1408. CDiandanOrderItem clickItem;
  1409. clickItem.food_id = foodinfo.id;
  1410. clickItem.food_name = foodinfo.name;
  1411. clickItem.type_id = foodinfo.type_id;
  1412. clickItem.barcode = foodinfo.barcode;
  1413. clickItem.price = foodinfo.price;
  1414. clickItem.is_dabao = false;
  1415. clickItem.dabao_money = foodinfo.dabao_money;
  1416. clickItem.num = "1";
  1417. if (foodinfo.member_price_used == "1")
  1418. {
  1419. clickItem.is_member_price_used = true;
  1420. }
  1421. else
  1422. {
  1423. clickItem.is_member_price_used = false;
  1424. }
  1425. //处理会员价的json
  1426. std::string member_price_json = foodinfo.member_price_json;
  1427. rapidjson::Document document;
  1428. document.Parse(member_price_json.c_str());
  1429. rapidjson::Value& member_price = document;
  1430. for (rapidjson::SizeType i = 0; i < member_price.Size(); ++i)
  1431. {
  1432. rapidjson::Value& member_price_info = member_price[i];
  1433. MemberPrice newPirce;
  1434. newPirce.id = CLewaimaiJson::ToString(member_price_info["id"]);
  1435. newPirce.level = CLewaimaiJson::ToString(member_price_info["level"]);
  1436. newPirce.price = CLewaimaiJson::ToString(member_price_info["price"]);
  1437. clickItem.m_member_price.push_back(newPirce);
  1438. }
  1439. //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
  1440. clickItem.SetFoodInfo(m_cur_click_food_item->GetFoodInfo());
  1441. clickItem.SetIsTaocan(false);
  1442. if (foodinfo.is_weight == "1")
  1443. {
  1444. if (m_is_dianzicheng_lianjie == false)
  1445. {
  1446. //设置中心未连接电子秤
  1447. m_pMainWnd->ShowToast(L"未连接电子秤,请检查连接设置");
  1448. return;
  1449. }
  1450. clickItem.is_weight = true;
  1451. if (m_is_show_modal_wnd == true)
  1452. {
  1453. return;
  1454. }
  1455. //这里要弹出称重框,不弹属性框
  1456. CChengzhongWnd* pChengzhongFrame = new CChengzhongWnd();
  1457. if (pChengzhongFrame != NULL)
  1458. {
  1459. m_is_show_modal_wnd = true;
  1460. m_curModalWnd = pChengzhongFrame;
  1461. pChengzhongFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1462. pChengzhongFrame->SetIcon(IDI_ICON_DUILIB);
  1463. pChengzhongFrame->CenterWindow();
  1464. pChengzhongFrame->SetTitle(CLewaimaiString::UTF8ToUnicode(foodinfo.name));
  1465. UINT ret = pChengzhongFrame->ShowModal();
  1466. if (ret == IDOK)
  1467. {
  1468. std::string weight = pChengzhongFrame->m_weight;
  1469. if (atof(weight.c_str()) < 0.001)
  1470. {
  1471. return;
  1472. }
  1473. clickItem.num = weight;
  1474. m_is_show_modal_wnd = false;
  1475. delete pChengzhongFrame;
  1476. }
  1477. else
  1478. {
  1479. m_is_show_modal_wnd = false;
  1480. delete pChengzhongFrame;
  1481. return;
  1482. }
  1483. }
  1484. }
  1485. else
  1486. {
  1487. clickItem.is_weight = false;
  1488. if (foodinfo.is_nature == "1")
  1489. {
  1490. //商品有商品属性
  1491. clickItem.is_nature = true;
  1492. if (m_is_show_modal_wnd == true)
  1493. {
  1494. return;
  1495. }
  1496. //先弹框进行选择属性
  1497. CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
  1498. pNatureFrame->SetFoodItemUI(m_cur_click_food_item);
  1499. if (pNatureFrame != NULL)
  1500. {
  1501. m_is_show_modal_wnd = true;
  1502. m_curModalWnd = pNatureFrame;
  1503. pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1504. pNatureFrame->SetIcon(IDI_ICON_DUILIB);
  1505. pNatureFrame->CenterWindow();
  1506. UINT ret = pNatureFrame->ShowModal();
  1507. if (ret == IDOK)
  1508. {
  1509. //保存选择的属性
  1510. std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
  1511. clickItem.natureSelectedArray = natureSelectedArray;
  1512. m_is_show_modal_wnd = false;
  1513. delete pNatureFrame;
  1514. }
  1515. else
  1516. {
  1517. m_is_show_modal_wnd = false;
  1518. delete pNatureFrame;
  1519. return;
  1520. }
  1521. }
  1522. }
  1523. }
  1524. //商品没有商品属性
  1525. bool is_add_new = false;
  1526. int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
  1527. this->UpdateShopcartShow(is_add_new);
  1528. }
  1529. }
  1530. void CSaomashouyinPageUI::ClickAdd()
  1531. {
  1532. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  1533. int nIndex = pList->GetCurSel();
  1534. if (nIndex == -1)
  1535. {
  1536. return;
  1537. }
  1538. m_cur_diandan_order.AddNum(nIndex);
  1539. this->UpdateShopcartShow();
  1540. }
  1541. void CSaomashouyinPageUI::ClickDel()
  1542. {
  1543. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  1544. int nIndex = pList->GetCurSel();
  1545. if (nIndex == -1)
  1546. {
  1547. return;
  1548. }
  1549. bool is_del = m_cur_diandan_order.DelNum(nIndex);
  1550. this->UpdateShopcartShow();
  1551. }
  1552. void CSaomashouyinPageUI::ClickRemove()
  1553. {
  1554. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  1555. int nIndex = pList->GetCurSel();
  1556. if (nIndex == -1)
  1557. {
  1558. return;
  1559. }
  1560. m_cur_diandan_order.Remove(nIndex);
  1561. this->UpdateShopcartShow();
  1562. }
  1563. void CSaomashouyinPageUI::ClickGuige()
  1564. {
  1565. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  1566. int nIndex = pList->GetCurSel();
  1567. if (nIndex == -1)
  1568. {
  1569. return;
  1570. }
  1571. bool is_taocan = m_cur_diandan_order.getDiandanOrderItem(nIndex).m_is_taocan;
  1572. if (is_taocan)
  1573. {
  1574. if (m_is_show_modal_wnd == true)
  1575. {
  1576. return;
  1577. }
  1578. //弹出属性框,开始重新选择属性
  1579. CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(2);
  1580. pNatureFrame->SetDiandanOrderItem(m_cur_diandan_order.getDiandanOrderItem(nIndex));
  1581. if (pNatureFrame != NULL)
  1582. {
  1583. m_is_show_modal_wnd = true;
  1584. m_curModalWnd = pNatureFrame;
  1585. pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1586. pNatureFrame->SetIcon(IDI_ICON_DUILIB);
  1587. pNatureFrame->CenterWindow();
  1588. UINT ret = pNatureFrame->ShowModal();
  1589. if (ret == IDOK)
  1590. {
  1591. //保存选择的属性
  1592. std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
  1593. m_cur_diandan_order.UpdateItemGuige(nIndex, natureSelectedArray);
  1594. m_is_show_modal_wnd = false;
  1595. delete pNatureFrame;
  1596. this->UpdateShopcartShow();
  1597. }
  1598. else
  1599. {
  1600. m_is_show_modal_wnd = false;
  1601. delete pNatureFrame;
  1602. return;
  1603. }
  1604. }
  1605. }
  1606. else
  1607. {
  1608. bool is_nature = m_cur_diandan_order.getDiandanOrderItem(nIndex).is_nature;
  1609. if (!is_nature)
  1610. {
  1611. //当前商品没有商品属性
  1612. return;
  1613. }
  1614. //弹出属性框,开始重新选择属性
  1615. CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(2);
  1616. pNatureFrame->SetDiandanOrderItem(m_cur_diandan_order.getDiandanOrderItem(nIndex));
  1617. if (pNatureFrame != NULL)
  1618. {
  1619. pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1620. pNatureFrame->SetIcon(IDI_ICON_DUILIB);
  1621. pNatureFrame->CenterWindow();
  1622. UINT ret = pNatureFrame->ShowModal();
  1623. if (ret == IDOK)
  1624. {
  1625. //保存选择的属性
  1626. std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
  1627. m_cur_diandan_order.UpdateItemGuige(nIndex, natureSelectedArray);
  1628. delete pNatureFrame;
  1629. this->UpdateShopcartShow();
  1630. }
  1631. else
  1632. {
  1633. return;
  1634. }
  1635. }
  1636. }
  1637. }
  1638. void CSaomashouyinPageUI::ClickDabao()
  1639. {
  1640. CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_saomashouyin_cart")));
  1641. int nIndex = pList->GetCurSel();
  1642. if (nIndex == -1)
  1643. {
  1644. return;
  1645. }
  1646. m_cur_diandan_order.SetDabao(nIndex);
  1647. this->UpdateShopcartShow();
  1648. }
  1649. void CSaomashouyinPageUI::ClickQingkong()
  1650. {
  1651. m_cur_diandan_order.Clear();
  1652. this->UpdateShopcartShow();
  1653. }
  1654. //点击存单之后的逻辑
  1655. void CSaomashouyinPageUI::ClickCundan()
  1656. {
  1657. if (m_cur_diandan_order.getItemNum() == 0)
  1658. {
  1659. //没有选任何商品
  1660. return;
  1661. }
  1662. m_cur_diandan_order.m_guadan_time = CLewaimaiTime::DatetimeToString(time(NULL));
  1663. m_guadan_orders.push_back(m_cur_diandan_order);
  1664. //挂单之后,刷新所有显示
  1665. RefreshShow();
  1666. }
  1667. //点击取单之后的逻辑
  1668. void CSaomashouyinPageUI::ClickQudan()
  1669. {
  1670. if (m_guadan_orders.size() == 0)
  1671. {
  1672. return;
  1673. }
  1674. if (m_is_show_modal_wnd == true)
  1675. {
  1676. return;
  1677. }
  1678. CGuadanWnd* pQudanDlg = new CGuadanWnd();
  1679. if (pQudanDlg != NULL)
  1680. {
  1681. m_is_show_modal_wnd = true;
  1682. m_curModalWnd = pQudanDlg;
  1683. pQudanDlg->SetGuadanOrders(m_guadan_orders);
  1684. pQudanDlg->SetPageUI(this);
  1685. pQudanDlg->SetPageType(1);
  1686. pQudanDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1687. pQudanDlg->SetIcon(IDI_ICON_DUILIB);
  1688. pQudanDlg->CenterWindow();
  1689. pQudanDlg->SetTitle(L"取单");
  1690. UINT ret = pQudanDlg->ShowModal();
  1691. if (ret == IDOK)
  1692. {
  1693. //取单成功逻辑处理
  1694. int nQudanNum = pQudanDlg->m_nQudanNum;
  1695. //先对当前的数据进行清空
  1696. RefreshShow();
  1697. //然后保存取单的订单
  1698. m_cur_diandan_order = m_guadan_orders[nQudanNum];
  1699. m_guadan_orders.erase(m_guadan_orders.begin() + nQudanNum);
  1700. RefreshGuadanNum();
  1701. //然后展示购物车
  1702. this->UpdateShopcartShow();
  1703. m_is_show_modal_wnd = false;
  1704. delete pQudanDlg;
  1705. }
  1706. else
  1707. {
  1708. RefreshGuadanNum();
  1709. m_is_show_modal_wnd = false;
  1710. delete pQudanDlg;
  1711. return;
  1712. }
  1713. }
  1714. }
  1715. void CSaomashouyinPageUI::ClickGengduoPay()
  1716. {
  1717. if (m_cur_diandan_order.getItemNum() == 0)
  1718. {
  1719. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  1720. return;
  1721. }
  1722. }
  1723. void CSaomashouyinPageUI::ClickMemberLogin()
  1724. {
  1725. if (m_is_show_modal_wnd == true)
  1726. {
  1727. return;
  1728. }
  1729. if (m_is_member == true)
  1730. {
  1731. m_pMainWnd->ShowToast(L"会员已登录!");
  1732. }
  1733. CMemberLoginWnd* pMemberLoginDlg = new CMemberLoginWnd();
  1734. if (pMemberLoginDlg != NULL)
  1735. {
  1736. m_is_show_modal_wnd = true;
  1737. m_curModalWnd = pMemberLoginDlg;
  1738. pMemberLoginDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1739. pMemberLoginDlg->SetIcon(IDI_ICON_DUILIB);
  1740. pMemberLoginDlg->CenterWindow();
  1741. UINT ret = pMemberLoginDlg->ShowModal();
  1742. if (ret == IDOK)
  1743. {
  1744. //这说明会员登录成功了
  1745. m_is_member = true;
  1746. m_member_name = pMemberLoginDlg->m_name;
  1747. m_member_level = pMemberLoginDlg->m_member_level;
  1748. m_member_level_name = pMemberLoginDlg->m_member_level_name;
  1749. m_member_id = pMemberLoginDlg->m_member_id;
  1750. m_card_no = pMemberLoginDlg->m_card_no;
  1751. m_balance = pMemberLoginDlg->m_balance;
  1752. m_phone = pMemberLoginDlg->m_phone;
  1753. m_birthday = pMemberLoginDlg->m_birthday;
  1754. m_sex = pMemberLoginDlg->m_sex;
  1755. m_address = pMemberLoginDlg->m_address;
  1756. m_is_card = pMemberLoginDlg->m_is_card;
  1757. m_point = pMemberLoginDlg->m_point;
  1758. m_open_no_card_payment = pMemberLoginDlg->m_open_no_card_payment;
  1759. m_pay_password = pMemberLoginDlg->m_pay_password;
  1760. m_freeze = pMemberLoginDlg->m_freeze;
  1761. m_card_identify = pMemberLoginDlg->m_card_identify;
  1762. CLabelUI* pMemberInfo = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_page_member_name")));
  1763. pMemberInfo->SetText(CLewaimaiString::UTF8ToUnicode(m_member_name).c_str());
  1764. //动态文本 SetText 后须清缓存,避免 autocalcwidth 不刷新
  1765. pMemberInfo->SetFont(pMemberInfo->GetFont());
  1766. CLabelUI* pMemberBalance = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_page_member_balance")));
  1767. pMemberBalance->SetText((L"¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(atof(m_balance.c_str()), 2))).c_str());
  1768. //整块隐藏登录卡(浮层说明文字随卡一起隐藏)
  1769. this->FindSubControl(_T("saomashouyin_member_login_wrap"))->SetVisible(false);
  1770. CButtonUI* pMemberLoginBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_saomashouyin_member_login")));
  1771. pMemberLoginBtn->SetVisible(false);
  1772. this->FindSubControl(_T("saomashouyin_page_member_info"))->SetVisible(true);
  1773. this->UpdateJiesuanInfo();
  1774. m_is_show_modal_wnd = false;
  1775. delete pMemberLoginDlg;
  1776. }
  1777. else
  1778. {
  1779. //说明会员登录失败了
  1780. m_is_member = false;
  1781. m_is_show_modal_wnd = false;
  1782. delete pMemberLoginDlg;
  1783. return;
  1784. }
  1785. }
  1786. }
  1787. //处理会员退出登陆
  1788. void CSaomashouyinPageUI::ClickMemberLogout()
  1789. {
  1790. m_is_member = false;
  1791. CButtonUI* pMemberLoginBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_saomashouyin_member_login")));
  1792. pMemberLoginBtn->SetVisible(true);
  1793. this->FindSubControl(_T("saomashouyin_member_login_wrap"))->SetVisible(true);
  1794. this->FindSubControl(_T("saomashouyin_page_member_info"))->SetVisible(false);
  1795. this->UpdateJiesuanInfo();
  1796. }
  1797. //会员充值(照搬点单页实现,充值成功后刷新本页余额)
  1798. void CSaomashouyinPageUI::ClickMemberChongzhi()
  1799. {
  1800. if (m_is_show_modal_wnd == true)
  1801. {
  1802. return;
  1803. }
  1804. if (m_member_id == "")
  1805. {
  1806. return;
  1807. }
  1808. CHuiyuanChongzhiWnd* pChongzhiWnd = new CHuiyuanChongzhiWnd();
  1809. if (pChongzhiWnd != NULL)
  1810. {
  1811. m_is_show_modal_wnd = true;
  1812. m_curModalWnd = pChongzhiWnd;
  1813. pChongzhiWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  1814. pChongzhiWnd->SetIcon(IDI_ICON_DUILIB);
  1815. pChongzhiWnd->CenterWindow();
  1816. pChongzhiWnd->SetCurBalance(m_balance);
  1817. pChongzhiWnd->m_member_id = m_member_id;
  1818. pChongzhiWnd->m_member_card_no = m_card_no;
  1819. UINT ret = pChongzhiWnd->ShowModal();
  1820. if (ret == IDOK)
  1821. {
  1822. //充值成功:本地计算新余额并刷新显示(与会员页同口径)
  1823. m_balance = CLewaimaiString::DoubleToString(atof(m_balance.c_str()) + atof(pChongzhiWnd->m_chongzhi.c_str()) + atof(pChongzhiWnd->m_zengsong.c_str()), 2);
  1824. CLabelUI* pMemberBalance = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_page_member_balance")));
  1825. pMemberBalance->SetText((L"¥" + CLewaimaiString::UTF8ToUnicode(m_balance)).c_str());
  1826. }
  1827. m_is_show_modal_wnd = false;
  1828. delete pChongzhiWnd;
  1829. }
  1830. }
  1831. void CSaomashouyinPageUI::ClickMemberInfoShow()
  1832. {
  1833. if (m_is_show_modal_wnd == true)
  1834. {
  1835. return;
  1836. }
  1837. CHuiyuanInfoShowWnd* pMemberLoginDlg = new CHuiyuanInfoShowWnd();
  1838. if (pMemberLoginDlg != NULL)
  1839. {
  1840. m_is_show_modal_wnd = true;
  1841. m_curModalWnd = pMemberLoginDlg;
  1842. pMemberLoginDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1843. pMemberLoginDlg->SetIcon(IDI_ICON_DUILIB);
  1844. pMemberLoginDlg->CenterWindow();
  1845. pMemberLoginDlg->SetHuiyuanInfo(m_member_id, m_member_name, m_member_level, m_member_level_name, m_card_no, m_balance, m_phone, \
  1846. m_birthday, m_sex, m_address, m_is_card, m_point, m_open_no_card_payment, m_pay_password, m_freeze, m_card_identify);
  1847. UINT ret = pMemberLoginDlg->ShowModal();
  1848. if (ret == IDOK)
  1849. {
  1850. m_is_show_modal_wnd = false;
  1851. delete pMemberLoginDlg;
  1852. }
  1853. else
  1854. {
  1855. m_is_show_modal_wnd = false;
  1856. delete pMemberLoginDlg;
  1857. return;
  1858. }
  1859. }
  1860. }
  1861. void CSaomashouyinPageUI::ClickZhekou()
  1862. {
  1863. if (m_is_show_modal_wnd == true)
  1864. {
  1865. return;
  1866. }
  1867. CNumInputWnd* pNumDlg = new CNumInputWnd();
  1868. if (pNumDlg != NULL)
  1869. {
  1870. m_is_show_modal_wnd = true;
  1871. m_curModalWnd = pNumDlg;
  1872. pNumDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1873. pNumDlg->SetIcon(IDI_ICON_DUILIB);
  1874. pNumDlg->CenterWindow();
  1875. pNumDlg->SetTitle(L"输入折扣值");
  1876. pNumDlg->SetAttention(L"请输入折扣值(1到100之间的整数)");
  1877. pNumDlg->SetRange(1, 100);
  1878. UINT ret = pNumDlg->ShowModal();
  1879. if (ret == IDOK)
  1880. {
  1881. //这说明折扣输入了
  1882. std::string zhekou = pNumDlg->GetNum();
  1883. CButtonUI* pZhekouEdit = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhekou_value")));
  1884. pZhekouEdit->SetText(CLewaimaiString::UTF8ToUnicode(zhekou).c_str());
  1885. this->UpdateJiesuanInfo();
  1886. m_is_show_modal_wnd = false;
  1887. delete pNumDlg;
  1888. }
  1889. else
  1890. {
  1891. m_is_show_modal_wnd = false;
  1892. delete pNumDlg;
  1893. return;
  1894. }
  1895. }
  1896. }
  1897. void CSaomashouyinPageUI::ClickJiajia()
  1898. {
  1899. if (m_is_show_modal_wnd == true)
  1900. {
  1901. return;
  1902. }
  1903. CNumInputWnd* pNumDlg = new CNumInputWnd();
  1904. if (pNumDlg != NULL)
  1905. {
  1906. m_is_show_modal_wnd = true;
  1907. m_curModalWnd = pNumDlg;
  1908. pNumDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1909. pNumDlg->SetIcon(IDI_ICON_DUILIB);
  1910. pNumDlg->CenterWindow();
  1911. pNumDlg->SetTitle(L"输入加价金额");
  1912. pNumDlg->SetAttention(L"请输入加价金额(0到1000之间的整数)");
  1913. pNumDlg->SetRange(0, 1000);
  1914. UINT ret = pNumDlg->ShowModal();
  1915. if (ret == IDOK)
  1916. {
  1917. //这说明加价金额输入了
  1918. std::string jiajia = pNumDlg->GetNum();
  1919. CButtonUI* pJiajiaEdit = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_jiajia_value")));
  1920. pJiajiaEdit->SetText(CLewaimaiString::UTF8ToUnicode(jiajia).c_str());
  1921. this->UpdateJiesuanInfo();
  1922. m_is_show_modal_wnd = false;
  1923. delete pNumDlg;
  1924. }
  1925. else
  1926. {
  1927. m_is_show_modal_wnd = false;
  1928. delete pNumDlg;
  1929. return;
  1930. }
  1931. }
  1932. }
  1933. void CSaomashouyinPageUI::ClickRengongyouhui()
  1934. {
  1935. if (m_is_show_modal_wnd == true)
  1936. {
  1937. return;
  1938. }
  1939. CNumInputWnd* pNumDlg = new CNumInputWnd();
  1940. if (pNumDlg != NULL)
  1941. {
  1942. m_is_show_modal_wnd = true;
  1943. m_curModalWnd = pNumDlg;
  1944. pNumDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1945. pNumDlg->SetIcon(IDI_ICON_DUILIB);
  1946. pNumDlg->CenterWindow();
  1947. pNumDlg->SetTitle(L"输入优惠金额");
  1948. pNumDlg->SetAttention(L"请输入优惠金额(0到1000之间的整数)");
  1949. pNumDlg->SetRange(0, 1000);
  1950. UINT ret = pNumDlg->ShowModal();
  1951. if (ret == IDOK)
  1952. {
  1953. //这说明优惠金额输入了
  1954. std::string youhui = pNumDlg->GetNum();
  1955. CButtonUI* pYouhuiEdit = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhui_value")));
  1956. pYouhuiEdit->SetText(CLewaimaiString::UTF8ToUnicode(youhui).c_str());
  1957. this->UpdateJiesuanInfo();
  1958. m_is_show_modal_wnd = false;
  1959. delete pNumDlg;
  1960. }
  1961. else
  1962. {
  1963. m_is_show_modal_wnd = false;
  1964. delete pNumDlg;
  1965. return;
  1966. }
  1967. }
  1968. }
  1969. void CSaomashouyinPageUI::ClickSaomaYouhuiquan()
  1970. {
  1971. if (m_is_show_modal_wnd == true)
  1972. {
  1973. return;
  1974. }
  1975. CSaomaYouhuiquanWnd* pSaomaYouhuiquanDlg = new CSaomaYouhuiquanWnd();
  1976. if (pSaomaYouhuiquanDlg != NULL)
  1977. {
  1978. m_is_show_modal_wnd = true;
  1979. m_curModalWnd = pSaomaYouhuiquanDlg;
  1980. pSaomaYouhuiquanDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  1981. pSaomaYouhuiquanDlg->SetIcon(IDI_ICON_DUILIB);
  1982. pSaomaYouhuiquanDlg->CenterWindow();
  1983. pSaomaYouhuiquanDlg->SetTitle(L"扫码使用优惠券");
  1984. UINT ret = pSaomaYouhuiquanDlg->ShowModal();
  1985. if (ret == IDOK)
  1986. {
  1987. //这说明优惠券核销成功了
  1988. m_is_youhuiquan = true;
  1989. m_youhuiquan_id = pSaomaYouhuiquanDlg->m_coupon_id;
  1990. m_coupon_basic_price = pSaomaYouhuiquanDlg->m_coupon_basic_price;
  1991. m_coupon_deadline = pSaomaYouhuiquanDlg->m_coupon_deadline;
  1992. m_coupon_value = pSaomaYouhuiquanDlg->m_coupon_value;
  1993. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_status")));
  1994. pYouhuiEdit->SetText(L"已使用");
  1995. CButtonUI* pYouhuiquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_btn_cancel")));
  1996. pYouhuiquanCancel->SetVisible(true);
  1997. this->UpdateJiesuanInfo();
  1998. m_is_show_modal_wnd = false;
  1999. delete pSaomaYouhuiquanDlg;
  2000. }
  2001. else
  2002. {
  2003. m_is_show_modal_wnd = false;
  2004. delete pSaomaYouhuiquanDlg;
  2005. return;
  2006. }
  2007. }
  2008. }
  2009. //点击扫码商品券
  2010. void CSaomashouyinPageUI::ClickSaomaShangpinquan()
  2011. {
  2012. if (m_is_show_modal_wnd == true)
  2013. {
  2014. return;
  2015. }
  2016. CSaomaShangpinquanWnd* pSaomaShangpinquanDlg = new CSaomaShangpinquanWnd();
  2017. if (pSaomaShangpinquanDlg != NULL)
  2018. {
  2019. m_is_show_modal_wnd = true;
  2020. m_curModalWnd = pSaomaShangpinquanDlg;
  2021. pSaomaShangpinquanDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  2022. pSaomaShangpinquanDlg->SetIcon(IDI_ICON_DUILIB);
  2023. pSaomaShangpinquanDlg->CenterWindow();
  2024. pSaomaShangpinquanDlg->SetTitle(L"扫码使用商品券");
  2025. UINT ret = pSaomaShangpinquanDlg->ShowModal();
  2026. if (ret == IDOK)
  2027. {
  2028. //这说明商品券核销成功了
  2029. m_is_shangpinquan = true;
  2030. m_shangpinquan_lewaimai_customer_id = pSaomaShangpinquanDlg->m_lewaimai_customer_id;
  2031. m_shangpinquan_id = pSaomaShangpinquanDlg->m_goodscoupon_id;
  2032. m_shangpinquan_name = pSaomaShangpinquanDlg->m_goods_coupon_name;
  2033. m_shangpinquan_foodid = pSaomaShangpinquanDlg->m_bind_foods_id;
  2034. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_status")));
  2035. pYouhuiEdit->SetText(L"已使用");
  2036. CButtonUI* pShangpinquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_btn_cancel")));
  2037. pShangpinquanCancel->SetVisible(true);
  2038. this->UpdateJiesuanInfo();
  2039. m_is_show_modal_wnd = false;
  2040. delete pSaomaShangpinquanDlg;
  2041. }
  2042. else
  2043. {
  2044. m_is_show_modal_wnd = false;
  2045. delete pSaomaShangpinquanDlg;
  2046. return;
  2047. }
  2048. }
  2049. }
  2050. //点击扫码权益卡
  2051. void CSaomashouyinPageUI::ClickSaomaQuanyika()
  2052. {
  2053. if (m_is_show_modal_wnd == true)
  2054. {
  2055. return;
  2056. }
  2057. CSaomaQuanyikaWnd* pSaomaQuanyikaDlg = new CSaomaQuanyikaWnd();
  2058. if (pSaomaQuanyikaDlg != NULL)
  2059. {
  2060. m_is_show_modal_wnd = true;
  2061. m_curModalWnd = pSaomaQuanyikaDlg;
  2062. pSaomaQuanyikaDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  2063. pSaomaQuanyikaDlg->SetIcon(IDI_ICON_DUILIB);
  2064. pSaomaQuanyikaDlg->CenterWindow();
  2065. pSaomaQuanyikaDlg->SetTitle(L"扫码使用权益卡");
  2066. UINT ret = pSaomaQuanyikaDlg->ShowModal();
  2067. if (ret == IDOK)
  2068. {
  2069. //这说明权益卡核销成功了
  2070. m_is_quanyika = true;
  2071. m_quanyika_discount = pSaomaQuanyikaDlg->m_discount;
  2072. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_status")));
  2073. pYouhuiEdit->SetText(L"已使用");
  2074. CButtonUI* pQuanyikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_btn_cancel")));
  2075. pQuanyikaCancel->SetVisible(true);
  2076. this->UpdateJiesuanInfo();
  2077. m_is_show_modal_wnd = false;
  2078. delete pSaomaQuanyikaDlg;
  2079. }
  2080. else
  2081. {
  2082. m_is_show_modal_wnd = false;
  2083. delete pSaomaQuanyikaDlg;
  2084. return;
  2085. }
  2086. }
  2087. }
  2088. //点击取消使用优惠券
  2089. void CSaomashouyinPageUI::ClickQuxiaoYouhuiquan()
  2090. {
  2091. m_is_youhuiquan = false;
  2092. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_status")));
  2093. pYouhuiEdit->SetText(L"未使用");
  2094. CButtonUI* pYouhuiquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_youhuiquan_btn_cancel")));
  2095. pYouhuiquanCancel->SetVisible(false);
  2096. }
  2097. //点击取消商品券
  2098. void CSaomashouyinPageUI::ClickQuxiaoShangpinquan()
  2099. {
  2100. m_is_shangpinquan = false;
  2101. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_status")));
  2102. pYouhuiEdit->SetText(L"未使用");
  2103. CButtonUI* pShangpinquanCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_shangpinquan_btn_cancel")));
  2104. pShangpinquanCancel->SetVisible(false);
  2105. }
  2106. //点击取消权益卡
  2107. void CSaomashouyinPageUI::ClickQuxiaoQuanyika()
  2108. {
  2109. m_is_quanyika = false;
  2110. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_status")));
  2111. pYouhuiEdit->SetText(L"未使用");
  2112. CButtonUI* pQuanyikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_quanyika_btn_cancel")));
  2113. pQuanyikaCancel->SetVisible(false);
  2114. }
  2115. //点击取消次卡
  2116. void CSaomashouyinPageUI::ClickQuxiaoCika()
  2117. {
  2118. m_is_cika = false;
  2119. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_status")));
  2120. pYouhuiEdit->SetText(L"未使用");
  2121. CButtonUI* pCikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_btn_cancel")));
  2122. pCikaCancel->SetVisible(false);
  2123. }
  2124. //点击扫码次卡
  2125. void CSaomashouyinPageUI::ClickSaomaCika()
  2126. {
  2127. if (m_is_show_modal_wnd == true)
  2128. {
  2129. return;
  2130. }
  2131. CSaomaCikaWnd* pSaomaCikaDlg = new CSaomaCikaWnd();
  2132. if (pSaomaCikaDlg != NULL)
  2133. {
  2134. m_is_show_modal_wnd = true;
  2135. m_curModalWnd = pSaomaCikaDlg;
  2136. pSaomaCikaDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
  2137. pSaomaCikaDlg->SetIcon(IDI_ICON_DUILIB);
  2138. pSaomaCikaDlg->CenterWindow();
  2139. pSaomaCikaDlg->SetTitle(L"扫码使用次卡");
  2140. UINT ret = pSaomaCikaDlg->ShowModal();
  2141. if (ret == IDOK)
  2142. {
  2143. //这说明商品券核销成功了
  2144. m_is_cika = true;
  2145. m_cika_lewaimai_customer_id = pSaomaCikaDlg->m_cika_lewaimai_customer_id;
  2146. m_cika_id = pSaomaCikaDlg->m_timescoupon_id;
  2147. m_cika_deduct_type = pSaomaCikaDlg->m_deduct_type;
  2148. m_cika_discount = pSaomaCikaDlg->m_discount;
  2149. m_cika_discount_value = pSaomaCikaDlg->m_discount_value;
  2150. m_cika_full_reduce = pSaomaCikaDlg->m_full_reduce;
  2151. m_cika_full_reduce_value = pSaomaCikaDlg->m_full_reduce_value;
  2152. m_cika_offer = pSaomaCikaDlg->m_offer;
  2153. m_cika_offer_value = pSaomaCikaDlg->m_offer_value;
  2154. m_cika_bind_foods_id = pSaomaCikaDlg->m_bind_foods_id;
  2155. CLabelUI* pYouhuiEdit = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_status")));
  2156. pYouhuiEdit->SetText(L"已使用");
  2157. CButtonUI* pCikaCancel = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_cika_btn_cancel")));
  2158. pCikaCancel->SetVisible(true);
  2159. this->UpdateJiesuanInfo();
  2160. m_is_show_modal_wnd = false;
  2161. delete pSaomaCikaDlg;
  2162. }
  2163. else
  2164. {
  2165. m_is_show_modal_wnd = false;
  2166. delete pSaomaCikaDlg;
  2167. return;
  2168. }
  2169. }
  2170. }
  2171. //获取通用参数,任何支付方式都要用到的参数,个性化参数在弹框里面处理
  2172. //参考文档 http://apidoc.zhipuzi.com/index.php/home/item/show?item_id=4
  2173. std::map<std::string, std::string> CSaomashouyinPageUI::GetSendorderParams()
  2174. {
  2175. std::map<std::string, std::string> params;
  2176. params["order_no"] = CRandomHelper::GetRandString(20);
  2177. //构建food_list参数
  2178. params["food_list"] = m_cur_diandan_order.getDiandanFoodlistParam();
  2179. params["foodpackage_array"] = m_cur_diandan_order.getDiandanTaocanParam();
  2180. params["person_num"] = "1";
  2181. params["table_name"] = "";
  2182. params["note"] = m_cur_diandan_order.GetMemo();
  2183. params["dabao_price"] = CLewaimaiString::DoubleToString(m_dabao, 2);
  2184. params["food_price"] = CLewaimaiString::DoubleToString(m_cur_diandan_order.getTotalPrice(), 2);
  2185. params["total_price"] = CLewaimaiString::DoubleToString(m_cur_diandan_order.getTotalPrice() + m_dabao, 2);
  2186. CEditUI* pZhekouEdit = static_cast<CEditUI*>(this->FindSubControl(_T("saomashouyin_jiesuan_zhekou_value")));
  2187. std::wstring ws_zhekou = pZhekouEdit->GetText();
  2188. params["discount"] = CLewaimaiString::UnicodeToUTF8(ws_zhekou);
  2189. params["coupon"] = CLewaimaiString::DoubleToString(m_rengong_youhui, 2);
  2190. params["price_plus"] = CLewaimaiString::DoubleToString(m_jiajia, 2);
  2191. params["price_moling"] = CLewaimaiString::DoubleToString(m_moling_youhui, 2);
  2192. params["yingshou_value"] = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2193. params["shishou_value"] = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2194. params["zhaoling_value"] = "0";
  2195. params["zhifu_type"] = "";
  2196. if (m_is_youhuiquan)
  2197. {
  2198. params["coupon_id"] = m_youhuiquan_id;
  2199. }
  2200. if (m_is_cika)
  2201. {
  2202. params["timescoupon_id"] = m_cika_id;
  2203. params["lewaimai_customer_id"] = m_cika_lewaimai_customer_id;
  2204. }
  2205. if (m_is_shangpinquan)
  2206. {
  2207. params["goodscoupon_id"] = m_shangpinquan_id;
  2208. }
  2209. if (m_is_quanyika)
  2210. {
  2211. params["is_eq_card_discount"] = "1";
  2212. params["eq_card_discount_value"] = m_quanyika_discount;
  2213. }
  2214. else
  2215. {
  2216. params["is_eq_card_discount"] = "0";
  2217. }
  2218. if (m_is_member)
  2219. {
  2220. params["member_id"] = m_member_id;
  2221. params["member_level"] = m_member_level;
  2222. if (m_is_member_zhekou)
  2223. {
  2224. params["member_level_value"] = m_member_zhekou_value;
  2225. }
  2226. else
  2227. {
  2228. params["member_level_value"] = 10;
  2229. }
  2230. }
  2231. if (m_is_cika == true)
  2232. {
  2233. params["time_coupon_type"] = m_cika_deduct_type;
  2234. params["time_coupon_discount_value"] = m_cika_discount_value;
  2235. params["time_coupon_full_reduce_value"] = m_cika_full_reduce_value;
  2236. params["time_coupon_offer_value"] = m_cika_offer_value;
  2237. params["time_coupon_band_food_value"] = CLewaimaiString::DoubleToString(m_cika_youhui, 2);
  2238. }
  2239. if (m_is_shangpinquan)
  2240. {
  2241. params["goods_coupon_band_food_value"] = CLewaimaiString::DoubleToString(m_shangpinquan_youhui, 2);
  2242. }
  2243. if (m_manjian_youhui > 0)
  2244. {
  2245. params["promotion_value"] = CLewaimaiString::DoubleToString(m_manjian_youhui, 2);
  2246. }
  2247. if (m_youhuiquan_youhui > 0)
  2248. {
  2249. params["coupon_value"] = CLewaimaiString::DoubleToString(m_youhuiquan_youhui, 2);
  2250. }
  2251. if (m_total_member_youhui > 0)
  2252. {
  2253. params["member_delete"] = CLewaimaiString::DoubleToString(m_total_member_youhui, 2);
  2254. }
  2255. if (m_member_zhekou_youhui > 0)
  2256. {
  2257. params["member_discount_money"] = CLewaimaiString::DoubleToString(m_member_zhekou_youhui, 2);
  2258. }
  2259. if (m_zhekou_youhui > 0)
  2260. {
  2261. params["shop_discount_money"] = CLewaimaiString::DoubleToString(m_zhekou_youhui, 2);
  2262. }
  2263. if (m_cika_youhui > 0)
  2264. {
  2265. params["timescoupon_discount_money"] = CLewaimaiString::DoubleToString(m_cika_youhui, 2);
  2266. }
  2267. if (m_quanyika_youhui > 0)
  2268. {
  2269. params["eq_card_discount_money"] = CLewaimaiString::DoubleToString(m_quanyika_youhui, 2);
  2270. }
  2271. params["total_delete_money"] = CLewaimaiString::DoubleToString(m_total_youhui, 2);
  2272. return params;
  2273. }
  2274. void CSaomashouyinPageUI::StartWeixinzhifuShoukuan(std::string fukuanma)
  2275. {
  2276. if (m_is_show_modal_wnd == true)
  2277. {
  2278. return;
  2279. }
  2280. if (m_cur_diandan_order.getItemNum() == 0)
  2281. {
  2282. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  2283. return;
  2284. }
  2285. CWeixinzhifuShoukuanWnd* pShoukuanWnd = new CWeixinzhifuShoukuanWnd;
  2286. if (pShoukuanWnd != NULL)
  2287. {
  2288. m_is_show_modal_wnd = true;
  2289. m_curModalWnd = pShoukuanWnd;
  2290. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  2291. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  2292. pShoukuanWnd->CenterWindow();
  2293. std::string format_string = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2294. std::wstring watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
  2295. pShoukuanWnd->InitMoney(watchValue);
  2296. //这里要对提交订单的参数进行组装,然后方便请求
  2297. pShoukuanWnd->SetCommonParams(GetSendorderParams());
  2298. if (fukuanma != "")
  2299. {
  2300. pShoukuanWnd->InitFukuanma(fukuanma);
  2301. }
  2302. UINT ret = pShoukuanWnd->ShowModal();
  2303. if (ret == IDOK)
  2304. {
  2305. int fukuanma_type = pShoukuanWnd->m_fukuanma_type;
  2306. std::string zhifu_type;
  2307. if (fukuanma_type == 1)
  2308. {
  2309. zhifu_type = "weixinzhifu";
  2310. }
  2311. else if (fukuanma_type == 2)
  2312. {
  2313. zhifu_type = "zhifubao";
  2314. }
  2315. else if (fukuanma_type == 3)
  2316. {
  2317. zhifu_type = "yunshanfu";
  2318. }
  2319. //说明收款成功了,需要进行一些后续的处理
  2320. this->StartWorkAfterShoukuan(pShoukuanWnd->m_kucun_string, pShoukuanWnd->m_take_food_code, pShoukuanWnd->m_show_trade_no, zhifu_type);
  2321. m_pMainWnd->ShowToast(L"收款成功!");
  2322. }
  2323. else
  2324. {
  2325. int a = 1;
  2326. }
  2327. m_is_show_modal_wnd = false;
  2328. delete pShoukuanWnd;
  2329. }
  2330. }
  2331. void CSaomashouyinPageUI::StartHuiyuanShoukuan()
  2332. {
  2333. if (m_is_show_modal_wnd == true)
  2334. {
  2335. return;
  2336. }
  2337. if (m_cur_diandan_order.getItemNum() == 0)
  2338. {
  2339. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  2340. return;
  2341. }
  2342. if (m_is_member == false)
  2343. {
  2344. //会员还没登录,提示先登录会员
  2345. this->ClickMemberLogin();
  2346. }
  2347. if (m_is_member == false)
  2348. {
  2349. //说明会员没有成功登陆
  2350. return;
  2351. }
  2352. CHuiyuanShoukuanWnd* pShoukuanWnd = new CHuiyuanShoukuanWnd();
  2353. if (pShoukuanWnd != NULL)
  2354. {
  2355. m_is_show_modal_wnd = true;
  2356. m_curModalWnd = pShoukuanWnd;
  2357. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  2358. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  2359. pShoukuanWnd->CenterWindow();
  2360. std::string format_string = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2361. std::wstring watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
  2362. pShoukuanWnd->InitMoney(watchValue);
  2363. //把会员登录的信息传递进去
  2364. pShoukuanWnd->SetMemberInfo(m_member_id, m_card_no, m_balance, m_member_name, m_member_level_name);
  2365. //这里要对提交订单的参数进行组装,然后方便请求
  2366. pShoukuanWnd->SetCommonParams(GetSendorderParams());
  2367. /*
  2368. if (m_is_start_catch && m_catch_string.length() == 18)
  2369. {
  2370. pShoukuanWnd->InitFukuanma(m_catch_string);
  2371. }
  2372. }*/
  2373. UINT ret = pShoukuanWnd->ShowModal();
  2374. if (ret == IDOK)
  2375. {
  2376. std::string balance = pShoukuanWnd->m_balance;
  2377. std::string member_number = pShoukuanWnd->m_member_number;
  2378. //说明收款成功了,需要进行一些后续的处理
  2379. this->StartWorkAfterShoukuan(pShoukuanWnd->m_kucun_string, pShoukuanWnd->m_take_food_code, pShoukuanWnd->m_show_trade_no, "huiyuanzhifu", balance, member_number);
  2380. m_pMainWnd->ShowToast(L"收款成功!");
  2381. }
  2382. m_is_show_modal_wnd = false;
  2383. delete pShoukuanWnd;
  2384. }
  2385. }
  2386. //开始进行现金收款
  2387. void CSaomashouyinPageUI::StartXianjinShoukuan()
  2388. {
  2389. if (m_is_show_modal_wnd == true)
  2390. {
  2391. return;
  2392. }
  2393. if (m_cur_diandan_order.getItemNum() == 0)
  2394. {
  2395. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  2396. return;
  2397. }
  2398. CXianjinShoukuanWnd* pShoukuanWnd = new CXianjinShoukuanWnd();
  2399. if (pShoukuanWnd != NULL)
  2400. {
  2401. m_is_show_modal_wnd = true;
  2402. m_curModalWnd = pShoukuanWnd;
  2403. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  2404. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  2405. pShoukuanWnd->CenterWindow();
  2406. std::string format_string = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2407. std::wstring watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
  2408. pShoukuanWnd->InitMoney(watchValue);
  2409. //这里要对提交订单的参数进行组装,然后方便请求
  2410. pShoukuanWnd->SetCommonParams(GetSendorderParams());
  2411. /*
  2412. if (m_is_start_catch && m_catch_string.length() == 18)
  2413. {
  2414. pShoukuanWnd->InitFukuanma(m_catch_string);
  2415. }
  2416. }*/
  2417. UINT ret = pShoukuanWnd->ShowModal();
  2418. if (ret == IDOK)
  2419. {
  2420. m_shishou_value = pShoukuanWnd->m_shishou;
  2421. m_zhaoling_value = pShoukuanWnd->m_zhaoling;
  2422. //说明收款成功了,需要进行一些后续的处理
  2423. this->StartWorkAfterShoukuan(pShoukuanWnd->m_kucun_string, pShoukuanWnd->m_take_food_code, pShoukuanWnd->m_show_trade_no, "xianjinzhifu");
  2424. m_pMainWnd->ShowToast(L"收款成功!");
  2425. }
  2426. m_is_show_modal_wnd = false;
  2427. delete pShoukuanWnd;
  2428. }
  2429. }
  2430. void CSaomashouyinPageUI::StartFulikaShoukuan()
  2431. {
  2432. if (m_is_show_modal_wnd == true)
  2433. {
  2434. return;
  2435. }
  2436. if (m_cur_diandan_order.getItemNum() == 0)
  2437. {
  2438. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  2439. return;
  2440. }
  2441. CFulikaShoukuanWnd* pShoukuanWnd = new CFulikaShoukuanWnd();
  2442. if (pShoukuanWnd != NULL)
  2443. {
  2444. m_is_show_modal_wnd = true;
  2445. m_curModalWnd = pShoukuanWnd;
  2446. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  2447. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  2448. pShoukuanWnd->CenterWindow();
  2449. std::string format_string = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2450. std::wstring watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
  2451. pShoukuanWnd->InitMoney(watchValue);
  2452. //这里要对提交订单的参数进行组装,然后方便请求
  2453. pShoukuanWnd->SetCommonParams(GetSendorderParams());
  2454. /*
  2455. if (m_is_start_catch && m_catch_string.length() == 18)
  2456. {
  2457. pShoukuanWnd->InitFukuanma(m_catch_string);
  2458. }
  2459. }*/
  2460. UINT ret = pShoukuanWnd->ShowModal();
  2461. if (ret == IDOK)
  2462. {
  2463. //说明收款成功了,需要进行一些后续的处理
  2464. this->StartWorkAfterShoukuan(pShoukuanWnd->m_kucun_string, pShoukuanWnd->m_take_food_code, pShoukuanWnd->m_show_trade_no, "fulikazhifu");
  2465. m_pMainWnd->ShowToast(L"收款成功!");
  2466. }
  2467. m_is_show_modal_wnd = false;
  2468. delete pShoukuanWnd;
  2469. }
  2470. }
  2471. void CSaomashouyinPageUI::StartZidingyiShoukuan(std::wstring name, std::wstring selfpay_id)
  2472. {
  2473. if (m_is_show_modal_wnd == true)
  2474. {
  2475. return;
  2476. }
  2477. if (m_cur_diandan_order.getItemNum() == 0)
  2478. {
  2479. m_pMainWnd->ShowToast(L"请先选择商品再支付");
  2480. return;
  2481. }
  2482. CZidingyiShoukuanWnd* pShoukuanWnd = new CZidingyiShoukuanWnd();
  2483. if (pShoukuanWnd != NULL)
  2484. {
  2485. m_is_show_modal_wnd = true;
  2486. m_curModalWnd = pShoukuanWnd;
  2487. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  2488. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  2489. pShoukuanWnd->CenterWindow();
  2490. std::string format_string = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2491. std::wstring watchValue = CLewaimaiString::UTF8ToUnicode(format_string);
  2492. pShoukuanWnd->InitMoney(watchValue);
  2493. //这里要对提交订单的参数进行组装,然后方便请求
  2494. pShoukuanWnd->SetCommonParams(GetSendorderParams());
  2495. /*
  2496. if (m_is_start_catch && m_catch_string.length() == 18)
  2497. {
  2498. pShoukuanWnd->InitFukuanma(m_catch_string);
  2499. }
  2500. }*/
  2501. pShoukuanWnd->SetZidingyiName(name);
  2502. pShoukuanWnd->SetZidingyiId(selfpay_id);
  2503. UINT ret = pShoukuanWnd->ShowModal();
  2504. if (ret == IDOK)
  2505. {
  2506. //说明收款成功了,需要进行一些后续的处理
  2507. this->StartWorkAfterShoukuan(pShoukuanWnd->m_kucun_string, pShoukuanWnd->m_take_food_code, pShoukuanWnd->m_show_trade_no, "zidingyizhifu");
  2508. m_pMainWnd->ShowToast(L"收款成功!");
  2509. }
  2510. m_is_show_modal_wnd = false;
  2511. delete pShoukuanWnd;
  2512. }
  2513. }
  2514. void CSaomashouyinPageUI::UpdateFoodStock(std::string food_stock)
  2515. {
  2516. rapidjson::Document doc;
  2517. rapidjson::Document::AllocatorType& allocator = doc.GetAllocator(); //获取分配器
  2518. Value& data = CLewaimaiJson::StringToJson(food_stock, allocator);
  2519. for (rapidjson::SizeType i = 0; i < data.Size(); ++i)
  2520. {
  2521. std::string food_id = data[i]["food_id"].GetString();
  2522. std::string stock = data[i]["stock"].GetString();
  2523. CSqlite3 sqlite;
  2524. sqlite.UpdateFoodStock(food_id, stock);
  2525. }
  2526. }
  2527. //扫描了商品条码的逻辑处理
  2528. bool CSaomashouyinPageUI::SaomiaoBarcode(std::string barcode)
  2529. {
  2530. CSqlite3 sqlite;
  2531. CFood foodinfo;
  2532. bool ret = sqlite.GetFoodByBarcode(barcode, foodinfo);
  2533. if (ret == false)
  2534. {
  2535. //说明没找到对应的商品条码
  2536. return false;
  2537. }
  2538. //这里说明找到了,那么处理添加购物车逻辑,扫码的情况下,这里不管有没有属性,都按没属性处理,不管有没有称重都按没称重处理(以后标签秤可能会修改)
  2539. if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < 1)
  2540. {
  2541. //库存为0了,不做任何处理
  2542. m_pMainWnd->ShowToast(L"该商品已售完");
  2543. //只要找到了就返回true
  2544. return true;
  2545. }
  2546. CDiandanOrderItem clickItem;
  2547. clickItem.food_id = foodinfo.id;
  2548. clickItem.food_name = foodinfo.name;
  2549. clickItem.type_id = foodinfo.type_id;
  2550. clickItem.price = foodinfo.price;
  2551. clickItem.is_dabao = false;
  2552. clickItem.dabao_money = foodinfo.dabao_money;
  2553. clickItem.num = "1";
  2554. if (foodinfo.member_price_used == "1")
  2555. {
  2556. clickItem.is_member_price_used = true;
  2557. }
  2558. else
  2559. {
  2560. clickItem.is_member_price_used = false;
  2561. }
  2562. //处理会员价的json
  2563. std::string member_price_json = foodinfo.member_price_json;
  2564. rapidjson::Document document;
  2565. document.Parse(member_price_json.c_str());
  2566. rapidjson::Value& member_price = document;
  2567. for (rapidjson::SizeType i = 0; i < member_price.Size(); ++i)
  2568. {
  2569. rapidjson::Value& member_price_info = member_price[i];
  2570. MemberPrice newPirce;
  2571. newPirce.id = CLewaimaiJson::ToString(member_price_info["id"]);
  2572. newPirce.level = CLewaimaiJson::ToString(member_price_info["level"]);
  2573. newPirce.price = CLewaimaiJson::ToString(member_price_info["price"]);
  2574. clickItem.m_member_price.push_back(newPirce);
  2575. }
  2576. //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
  2577. clickItem.SetFoodInfo(foodinfo);
  2578. clickItem.SetIsTaocan(false);
  2579. clickItem.is_weight = false;
  2580. clickItem.is_nature = false;
  2581. //商品没有商品属性
  2582. bool is_add_new = false;
  2583. int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
  2584. this->UpdateShopcartShow(is_add_new);
  2585. return true;
  2586. }
  2587. bool CSaomashouyinPageUI::BiaoqianchengSaomaBarcode(std::string barcode)
  2588. {
  2589. //先根据设置,分辨条码格式
  2590. std::string bianma;
  2591. std::string money;
  2592. std::string weight;
  2593. std::string jiaoyan;
  2594. std::string setting_tiaomacheng_geshi = CSetting::GetInstance()->GetParam("setting_tiaomacheng_geshi");
  2595. if (setting_tiaomacheng_geshi == "1")
  2596. {
  2597. if (barcode.length() != 12 && barcode.length() != 13)
  2598. {
  2599. //与该模式长度不匹配
  2600. return false;
  2601. }
  2602. if (barcode.length() == 12)
  2603. {
  2604. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2605. }
  2606. //13位【FWWWWWWEEEEEC】
  2607. bianma = barcode.substr(1, 6);
  2608. money = barcode.substr(7, 5);
  2609. jiaoyan = barcode.substr(12, 1);
  2610. }
  2611. else if (setting_tiaomacheng_geshi == "2")
  2612. {
  2613. if (barcode.length() != 12 && barcode.length() != 13)
  2614. {
  2615. //与该模式长度不匹配
  2616. return false;
  2617. }
  2618. if (barcode.length() == 12)
  2619. {
  2620. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2621. }
  2622. //13位【FWWWWWWNNNNNC】
  2623. bianma = barcode.substr(1, 6);
  2624. weight = barcode.substr(7, 5);
  2625. jiaoyan = barcode.substr(12, 1);
  2626. }
  2627. else if (setting_tiaomacheng_geshi == "3")
  2628. {
  2629. if (barcode.length() != 12 && barcode.length() != 13)
  2630. {
  2631. //与该模式长度不匹配
  2632. return false;
  2633. }
  2634. if (barcode.length() == 12)
  2635. {
  2636. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2637. }
  2638. //13位【FFWWWWWEEEEEC】
  2639. bianma = barcode.substr(2, 5);
  2640. money = barcode.substr(7, 5);
  2641. jiaoyan = barcode.substr(12, 1);
  2642. }
  2643. else if (setting_tiaomacheng_geshi == "4")
  2644. {
  2645. if (barcode.length() != 12 && barcode.length() != 13)
  2646. {
  2647. //与该模式长度不匹配
  2648. return false;
  2649. }
  2650. if (barcode.length() == 12)
  2651. {
  2652. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2653. }
  2654. //13位【FFWWWWWNNNNNC】
  2655. bianma = barcode.substr(2, 5);
  2656. weight = barcode.substr(7, 5);
  2657. jiaoyan = barcode.substr(12, 1);
  2658. }
  2659. else if (setting_tiaomacheng_geshi == "5")
  2660. {
  2661. if (barcode.length() != 17 && barcode.length() != 18)
  2662. {
  2663. //与该模式长度不匹配
  2664. return false;
  2665. }
  2666. if (barcode.length() == 17)
  2667. {
  2668. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2669. }
  2670. //18位【FWWWWWWEEEEENNNNNC】
  2671. bianma = barcode.substr(1, 6);
  2672. money = barcode.substr(7, 5);
  2673. weight = barcode.substr(12, 5);
  2674. jiaoyan = barcode.substr(17, 1);
  2675. }
  2676. else if (setting_tiaomacheng_geshi == "6")
  2677. {
  2678. if (barcode.length() != 17 && barcode.length() != 18)
  2679. {
  2680. //与该模式长度不匹配
  2681. return false;
  2682. }
  2683. if (barcode.length() == 17)
  2684. {
  2685. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2686. }
  2687. //18位【FWWWWWWNNNNNEEEEEC】
  2688. bianma = barcode.substr(1, 6);
  2689. weight = barcode.substr(7, 5);
  2690. money = barcode.substr(12, 5);
  2691. jiaoyan = barcode.substr(17, 1);
  2692. }
  2693. else if (setting_tiaomacheng_geshi == "7")
  2694. {
  2695. if (barcode.length() != 17 && barcode.length() != 18)
  2696. {
  2697. //与该模式长度不匹配
  2698. return false;
  2699. }
  2700. if (barcode.length() == 17)
  2701. {
  2702. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2703. }
  2704. //18位【FFWWWWWEEEEENNNNNC】
  2705. bianma = barcode.substr(2, 5);
  2706. money = barcode.substr(7, 5);
  2707. weight = barcode.substr(12, 5);
  2708. jiaoyan = barcode.substr(17, 1);
  2709. }
  2710. else if (setting_tiaomacheng_geshi == "8")
  2711. {
  2712. if (barcode.length() != 17 && barcode.length() != 18)
  2713. {
  2714. //与该模式长度不匹配
  2715. return false;
  2716. }
  2717. if (barcode.length() == 17)
  2718. {
  2719. barcode = CLewaimaiString::BuZifuLeft(barcode, 1, '0');
  2720. }
  2721. //18位【FFWWWWWNNNNNEEEEEC】
  2722. bianma = barcode.substr(2, 5);
  2723. weight = barcode.substr(7, 5);
  2724. money = barcode.substr(12, 5);
  2725. jiaoyan = barcode.substr(17, 1);
  2726. }
  2727. //先检查编码是否存在,如果编码不存在直接返回false
  2728. int i_bianma = atoi(bianma.c_str());
  2729. if (i_bianma < 1)
  2730. {
  2731. return false;
  2732. }
  2733. CFood foodinfo;
  2734. CSqlite3 sqlite;
  2735. bool ret = sqlite.GetFoodByPluBianma(std::to_string(i_bianma), foodinfo);
  2736. if (ret == false)
  2737. {
  2738. //没找到这个商品
  2739. return false;
  2740. }
  2741. //走到这里是找到商品了,那么就开始计算价格和重量
  2742. double d_money = 0;
  2743. double d_weight = 0;
  2744. //如果有价格,优先用价格
  2745. if (money.length() > 0)
  2746. {
  2747. //这个出来的单位是分,要把单位转成元
  2748. d_money = atof(money.c_str());
  2749. d_money = d_money / 100;
  2750. //根据价格计算重量
  2751. d_weight = d_money / atof(foodinfo.price.c_str());
  2752. }
  2753. else if (weight.length() > 0)
  2754. {
  2755. //这个单位是克,要转化成千克
  2756. d_weight = atof(weight.c_str());
  2757. d_weight = d_weight / 1000;
  2758. //有重量了,其实不需要计算价格,价格加到购物车的时候会自己计算
  2759. }
  2760. else
  2761. {
  2762. //价格和重量都没有,这是异常情况
  2763. return false;
  2764. }
  2765. if (foodinfo.stockvalid == "1" && atof(foodinfo.stock.c_str()) < d_weight)
  2766. {
  2767. //库存为0了,不做任何处理
  2768. m_pMainWnd->ShowToast(L"该商品已售完");
  2769. //只要找到了就返回true
  2770. return true;
  2771. }
  2772. CDiandanOrderItem clickItem;
  2773. clickItem.food_id = foodinfo.id;
  2774. clickItem.food_name = foodinfo.name;
  2775. clickItem.type_id = foodinfo.type_id;
  2776. clickItem.price = foodinfo.price;
  2777. clickItem.is_dabao = false;
  2778. clickItem.dabao_money = foodinfo.dabao_money;
  2779. clickItem.num = CLewaimaiString::DoubleToString(d_weight, 3); //重量保留3位小数
  2780. if (foodinfo.member_price_used == "1")
  2781. {
  2782. clickItem.is_member_price_used = true;
  2783. }
  2784. else
  2785. {
  2786. clickItem.is_member_price_used = false;
  2787. }
  2788. //处理会员价的json
  2789. std::string member_price_json = foodinfo.member_price_json;
  2790. rapidjson::Document document;
  2791. document.Parse(member_price_json.c_str());
  2792. rapidjson::Value& member_price = document;
  2793. for (rapidjson::SizeType i = 0; i < member_price.Size(); ++i)
  2794. {
  2795. rapidjson::Value& member_price_info = member_price[i];
  2796. MemberPrice newPirce;
  2797. newPirce.id = member_price_info["id"].GetString();
  2798. newPirce.level = member_price_info["level"].GetString();
  2799. newPirce.price = member_price_info["price"].GetString();
  2800. clickItem.m_member_price.push_back(newPirce);
  2801. }
  2802. //把当前点击商品的信息,保存到orderitem里面,方便后面修改规格的时候使用
  2803. clickItem.SetFoodInfo(foodinfo);
  2804. clickItem.SetIsTaocan(false);
  2805. clickItem.is_weight = true;
  2806. clickItem.is_nature = false;
  2807. //商品没有商品属性
  2808. bool is_add_new = false;
  2809. int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
  2810. this->UpdateShopcartShow(is_add_new);
  2811. return true;
  2812. }
  2813. //开始搜索某个商品名字
  2814. void CSaomashouyinPageUI::StartSearchFood(std::string foodname)
  2815. {
  2816. this->ShowXuangouPage();
  2817. //展示删除按钮
  2818. CButtonUI* pClear = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_food_search_clear")));
  2819. pClear->SetVisible(true);
  2820. if (m_cur_type_id != "sousuo")
  2821. {
  2822. m_type_id_before_sousuo = m_cur_type_id;
  2823. }
  2824. m_cur_type_id = "sousuo";
  2825. m_sousuo_foodname = foodname;
  2826. //搜索开始:隐藏占位提示语,避免与输入内容重影
  2827. CLabelUI* pTishi = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_food_search_tishi")));
  2828. if (pTishi != NULL)
  2829. {
  2830. pTishi->SetVisible(false);
  2831. }
  2832. this->InitFoodShow();
  2833. }
  2834. //停止搜索商品
  2835. void CSaomashouyinPageUI::StopSerachFood()
  2836. {
  2837. this->ShowJiesuanPage();
  2838. //隐藏删除按钮
  2839. CButtonUI* pClear = static_cast<CButtonUI*>(this->FindSubControl(_T("saomashouyin_food_search_clear")));
  2840. pClear->SetVisible(false);
  2841. m_cur_type_id = m_type_id_before_sousuo;
  2842. //搜索结束:输入框已清空,恢复占位提示语
  2843. CLabelUI* pTishi = static_cast<CLabelUI*>(this->FindSubControl(_T("saomashouyin_food_search_tishi")));
  2844. if (pTishi != NULL)
  2845. {
  2846. pTishi->SetVisible(true);
  2847. }
  2848. this->InitFoodShow();
  2849. }
  2850. void CSaomashouyinPageUI::StartWorkAfterShoukuan(std::string kucunstring, std::string take_food_code, std::string show_trade_no, std::string shoukuan_type, std::string balance, std::string member_number)
  2851. {
  2852. //针对现金收款成功,单独做一个打开钱箱的判断处理
  2853. if (shoukuan_type == "xianjinzhifu")
  2854. {
  2855. std::string setting_is_diannei_xianjin_qianxiang = CSetting::GetInstance()->GetParam("setting_is_diannei_xianjin_qianxiang");
  2856. if (setting_is_diannei_xianjin_qianxiang == "1")
  2857. {
  2858. //打开钱箱
  2859. CPosPrinter printer;
  2860. printer.OpenQianxiang();
  2861. }
  2862. }
  2863. //更新商品库存
  2864. this->UpdateFoodStock(kucunstring);
  2865. //处理打印
  2866. CDiandanOrder order = this->GetPrintOrderinfo(take_food_code, show_trade_no, shoukuan_type, balance, member_number);
  2867. CPosPrinter printer;
  2868. printer.PrintDiandanOrder(order);
  2869. //最后才初始化页面信息
  2870. RefreshShow();
  2871. }
  2872. CDiandanOrder CSaomashouyinPageUI::GetPrintOrderinfo(std::string take_food_code, std::string show_trade_no, std::string shoukuan_type, std::string balance, std::string member_number)
  2873. {
  2874. m_cur_diandan_order.shopname = CShopinfo::GetInstance()->m_shop_name;
  2875. m_cur_diandan_order.take_food_code = take_food_code;
  2876. m_cur_diandan_order.show_trade_no = show_trade_no;
  2877. m_cur_diandan_order.balance = balance;
  2878. m_cur_diandan_order.member_number = member_number;
  2879. if (shoukuan_type == "weixinzhifu")
  2880. {
  2881. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"微信支付");
  2882. }
  2883. else if (shoukuan_type == "zhifubao")
  2884. {
  2885. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"支付宝");
  2886. }
  2887. else if (shoukuan_type == "yunshanfu")
  2888. {
  2889. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"云闪付");
  2890. }
  2891. else if (shoukuan_type == "huiyuanzhifu")
  2892. {
  2893. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"会员支付");
  2894. }
  2895. else if (shoukuan_type == "xianjinzhifu")
  2896. {
  2897. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"现金支付");
  2898. }
  2899. else if (shoukuan_type == "fulikazhifu")
  2900. {
  2901. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"福利卡支付");
  2902. }
  2903. else if (shoukuan_type == "zidingyizhifu")
  2904. {
  2905. m_cur_diandan_order.shoukuan_type = CLewaimaiString::UnicodeToUTF8(L"自定义支付");
  2906. }
  2907. m_cur_diandan_order.order_from = 1;
  2908. m_cur_diandan_order.init_time = CLewaimaiTime::DatetimeToString(time(NULL));
  2909. m_cur_diandan_order.m_shangpinquan_youhui = CLewaimaiString::DoubleToString(m_shangpinquan_youhui, 2);
  2910. m_cur_diandan_order.m_cika_youhui = CLewaimaiString::DoubleToString(m_cika_youhui, 2);
  2911. m_cur_diandan_order.m_total_member_youhui = CLewaimaiString::DoubleToString(m_total_member_youhui, 2);
  2912. m_cur_diandan_order.m_zhekou_youhui = CLewaimaiString::DoubleToString(m_zhekou_youhui, 2);
  2913. m_cur_diandan_order.m_member_zhekou_youhui = CLewaimaiString::DoubleToString(m_member_zhekou_youhui, 2);
  2914. m_cur_diandan_order.m_quanyika_youhui = CLewaimaiString::DoubleToString(m_quanyika_youhui, 2);
  2915. m_cur_diandan_order.m_manjian_youhui = CLewaimaiString::DoubleToString(m_manjian_youhui, 2);
  2916. m_cur_diandan_order.m_youhuiquan_youhui = CLewaimaiString::DoubleToString(m_youhuiquan_youhui, 2);
  2917. m_cur_diandan_order.m_rengong_youhui = CLewaimaiString::DoubleToString(m_rengong_youhui, 2);
  2918. m_cur_diandan_order.m_moling_youhui = CLewaimaiString::DoubleToString(m_moling_youhui, 2);
  2919. m_cur_diandan_order.m_jiajia = CLewaimaiString::DoubleToString(m_jiajia, 2);
  2920. m_cur_diandan_order.m_shishou_value = m_shishou_value;
  2921. m_cur_diandan_order.m_zhaoling_value = m_zhaoling_value;
  2922. m_cur_diandan_order.m_zhekou_value = m_zhekou_value;
  2923. m_cur_diandan_order.m_dabao_money = CLewaimaiString::DoubleToString(m_cur_diandan_order.getDabaoMoney(), 2);
  2924. m_cur_diandan_order.m_total_price = CLewaimaiString::DoubleToString(m_cur_total_price, 2);
  2925. m_cur_diandan_order.m_canpai = "";
  2926. for (std::vector<CDiandanOrderItem>::iterator it = m_cur_diandan_order.m_items.begin(); it != m_cur_diandan_order.m_items.end(); it++)
  2927. {
  2928. CDiandanOrderItemPrint itemPrint;
  2929. itemPrint.m_food_name = it->getNameWanzhengShow();
  2930. itemPrint.m_quantity = it->num;
  2931. itemPrint.m_item_price = it->getSinglePrice();
  2932. itemPrint.m_type_id = it->type_id;
  2933. if (it->m_is_taocan == true)
  2934. {
  2935. itemPrint.is_taocan = true;
  2936. }
  2937. m_cur_diandan_order.m_items_print.push_back(itemPrint);
  2938. if (it->m_is_taocan == true)
  2939. {
  2940. //开始保存套餐里面的商品详情,主要用于厨房打印
  2941. CFoodpackage foodpackageinfo;
  2942. foodpackageinfo = it->GetFoodpackageInfo();
  2943. std::string nature = foodpackageinfo.nature;
  2944. rapidjson::Document document;
  2945. document.Parse(nature.c_str());
  2946. if (document.HasParseError())
  2947. {
  2948. //属性json报错,直接不处理了
  2949. continue;
  2950. }
  2951. rapidjson::Value& data = document;
  2952. //接下来要把这个套餐的详情也保存下来
  2953. for (std::vector<FoodNatureSelectValue>::iterator it_2 = it->natureSelectedArray.begin(); it_2 != it->natureSelectedArray.end(); it_2++)
  2954. {
  2955. std::string food_id = data[it_2->nNameIndex]["value"][it_2->m_nature_selects[0].nature_select_index].GetString();
  2956. //要根据商品ID找出商品的名字
  2957. CFood foodinfo;
  2958. CSqlite3 sqlite;
  2959. bool is_found = sqlite.GetFoodById(food_id, foodinfo);
  2960. if (!is_found)
  2961. {
  2962. continue;
  2963. }
  2964. CDiandanOrderItemPrint foodpackageitemPrint;
  2965. foodpackageitemPrint.m_food_name = foodinfo.name;
  2966. foodpackageitemPrint.m_quantity = it->num;
  2967. foodpackageitemPrint.m_item_price = foodinfo.price;
  2968. foodpackageitemPrint.m_type_id = foodinfo.type_id;
  2969. foodpackageitemPrint.is_taocan = false;
  2970. foodpackageitemPrint.is_taocan_item = true;
  2971. m_cur_diandan_order.m_items_print.push_back(foodpackageitemPrint);
  2972. }
  2973. }
  2974. }
  2975. return m_cur_diandan_order;
  2976. }
  2977. void CSaomashouyinPageUI::SetPos(RECT rc, bool bNeedInvalidate)
  2978. {
  2979. m_nPageWidth = rc.right - rc.left;
  2980. if (m_nPageWidth < 1294)
  2981. {
  2982. //窗口放不下「优惠卡330 + 账单卡292」整列时,隐藏优惠区域,避免账单卡被右侧截断
  2983. this->YincangYouhui();
  2984. }
  2985. else
  2986. {
  2987. //this->XianshiYouhui();
  2988. }
  2989. //拖动窗口的时候,更新位置
  2990. UpdateJiesuanZhifuPos();
  2991. CContainerUI::SetPos(rc, bNeedInvalidate);
  2992. }
  2993. //隐藏优惠区域
  2994. void CSaomashouyinPageUI::YincangYouhui()
  2995. {
  2996. m_is_yincangyouhui = true;
  2997. this->FindSubControl(L"saomashouyin_jiesuan_youhui_layout")->SetVisible(false);
  2998. this->FindSubControl(L"saomashouyin_jiesuan_yincangyouhui_btn")->SetVisible(false);
  2999. this->FindSubControl(L"saomashouyin_jiesuan_xianshiyouhui_btn")->SetVisible(true);
  3000. UpdateJiesuanZhifuPos();
  3001. }
  3002. //显示优惠区域
  3003. void CSaomashouyinPageUI::XianshiYouhui()
  3004. {
  3005. m_is_yincangyouhui = false;
  3006. this->FindSubControl(L"saomashouyin_jiesuan_youhui_layout")->SetVisible(true);
  3007. this->FindSubControl(L"saomashouyin_jiesuan_yincangyouhui_btn")->SetVisible(true);
  3008. this->FindSubControl(L"saomashouyin_jiesuan_xianshiyouhui_btn")->SetVisible(false);
  3009. UpdateJiesuanZhifuPos();
  3010. }
  3011. void CSaomashouyinPageUI::ClickAixuexi()
  3012. {
  3013. this->m_pMainWnd->SwitchPage(CMainWnd::AIXUEXI);
  3014. }
  3015. void CSaomashouyinPageUI::ZhiLing()
  3016. {
  3017. std::string setting_dianzicheng_xinghao = CSetting::GetInstance()->GetParam("setting_dianzicheng_xinghao");
  3018. if (setting_dianzicheng_xinghao == "dahua_acs")
  3019. {
  3020. m_pMainWnd->ShowToast(L"大华ACS电子秤不支持置零操作,请在秤上操作");
  3021. return;
  3022. }
  3023. CChengzhongWorker::GetInstance()->Zhiling();
  3024. }
  3025. void CSaomashouyinPageUI::Qupi()
  3026. {
  3027. std::string setting_dianzicheng_xinghao = CSetting::GetInstance()->GetParam("setting_dianzicheng_xinghao");
  3028. if (setting_dianzicheng_xinghao == "dahua_acs")
  3029. {
  3030. m_pMainWnd->ShowToast(L"大华ACS电子秤不支持去皮操作,请在秤上操作");
  3031. return;
  3032. }
  3033. CChengzhongWorker::GetInstance()->Qupi();
  3034. }