CSaomashouyinPageUI.cpp 86 KB

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