PrintactionModel.class.php 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566
  1. <?php
  2. namespace Seller\Model;
  3. use App\Api\PrinterService;
  4. use App\Oauth\YlyOauthClient;
  5. use App\Config\YlyConfig;
  6. use App\Api\PrintService;
  7. class PrintactionModel
  8. {
  9. private function _info()
  10. {
  11. $user = '353399459@qq.com'; //*必填*:飞鹅云后台注册账号
  12. $ukey = '5S64haPkEgxUWEMa'; //*必填*: 飞鹅云注册账号后生成的UKEY
  13. $sn = 'xxxxxxxxx'; //*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
  14. //以下参数不需要修改
  15. $ip = 'api.feieyun.cn';//接口IP或域名
  16. $port = 80; //接口IP端口
  17. $path = '/Api/Open/';//接口路径
  18. $stime = time(); //公共参数,请求时间
  19. $sig = sha1($user.$ukey.$stime); //公共参数,请求公钥
  20. return array(
  21. 'user' => $user,
  22. 'ukey' => $ukey,
  23. 'ip' => $ip,
  24. 'port' => $port,
  25. 'path' => $path,
  26. 'stime' => $stime,
  27. 'sig' => $sig,
  28. );
  29. }
  30. //===========添加打印机接口(支持批量)=============
  31. //***接口返回值说明***
  32. //正确例子:{"msg":"ok","ret":0,"data":{"ok":["sn#key#remark#carnum","316500011#abcdefgh#快餐前台"],"no":["316500012#abcdefgh#快餐前台#13688889999 (错误:识别码不正确)"]},"serverExecutedTime":3}
  33. //错误:{"msg":"参数错误 : 该帐号未注册.","ret":-2,"data":null,"serverExecutedTime":37}
  34. //打开注释可测试
  35. //提示:打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。
  36. //$snlist = "sn1#key1#remark1#carnum1\nsn2#key2#remark2#carnum2";
  37. //addprinter($snlist);
  38. function addprinter($snlist)
  39. {
  40. $info = $this->_info();
  41. $content = array(
  42. 'user'=>$info['user'],
  43. 'stime'=>$info['stime'],
  44. 'sig'=>$info['sig'],
  45. 'apiname'=>'Open_printerAddlist',
  46. 'printerContent'=>$snlist
  47. );
  48. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  49. require_once $lib_path."/Weixin/Httpclient.class.php";
  50. $client = new \Httpclient($info['ip'],$info['port']);
  51. $res = $client->post($info['path'],$content);
  52. if(!$res){
  53. // var_dump($res);die();
  54. }
  55. else{
  56. $result_json = $client->getContent();
  57. $result = json_decode($result_json, true);
  58. }
  59. }
  60. //==================方法1.打印订单==================
  61. //***接口返回值说明***
  62. //正确例子:{"msg":"ok","ret":0,"data":"316500004_20160823165104_1853029628","serverExecutedTime":6}
  63. //错误:{"msg":"错误信息.","ret":非零错误码,"data":null,"serverExecutedTime":5}
  64. //标签说明:
  65. //单标签:
  66. //"<BR>"为换行,"<CUT>"为切刀指令(主动切纸,仅限切刀打印机使用才有效果)
  67. //"<LOGO>"为打印LOGO指令(前提是预先在机器内置LOGO图片),"<PLUGIN>"为钱箱或者外置音响指令
  68. //成对标签:
  69. //"<CB></CB>"为居中放大一倍,"<B></B>"为放大一倍,"<C></C>"为居中,<L></L>字体变高一倍
  70. //<W></W>字体变宽一倍,"<QR></QR>"为二维码,"<BOLD></BOLD>"为字体加粗,"<RIGHT></RIGHT>"为右对齐
  71. //拼凑订单内容时可参考如下格式
  72. //根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
  73. /**
  74. $orderInfo = '<CB>测试打印</CB><BR>';
  75. $orderInfo .= '名称      单价 数量 金额<BR>';
  76. $orderInfo .= '--------------------------------<BR>';
  77. $orderInfo .= '饭       10.0 10 10.0<BR>';
  78. $orderInfo .= '炒饭      10.0 10 10.0<BR>';
  79. $orderInfo .= '蛋炒饭     10.0 100 100.0<BR>';
  80. $orderInfo .= '鸡蛋炒饭    100.0 100 100.0<BR>';
  81. $orderInfo .= '西红柿炒饭   1000.0 1 100.0<BR>';
  82. $orderInfo .= '西红柿蛋炒饭  100.0 100 100.0<BR>';
  83. $orderInfo .= '西红柿鸡蛋炒饭西红柿鸡蛋炒饭西';
  84. $orderInfo .= '备注:加辣<BR>';
  85. $orderInfo .= '--------------------------------<BR>';
  86. $orderInfo .= '合计:xx.0元<BR>';
  87. $orderInfo .= '送货地点:广州市南沙区xx路xx号<BR>';
  88. $orderInfo .= '联系电话:13888888888888<BR>';
  89. $orderInfo .= '订餐时间:2014-08-08 08:08:08<BR>';
  90. $orderInfo .= '<QR>http://www.dzist.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
  91. **/
  92. //打开注释可测试
  93. //wp_print(SN,$orderInfo,1);
  94. /*
  95. * 方法1
  96. 拼凑订单内容时可参考如下格式
  97. 根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
  98. */
  99. //旧版飞鹅打印机
  100. private function wp_print($orderInfo,$times=1 ,$printer_sn){
  101. //printer_sn
  102. $info = $this->_info();
  103. $content = array(
  104. 'user'=>$info['user'],
  105. 'stime'=>$info['stime'],
  106. 'sig'=>$info['sig'],
  107. 'apiname'=>'Open_printMsg',
  108. 'sn'=>$printer_sn,
  109. 'content'=>$orderInfo,
  110. 'times'=>$times//打印次数
  111. );
  112. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  113. require_once $lib_path."/Weixin/Httpclient.class.php";
  114. $client = new \Httpclient($info['ip'],$info['port']);
  115. if(!$client->post($info['path'],$content)){
  116. return false;
  117. }
  118. else{
  119. //服务器返回的JSON字符串,建议要当做日志记录起来
  120. $pr_result = json_decode($client->getContent(), true);
  121. if( $pr_result['ret'] == 0 )
  122. {
  123. return array( 'code' => 1,'msg' =>'' );
  124. }else{
  125. return array( 'code' => 0,'msg' =>$pr_result['msg'] );
  126. }
  127. }
  128. }
  129. //标签说明:
  130. //单标签:
  131. //"<BR>"为换行,"<CUT>"为切刀指令(主动切纸,仅限切刀打印机使用才有效果)
  132. //"<LOGO>"为打印LOGO指令(前提是预先在机器内置LOGO图片),"<PLUGIN>"为钱箱或者外置音响指令
  133. //成对标签:
  134. //"<CB></CB>"为居中放大一倍,"<B></B>"为放大一倍,"<C></C>"为居中,<L></L>字体变高一倍
  135. //<W></W>字体变宽一倍,"<QR></QR>"为二维码,"<BOLD></BOLD>"为字体加粗,"<RIGHT></RIGHT>"为右对齐
  136. //拼凑订单内容时可参考如下格式
  137. //根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
  138. //获取字符串里的中文字数
  139. //-----------------begin---------
  140. /**
  141. 添加易联云打印机
  142. **/
  143. public function addyilianyunprinter($yilian_client_id,$yilian_client_key,$yilian_machine_code, $yilian_msign)
  144. {
  145. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  146. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  147. //授权打印机(自有型应用使用,开放型应用请跳过该步骤) $_W['uniacid']
  148. $token = $this->_get_yilian_access_token($yilian_client_id,$yilian_client_key);
  149. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  150. $printer = new PrinterService($token['access_token'], $config);
  151. $data = $printer->addPrinter($yilian_machine_code, $yilian_msign);
  152. return $data->error;
  153. }
  154. /**
  155. 获取易联云access_token
  156. **/
  157. private function _get_yilian_access_token($yilian_client_id,$yilian_client_key)
  158. {
  159. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  160. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  161. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  162. $token = D('Home/Front')->get_config_by_name('token_yilian_'.$yilian_client_id);
  163. //$yilian_client_id = D('Home/Front')->get_config_by_name('yilian_client_id');
  164. $client = new YlyOauthClient($config);
  165. if( empty($token) )
  166. {
  167. $new_token = $client->getToken(); //若是开放型应用请传授权码code
  168. $save_token = array();
  169. $save_token['access_token'] = $new_token->access_token;
  170. $save_token['refresh_token'] = $new_token->refresh_token;
  171. $save_token['machine_code'] = $new_token->machine_code;
  172. $save_token['expires_in'] = $new_token->expires_in;
  173. $save_token['scope'] = $new_token->scope;
  174. $save_token['expires_end'] = time() + $new_token->expires_in -86400;
  175. $cd_key = 'token_yilian_'.$yilian_client_id;
  176. D('Seller/Config')->update( array( $cd_key => serialize($save_token) ) );
  177. return $save_token;
  178. }else{
  179. $save_token = unserialize($token['value']);
  180. if( empty($save_token) )
  181. {
  182. $save_token = unserialize($token);
  183. }
  184. if($save_token['expires_end'] < time() && false)
  185. {
  186. $save_token = $this->_relush_access_token($yilian_client_id,$yilian_client_key);
  187. }
  188. return $save_token;
  189. }
  190. }
  191. private function _relush_access_token($yilian_client_id,$yilian_client_key)
  192. {
  193. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  194. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  195. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  196. $token_info = D('Home/Front')->get_config_by_name('token_yilian_'.$yilian_client_id);
  197. $token = unserialize($token_info);
  198. $client = new YlyOauthClient($config);
  199. //refresh_token
  200. $new_token = $client->refreshToken($token['refresh_token']);
  201. $save_token = array();
  202. $save_token['access_token'] = $new_token->access_token;
  203. $save_token['refresh_token'] = $new_token->refresh_token;
  204. $save_token['machine_code'] = $new_token->machine_code;
  205. $save_token['expires_in'] = $new_token->expires_in;
  206. $save_token['scope'] = $new_token->scope;
  207. $save_token['expires_end'] = time() + $new_token->expires_in -86400;
  208. $cd_key = 'token_yilian_'.$yilian_client_id;
  209. D('Seller/Config')->update( array( $cd_key => serialize($save_token) ) );
  210. return $save_token;
  211. }
  212. //-----------------end-----------
  213. //begin---------
  214. public function print_supply_order($order_id, $supply_goods_info,$title = '在线支付')
  215. {
  216. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  217. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');//快递费
  218. if( !isset($placeorder_trans_name) || empty($placeorder_trans_name) )
  219. {
  220. $placeorder_trans_name = '快递费';
  221. }
  222. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');//配送费
  223. if( !isset($placeorder_tuan_name) || empty($placeorder_tuan_name) )
  224. {
  225. $placeorder_tuan_name = '配送费';
  226. }
  227. //打印隐藏会员手机号
  228. $is_printhide_membermobile = D('Home/Front')->get_config_by_name('is_printhide_membermobile');
  229. if( isset($is_printhide_membermobile) && $is_printhide_membermobile == 1 )
  230. {
  231. //隐藏
  232. $order_info['shipping_tel'] = substr($order_info['shipping_tel'],0,3).'*****'.substr($order_info['shipping_tel'],-3,3);
  233. }
  234. $owner_name = D('Home/Front')->get_config_by_name('owner_name');
  235. if( empty($owner_name) )
  236. {
  237. $owner_name = '团长';
  238. }
  239. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');//团长配送
  240. if( empty($delivery_tuanzshipping_name) )
  241. {
  242. $delivery_tuanzshipping_name = '';
  243. }
  244. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');//快递配送
  245. if( empty($delivery_express_name) )
  246. {
  247. $delivery_express_name = '';
  248. }
  249. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');//到点自提
  250. if( empty($delivery_ziti_name) )
  251. {
  252. $delivery_ziti_name = '';
  253. }
  254. $shoname = D('Home/Front')->get_config_by_name('shoname');
  255. foreach( $supply_goods_info as $supply_id => $order_goods )
  256. {
  257. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print'.$supply_id);
  258. $feier_print_sn = D('Home/Front')->get_config_by_name('feier_print_sn'.$supply_id);
  259. $last_print_time = D('Home/Front')->get_config_by_name('last_print_time'.$supply_id);
  260. $last_print_index = D('Home/Front')->get_config_by_name('last_print_index'.$supply_id);
  261. $now_time = strtotime( date('Y-m-d').' 00:00:00' );
  262. if( empty($last_print_time) || $last_print_time < $now_time )
  263. {
  264. $last_print_index = 1;
  265. $last_print_time = time();
  266. $sup_key = 'last_print_index'.$supply_id;
  267. $sup_key2 = 'last_print_time'.$supply_id;
  268. D('Seller/Config')->update( array( $sup_key => $last_print_index, $sup_key2 => $last_print_time) );
  269. }else if($last_print_time > $now_time) {
  270. $last_print_index = empty($last_print_index) ? 1: $last_print_index+1;
  271. $sup_key = 'last_print_index'.$supply_id;
  272. $sup_key2 = 'last_print_time'.$supply_id;
  273. D('Seller/Config')->update( array( $sup_key => $last_print_index, $sup_key2 => time() ) );
  274. }
  275. if( !empty($open_feier_print) && $open_feier_print == 2)
  276. {
  277. //易联云
  278. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  279. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  280. $yilian_client_id = D('Home/Front')->get_config_by_name('yilian_client_id'.$supply_id);
  281. $yilian_client_key = D('Home/Front')->get_config_by_name('yilian_client_key'.$supply_id);
  282. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  283. $token = $this->_get_yilian_access_token($yilian_client_id,$yilian_client_key);
  284. $yilian_machine_code = D('Home/Front')->get_config_by_name('yilian_machine_code'.$supply_id);
  285. $print = new PrintService($token['access_token'], $config);
  286. $yilian_print_lian = D('Home/Front')->get_config_by_name('yilian_print_lian'.$supply_id);
  287. if( empty($yilian_print_lian) || $yilian_print_lian < 1)
  288. {
  289. $yilian_print_lian = 1;
  290. }
  291. $orderInfo = '<MN>'.$yilian_print_lian.'</MN>';
  292. $total_length = 32;
  293. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  294. //printer_sn $content = "<FS2><center>**#1 美团**</center></FS2>";
  295. $orderInfo = '<FS2><center>--#'.$last_print_index.'#'.$title.'--</center></FS2>';
  296. $orderInfo .= '<FS2><center>'.$shoname.'</center></FS2>';
  297. $orderInfo .= '订单时间:'.$pay_time."\n";
  298. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  299. {
  300. $refund_time = date('Y-m-d H:i:s', time() );
  301. $orderInfo .= '取消时间:'.$refund_time."\n";
  302. }
  303. $orderInfo .= '订单编号:'.$order_info['order_num_alias']."\n";
  304. //head_id order_id
  305. if( $order_info['payment_code'] == 'cashon_delivery'){
  306. $orderInfo .= '支付方式:货到付款'."\n";
  307. }
  308. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' => $order_info['head_id'] ) )->find();
  309. if( !empty($head_relative_line) )
  310. {
  311. $line_id = $head_relative_line['line_id'];
  312. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  313. $orderInfo .= '线路名称:'.$line_info['name']."\n";
  314. }
  315. if($order_info['expected_delivery_time']){
  316. $orderInfo .= '--------------------------------'."\n";
  317. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time']."\n";
  318. $orderInfo .= '--------------------------------'."\n";
  319. }
  320. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  321. $orderInfo .= '收货小区:'.$head_info['community_name']."\n";
  322. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name']."\n";
  323. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile']."\n";
  324. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  325. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  326. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'(付费VIP)</FS>'."\n";
  327. }else{
  328. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'</FS>'."\n";
  329. }
  330. $orderInfo .= '<FS>电 话:'.$order_info['shipping_tel'].'</FS>'."\n";
  331. //delivery pickup tuanz_send
  332. if( $order_info['delivery'] == 'pickup' )
  333. {
  334. if( $order_info['type'] == 'virtual' )
  335. {
  336. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  337. $orderInfo .= '配送方式:门店核销'."\n";//团长配送
  338. }else{
  339. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  340. if( !empty($delivery_ziti_name) )
  341. {
  342. $orderInfo .= '配送方式:'.$delivery_ziti_name."\n";//团长配送
  343. }else{
  344. $orderInfo .= '配送方式:团员自提'."\n";//团长配送
  345. }
  346. }
  347. }else if( $order_info['delivery'] == 'tuanz_send'){
  348. // address_id
  349. if($order_info['address_id'] > 0)
  350. {
  351. $ad_info = M('lionfish_comshop_address')->field('lou_meng_hao')->where( array('address_id' => $order_info['address_id'] ) )->find();
  352. if( !empty($ad_info) )
  353. {
  354. //$order_info['tuan_send_address'] .= $ad_info['lou_meng_hao'];
  355. }
  356. }
  357. $orderInfo .= '送货地址:'.$order_info['tuan_send_address']."\n";
  358. if( !empty($delivery_tuanzshipping_name) )
  359. {
  360. $orderInfo .= '配送方式:'.$delivery_tuanzshipping_name.''."\n";//团长配送
  361. }else{
  362. $orderInfo .= '配送方式:'.$owner_name.'送货上门'."\n";//团长配送
  363. }
  364. }else{
  365. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  366. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  367. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  368. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  369. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."\n";
  370. if( !empty($delivery_express_name) )
  371. {
  372. $orderInfo .= '配送方式:'.$delivery_express_name."\n";
  373. }else{
  374. $orderInfo .= '配送方式:快递'."\n";
  375. }
  376. }
  377. $orderInfo .= '-------------商品---------------'."\n";
  378. $orderInfo .= '商品名称    数量  金额'."\n";
  379. $demo_str = '商品名称    数量  金额'."\n";
  380. $total_count = 0;
  381. $shipping_fare = $order_info['shipping_fare'];
  382. $man_e_money = $order_info['man_e_money'];
  383. $fare_shipping_free = $order_info['fare_shipping_free'];
  384. $is_free_shipping_fare = $order_info['is_free_shipping_fare'];
  385. $fullreduction_money = 0;
  386. $voucher_credit = 0;
  387. $comment = '';
  388. $total_money = 0;
  389. $score_for_money = 0;
  390. foreach($order_goods as $val )
  391. {
  392. $fullreduction_money += $val['fullreduction_money'];
  393. $voucher_credit += $val['voucher_credit'];
  394. $comment .= $val['comment'];
  395. $total_money += $val['total'];
  396. $score_for_money += $val['score_for_money'];
  397. $name = $val['name'];
  398. $total = $val['total'];
  399. $quantity = $val['quantity'];
  400. $goods_id = $val['goods_id'];
  401. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id ) )->find();
  402. $goods_name_str = "";
  403. if( !empty($goods_common['print_sub_title']) )
  404. {
  405. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  406. }else{
  407. $goods_name_str = $name.' '.$val['option_sku'];
  408. }
  409. $orderInfo .= $goods_name_str."\n";;
  410. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  411. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  412. //$zw_length = $this->linyufan_get_cn_num($goods_name_last);
  413. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  414. //mb_strlen($goods_name_last,'utf-8') -
  415. $zhongjian = 18;
  416. $zhognjian_ge = '';
  417. for($i =1;$i<=$zhongjian;$i++)
  418. {
  419. $zhognjian_ge .= ' ';
  420. }
  421. //$orderInfo .= $zhognjian_ge;
  422. $orderInfo .= "\t\t\t\t";
  423. $quantity_str = 'x'.$quantity;
  424. $total_str = sprintf('%.2f',$total);
  425. $orderInfo .= $quantity_str;
  426. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  427. for( $i =1;$i<=$right_gezi;$i++ )
  428. {
  429. $orderInfo .= ' ';
  430. }
  431. $orderInfo .= sprintf('%.2f',$total)."\n";
  432. $total_count += $quantity;
  433. }
  434. $orderInfo .= '--------------------------------'."\n";
  435. //var_dump( strlen($demo_str), mb_strlen($demo_str,'utf-8') );
  436. $zhongjian = 32 - 10 - strlen($total_count);
  437. $zhognjian_ge = '';
  438. for($i =1;$i<=$zhongjian;$i++)
  439. {
  440. $zhognjian_ge .= ' ';
  441. }
  442. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count."\n";
  443. if( !empty($fullreduction_money) && $fullreduction_money >0)
  444. {
  445. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$fullreduction_money));
  446. $zhognjian_ge = '';
  447. for($i =1;$i<=$zhongjian;$i++)
  448. {
  449. $zhognjian_ge .= ' ';
  450. }
  451. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$fullreduction_money).'元'."\n";
  452. }
  453. if( !empty($score_for_money) && $score_for_money >0)
  454. {
  455. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  456. $zhognjian_ge = '';
  457. for($i =1;$i<=$zhongjian;$i++)
  458. {
  459. $zhognjian_ge .= ' ';
  460. }
  461. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元'."\n";
  462. }
  463. if( !empty($voucher_credit) && $voucher_credit >0)
  464. {
  465. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$voucher_credit));
  466. $zhognjian_ge = '';
  467. for($i =1;$i<=$zhongjian;$i++)
  468. {
  469. $zhognjian_ge .= ' ';
  470. }
  471. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$voucher_credit).'元'."\n";
  472. }
  473. /**
  474. if( !empty($shipping_fare) && $shipping_fare >0)
  475. {
  476. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  477. $zhognjian_ge = '';
  478. for($i =1;$i<=$zhongjian;$i++)
  479. {
  480. $zhognjian_ge .= ' ';
  481. }
  482. $orderInfo .= '运费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  483. }
  484. **/
  485. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  486. {
  487. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  488. {
  489. //满$man_e_money免运费 -7 man_e_money
  490. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  491. $zhognjian_ge = '';
  492. for($i =1;$i<=$zhongjian;$i++)
  493. {
  494. $zhognjian_ge .= ' ';
  495. }
  496. if( $order_info['delivery'] == 'tuanz_send')
  497. {
  498. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  499. }else if( $order_info['delivery'] == 'express')
  500. {
  501. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  502. }
  503. }
  504. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  505. {
  506. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  507. $zhognjian_ge = '';
  508. for($i =1;$i<=$zhongjian;$i++)
  509. {
  510. $zhognjian_ge .= ' ';
  511. }
  512. $man_e_money = floor($man_e_money * 100) / 100;
  513. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  514. $shipping_fare = 0;
  515. }
  516. }else{
  517. if( !empty($shipping_fare) && $shipping_fare >0)
  518. {
  519. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  520. $zhognjian_ge = '';
  521. for($i =1;$i<=$zhongjian;$i++)
  522. {
  523. $zhognjian_ge .= ' ';
  524. }
  525. if( $order_info['delivery'] == 'tuanz_send')
  526. {
  527. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  528. }else if( $order_info['delivery'] == 'express')
  529. {
  530. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  531. }
  532. }
  533. }
  534. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$total_money));
  535. $zhognjian_ge = '';
  536. for($i =1;$i<=$zhongjian;$i++)
  537. {
  538. $zhognjian_ge .= ' ';
  539. }
  540. $order_type = $order_info['type'];
  541. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  542. if ($order_type == "integral"){
  543. $orderInfo .= "积分"."\n";
  544. }else{
  545. $orderInfo .= "元"."\n";
  546. }
  547. $orderInfo .= '********************************'."\n";
  548. $real_price = $total_money+$shipping_fare-$voucher_credit-$fullreduction_money-$score_for_money;
  549. if($real_price < 0)
  550. {
  551. $real_price = 0;
  552. }
  553. $real_price = sprintf('%.2f',$real_price);
  554. $zhongjian = 32 - 12 - strlen($real_price);
  555. $zhognjian_ge = '';
  556. for($i =1;$i<=$zhongjian;$i++)
  557. {
  558. $zhognjian_ge .= ' ';
  559. }
  560. if ($order_type == "integral"){
  561. if($real_price- $order_info['total'] == 0){
  562. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  563. }else{
  564. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  565. }
  566. }else{
  567. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元'."\n";
  568. }
  569. //comment
  570. $orderInfo .= '--------------------------------'."\n";
  571. //order_info <BR>
  572. if( !empty($comment) )
  573. {
  574. $orderInfo .= '备注:'.$comment.''."\n";
  575. }
  576. //是否打印会员备注:is_print_member_note
  577. //是否打印订单备注: is_print_order_note
  578. //begin pr
  579. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  580. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  581. {
  582. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  583. if( !empty($mb_info['content']) )
  584. {
  585. $orderInfo .= '会员备注:'.$mb_info['content'].''."\n";
  586. }
  587. }
  588. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  589. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  590. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  591. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  592. {
  593. if( !empty($order_info['note_content']) )
  594. {
  595. if( !empty($order_note_open) && !empty($order_note_name))
  596. {
  597. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  598. }else{
  599. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  600. }
  601. }
  602. }
  603. //end pr
  604. if($order_info['order_status_id'] == 7){
  605. $orderInfo .= '--------------------------------<BR>';
  606. $orderInfo .= '<FS>订单已退款</<FS><BR>';
  607. }
  608. $orderInfo .= '<FS2><center>**#'.$last_print_index.' 完**</center></FS2>';
  609. $data = $print->index($yilian_machine_code,$orderInfo,$order_id);
  610. ///......待查看格式
  611. }
  612. if( !empty($open_feier_print) && $open_feier_print == 1)
  613. {
  614. //飞蛾
  615. $total_length = 32;
  616. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  617. //printer_sn
  618. $orderInfo = '<CB>--#'.$last_print_index.'#'.$title.'--</CB><BR>';
  619. $orderInfo .= '<C><L>'.$shoname.'</L></C><BR>';
  620. $orderInfo .= '订单时间:'.$pay_time.'<BR>';
  621. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  622. {
  623. $refund_time = date('Y-m-d H:i:s', time() );
  624. $orderInfo .= '取消时间:'.$refund_time."<BR>";
  625. }
  626. $orderInfo .= '订单编号:'.$order_info['order_num_alias'].'<BR>';
  627. if( $order_info['payment_code'] == 'cashon_delivery'){
  628. $orderInfo .= '支付方式:货到付款'.'<BR>';
  629. }
  630. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' =>$order_info['head_id'] ) )->find();
  631. if( !empty($head_relative_line) )
  632. {
  633. $line_id = $head_relative_line['line_id'];
  634. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  635. $orderInfo .= '线路名称:'.$line_info['name'].'<BR>';
  636. }
  637. if($order_info['expected_delivery_time']){
  638. $orderInfo .= '--------------------------------<BR>';
  639. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time'].'<BR>';
  640. $orderInfo .= '--------------------------------<BR>';
  641. }
  642. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  643. $orderInfo .= '收货小区:'.$head_info['community_name'].'<BR>';
  644. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name'].'<BR>';
  645. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile'].'<BR>';
  646. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  647. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  648. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'(付费VIP)</L><BR>';
  649. }else{
  650. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'</L><BR>';
  651. }
  652. $orderInfo .= '<L>电 话:'.$order_info['shipping_tel'].'</L><BR>';
  653. if( $order_info['delivery'] == 'pickup' )
  654. {
  655. if( $order_info['type'] == 'virtual' )
  656. {
  657. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  658. $orderInfo .= '配送方式:门店核销<BR>';//团长配送
  659. }else{
  660. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  661. if( !empty($delivery_ziti_name) )
  662. {
  663. $orderInfo .= '配送方式:'.$delivery_ziti_name.'<BR>';//团长配送
  664. }else{
  665. $orderInfo .= '配送方式:团员自提<BR>';//团长配送
  666. }
  667. }
  668. }else if( $order_info['delivery'] == 'tuanz_send'){
  669. if($order_info['address_id'] > 0)
  670. {
  671. $ad_info = M('lionfish_comshop_address')->field('lou_meng_hao')->where( array('address_id' => $order_info['address_id'] ) )->find();
  672. if( !empty($ad_info) )
  673. {
  674. //$order_info['tuan_send_address'] .= $ad_info['lou_meng_hao'];
  675. }
  676. }
  677. $orderInfo .= '送货地址:'.$order_info['tuan_send_address'].'<BR>';
  678. if( !empty($delivery_tuanzshipping_name) )
  679. {
  680. $orderInfo .= '配送方式:'.$delivery_tuanzshipping_name.'<BR>';//团长配送
  681. }else{
  682. $orderInfo .= '配送方式:'.$owner_name.'送货上门<BR>';//团长配送
  683. }
  684. }else{
  685. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  686. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  687. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  688. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  689. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."<BR>";
  690. if( !empty($delivery_express_name) )
  691. {
  692. $orderInfo .= '配送方式:'.$delivery_express_name.'<BR>';
  693. }else{
  694. $orderInfo .= '配送方式:快递<BR>';
  695. }
  696. }
  697. $orderInfo .= '-------------商品---------------<BR>';
  698. $orderInfo .= '商品名称    数量  金额<BR>';
  699. $demo_str = '商品名称    数量  金额';
  700. $total_count = 0;
  701. $shipping_fare = $order_info['shipping_fare'];
  702. $man_e_money = $order_info['man_e_money'];
  703. $fare_shipping_free = $order_info['fare_shipping_free'];
  704. $fullreduction_money = 0;
  705. $voucher_credit = 0;
  706. $comment = '';
  707. $total_money = 0;
  708. $score_for_money = 0;
  709. foreach($order_goods as $val )
  710. {
  711. $fullreduction_money += $val['fullreduction_money'];
  712. $voucher_credit += $val['voucher_credit'];
  713. $score_for_money += $val['score_for_money'];
  714. $comment .= $val['comment'];
  715. $total_money += $val['total'];
  716. $name = $val['name'];
  717. $total = $val['total'];
  718. $quantity = $val['quantity'];
  719. $goods_id = $val['goods_id'];
  720. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id) )->find();
  721. $goods_name_str = "";
  722. if( !empty($goods_common['print_sub_title']) )
  723. {
  724. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  725. }else{
  726. $goods_name_str = $name.' '.$val['option_sku'];
  727. }
  728. //17
  729. //$goods_name_last = mb_substr($goods_name_str,0,7,'utf-8');
  730. //$orderInfo .= $goods_name_last;
  731. $orderInfo .= $goods_name_str.'<BR>';
  732. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  733. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  734. //$zw_length = $this->linyufan_get_cn_num($goods_name_last);
  735. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  736. //mb_strlen($goods_name_last,'utf-8') -
  737. $zhongjian = 18;
  738. $zhognjian_ge = '';
  739. for($i =1;$i<=$zhongjian;$i++)
  740. {
  741. $zhognjian_ge .= ' ';
  742. }
  743. $orderInfo .= $zhognjian_ge;
  744. $quantity_str = 'x'.$quantity;
  745. $total_str = sprintf('%.2f',$total);
  746. $orderInfo .= $quantity_str;
  747. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  748. for( $i =1;$i<=$right_gezi;$i++ )
  749. {
  750. $orderInfo .= ' ';
  751. }
  752. $orderInfo .= sprintf('%.2f',$total).'<BR>';
  753. $total_count += $quantity;
  754. }
  755. $orderInfo .= '--------------------------------<BR>';
  756. $zhongjian = 32 - 10 - strlen($total_count);
  757. $zhognjian_ge = '';
  758. for($i =1;$i<=$zhongjian;$i++)
  759. {
  760. $zhognjian_ge .= ' ';
  761. }
  762. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count.'<BR>';
  763. if( !empty($fullreduction_money) && $fullreduction_money >0)
  764. {
  765. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$fullreduction_money));
  766. $zhognjian_ge = '';
  767. for($i =1;$i<=$zhongjian;$i++)
  768. {
  769. $zhognjian_ge .= ' ';
  770. }
  771. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$fullreduction_money).'元<BR>';
  772. }
  773. if( !empty($score_for_money) && $score_for_money >0)
  774. {
  775. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  776. $zhognjian_ge = '';
  777. for($i =1;$i<=$zhongjian;$i++)
  778. {
  779. $zhognjian_ge .= ' ';
  780. }
  781. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元'."<BR>";
  782. }
  783. if( !empty($voucher_credit) && $voucher_credit >0)
  784. {
  785. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$voucher_credit));
  786. $zhognjian_ge = '';
  787. for($i =1;$i<=$zhongjian;$i++)
  788. {
  789. $zhognjian_ge .= ' ';
  790. }
  791. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$voucher_credit).'元<BR>';
  792. }
  793. /**
  794. if( !empty($shipping_fare) && $shipping_fare >0)
  795. {
  796. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  797. $zhognjian_ge = '';
  798. for($i =1;$i<=$zhongjian;$i++)
  799. {
  800. $zhognjian_ge .= ' ';
  801. }
  802. $orderInfo .= '配送费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  803. }
  804. **/
  805. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  806. {
  807. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  808. {
  809. //满$man_e_money免运费 -7 man_e_money
  810. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  811. $zhognjian_ge = '';
  812. for($i =1;$i<=$zhongjian;$i++)
  813. {
  814. $zhognjian_ge .= ' ';
  815. }
  816. if( $order_info['delivery'] == 'tuanz_send')
  817. {
  818. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  819. }else if( $order_info['delivery'] == 'express')
  820. {
  821. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  822. }
  823. }
  824. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  825. {
  826. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  827. $zhognjian_ge = '';
  828. for($i =1;$i<=$zhongjian;$i++)
  829. {
  830. $zhognjian_ge .= ' ';
  831. }
  832. $man_e_money = floor($man_e_money * 100) / 100;
  833. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  834. $shipping_fare = 0;
  835. }
  836. }else{
  837. if( !empty($shipping_fare) && $shipping_fare >0)
  838. {
  839. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  840. $zhognjian_ge = '';
  841. for($i =1;$i<=$zhongjian;$i++)
  842. {
  843. $zhognjian_ge .= ' ';
  844. }
  845. if( $order_info['delivery'] == 'tuanz_send')
  846. {
  847. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  848. }else if( $order_info['delivery'] == 'express')
  849. {
  850. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  851. }
  852. }
  853. }
  854. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$total_money));
  855. $zhognjian_ge = '';
  856. for($i =1;$i<=$zhongjian;$i++)
  857. {
  858. $zhognjian_ge .= ' ';
  859. }
  860. $order_type = $order_info['type'];
  861. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  862. if ($order_type == "integral"){
  863. $orderInfo .= "积分"."<BR>";
  864. }else{
  865. $orderInfo .= "元"."<BR>";
  866. }
  867. $orderInfo .= '********************************<BR>';
  868. $real_price = $total_money + $shipping_fare -$voucher_credit-$fullreduction_money-$score_for_money;
  869. if($real_price < 0)
  870. {
  871. $real_price = 0;
  872. }
  873. $real_price = sprintf('%.2f',$real_price);
  874. $zhongjian = 32 - 12 - strlen($real_price);
  875. $zhognjian_ge = '';
  876. for($i =1;$i<=$zhongjian;$i++)
  877. {
  878. $zhognjian_ge .= ' ';
  879. }
  880. if ($order_type == "integral"){
  881. if($real_price- $order_info['total'] == 0){
  882. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  883. }else{
  884. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  885. }
  886. }else{
  887. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元<BR>';
  888. }
  889. //comment
  890. $orderInfo .= '--------------------------------<BR>';
  891. //order_info <BR>
  892. if( !empty($comment) )
  893. {
  894. $orderInfo .= '备注:'.$comment.'<BR>';
  895. }
  896. //begin pr
  897. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  898. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  899. {
  900. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  901. if( !empty($mb_info['content']) )
  902. {
  903. $orderInfo .= '会员备注:'.$mb_info['content'].''."<BR>";
  904. }
  905. }
  906. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  907. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  908. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  909. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  910. {
  911. if( !empty($order_info['note_content']) )
  912. {
  913. if( !empty($order_note_open) && !empty($order_note_name))
  914. {
  915. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  916. }else{
  917. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  918. }
  919. }
  920. }
  921. //end pr
  922. if($order_info['order_status_id'] == 7){
  923. $orderInfo .= '--------------------------------<BR>';
  924. $orderInfo .= '<L>订单已退款</<L><BR>';
  925. }
  926. $orderInfo .= '<CB>**#'.$last_print_index.' 完**</CB><BR>';
  927. //$orderInfo .= '<QR>http://www.dzist.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
  928. //feier_print_lian
  929. $feier_print_lian = D('Home/Front')->get_config_by_name('feier_print_lian'.$supply_id);
  930. if( empty($feier_print_lian) || $feier_print_lian < 1)
  931. {
  932. $feier_print_lian = 1;
  933. }
  934. $this->wp_print($orderInfo, $feier_print_lian, $feier_print_sn);
  935. }
  936. }
  937. }
  938. //end
  939. //打印小票
  940. public function check_print_order($order_id,$title='在线支付')
  941. {
  942. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  943. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  944. foreach($order_goods as &$value)
  945. {
  946. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
  947. }
  948. $owner_name = D('Home/Front')->get_config_by_name('owner_name');
  949. if( empty($owner_name) )
  950. {
  951. $owner_name = '团长';
  952. }
  953. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');//团长配送
  954. if( empty($delivery_tuanzshipping_name) )
  955. {
  956. $delivery_tuanzshipping_name = '';
  957. }
  958. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');//快递配送
  959. if( empty($delivery_express_name) )
  960. {
  961. $delivery_express_name = '';
  962. }
  963. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');//到点自提
  964. if( empty($delivery_ziti_name) )
  965. {
  966. $delivery_ziti_name = '';
  967. }
  968. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');//快递费
  969. if( !isset($placeorder_trans_name) || empty($placeorder_trans_name) )
  970. {
  971. $placeorder_trans_name = '快递费';
  972. }
  973. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');//配送费
  974. if( !isset($placeorder_tuan_name) || empty($placeorder_tuan_name) )
  975. {
  976. $placeorder_tuan_name = '配送费';
  977. }
  978. /***
  979. 供应商订单商品集合
  980. **/
  981. $supply_goods_info = array();
  982. /***
  983. 供应商订单商品集合
  984. **/
  985. $is_print_dansupply_order = D('Home/Front')->get_config_by_name('is_print_dansupply_order');
  986. if( isset($is_print_dansupply_order) && $is_print_dansupply_order == 1 )
  987. {
  988. $is_print_dansupply_order = 1;
  989. }else if( !isset($is_print_dansupply_order) || $is_print_dansupply_order == 0 )
  990. {
  991. $is_print_dansupply_order = 0;
  992. }
  993. //打印隐藏会员手机号
  994. $is_printhide_membermobile = D('Home/Front')->get_config_by_name('is_printhide_membermobile');
  995. if( isset($is_printhide_membermobile) && $is_printhide_membermobile == 1 )
  996. {
  997. //隐藏
  998. $order_info['shipping_tel'] = substr($order_info['shipping_tel'],0,3).'*****'.substr($order_info['shipping_tel'],-3,3);
  999. }
  1000. $is_print = true;
  1001. foreach($order_goods as &$value)
  1002. {
  1003. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($value['order_id'], $value['order_goods_id']);
  1004. if( $value['supply_id'] > 0 )
  1005. {
  1006. if( isset($supply_goods_info[ $value['supply_id'] ]) )
  1007. {
  1008. $supply_goods_info[ $value['supply_id'] ][] = $value;
  1009. }else{
  1010. $supply_goods_info[ $value['supply_id'] ] = array();
  1011. $supply_goods_info[ $value['supply_id'] ][] = $value;
  1012. }
  1013. }
  1014. }
  1015. $shoname = D('Home/Front')->get_config_by_name('shoname');
  1016. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  1017. //打印联数
  1018. $feier_print_sn = D('Home/Front')->get_config_by_name('feier_print_sn');
  1019. $last_print_time = D('Home/Front')->get_config_by_name('last_print_time');
  1020. $last_print_index = D('Home/Front')->get_config_by_name('last_print_index');
  1021. $now_time = strtotime( date('Y-m-d').' 00:00:00' );
  1022. if( empty($last_print_time) || $last_print_time < $now_time )
  1023. {
  1024. $last_print_index = 1;
  1025. $last_print_time = time();
  1026. D('Seller/Config')->update( array('last_print_index' => $last_print_index, 'last_print_time' => $last_print_time) );
  1027. }else if($last_print_time > $now_time) {
  1028. $last_print_index = empty($last_print_index) ? 1: $last_print_index+1;
  1029. D('Seller/Config')->update( array('last_print_index' => $last_print_index, 'last_print_time' => time() ) );
  1030. }
  1031. //继续使用原有的打印机设置,旧版打印机与“默认订单打印机”一起打印小票,也可以关闭旧版打印机设置使用新版本“默认打印机”
  1032. //默认打印机的参数
  1033. $data = D('Seller/Config')->get_all_config();
  1034. if(isset($data['is_printer_list']) && !empty($data['is_printer_list'])){
  1035. $printer_list = M('lionfish_comshop_printer')->where( array('id' => array('in',$data['is_printer_list']) ) )->select();
  1036. }
  1037. //旧版
  1038. //易联云
  1039. if( !empty($open_feier_print) && $open_feier_print == 2)
  1040. {
  1041. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  1042. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  1043. $yilian_client_id = D('Home/Front')->get_config_by_name('yilian_client_id');
  1044. $yilian_client_key = D('Home/Front')->get_config_by_name('yilian_client_key' );
  1045. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  1046. $token = $this->_get_yilian_access_token($yilian_client_id,$yilian_client_key);
  1047. $yilian_machine_code = D('Home/Front')->get_config_by_name('yilian_machine_code' );
  1048. $print = new PrintService($token['access_token'], $config);
  1049. //object(stdClass)#14 (3) { ["error"]=> string(1) "0" ["error_description"]=> string(7) "success" ["body"]=> object(stdClass)#15 (2) { ["id"]=> string(9) "221354299" ["origin_id"]=> string(3) "558" } }
  1050. //<MN>1</MN>
  1051. //$data = $print->index($yilian_machine_code,'打印内容排版可看Demo下的callback.php','558');
  1052. //-------------------------------------------------------------------------------------------
  1053. $yilian_print_lian = D('Home/Front')->get_config_by_name('yilian_print_lian');
  1054. if( empty($yilian_print_lian) || $yilian_print_lian < 1)
  1055. {
  1056. $yilian_print_lian = 1;
  1057. }
  1058. $orderInfo = '<MN>'.$yilian_print_lian.'</MN>';
  1059. $total_length = 32;
  1060. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  1061. $orderInfo = '<FS2><center>--#'.$last_print_index.$title.'--</center></FS2>';
  1062. $orderInfo .= '<FS2><center>'.$shoname.'</center></FS2>';
  1063. $orderInfo .= '订单时间:'.$pay_time."\n";
  1064. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  1065. {
  1066. $refund_time = date('Y-m-d H:i:s', time() );
  1067. $orderInfo .= '取消时间:'.$refund_time."\n";
  1068. }
  1069. $orderInfo .= '订单编号:'.$order_info['order_num_alias']."\n";
  1070. if( $order_info['payment_code'] == 'cashon_delivery'){
  1071. $orderInfo .= '支付方式:货到付款'."\n";
  1072. }
  1073. //head_id order_id
  1074. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' => $order_info['head_id'] ) )->find();
  1075. if( !empty($head_relative_line) )
  1076. {
  1077. $line_id = $head_relative_line['line_id'];
  1078. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  1079. $orderInfo .= '线路名称:'.$line_info['name']."\n";
  1080. }
  1081. if($order_info['expected_delivery_time']){
  1082. $orderInfo .= '--------------------------------'."\n";
  1083. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time']."\n";
  1084. $orderInfo .= '--------------------------------'."\n";
  1085. }
  1086. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  1087. $orderInfo .= '收货小区:'.$head_info['community_name']."\n";
  1088. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name']."\n";
  1089. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile']."\n";
  1090. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1091. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  1092. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'(付费VIP)</FS>'."\n";
  1093. }else{
  1094. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'</FS>'."\n";
  1095. }
  1096. $orderInfo .= '<FS>电 话:'.$order_info['shipping_tel'].'</FS>'."\n";
  1097. //delivery pickup tuanz_send
  1098. if( $order_info['delivery'] == 'pickup' )
  1099. {
  1100. if( $order_info['type'] == 'virtual' )
  1101. {
  1102. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  1103. $orderInfo .= '配送方式:门店核销'."\n";//团长配送
  1104. }else{
  1105. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  1106. if( !empty($delivery_ziti_name) )
  1107. {
  1108. $orderInfo .= '配送方式:'.$delivery_ziti_name."\n";//团长配送
  1109. }else{
  1110. $orderInfo .= '配送方式:团员自提'."\n";//团长配送
  1111. }
  1112. }
  1113. }else if( $order_info['delivery'] == 'tuanz_send'){
  1114. // address_id
  1115. if($order_info['address_id'] > 0)
  1116. {
  1117. $ad_info = M('lionfish_comshop_address')->field('lou_meng_hao')->where( array('address_id' => $order_info['address_id'] ) )->find();
  1118. if( !empty($ad_info) )
  1119. {
  1120. //$order_info['tuan_send_address'] .= $ad_info['lou_meng_hao'];
  1121. }
  1122. }
  1123. $orderInfo .= '送货地址:'.$order_info['tuan_send_address']."\n";
  1124. if( !empty($delivery_tuanzshipping_name) )
  1125. {
  1126. $orderInfo .= '配送方式:'.$delivery_tuanzshipping_name.''."\n";//团长配送
  1127. }else{
  1128. $orderInfo .= '配送方式:'.$owner_name.'送货上门'."\n";//团长配送
  1129. }
  1130. }else{
  1131. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  1132. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  1133. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  1134. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  1135. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."\n";
  1136. if( $order_info['delivery'] == 'localtown_delivery'){
  1137. $orderInfo .= '配送方式:同城配送'."\n";//同城配送
  1138. }else if( $order_info['delivery'] == 'hexiao'){
  1139. $orderInfo .= '<L>配送方式:到店核销</L><BR>';//到店核销
  1140. }else{
  1141. if( !empty($delivery_express_name) )
  1142. {
  1143. $orderInfo .= '配送方式:'.$delivery_express_name."\n";
  1144. }else{
  1145. $orderInfo .= '配送方式:快递'."\n";
  1146. }
  1147. }
  1148. }
  1149. $orderInfo .= '-------------商品---------------'."\n";
  1150. $orderInfo .= '商品名称    数量  金额'."\n";
  1151. $demo_str = '商品名称    数量  金额'."\n";
  1152. $total_count = 0;
  1153. foreach($order_goods as $val )
  1154. {
  1155. $name = $val['name'];
  1156. $total = $val['total'];
  1157. $quantity = $val['quantity'];
  1158. $goods_id = $val['goods_id'];
  1159. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id ) )->find();
  1160. $goods_name_str = "";
  1161. if( !empty($goods_common['print_sub_title']) )
  1162. {
  1163. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  1164. }else{
  1165. $goods_name_str = $name.' '.$val['option_sku'];
  1166. }
  1167. //17
  1168. $orderInfo .= $goods_name_str."\n";;
  1169. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  1170. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  1171. //$zw_length = $this->linyufan_get_cn_num($goods_name_last);
  1172. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  1173. //mb_strlen($goods_name_last,'utf-8') -
  1174. $zhongjian = 18;
  1175. $zhognjian_ge = '';
  1176. for($i =1;$i<=$zhongjian;$i++)
  1177. {
  1178. $zhognjian_ge .= ' ';
  1179. }
  1180. //$orderInfo .= $zhognjian_ge;
  1181. $orderInfo .= "\t\t\t\t";
  1182. $quantity_str = 'x'.$quantity;
  1183. $total_str = sprintf('%.2f',$total);
  1184. $orderInfo .= $quantity_str;
  1185. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  1186. for( $i =1;$i<=$right_gezi;$i++ )
  1187. {
  1188. $orderInfo .= ' ';
  1189. }
  1190. $orderInfo .= sprintf('%.2f',$total)."\n";
  1191. $total_count += $quantity;
  1192. }
  1193. $orderInfo .= '--------------------------------'."\n";
  1194. //var_dump( strlen($demo_str), mb_strlen($demo_str,'utf-8') );
  1195. $zhongjian = 32 - 10 - strlen($total_count);
  1196. $zhognjian_ge = '';
  1197. for($i =1;$i<=$zhongjian;$i++)
  1198. {
  1199. $zhognjian_ge .= ' ';
  1200. }
  1201. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count."\n";
  1202. if( !empty($order_info['fullreduction_money']) && $order_info['fullreduction_money'] >0)
  1203. {
  1204. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$order_info['fullreduction_money']));
  1205. $zhognjian_ge = '';
  1206. for($i =1;$i<=$zhongjian;$i++)
  1207. {
  1208. $zhognjian_ge .= ' ';
  1209. }
  1210. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['fullreduction_money']).'元'."\n";
  1211. }
  1212. if( !empty($order_info['voucher_credit']) && $order_info['voucher_credit'] >0)
  1213. {
  1214. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$order_info['voucher_credit']));
  1215. $zhognjian_ge = '';
  1216. for($i =1;$i<=$zhongjian;$i++)
  1217. {
  1218. $zhognjian_ge .= ' ';
  1219. }
  1220. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['voucher_credit']).'元'."\n";
  1221. }
  1222. $score_for_money = $order_info['score_for_money'];
  1223. if( !empty($score_for_money) && $score_for_money >0)
  1224. {
  1225. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  1226. $zhognjian_ge = '';
  1227. for($i =1;$i<=$zhongjian;$i++)
  1228. {
  1229. $zhognjian_ge .= ' ';
  1230. }
  1231. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元'."\n";
  1232. }
  1233. /**
  1234. $shipping_fare = $order_info['shipping_fare'];
  1235. if( !empty($shipping_fare) && $shipping_fare >0)
  1236. {
  1237. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  1238. $zhognjian_ge = '';
  1239. for($i =1;$i<=$zhongjian;$i++)
  1240. {
  1241. $zhognjian_ge .= ' ';
  1242. }
  1243. $orderInfo .= '配送费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  1244. }
  1245. **/
  1246. $man_e_money = $order_info['man_e_money'];
  1247. $fare_shipping_free = $order_info['fare_shipping_free'];
  1248. $is_free_shipping_fare = $order_info['is_free_shipping_fare'];
  1249. $shipping_fare = $order_info['shipping_fare'];
  1250. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  1251. {
  1252. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  1253. {
  1254. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  1255. $zhognjian_ge = '';
  1256. for($i =1;$i<=$zhongjian;$i++)
  1257. {
  1258. $zhognjian_ge .= ' ';
  1259. }
  1260. if( $order_info['delivery'] == 'tuanz_send')
  1261. {
  1262. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  1263. }else if( $order_info['delivery'] == 'express')
  1264. {
  1265. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  1266. }
  1267. }
  1268. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  1269. {
  1270. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  1271. $zhognjian_ge = '';
  1272. for($i =1;$i<=$zhongjian;$i++)
  1273. {
  1274. $zhognjian_ge .= ' ';
  1275. }
  1276. $man_e_money = floor($man_e_money * 100) / 100;
  1277. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  1278. $shipping_fare = 0;
  1279. }
  1280. }else{
  1281. if( !empty($shipping_fare) && $shipping_fare >0)
  1282. {
  1283. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  1284. $zhognjian_ge = '';
  1285. for($i =1;$i<=$zhongjian;$i++)
  1286. {
  1287. $zhognjian_ge .= ' ';
  1288. }
  1289. if( $order_info['delivery'] == 'tuanz_send')
  1290. {
  1291. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  1292. }else if( $order_info['delivery'] == 'express')
  1293. {
  1294. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  1295. }
  1296. }
  1297. }
  1298. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$order_info['total']));
  1299. $zhognjian_ge = '';
  1300. for($i =1;$i<=$zhongjian;$i++)
  1301. {
  1302. $zhognjian_ge .= ' ';
  1303. }
  1304. // $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']).'元'."\n";
  1305. $order_type = $order_info['type'];
  1306. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  1307. if ($order_type == "integral"){
  1308. $orderInfo .= "积分"."\n";
  1309. }else{
  1310. $orderInfo .= "元"."\n";
  1311. }
  1312. $orderInfo .= '********************************'."\n";
  1313. if($shipping_fare == 0){
  1314. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare'];
  1315. }else{
  1316. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']-$order_info['fare_shipping_free']+$order_info['localtown_add_shipping_fare'];
  1317. }
  1318. if($real_price < 0)
  1319. {
  1320. $real_price = 0;
  1321. }
  1322. $real_price = sprintf('%.2f',$real_price);
  1323. $zhongjian = 32 - 12 - strlen($real_price);
  1324. $zhognjian_ge = '';
  1325. for($i =1;$i<=$zhongjian;$i++)
  1326. {
  1327. $zhognjian_ge .= ' ';
  1328. }
  1329. if ($order_type == "integral"){
  1330. if($real_price- $order_info['total'] == 0){
  1331. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  1332. }else{
  1333. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  1334. }
  1335. }else{
  1336. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元'."\n";
  1337. }
  1338. //comment
  1339. $orderInfo .= '--------------------------------'."\n";
  1340. //order_info <BR>
  1341. if( !empty($order_info['comment']) )
  1342. {
  1343. $orderInfo .= '<FS>备注:'.$order_info['comment'].'</FS>'."\n";
  1344. }
  1345. //begin pr
  1346. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  1347. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  1348. {
  1349. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1350. if( !empty($mb_info['content']) )
  1351. {
  1352. $orderInfo .= '会员备注:'.$mb_info['content'].''."\n";
  1353. }
  1354. }
  1355. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  1356. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  1357. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  1358. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  1359. {
  1360. if( !empty($order_info['note_content']) )
  1361. {
  1362. if( !empty($order_note_open) && !empty($order_note_name))
  1363. {
  1364. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  1365. }else{
  1366. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  1367. }
  1368. }
  1369. }
  1370. //end pr
  1371. if($order_info['order_status_id'] == 7){
  1372. $orderInfo .= '--------------------------------<BR>';
  1373. $orderInfo .= '<FS>订单已退款</<FS><BR>';
  1374. }
  1375. $orderInfo .= '<FS2><center>**#'.$last_print_index.' 完**</center></FS2>';
  1376. $data = $print->index($yilian_machine_code,$orderInfo,$order_id);
  1377. $print_result = array('code' => 1);
  1378. ///......待查看格式
  1379. }
  1380. //飞鹅
  1381. if( !empty($open_feier_print) && $open_feier_print == 1)
  1382. {
  1383. $total_length = 32;
  1384. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  1385. //printer_sn
  1386. $orderInfo = '<CB>--#'.$last_print_index.$title.'--</CB><BR>';
  1387. $orderInfo .= '<C><L>'.$shoname.'</L></C><BR>';
  1388. $orderInfo .= '订单时间:'.$pay_time.'<BR>';
  1389. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  1390. {
  1391. $refund_time = date('Y-m-d H:i:s', time() );
  1392. $orderInfo .= '取消时间:'.$refund_time."<BR>";
  1393. }
  1394. $orderInfo .= '订单编号:'.$order_info['order_num_alias'].'<BR>';
  1395. if( $order_info['payment_code'] == 'cashon_delivery'){
  1396. $orderInfo .= '支付方式:货到付款'.'<BR>';
  1397. }
  1398. //head_id order_id
  1399. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' => $order_info['head_id']) )->find();
  1400. if( !empty($head_relative_line) )
  1401. {
  1402. $line_id = $head_relative_line['line_id'];
  1403. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  1404. $orderInfo .= '线路名称:'.$line_info['name'].'<BR>';
  1405. }
  1406. if($order_info['expected_delivery_time']){
  1407. $orderInfo .= '--------------------------------<BR>';
  1408. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time'].'<BR>';
  1409. $orderInfo .= '--------------------------------<BR>';
  1410. }
  1411. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  1412. $orderInfo .= '收货小区:'.$head_info['community_name'].'<BR>';
  1413. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name'].'<BR>';
  1414. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile'].'<BR>';
  1415. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1416. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  1417. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'(付费VIP)</L><BR>';
  1418. }else{
  1419. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'</L><BR>';
  1420. }
  1421. $orderInfo .= '<L>电 话:'.$order_info['shipping_tel'].'</L><BR>';
  1422. //delivery pickup tuanz_send
  1423. if( $order_info['delivery'] == 'pickup' )
  1424. {
  1425. if( $order_info['type'] == 'virtual' )
  1426. {
  1427. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  1428. $orderInfo .= '配送方式:门店核销<BR>';//团长配送
  1429. }else{
  1430. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  1431. if( !empty($delivery_ziti_name) )
  1432. {
  1433. $orderInfo .= '配送方式:'.$delivery_ziti_name.'<BR>';//团长配送
  1434. }else{
  1435. $orderInfo .= '配送方式:团员自提<BR>';//团长配送
  1436. }
  1437. }
  1438. }else if( $order_info['delivery'] == 'tuanz_send'){
  1439. // address_id
  1440. $orderInfo .= '送货地址:'.$order_info['tuan_send_address'].'<BR>';
  1441. if( !empty($delivery_tuanzshipping_name) )
  1442. {
  1443. $orderInfo .= '<L>配送方式:'.$delivery_tuanzshipping_name.'</L><BR>';//团长配送
  1444. }else{
  1445. $orderInfo .= '<L>配送方式:'.$owner_name.'送货上门</L><BR>';//团长配送
  1446. }
  1447. }else{
  1448. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  1449. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  1450. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  1451. //name
  1452. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  1453. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."<BR>";
  1454. if( $order_info['delivery'] == 'localtown_delivery'){
  1455. $orderInfo .= '<L>配送方式:同城配送</L><BR>';//同城配送
  1456. }else if( $order_info['delivery'] == 'hexiao'){
  1457. $orderInfo .= '<L>配送方式:到店核销</L><BR>';//到店核销
  1458. }else{
  1459. if( !empty($delivery_express_name) )
  1460. {
  1461. $orderInfo .= '<L>配送方式:'.$delivery_express_name.'</L><BR>';
  1462. }else{
  1463. $orderInfo .= '<L>配送方式:快递</L><BR>';
  1464. }
  1465. }
  1466. }
  1467. $orderInfo .= '-------------商品---------------<BR>';
  1468. $orderInfo .= '商品名称    数量  金额<BR>';
  1469. $demo_str = '商品名称    数量  金额';
  1470. $total_count = 0;
  1471. foreach($order_goods as $val )
  1472. {
  1473. $name = $val['name'];
  1474. $total = $val['total'];
  1475. $quantity = $val['quantity'];
  1476. $goods_id = $val['goods_id'];
  1477. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id) )->find();
  1478. $goods_name_str = "";
  1479. if( !empty($goods_common['print_sub_title']) )
  1480. {
  1481. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  1482. }else{
  1483. $goods_name_str = $name.' '.$val['option_sku'];
  1484. }
  1485. //17
  1486. //$goods_name_last = mb_substr($goods_name_str,0,7,'utf-8');//20190221
  1487. $orderInfo .= $goods_name_str.'<BR>';
  1488. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  1489. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  1490. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  1491. //mb_strlen($goods_name_last,'utf-8') -
  1492. $zhongjian = 18;
  1493. if($zw_length <= 0)
  1494. {
  1495. $zhongjian = $zhongjian -1;
  1496. }
  1497. $zhognjian_ge = '';
  1498. for($i =1;$i<=$zhongjian;$i++)
  1499. {
  1500. $zhognjian_ge .= ' ';
  1501. }
  1502. $orderInfo .= $zhognjian_ge;
  1503. $quantity_str = 'x'.$quantity;
  1504. $total_str = sprintf('%.2f',$total);
  1505. $orderInfo .= $quantity_str;
  1506. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  1507. $ggg_zi = '';
  1508. for( $i =1;$i<=$right_gezi;$i++ )
  1509. {
  1510. $ggg_zi .= ' ';
  1511. }
  1512. $orderInfo.= $ggg_zi;
  1513. $orderInfo .= sprintf('%.2f',$total).'<BR>';
  1514. $total_count += $quantity;
  1515. }
  1516. $orderInfo .= '--------------------------------<BR>';
  1517. $zhongjian = 32 - 10 - strlen($total_count);
  1518. $zhognjian_ge = '';
  1519. for($i =1;$i<=$zhongjian;$i++)
  1520. {
  1521. $zhognjian_ge .= ' ';
  1522. }
  1523. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count.'<BR>';
  1524. if( !empty($order_info['fullreduction_money']) && $order_info['fullreduction_money'] >0)
  1525. {
  1526. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$order_info['fullreduction_money']));
  1527. $zhognjian_ge = '';
  1528. for($i =1;$i<=$zhongjian;$i++)
  1529. {
  1530. $zhognjian_ge .= ' ';
  1531. }
  1532. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['fullreduction_money']).'元<BR>';
  1533. }
  1534. if( !empty($order_info['voucher_credit']) && $order_info['voucher_credit'] >0)
  1535. {
  1536. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$order_info['voucher_credit']));
  1537. $zhognjian_ge = '';
  1538. for($i =1;$i<=$zhongjian;$i++)
  1539. {
  1540. $zhognjian_ge .= ' ';
  1541. }
  1542. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['voucher_credit']).'元<BR>';
  1543. }
  1544. //score_for_money
  1545. $score_for_money = $order_info['score_for_money'];
  1546. if( !empty($score_for_money) && $score_for_money >0)
  1547. {
  1548. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  1549. $zhognjian_ge = '';
  1550. for($i =1;$i<=$zhongjian;$i++)
  1551. {
  1552. $zhognjian_ge .= ' ';
  1553. }
  1554. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元<BR>';
  1555. }
  1556. /**
  1557. $shipping_fare = $order_info['shipping_fare'];
  1558. if( !empty($shipping_fare) && $shipping_fare >0)
  1559. {
  1560. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  1561. $zhognjian_ge = '';
  1562. for($i =1;$i<=$zhongjian;$i++)
  1563. {
  1564. $zhognjian_ge .= ' ';
  1565. }
  1566. $orderInfo .= '配送费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  1567. }
  1568. **/
  1569. $shipping_fare = $order_info['shipping_fare'];
  1570. $man_e_money = $order_info['man_e_money'];
  1571. $fare_shipping_free = $order_info['fare_shipping_free'];
  1572. $is_free_shipping_fare = $order_info['is_free_shipping_fare'];
  1573. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  1574. {
  1575. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  1576. {
  1577. //满$man_e_money免运费 -7 man_e_money
  1578. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  1579. $zhognjian_ge = '';
  1580. for($i =1;$i<=$zhongjian;$i++)
  1581. {
  1582. $zhognjian_ge .= ' ';
  1583. }
  1584. if( $order_info['delivery'] == 'tuanz_send')
  1585. {
  1586. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  1587. }else if( $order_info['delivery'] == 'express')
  1588. {
  1589. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  1590. }
  1591. }
  1592. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  1593. {
  1594. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  1595. $zhognjian_ge = '';
  1596. for($i =1;$i<=$zhongjian;$i++)
  1597. {
  1598. $zhognjian_ge .= ' ';
  1599. }
  1600. $man_e_money = floor($man_e_money * 100) / 100;
  1601. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  1602. $shipping_fare = 0;
  1603. }
  1604. }else{
  1605. if( !empty($shipping_fare) && $shipping_fare >0)
  1606. {
  1607. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  1608. $zhognjian_ge = '';
  1609. for($i =1;$i<=$zhongjian;$i++)
  1610. {
  1611. $zhognjian_ge .= ' ';
  1612. }
  1613. if( $order_info['delivery'] == 'tuanz_send')
  1614. {
  1615. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  1616. }else if( $order_info['delivery'] == 'express')
  1617. {
  1618. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  1619. }
  1620. }
  1621. }
  1622. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$order_info['total']));
  1623. $zhognjian_ge = '';
  1624. for($i =1;$i<=$zhongjian;$i++)
  1625. {
  1626. $zhognjian_ge .= ' ';
  1627. }
  1628. // $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']).'元<BR>';
  1629. $order_type = $order_info['type'];
  1630. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  1631. if ($order_type == "integral"){
  1632. $orderInfo .= "积分"."<BR>";
  1633. }else{
  1634. $orderInfo .= "元"."<BR>";
  1635. }
  1636. $orderInfo .= '********************************<BR>';
  1637. if($shipping_fare == 0){
  1638. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare'];
  1639. }else{
  1640. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']-$order_info['fare_shipping_free']+$order_info['localtown_add_shipping_fare'];
  1641. }
  1642. if($real_price < 0)
  1643. {
  1644. $real_price = 0;
  1645. }
  1646. $real_price = sprintf('%.2f',$real_price);
  1647. $zhongjian = 32 - 12 - strlen($real_price);
  1648. $zhognjian_ge = '';
  1649. for($i =1;$i<=$zhongjian;$i++)
  1650. {
  1651. $zhognjian_ge .= ' ';
  1652. }
  1653. if ($order_type == "integral"){
  1654. if($real_price- $order_info['total'] == 0){
  1655. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  1656. }else{
  1657. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  1658. }
  1659. }else{
  1660. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元<BR>';
  1661. }
  1662. //comment
  1663. $orderInfo .= '--------------------------------<BR>';
  1664. //order_info <BR>
  1665. if( !empty($order_info['comment']) )
  1666. {
  1667. $orderInfo .= '<B>备注:'.$order_info['comment'].'</B><BR>';
  1668. }
  1669. //begin pr
  1670. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  1671. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  1672. {
  1673. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1674. if( !empty($mb_info['content']) )
  1675. {
  1676. $orderInfo .= '会员备注:'.$mb_info['content'].''."<BR>";
  1677. }
  1678. }
  1679. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  1680. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  1681. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  1682. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  1683. {
  1684. if( !empty($order_info['note_content']) )
  1685. {
  1686. if( !empty($order_note_open) && !empty($order_note_name))
  1687. {
  1688. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  1689. }else{
  1690. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  1691. }
  1692. }
  1693. }
  1694. //end pr
  1695. if($order_info['order_status_id'] == 7){
  1696. $orderInfo .= '--------------------------------<BR>';
  1697. $orderInfo .= '<L>订单已退款</<L><BR>';
  1698. }
  1699. $orderInfo .= '<CB>**#'.$last_print_index.' 完**</CB><BR>';
  1700. $feier_print_lian = D('Home/Front')->get_config_by_name('feier_print_lian');
  1701. if( empty($feier_print_lian) || $feier_print_lian < 1)
  1702. {
  1703. $feier_print_lian = 1;
  1704. }
  1705. $print_result = $this->wp_print($orderInfo, $feier_print_lian, $feier_print_sn);
  1706. if( $print_result['code'] == 0)
  1707. {
  1708. M('lionfish_comshop_order')->where( array('order_id' =>$order_id ) )->save( array('is_print_suc' => 0) );
  1709. }
  1710. }
  1711. // $this->print_supply_order($order_id, $supply_goods_info);
  1712. /**
  1713. 后台操作取消订单
  1714. 群接龙后台取消订单
  1715. 用户取消订单
  1716. **/
  1717. $print_result2 = $this->print_supply_order($order_id, $supply_goods_info, $title);
  1718. if( !$is_print )
  1719. {
  1720. $print_result = $print_result2;
  1721. if( empty($print_result) )
  1722. {
  1723. $print_result = array('code' => 0, 'msg' => '独立供应商订单不打印');
  1724. }
  1725. }
  1726. return $print_result;
  1727. }
  1728. //新版打印小票
  1729. public function check_print_order2($order_id,$title='在线支付')
  1730. {
  1731. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  1732. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  1733. foreach($order_goods as &$value)
  1734. {
  1735. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($order_id, $value['order_goods_id']);
  1736. }
  1737. $owner_name = D('Home/Front')->get_config_by_name('owner_name');
  1738. if( empty($owner_name) )
  1739. {
  1740. $owner_name = '团长';
  1741. }
  1742. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');//团长配送
  1743. if( empty($delivery_tuanzshipping_name) )
  1744. {
  1745. $delivery_tuanzshipping_name = '';
  1746. }
  1747. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');//快递配送
  1748. if( empty($delivery_express_name) )
  1749. {
  1750. $delivery_express_name = '';
  1751. }
  1752. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');//到点自提
  1753. if( empty($delivery_ziti_name) )
  1754. {
  1755. $delivery_ziti_name = '';
  1756. }
  1757. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');//快递费
  1758. if( !isset($placeorder_trans_name) || empty($placeorder_trans_name) )
  1759. {
  1760. $placeorder_trans_name = '快递费';
  1761. }
  1762. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');//配送费
  1763. if( !isset($placeorder_tuan_name) || empty($placeorder_tuan_name) )
  1764. {
  1765. $placeorder_tuan_name = '配送费';
  1766. }
  1767. /***
  1768. 供应商订单商品集合
  1769. **/
  1770. $supply_goods_info = array();
  1771. /***
  1772. 供应商订单商品集合
  1773. **/
  1774. $is_print_dansupply_order = D('Home/Front')->get_config_by_name('is_print_dansupply_order');
  1775. if( isset($is_print_dansupply_order) && $is_print_dansupply_order == 1 )
  1776. {
  1777. $is_print_dansupply_order = 1;
  1778. }else if( !isset($is_print_dansupply_order) || $is_print_dansupply_order == 0 )
  1779. {
  1780. $is_print_dansupply_order = 0;
  1781. }
  1782. //打印隐藏会员手机号
  1783. $is_printhide_membermobile = D('Home/Front')->get_config_by_name('is_printhide_membermobile');
  1784. if( isset($is_printhide_membermobile) && $is_printhide_membermobile == 1 )
  1785. {
  1786. //隐藏
  1787. $order_info['shipping_tel'] = substr($order_info['shipping_tel'],0,3).'*****'.substr($order_info['shipping_tel'],-3,3);
  1788. }
  1789. $is_print = true;
  1790. foreach($order_goods as &$value)
  1791. {
  1792. $value['option_sku'] = D('Seller/Order')->get_order_option_sku($value['order_id'], $value['order_goods_id']);
  1793. if( $value['supply_id'] > 0 )
  1794. {
  1795. if( isset($supply_goods_info[ $value['supply_id'] ]) )
  1796. {
  1797. $supply_goods_info[ $value['supply_id'] ][] = $value;
  1798. }else{
  1799. $supply_goods_info[ $value['supply_id'] ] = array();
  1800. $supply_goods_info[ $value['supply_id'] ][] = $value;
  1801. }
  1802. }
  1803. }
  1804. $shoname = D('Home/Front')->get_config_by_name('shoname');
  1805. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  1806. //打印联数
  1807. $feier_print_sn = D('Home/Front')->get_config_by_name('feier_print_sn');
  1808. $last_print_time = D('Home/Front')->get_config_by_name('last_print_time');
  1809. $last_print_index = D('Home/Front')->get_config_by_name('last_print_index');
  1810. $now_time = strtotime( date('Y-m-d').' 00:00:00' );
  1811. /*
  1812. if( empty($last_print_time) || $last_print_time < $now_time )
  1813. {
  1814. $last_print_index = 1;
  1815. $last_print_time = time();
  1816. D('Seller/Config')->update( array('last_print_index' => $last_print_index, 'last_print_time' => $last_print_time) );
  1817. }else if($last_print_time > $now_time) {
  1818. $last_print_index = empty($last_print_index) ? 1: $last_print_index+1;
  1819. D('Seller/Config')->update( array('last_print_index' => $last_print_index, 'last_print_time' => time() ) );
  1820. }
  1821. */
  1822. //继续使用原有的打印机设置,旧版打印机与“默认订单打印机”一起打印小票,也可以关闭旧版打印机设置使用新版本“默认打印机”
  1823. //默认打印机的参数
  1824. $data = D('Seller/Config')->get_all_config();
  1825. if(isset($data['is_printer_list']) && !empty($data['is_printer_list'])){
  1826. $printer_list = M('lionfish_comshop_printer')->where( array('id' => array('in',$data['is_printer_list']) ) )->select();
  1827. }
  1828. //新版打印机 有绑定打印机
  1829. if( !empty($printer_list) ){
  1830. //“默认打印机”
  1831. foreach($printer_list as $var){
  1832. if(!empty($var["status"])){
  1833. //判断打印机 1飞鹅 2易联云
  1834. if($var["printer_type"] == 1){
  1835. //$var["printer_sn"]-sn $var["printer_key"]-key $var["printer_num"]-打印联数
  1836. // 订单信息 标题 ,商城名称,运费,运费,sn,key,打印联数,
  1837. $print_result = $this->newfeier($order_info,$order_id,$last_print_index,$title,$shoname,$order_goods,$placeorder_tuan_name,$placeorder_trans_name,$var["printer_sn"],$var["printer_key"],$var["printer_num"]);
  1838. }
  1839. if($var["printer_type"] == 2){
  1840. //$var["api_id"]-应用id $var["api_key"]-应用密钥key $var["printer_sn"]-打印机终端号 $var["printer_key"]-终端密钥 $var["printer_num"]-打印联数
  1841. // 订单信息 标题 ,商城名称,订单商品,运费,运费,id key 终端号,终端密钥,打印联数,
  1842. $print_result = $this->newyilian($order_info,$order_id,$last_print_index,$title,$shoname,$order_goods,$placeorder_tuan_name,$placeorder_trans_name,$var["api_id"],$var["api_key"],$var["printer_sn"],$var["printer_key"],$var["printer_num"]);
  1843. }
  1844. }
  1845. }
  1846. }
  1847. // $this->print_supply_order($order_id, $supply_goods_info);
  1848. /**
  1849. 后台操作取消订单
  1850. 群接龙后台取消订单
  1851. 用户取消订单
  1852. **/
  1853. return $print_result;
  1854. }
  1855. //===========方法2.查询某订单是否打印成功=============
  1856. //***接口返回值说明***
  1857. //正确例子:
  1858. //已打印:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":6}
  1859. //未打印:{"msg":"ok","ret":0,"data":false,"serverExecutedTime":6}
  1860. //打开注释可测试
  1861. //$orderid = "xxxxxxxx_xxxxxxxxxx_xxxxxxxx";//订单ID,从方法1返回值中获取
  1862. //queryOrderState($orderid);
  1863. /*
  1864. * 方法2
  1865. 根据订单索引,去查询订单是否打印成功,订单索引由方法1返回
  1866. */
  1867. function queryOrderState($index){
  1868. $msgInfo = array(
  1869. 'user'=>$this->user,
  1870. 'stime'=>$this->stime,
  1871. 'sig'=>$this->sig,
  1872. 'apiname'=>'Open_queryOrderState',
  1873. 'orderid'=>$index
  1874. );
  1875. $http_model = load_model_class('httpclient');
  1876. $client = new $http_model($this->ip,$this->port);
  1877. if(!$client->post($this->path,$msgInfo)){
  1878. var_dump('error');
  1879. die();
  1880. }
  1881. else{
  1882. $result = $client->getContent();
  1883. var_dump($result);
  1884. die();
  1885. }
  1886. }
  1887. //===========方法3.查询指定打印机某天的订单详情============
  1888. //***接口返回值说明***
  1889. //正确例子:{"msg":"ok","ret":0,"data":{"print":6,"waiting":1},"serverExecutedTime":9}
  1890. //打开注释可测试
  1891. //$date = "2017-04-02";//注意时间格式为"yyyy-MM-dd",如2016-08-27
  1892. //queryOrderInfoByDate(SN,$date);
  1893. /*
  1894. * 方法3
  1895. 查询指定打印机某天的订单详情
  1896. */
  1897. function queryOrderInfoByDate($printer_sn,$date){
  1898. $msgInfo = array(
  1899. 'user'=>$this->user,
  1900. 'stime'=>$this->stime,
  1901. 'sig'=>$this->sig,
  1902. 'apiname'=>'Open_queryOrderInfoByDate',
  1903. 'sn'=>$printer_sn,
  1904. 'date'=>$date
  1905. );
  1906. $http_model = load_model_class('httpclient');
  1907. $client = new $http_model($this->ip,$this->port);
  1908. if(!$client->post($this->path,$msgInfo)){
  1909. var_dump('error');
  1910. die();
  1911. }
  1912. else{
  1913. $result = $client->getContent();
  1914. echo $result;
  1915. }
  1916. }
  1917. //===========方法4.查询打印机的状态==========================
  1918. //***接口返回值说明***
  1919. //正确例子:
  1920. //{"msg":"ok","ret":0,"data":"离线","serverExecutedTime":9}
  1921. //{"msg":"ok","ret":0,"data":"在线,工作状态正常","serverExecutedTime":9}
  1922. //{"msg":"ok","ret":0,"data":"在线,工作状态不正常","serverExecutedTime":9}
  1923. //打开注释可测试
  1924. //queryPrinterStatus(SN);
  1925. /*
  1926. * 方法4
  1927. 查询打印机的状态
  1928. */
  1929. function queryPrinterStatus($printer_sn){
  1930. $msgInfo = array(
  1931. 'user'=>USER,
  1932. 'stime'=>STIME,
  1933. 'sig'=>SIG,
  1934. 'apiname'=>'Open_queryPrinterStatus',
  1935. 'sn'=>$printer_sn
  1936. );
  1937. $client = new HttpClient(IP,PORT);
  1938. if(!$client->post(PATH,$msgInfo)){
  1939. echo 'error';
  1940. }
  1941. else{
  1942. $result = $client->getContent();
  1943. echo $result;
  1944. }
  1945. }
  1946. //默认打印机小票参数
  1947. //易联云
  1948. //$this->newyilian($order_info,$last_print_index,$title,$shoname,$order_goods,$placeorder_tuan_name,$placeorder_trans_name,$var["api_id"],$var["api_key"],$var["printer_sn"],$var["printer_key"],$var["printer_num"]);
  1949. function newyilian($order_info,$order_id,$last_print_index,$title,$shoname,$order_goods,$placeorder_tuan_name,$placeorder_trans_name,$api_id,$api_key,$printer_sn,$printer_key,$printer_num ){
  1950. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  1951. require_once $lib_path."/Yilianyun/Lib/Autoloader.php";
  1952. //$yilian_client_id = D('Home/Front')->get_config_by_name('yilian_client_id');
  1953. //$yilian_client_key = D('Home/Front')->get_config_by_name('yilian_client_key' );
  1954. $yilian_client_id = $api_id;
  1955. $yilian_client_key = $api_key;
  1956. $config = new YlyConfig($yilian_client_id, $yilian_client_key);
  1957. $token = $this->_get_yilian_access_token($yilian_client_id,$yilian_client_key);
  1958. //$yilian_machine_code = D('Home/Front')->get_config_by_name('yilian_machine_code' );
  1959. $yilian_machine_code = $printer_sn;
  1960. $print = new PrintService($token['access_token'], $config);
  1961. //object(stdClass)#14 (3) { ["error"]=> string(1) "0" ["error_description"]=> string(7) "success" ["body"]=> object(stdClass)#15 (2) { ["id"]=> string(9) "221354299" ["origin_id"]=> string(3) "558" } }
  1962. //<MN>1</MN>
  1963. //$data = $print->index($yilian_machine_code,'打印内容排版可看Demo下的callback.php','558');
  1964. //-------------------------------------------------------------------------------------------
  1965. //$yilian_print_lian = D('Home/Front')->get_config_by_name('yilian_print_lian');
  1966. $yilian_print_lian = $printer_num;
  1967. if( empty($yilian_print_lian) || $yilian_print_lian < 1)
  1968. {
  1969. $yilian_print_lian = 1;
  1970. }
  1971. $orderInfo = '<MN>'.$yilian_print_lian.'</MN>';
  1972. $total_length = 32;
  1973. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  1974. $orderInfo = '<FS2><center>--#'.$last_print_index.$title.'--</center></FS2>';
  1975. $orderInfo .= '<FS2><center>'.$shoname.'</center></FS2>';
  1976. $orderInfo .= '订单时间:'.$pay_time."\n";
  1977. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  1978. {
  1979. $refund_time = date('Y-m-d H:i:s', time() );
  1980. $orderInfo .= '取消时间:'.$refund_time."\n";
  1981. }
  1982. $orderInfo .= '订单编号:'.$order_info['order_num_alias']."\n";
  1983. if( $order_info['payment_code'] == 'cashon_delivery'){
  1984. $orderInfo .= '支付方式:货到付款'."\n";
  1985. }
  1986. //head_id order_id
  1987. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' => $order_info['head_id'] ) )->find();
  1988. if( !empty($head_relative_line) )
  1989. {
  1990. $line_id = $head_relative_line['line_id'];
  1991. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  1992. $orderInfo .= '线路名称:'.$line_info['name']."\n";
  1993. }
  1994. if($order_info['expected_delivery_time']){
  1995. $orderInfo .= '--------------------------------'."\n";
  1996. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time']."\n";
  1997. $orderInfo .= '--------------------------------'."\n";
  1998. }
  1999. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  2000. $orderInfo .= '收货小区:'.$head_info['community_name']."\n";
  2001. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name']."\n";
  2002. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile']."\n";
  2003. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  2004. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  2005. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'(付费VIP)</FS>'."\n";
  2006. }else{
  2007. $orderInfo .= '<FS>姓 名:'.$order_info['shipping_name'].'</FS>'."\n";
  2008. }
  2009. $orderInfo .= '<FS>电 话:'.$order_info['shipping_tel'].'</FS>'."\n";
  2010. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');//团长配送
  2011. if( empty($delivery_tuanzshipping_name) )
  2012. {
  2013. $delivery_tuanzshipping_name = '';
  2014. }
  2015. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');//快递配送
  2016. if( empty($delivery_express_name) )
  2017. {
  2018. $delivery_express_name = '';
  2019. }
  2020. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');//到点自提
  2021. if( empty($delivery_ziti_name) )
  2022. {
  2023. $delivery_ziti_name = '';
  2024. }
  2025. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');//快递费
  2026. if( !isset($placeorder_trans_name) || empty($placeorder_trans_name) )
  2027. {
  2028. $placeorder_trans_name = '快递费';
  2029. }
  2030. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');//配送费
  2031. if( !isset($placeorder_tuan_name) || empty($placeorder_tuan_name) )
  2032. {
  2033. $placeorder_tuan_name = '配送费';
  2034. }
  2035. //delivery pickup tuanz_send
  2036. if( $order_info['delivery'] == 'pickup' )
  2037. {
  2038. if( $order_info['type'] == 'virtual' )
  2039. {
  2040. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  2041. $orderInfo .= '配送方式:门店核销'."\n";//团长配送
  2042. }else{
  2043. $orderInfo .= '收货地址:'.$order_info['shipping_address']."\n";
  2044. if( !empty($delivery_ziti_name) )
  2045. {
  2046. $orderInfo .= '配送方式:'.$delivery_ziti_name."\n";//团长配送
  2047. }else{
  2048. $orderInfo .= '配送方式:团员自提'."\n";//团长配送
  2049. }
  2050. }
  2051. }else if( $order_info['delivery'] == 'tuanz_send'){
  2052. // address_id
  2053. if($order_info['address_id'] > 0)
  2054. {
  2055. $ad_info = M('lionfish_comshop_address')->field('lou_meng_hao')->where( array('address_id' => $order_info['address_id'] ) )->find();
  2056. if( !empty($ad_info) )
  2057. {
  2058. //$order_info['tuan_send_address'] .= $ad_info['lou_meng_hao'];
  2059. }
  2060. }
  2061. $orderInfo .= '送货地址:'.$order_info['tuan_send_address']."\n";
  2062. if( !empty($delivery_tuanzshipping_name) )
  2063. {
  2064. $orderInfo .= '配送方式:'.$delivery_tuanzshipping_name.''."\n";//团长配送
  2065. }else{
  2066. $orderInfo .= '配送方式:'.$owner_name.'送货上门'."\n";//团长配送
  2067. }
  2068. }else{
  2069. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  2070. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  2071. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  2072. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  2073. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."\n";
  2074. if( $order_info['delivery'] == 'localtown_delivery'){
  2075. $orderInfo .= '配送方式:同城配送'."\n";//同城配送
  2076. }else if( $order_info['delivery'] == 'hexiao'){
  2077. $orderInfo .= '<L>配送方式:到店核销</L><BR>';//到店核销
  2078. }else{
  2079. if( !empty($delivery_express_name) )
  2080. {
  2081. $orderInfo .= '配送方式:'.$delivery_express_name."\n";
  2082. }else{
  2083. $orderInfo .= '配送方式:快递'."\n";
  2084. }
  2085. }
  2086. }
  2087. $orderInfo .= '-------------商品---------------'."\n";
  2088. $orderInfo .= '商品名称    数量  金额'."\n";
  2089. $demo_str = '商品名称    数量  金额'."\n";
  2090. $total_count = 0;
  2091. foreach($order_goods as $val )
  2092. {
  2093. $name = $val['name'];
  2094. $total = $val['total'];
  2095. $quantity = $val['quantity'];
  2096. $goods_id = $val['goods_id'];
  2097. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id ) )->find();
  2098. $goods_name_str = "";
  2099. if( !empty($goods_common['print_sub_title']) )
  2100. {
  2101. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  2102. }else{
  2103. $goods_name_str = $name.' '.$val['option_sku'];
  2104. }
  2105. //17
  2106. $orderInfo .= $goods_name_str."\n";;
  2107. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  2108. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  2109. //$zw_length = $this->linyufan_get_cn_num($goods_name_last);
  2110. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  2111. //mb_strlen($goods_name_last,'utf-8') -
  2112. $zhongjian = 18;
  2113. $zhognjian_ge = '';
  2114. for($i =1;$i<=$zhongjian;$i++)
  2115. {
  2116. $zhognjian_ge .= ' ';
  2117. }
  2118. //$orderInfo .= $zhognjian_ge;
  2119. $orderInfo .= "\t\t\t\t";
  2120. $quantity_str = 'x'.$quantity;
  2121. $total_str = sprintf('%.2f',$total);
  2122. $orderInfo .= $quantity_str;
  2123. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  2124. for( $i =1;$i<=$right_gezi;$i++ )
  2125. {
  2126. $orderInfo .= ' ';
  2127. }
  2128. $orderInfo .= sprintf('%.2f',$total)."\n";
  2129. $total_count += $quantity;
  2130. }
  2131. $orderInfo .= '--------------------------------'."\n";
  2132. //var_dump( strlen($demo_str), mb_strlen($demo_str,'utf-8') );
  2133. $zhongjian = 32 - 10 - strlen($total_count);
  2134. $zhognjian_ge = '';
  2135. for($i =1;$i<=$zhongjian;$i++)
  2136. {
  2137. $zhognjian_ge .= ' ';
  2138. }
  2139. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count."\n";
  2140. if( !empty($order_info['fullreduction_money']) && $order_info['fullreduction_money'] >0)
  2141. {
  2142. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$order_info['fullreduction_money']));
  2143. $zhognjian_ge = '';
  2144. for($i =1;$i<=$zhongjian;$i++)
  2145. {
  2146. $zhognjian_ge .= ' ';
  2147. }
  2148. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['fullreduction_money']).'元'."\n";
  2149. }
  2150. if( !empty($order_info['voucher_credit']) && $order_info['voucher_credit'] >0)
  2151. {
  2152. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$order_info['voucher_credit']));
  2153. $zhognjian_ge = '';
  2154. for($i =1;$i<=$zhongjian;$i++)
  2155. {
  2156. $zhognjian_ge .= ' ';
  2157. }
  2158. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['voucher_credit']).'元'."\n";
  2159. }
  2160. $score_for_money = $order_info['score_for_money'];
  2161. if( !empty($score_for_money) && $score_for_money >0)
  2162. {
  2163. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  2164. $zhognjian_ge = '';
  2165. for($i =1;$i<=$zhongjian;$i++)
  2166. {
  2167. $zhognjian_ge .= ' ';
  2168. }
  2169. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元'."\n";
  2170. }
  2171. /**
  2172. $shipping_fare = $order_info['shipping_fare'];
  2173. if( !empty($shipping_fare) && $shipping_fare >0)
  2174. {
  2175. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  2176. $zhognjian_ge = '';
  2177. for($i =1;$i<=$zhongjian;$i++)
  2178. {
  2179. $zhognjian_ge .= ' ';
  2180. }
  2181. $orderInfo .= '配送费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  2182. }
  2183. **/
  2184. $man_e_money = $order_info['man_e_money'];
  2185. $fare_shipping_free = $order_info['fare_shipping_free'];
  2186. $is_free_shipping_fare = $order_info['is_free_shipping_fare'];
  2187. $shipping_fare = $order_info['shipping_fare'];
  2188. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  2189. {
  2190. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  2191. {
  2192. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  2193. $zhognjian_ge = '';
  2194. for($i =1;$i<=$zhongjian;$i++)
  2195. {
  2196. $zhognjian_ge .= ' ';
  2197. }
  2198. if( $order_info['delivery'] == 'tuanz_send')
  2199. {
  2200. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  2201. }else if( $order_info['delivery'] == 'express')
  2202. {
  2203. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  2204. }
  2205. }
  2206. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  2207. {
  2208. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  2209. $zhognjian_ge = '';
  2210. for($i =1;$i<=$zhongjian;$i++)
  2211. {
  2212. $zhognjian_ge .= ' ';
  2213. }
  2214. $man_e_money = floor($man_e_money * 100) / 100;
  2215. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."\n";
  2216. $shipping_fare = 0;
  2217. }
  2218. }else{
  2219. if( !empty($shipping_fare) && $shipping_fare >0)
  2220. {
  2221. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  2222. $zhognjian_ge = '';
  2223. for($i =1;$i<=$zhongjian;$i++)
  2224. {
  2225. $zhognjian_ge .= ' ';
  2226. }
  2227. if( $order_info['delivery'] == 'tuanz_send')
  2228. {
  2229. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  2230. }else if( $order_info['delivery'] == 'express')
  2231. {
  2232. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元'."\n";
  2233. }
  2234. }
  2235. }
  2236. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$order_info['total']));
  2237. $zhognjian_ge = '';
  2238. for($i =1;$i<=$zhongjian;$i++)
  2239. {
  2240. $zhognjian_ge .= ' ';
  2241. }
  2242. $order_type = $order_info['type'];
  2243. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  2244. if ($order_type == "integral"){
  2245. $orderInfo .= "积分"."\n";
  2246. }else{
  2247. $orderInfo .= "元"."\n";
  2248. }
  2249. $orderInfo .= '********************************'."\n";
  2250. if($shipping_fare == 0){
  2251. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare'];
  2252. }else{
  2253. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']-$order_info['fare_shipping_free']+$order_info['localtown_add_shipping_fare'];
  2254. }
  2255. if($real_price < 0)
  2256. {
  2257. $real_price = 0;
  2258. }
  2259. $real_price = sprintf('%.2f',$real_price);
  2260. $zhongjian = 32 - 12 - strlen($real_price);
  2261. $zhognjian_ge = '';
  2262. for($i =1;$i<=$zhongjian;$i++)
  2263. {
  2264. $zhognjian_ge .= ' ';
  2265. }
  2266. if ($order_type == "integral"){
  2267. if($real_price- $order_info['total'] == 0){
  2268. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  2269. }else{
  2270. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分'."\n";
  2271. }
  2272. }else{
  2273. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元'."\n";
  2274. }
  2275. //comment
  2276. $orderInfo .= '--------------------------------'."\n";
  2277. //order_info <BR>
  2278. if( !empty($order_info['comment']) )
  2279. {
  2280. $orderInfo .= '<FS>备注:'.$order_info['comment'].'</FS>'."\n";
  2281. }
  2282. //begin pr
  2283. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  2284. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  2285. {
  2286. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  2287. if( !empty($mb_info['content']) )
  2288. {
  2289. $orderInfo .= '会员备注:'.$mb_info['content'].''."\n";
  2290. }
  2291. }
  2292. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  2293. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  2294. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  2295. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  2296. {
  2297. if( !empty($order_info['note_content']) )
  2298. {
  2299. if( !empty($order_note_open) && !empty($order_note_name))
  2300. {
  2301. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  2302. }else{
  2303. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  2304. }
  2305. }
  2306. }
  2307. //end pr
  2308. if($order_info['order_status_id'] == 7){
  2309. $orderInfo .= '--------------------------------<BR>';
  2310. $orderInfo .= '<FS>订单已退款</<FS><BR>';
  2311. }
  2312. $orderInfo .= '<FS2><center>**#'.$last_print_index.' 完**</center></FS2>';
  2313. $data = $print->index($yilian_machine_code,$orderInfo,$order_id);
  2314. $print_result = array('code' => 1);
  2315. return $data;
  2316. ///......待查看格式
  2317. }
  2318. //$print_result = $this->newfeier($order_info,$last_print_index,$title,$shoname,$var["printer_sn"],$var["printer_key"],$var["printer_num"]);
  2319. //飞鹅 // 订单信息 标题 ,商城名称,订单商品 运费 运费 ,sn,key,打印联数,
  2320. function newfeier($order_info,$order_id,$last_print_index,$title,$shoname,$order_goods,$placeorder_tuan_name,$placeorder_trans_name,$printer_sn,$printer_key,$printer_num){
  2321. $total_length = 32;
  2322. $pay_time = date('Y-m-d H:i', $order_info['pay_time']);
  2323. //printer_sn
  2324. $orderInfo = '<CB>--#'.$last_print_index.$title.'--</CB><BR>';
  2325. $orderInfo .= '<C><L>'.$shoname.'</L></C><BR>';
  2326. $orderInfo .= '订单时间:'.$pay_time.'<BR>';
  2327. if( in_array($title, array('用户取消订单','后台操作取消订单','群接龙后台取消订单') ) )
  2328. {
  2329. $refund_time = date('Y-m-d H:i:s', time() );
  2330. $orderInfo .= '取消时间:'.$refund_time."<BR>";
  2331. }
  2332. $orderInfo .= '订单编号:'.$order_info['order_num_alias'].'<BR>';
  2333. if( $order_info['payment_code'] == 'cashon_delivery'){
  2334. $orderInfo .= '支付方式:货到付款'.'<BR>';
  2335. }
  2336. //head_id order_id
  2337. $head_relative_line = M('lionfish_comshop_deliveryline_headrelative')->where( array('head_id' => $order_info['head_id']) )->find();
  2338. if( !empty($head_relative_line) )
  2339. {
  2340. $line_id = $head_relative_line['line_id'];
  2341. $line_info = M('lionfish_comshop_deliveryline')->where( array('id' => $line_id ) )->find();
  2342. $orderInfo .= '线路名称:'.$line_info['name'].'<BR>';
  2343. }
  2344. if($order_info['expected_delivery_time']){
  2345. $orderInfo .= '--------------------------------<BR>';
  2346. $orderInfo .= '配送时间段:'.$order_info['expected_delivery_time'].'<BR>';
  2347. $orderInfo .= '--------------------------------<BR>';
  2348. }
  2349. $head_info = M('lionfish_community_head')->where( array('id' => $order_info['head_id'] ) )->find();
  2350. $orderInfo .= '收货小区:'.$head_info['community_name'].'<BR>';
  2351. $orderInfo .= $owner_name.'姓名:'.$head_info['head_name'].'<BR>';
  2352. $orderInfo .= $owner_name.'手机:'.$head_info['head_mobile'].'<BR>';
  2353. $member = M('lionfish_comshop_member')->where( array('member_id' => $order_info['member_id'] ) )->find();
  2354. if($member['card_id'] > 0 && $member['card_end_time'] >time() ){
  2355. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'(付费VIP)</L><BR>';
  2356. }else{
  2357. $orderInfo .= '<L>姓 名:'.$order_info['shipping_name'].'</L><BR>';
  2358. }
  2359. $orderInfo .= '<L>电 话:'.$order_info['shipping_tel'].'</L><BR>';
  2360. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name');//团长配送
  2361. if( empty($delivery_tuanzshipping_name) )
  2362. {
  2363. $delivery_tuanzshipping_name = '';
  2364. }
  2365. $delivery_express_name = D('Home/Front')->get_config_by_name('delivery_express_name');//快递配送
  2366. if( empty($delivery_express_name) )
  2367. {
  2368. $delivery_express_name = '';
  2369. }
  2370. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name');//到点自提
  2371. if( empty($delivery_ziti_name) )
  2372. {
  2373. $delivery_ziti_name = '';
  2374. }
  2375. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name');//快递费
  2376. if( !isset($placeorder_trans_name) || empty($placeorder_trans_name) )
  2377. {
  2378. $placeorder_trans_name = '快递费';
  2379. }
  2380. $placeorder_tuan_name = D('Home/Front')->get_config_by_name('placeorder_tuan_name');//配送费
  2381. if( !isset($placeorder_tuan_name) || empty($placeorder_tuan_name) )
  2382. {
  2383. $placeorder_tuan_name = '配送费';
  2384. }
  2385. //delivery pickup tuanz_send
  2386. if( $order_info['delivery'] == 'pickup' )
  2387. {
  2388. if( $order_info['type'] == 'virtual' )
  2389. {
  2390. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  2391. $orderInfo .= '配送方式:门店核销<BR>';//团长配送
  2392. }else{
  2393. $orderInfo .= '收货地址:'.$order_info['shipping_address'].'<BR>';
  2394. if( !empty($delivery_ziti_name) )
  2395. {
  2396. $orderInfo .= '配送方式:'.$delivery_ziti_name.'<BR>';//团长配送
  2397. }else{
  2398. $orderInfo .= '配送方式:团员自提<BR>';//团长配送
  2399. }
  2400. }
  2401. }else if( $order_info['delivery'] == 'tuanz_send'){
  2402. // address_id
  2403. $orderInfo .= '送货地址:'.$order_info['tuan_send_address'].'<BR>';
  2404. if( !empty($delivery_tuanzshipping_name) )
  2405. {
  2406. $orderInfo .= '<L>配送方式:'.$delivery_tuanzshipping_name.'</L><BR>';//团长配送
  2407. }else{
  2408. $orderInfo .= '<L>配送方式:'.$owner_name.'送货上门</L><BR>';//团长配送
  2409. }
  2410. }else{
  2411. $province_info = D('Home/Front')->get_area_info($order_info['shipping_province_id']);
  2412. $city_info = D('Home/Front')->get_area_info($order_info['shipping_city_id']);
  2413. $area_info = D('Home/Front')->get_area_info($order_info['shipping_country_id']);
  2414. //name
  2415. $sp_address = $province_info['name'].$city_info['name'].$area_info['name'];
  2416. $orderInfo .= '收货地址:'.$sp_address.$order_info['shipping_address']."<BR>";
  2417. if( $order_info['delivery'] == 'localtown_delivery'){
  2418. $orderInfo .= '<L>配送方式:同城配送</L><BR>';//同城配送
  2419. }else if( $order_info['delivery'] == 'hexiao'){
  2420. $orderInfo .= '<L>配送方式:到店核销</L><BR>';//到店核销
  2421. }else{
  2422. if( !empty($delivery_express_name) )
  2423. {
  2424. $orderInfo .= '<L>配送方式:'.$delivery_express_name.'</L><BR>';
  2425. }else{
  2426. $orderInfo .= '<L>配送方式:快递</L><BR>';
  2427. }
  2428. }
  2429. }
  2430. $orderInfo .= '-------------商品---------------<BR>';
  2431. $orderInfo .= '商品名称    数量  金额<BR>';
  2432. $demo_str = '商品名称    数量  金额';
  2433. $total_count = 0;
  2434. foreach($order_goods as $val )
  2435. {
  2436. $name = $val['name'];
  2437. $total = $val['total'];
  2438. $quantity = $val['quantity'];
  2439. $goods_id = $val['goods_id'];
  2440. $goods_common = M('lionfish_comshop_good_common')->field('print_sub_title')->where( array('goods_id' => $goods_id) )->find();
  2441. $goods_name_str = "";
  2442. if( !empty($goods_common['print_sub_title']) )
  2443. {
  2444. $goods_name_str = $goods_common['print_sub_title'].' '.$val['option_sku'];
  2445. }else{
  2446. $goods_name_str = $name.' '.$val['option_sku'];
  2447. }
  2448. //17
  2449. //$goods_name_last = mb_substr($goods_name_str,0,7,'utf-8');//20190221
  2450. $orderInfo .= $goods_name_str.'<BR>';
  2451. $newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $goods_name_last); //正则匹配中文
  2452. $zw_length = mb_strlen($newStr,"utf-8"); //得到中汉字个数
  2453. $tt_length = mb_strlen($goods_name_last,'utf-8') - $zw_length;
  2454. //mb_strlen($goods_name_last,'utf-8') -
  2455. $zhongjian = 18;
  2456. if($zw_length <= 0)
  2457. {
  2458. $zhongjian = $zhongjian -1;
  2459. }
  2460. $zhognjian_ge = '';
  2461. for($i =1;$i<=$zhongjian;$i++)
  2462. {
  2463. $zhognjian_ge .= ' ';
  2464. }
  2465. $orderInfo .= $zhognjian_ge;
  2466. $quantity_str = 'x'.$quantity;
  2467. $total_str = sprintf('%.2f',$total);
  2468. $orderInfo .= $quantity_str;
  2469. $right_gezi = 14 - strlen($quantity_str) - strlen(sprintf('%.2f',$total));
  2470. $ggg_zi = '';
  2471. for( $i =1;$i<=$right_gezi;$i++ )
  2472. {
  2473. $ggg_zi .= ' ';
  2474. }
  2475. $orderInfo.= $ggg_zi;
  2476. $orderInfo .= sprintf('%.2f',$total).'<BR>';
  2477. $total_count += $quantity;
  2478. }
  2479. $orderInfo .= '--------------------------------<BR>';
  2480. $zhongjian = 32 - 10 - strlen($total_count);
  2481. $zhognjian_ge = '';
  2482. for($i =1;$i<=$zhongjian;$i++)
  2483. {
  2484. $zhognjian_ge .= ' ';
  2485. }
  2486. $orderInfo .= '商品总数:'.$zhognjian_ge.$total_count.'<BR>';
  2487. if( !empty($order_info['fullreduction_money']) && $order_info['fullreduction_money'] >0)
  2488. {
  2489. $zhongjian = 32 - 9 - strlen(sprintf('%.2f',$order_info['fullreduction_money']));
  2490. $zhognjian_ge = '';
  2491. for($i =1;$i<=$zhongjian;$i++)
  2492. {
  2493. $zhognjian_ge .= ' ';
  2494. }
  2495. $orderInfo .= '满减:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['fullreduction_money']).'元<BR>';
  2496. }
  2497. if( !empty($order_info['voucher_credit']) && $order_info['voucher_credit'] >0)
  2498. {
  2499. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$order_info['voucher_credit']));
  2500. $zhognjian_ge = '';
  2501. for($i =1;$i<=$zhongjian;$i++)
  2502. {
  2503. $zhognjian_ge .= ' ';
  2504. }
  2505. $orderInfo .= '优惠券:'.$zhognjian_ge.'-'.sprintf('%.2f',$order_info['voucher_credit']).'元<BR>';
  2506. }
  2507. //score_for_money
  2508. $score_for_money = $order_info['score_for_money'];
  2509. if( !empty($score_for_money) && $score_for_money >0)
  2510. {
  2511. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$score_for_money));
  2512. $zhognjian_ge = '';
  2513. for($i =1;$i<=$zhongjian;$i++)
  2514. {
  2515. $zhognjian_ge .= ' ';
  2516. }
  2517. $orderInfo .= '积分抵:'.$zhognjian_ge.'-'.sprintf('%.2f',$score_for_money).'元<BR>';
  2518. }
  2519. /**
  2520. $shipping_fare = $order_info['shipping_fare'];
  2521. if( !empty($shipping_fare) && $shipping_fare >0)
  2522. {
  2523. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  2524. $zhognjian_ge = '';
  2525. for($i =1;$i<=$zhongjian;$i++)
  2526. {
  2527. $zhognjian_ge .= ' ';
  2528. }
  2529. $orderInfo .= '配送费:'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  2530. }
  2531. **/
  2532. $shipping_fare = $order_info['shipping_fare'];
  2533. $man_e_money = $order_info['man_e_money'];
  2534. $fare_shipping_free = $order_info['fare_shipping_free'];
  2535. $is_free_shipping_fare = $order_info['is_free_shipping_fare'];
  2536. if($is_free_shipping_fare == 1 && $fare_shipping_free > 0)
  2537. {
  2538. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  2539. {
  2540. //满$man_e_money免运费 -7 man_e_money
  2541. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  2542. $zhognjian_ge = '';
  2543. for($i =1;$i<=$zhongjian;$i++)
  2544. {
  2545. $zhognjian_ge .= ' ';
  2546. }
  2547. if( $order_info['delivery'] == 'tuanz_send')
  2548. {
  2549. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  2550. }else if( $order_info['delivery'] == 'express')
  2551. {
  2552. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  2553. }
  2554. }
  2555. if( !empty($fare_shipping_free) && $fare_shipping_free >0)
  2556. {
  2557. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$fare_shipping_free));
  2558. $zhognjian_ge = '';
  2559. for($i =1;$i<=$zhongjian;$i++)
  2560. {
  2561. $zhognjian_ge .= ' ';
  2562. }
  2563. $man_e_money = floor($man_e_money * 100) / 100;
  2564. $orderInfo .= '满'.$man_e_money.'免运费:'.$zhognjian_ge.'-'.sprintf('%.2f',$fare_shipping_free).'元'."<BR>";
  2565. $shipping_fare = 0;
  2566. }
  2567. }else{
  2568. if( !empty($shipping_fare) && $shipping_fare >0)
  2569. {
  2570. $zhongjian = 32 - 11 - strlen(sprintf('%.2f',$shipping_fare));
  2571. $zhognjian_ge = '';
  2572. for($i =1;$i<=$zhongjian;$i++)
  2573. {
  2574. $zhognjian_ge .= ' ';
  2575. }
  2576. if( $order_info['delivery'] == 'tuanz_send')
  2577. {
  2578. $orderInfo .= $placeorder_tuan_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  2579. }else if( $order_info['delivery'] == 'express')
  2580. {
  2581. $orderInfo .= $placeorder_trans_name.':'.$zhognjian_ge.'+'.sprintf('%.2f',$shipping_fare).'元<BR>';
  2582. }
  2583. }
  2584. }
  2585. $zhongjian = 32 - 10 - strlen(sprintf('%.2f',$order_info['total']));
  2586. $zhognjian_ge = '';
  2587. for($i =1;$i<=$zhongjian;$i++)
  2588. {
  2589. $zhognjian_ge .= ' ';
  2590. }
  2591. $order_type = $order_info['type'];
  2592. $orderInfo .= '总金额:'.$zhognjian_ge.sprintf('%.2f',$order_info['total']);
  2593. if ($order_type == "integral"){
  2594. $orderInfo .= "积分"."<BR>";
  2595. }else{
  2596. $orderInfo .= "元"."<BR>";
  2597. }
  2598. $orderInfo .= '********************************<BR>';
  2599. if($shipping_fare == 0){
  2600. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']+$order_info['localtown_add_shipping_fare'];
  2601. }else{
  2602. $real_price = $order_info['total'] + $shipping_fare -$order_info['voucher_credit']-$order_info['fullreduction_money']-$order_info['score_for_money']-$order_info['fare_shipping_free']+$order_info['localtown_add_shipping_fare'];
  2603. }
  2604. if($real_price < 0)
  2605. {
  2606. $real_price = 0;
  2607. }
  2608. $real_price = sprintf('%.2f',$real_price);
  2609. $zhongjian = 32 - 12 - strlen($real_price);
  2610. $zhognjian_ge = '';
  2611. for($i =1;$i<=$zhongjian;$i++)
  2612. {
  2613. $zhognjian_ge .= ' ';
  2614. }
  2615. if ($order_type == "integral"){
  2616. if($real_price- $order_info['total'] == 0){
  2617. $orderInfo .= '实付金额:'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  2618. }else{
  2619. $orderInfo .= '实付金额:'.$zhognjian_ge.($real_price- $order_info['total']).'元+'.sprintf('%.2f',$order_info['total']).'积分<BR>';
  2620. }
  2621. }else{
  2622. $orderInfo .= '实付金额:'.$zhognjian_ge.$real_price.'元<BR>';
  2623. }
  2624. //comment
  2625. $orderInfo .= '--------------------------------<BR>';
  2626. //order_info <BR>
  2627. if( !empty($order_info['comment']) )
  2628. {
  2629. $orderInfo .= '<B>备注:'.$order_info['comment'].'</B><BR>';
  2630. }
  2631. //begin pr
  2632. $is_print_member_note = D('Home/Front')->get_config_by_name('is_print_member_note');
  2633. if( isset($is_print_member_note) && $is_print_member_note == 1 )
  2634. {
  2635. $mb_info = M('lionfish_comshop_member')->field('content')->where( array('member_id' => $order_info['member_id'] ) )->find();
  2636. if( !empty($mb_info['content']) )
  2637. {
  2638. $orderInfo .= '会员备注:'.$mb_info['content'].''."<BR>";
  2639. }
  2640. }
  2641. $is_print_order_note = D('Home/Front')->get_config_by_name('is_print_order_note');
  2642. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  2643. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  2644. if( !empty($is_print_order_note) && $is_print_order_note == 1 )
  2645. {
  2646. if( !empty($order_info['note_content']) )
  2647. {
  2648. if( !empty($order_note_open) && !empty($order_note_name))
  2649. {
  2650. $orderInfo .= $order_note_name.':'.$order_info['note_content'].''."<BR>";
  2651. }else{
  2652. $orderInfo .= '自定义备注:'.$order_info['note_content'].''."<BR>";
  2653. }
  2654. }
  2655. }
  2656. //end pr
  2657. if($order_info['order_status_id'] == 7){
  2658. $orderInfo .= '--------------------------------<BR>';
  2659. $orderInfo .= '<L>订单已退款</<L><BR>';
  2660. }
  2661. $orderInfo .= '<CB>**#'.$last_print_index.' 完**</CB><BR>';
  2662. //$feier_print_lian = D('Home/Front')->get_config_by_name('feier_print_lian');
  2663. if( empty($printer_num) || $printer_num < 1)
  2664. {
  2665. $printer_num = 1;
  2666. }
  2667. $print_result = $this->wp_print($orderInfo, $printer_num, $printer_sn);
  2668. if( $print_result['code'] == 0)
  2669. {
  2670. M('lionfish_comshop_order')->where( array('order_id' =>$order_id ) )->save( array('is_print_suc' => 0) );
  2671. }
  2672. return $print_result;
  2673. }
  2674. }
  2675. ?>