Systemfouttest.php 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemfouttest extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullorderamz','fullorderamz');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_outbound','outbound');
  16. $this->load->_model('Model_express','express');
  17. $this->load->_model('Model_shop','shop');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_country','country');
  20. $this->load->_model('Model_kdniao','kdniao');
  21. $this->load->_model('Model_notice','notice');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_dhlhz','dhlhz');
  24. $this->load->_model('Model_usps','usps');
  25. $this->load->_model('Model_fedex','fedex');
  26. $this->load->_model('Model_fedex_cby','fedex_cby');
  27. $this->load->_model('Model_ups','ups');
  28. $this->load->_model('Model_ali','ali');
  29. $this->load->_model('Model_dpd','dpd');
  30. $this->load->_model('Model_shop','shop');
  31. $this->load->_model('Model_user','user');
  32. $this->load->_model('Model_whlabel','whlabel');
  33. $this->load->_model('Model_specialstock','specialstock');
  34. $this->load->_model('Model_ck','ck');
  35. $this->load->_model('Model_whlabellabel','whlabellabel');
  36. $this->load->_model('Model_apiyy','apiyy');
  37. $this->load->helper('url');
  38. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  39. $this->load->_model('Model_systemtransfer','systemtransfer');
  40. $this->load->_model('Model_classid','classid');
  41. $this->load->_model('Model_allocation','allocation');
  42. $this->load->_model('Model_fullorderxw','fullorderxw');
  43. $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_fedexv1",'fedexv1');
  46. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  47. $this->load->_model("Model_customsdeclaration","customsdeclaration");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg,$arg_array)
  51. {
  52. if($arg == 'fedexhz')
  53. {
  54. $this->_fedexhz();
  55. }
  56. else if($arg == 'fout')
  57. {
  58. $this->_fout($arg_array);
  59. }
  60. else if($arg == 'fouthb')//合并出库的
  61. {
  62. $this->_fouthb($arg_array);
  63. }
  64. else if($arg == 'excel')
  65. {
  66. $this->_excel($arg_array);
  67. }
  68. else if($arg == 'cpexcel')
  69. {
  70. $this->_cpexcel($arg_array);
  71. }
  72. else if($arg == 'orderyz')
  73. {
  74. $this->_orderyz();
  75. }
  76. else if($arg == 'hwyz')
  77. {
  78. $this->_hwyz();
  79. }
  80. else if($arg == 'outnumber')
  81. {
  82. $this->_outnumber();
  83. }
  84. else if($arg == 'hb')
  85. {
  86. $this->_hb();
  87. }
  88. else
  89. {
  90. $this->_index();
  91. }
  92. }
  93. public function _index()
  94. {
  95. $post = $this->input->post(NULL, TRUE);
  96. $xw = '';
  97. if(isset($_SESSION['api']))
  98. {
  99. $user = $this->user->get_api($_SESSION['api']);
  100. $usp = $user;
  101. $fgshop = "";$sid = "";$wid="";$wtype="";
  102. $usersp = explode('|',trim($user['shop'],'|'));
  103. $userwh = explode('|',trim($user['warehouse'],'|'));
  104. foreach ($usersp as $value)
  105. {
  106. $fgshop .= " shop = ".$value." or";
  107. $sid .= " id = ".$value." or";
  108. }
  109. foreach ($userwh as $value)
  110. {
  111. $wid .= " id = ".$value." or";
  112. $wtype .= " type = ".$value." or";
  113. }
  114. if($user['userid'] == 'xw')
  115. {
  116. $xw = 1;
  117. }
  118. }
  119. if(isset($post['page']))
  120. {
  121. $page = $this->input->post('page',true);
  122. $perpage = $this->input->post('perpage',true);
  123. $timetk = $this->input->post('timetk',true);
  124. $timetj = $this->input->post('timetj',true);
  125. $shop = $this->input->post('shop',true);
  126. $source = $this->input->post('source',true);
  127. $orderinfo = $this->input->post('orderinfo',true);
  128. $number = $this->input->post('number',true);
  129. $library = $this->input->post('library',true);
  130. $waybill = $this->input->post('waybill',true);
  131. $express = $this->input->post('express',true);
  132. $type = $this->input->post('type',true);
  133. $lowe = $this->input->post('lowe',true);
  134. $so = $this->input->post('so',true);
  135. $librarytime = $this->input->post('librarytime',true);
  136. $timetk = strtotime($timetk);
  137. $timetj = strtotime($timetj);
  138. $cxtime = 'id';
  139. $where = "library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")";
  140. if($timetk && $timetj && $library == 1)
  141. {
  142. //$cxtime = 'reviewtime';
  143. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  144. $where .= " and state != 217";
  145. }
  146. else if($timetk && $timetj && $library == 2)
  147. {
  148. $cxtime = 'librarytime';
  149. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  150. }
  151. if($shop)
  152. {
  153. $where .= " and shop = '$shop'";
  154. }
  155. if($number)
  156. {
  157. $where .= " and number = '$number'";
  158. }
  159. if($library)
  160. {
  161. $where .= " and library = '$library'";
  162. }
  163. if($waybill)
  164. {
  165. $where .= " and waybill = '$waybill'";
  166. }
  167. if($express)
  168. {
  169. $where .= " and express = '$express'";
  170. }
  171. if($orderinfo)
  172. {
  173. $where .= " and orderinfo = '$orderinfo'";
  174. }
  175. if($type)
  176. {
  177. $where .= " and type = '$type'";
  178. }
  179. if($lowe)
  180. {
  181. $where .= " and shipremarks like '%$lowe%'";
  182. }
  183. if($so)
  184. {
  185. $where .= " and shipremarks like '%$so%'";
  186. }
  187. //数据排序
  188. $order_str = $cxtime." desc";
  189. if(empty($page))
  190. {
  191. $start = 0;
  192. $perpage = 1;
  193. }
  194. else
  195. {
  196. $start = ($page - 1)*$perpage;
  197. }
  198. $dlz_num = $tt_num = $amz_num = $smt_num = $xw_num = 0;
  199. $dlz_arr = $tt_arr = $amz_arr = $smt_arr = $xw_arr = [];
  200. $dlz_jj_num = $tt_jj_num = $amz_jj_num = $smt_jj_num = $xw_jj_num = 0;
  201. $dlz_jj_arr = $tt_jj_arr = $amz_jj_arr = $smt_jj_arr = $xw_jj_arr = [];
  202. $shop_list = $this->shop->find_all();
  203. $shop_list = array_column($shop_list,null,'id');
  204. $express_list = $this->express->find_all();
  205. $express_list = array_column($express_list,'null','id');
  206. $warehouse_list = $this->warehouse->find_all();
  207. $warehouse_list = array_column($warehouse_list,null,'id');
  208. $filed = "id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,is_jiaji";
  209. $where_jj = $where." and is_jiaji = 1 ";
  210. $dlz_jj_ret =$this->indexData('fullorder',$start,$perpage,$where_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  211. $dlz_jj_num = $dlz_jj_ret['total'];
  212. $dlz_jj_arr = $dlz_jj_ret['list'];
  213. $tt_jj_ret = $this->indexData('fullordertt',$start,$perpage,$where_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  214. $tt_jj_num = $tt_jj_ret['total'];
  215. $tt_jj_arr = $tt_jj_ret['list'];
  216. $amz_jj_ret = $this->indexData('fullorderamz',$start,$perpage,$where_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  217. $amz_jj_num = $amz_jj_ret['total'];
  218. $amz_jj_arr = $amz_jj_ret['list'];
  219. $smt_jj_ret = $this->indexData('fullordersmt',$start,$perpage,$where_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  220. $smt_jj_num = $smt_jj_ret['total'];
  221. $smt_jj_arr = $smt_jj_ret['list'];
  222. /******************** 非加急 *************************/
  223. $where_no_jj = $where." and is_jiaji = 0 ";
  224. $dlz_no_ret =$this->indexData('fullorder',$start,$perpage,$where_no_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  225. $dlz_num = $dlz_no_ret['total'];
  226. $dlz_arr = $dlz_no_ret['list'];
  227. $tt_no_ret = $this->indexData('fullordertt',$start,$perpage,$where_no_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  228. $tt_num = $tt_no_ret['total'];
  229. $tt_arr = $tt_no_ret['list'];
  230. $amz_no_ret = $this->indexData('fullorderamz',$start,$perpage,$where_no_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  231. $amz_num = $amz_no_ret['total'];
  232. $amz_arr = $amz_no_ret['list'];
  233. $smt_no_ret = $this->indexData('fullordersmt',$start,$perpage,$where_no_jj,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  234. $smt_num = $smt_no_ret['total'];
  235. $smt_arr = $smt_no_ret['list'];
  236. /**************************翔文的不管**************************/
  237. $xw_no_ret = $this->indexData('fullorderxw',$start,$perpage,$where,$filed,$order_str,$shop_list,$express_list,$warehouse_list);
  238. $xw_num = $xw_no_ret['total'];
  239. $xw_arr = $xw_no_ret['list'];
  240. $total = $dlz_num + $dlz_jj_num + $tt_num + $tt_jj_num + $amz_num + $amz_jj_num + $smt_num + $smt_jj_num + $xw_num;
  241. $pagenum = ceil($total/$perpage);
  242. $over = $total-($start+$perpage);
  243. $rows = array_merge($dlz_jj_arr,$tt_jj_arr,$amz_jj_arr,$smt_jj_arr,$dlz_arr,$tt_arr,$amz_arr,$smt_arr,$xw_arr);
  244. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>$rows);
  245. echo json_encode($rows);exit;
  246. }
  247. if(isset($_SESSION['api']))
  248. {
  249. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  250. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  251. $this->data['wlshop'] = $wlshop;
  252. $this->data['warehouse'] = $warehouse;
  253. }
  254. $this->data['xw'] = $xw;
  255. $this->_Template('systemfouttest',$this->data);
  256. }
  257. /**
  258. * $table_name 订单表名
  259. * $start 偏移开始坐标
  260. * $limit 偏移量
  261. * $where 条件
  262. * $field 字段
  263. * $order_str 排序
  264. */
  265. protected function indexData($table_name,$start,$limit,$where,$filed,$order_str,$shop_list,$express_list,$warehouse_list){
  266. $info_list = $this->$table_name->find_all($where,$filed,$order_str,$start,$limit);
  267. if(empty($info_list)){
  268. $info_list = [];
  269. }
  270. //格式化数据
  271. foreach ($info_list as $key=>$value)
  272. {
  273. if($value['is_jiaji'] == 1){
  274. $info_list[$key]['number'] = "<c style='color:red'>".$value['number']."</c>";
  275. }
  276. $info_list[$key]['shop'] = isset($shop_list[$value['shop']])?$shop_list[$value['shop']]['shopname']:"";
  277. if($value['waybill'] == '0')
  278. {
  279. $info_list[$key]['waybill'] = "";
  280. }
  281. $info_list[$key]['express'] = isset($express_list[$value['express']])?$express_list[$value['express']]['servicename']:"";
  282. $info_list[$key]['type'] = isset($warehouse_list[$value['type']])?$warehouse_list[$value['type']]['title']:"";
  283. if($value['print'] == 1)
  284. {
  285. $info_list[$key]['print'] = '不可打印';
  286. }
  287. else if($value['print'] == 2)
  288. {
  289. $info_list[$key]['print'] = '未打印';
  290. }
  291. else if($value['print'] == 3)
  292. {
  293. $info_list[$key]['print'] = '已打印';
  294. }
  295. if($value['library'] == 1)
  296. {
  297. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  298. }
  299. else if($value['library'] == 2)
  300. {
  301. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  302. }
  303. else if($value['library'] == 3)
  304. {
  305. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  306. }
  307. if($value['librarytime'] == '0')
  308. {
  309. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  310. }
  311. else
  312. {
  313. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  314. }
  315. }
  316. $total = $this->$table_name->find_count($where);
  317. return [
  318. 'list'=>$info_list,
  319. 'total'=>$total,
  320. ];
  321. }
  322. public function _fout()
  323. {
  324. $post = $this->input->post(NULL, TRUE);
  325. if(isset($post['order']))
  326. {
  327. $time = time();
  328. $order = $this->input->post('order',true);
  329. $weight = $this->input->post('weight',true);
  330. if(!isset($weight))//测试没问题后可以删
  331. {
  332. $weight = '';
  333. }
  334. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  335. {
  336. $order = substr($order,0,12);
  337. }
  338. if(strlen($order) == '34')//联邦杭州超长运单截取
  339. {
  340. $order = substr($order,22,12);
  341. }
  342. if(!$order)
  343. {
  344. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  345. }
  346. if(strlen($order) == 30)
  347. {
  348. $order = substr($order, 8);
  349. }
  350. $fullorder_name = 'fullorder';$outtype = 1;
  351. $y = $this->fullorder->get_waybill($order);
  352. if(!$y)
  353. {
  354. $y = $this->fullorder->get_number($order);
  355. $outtype = 2;
  356. if(!$y)
  357. {
  358. $fullorder_name = 'fullordersmt';$outtype = 1;
  359. $y = $this->fullordersmt->get_waybill($order);
  360. if(!$y)
  361. {
  362. $y = $this->fullordersmt->get_number($order);
  363. $outtype = 2;
  364. if(!$y)
  365. {
  366. $fullorder_name = 'fullordertt';$outtype = 1;
  367. $y = $this->fullordertt->get_waybill($order);
  368. if(!$y)
  369. {
  370. $y = $this->fullordertt->get_number($order);
  371. $outtype = 2;
  372. if(!$y)
  373. {
  374. $fullorder_name = 'fullorderamz';$outtype = 1;
  375. $y = $this->fullorderamz->get_waybill($order);
  376. if(!$y)
  377. {
  378. $y = $this->fullorderamz->get_number($order);
  379. $outtype = 2;
  380. if(!$y){
  381. $fullorder_name = 'fullorderxw';$outtype = 1;
  382. $y = $this->fullorderxw->get_waybill($order);
  383. if(!$y)
  384. {
  385. $y = $this->fullorderxw->get_number($order);
  386. $outtype = 2;
  387. if(!$y)
  388. {
  389. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  390. }
  391. }
  392. }
  393. }
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. if($y['mergeid'] == '1')
  401. {
  402. $y = $this->$fullorder_name->read($y['merge']);
  403. }
  404. $express = $this->express->read($y['express']);
  405. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  406. {
  407. $y['librarynot'] = '客户已取消!';
  408. }
  409. if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
  410. {
  411. echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  412. }
  413. if($y['library'] > 1)
  414. {
  415. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  416. }
  417. if($express['out'] != 3)
  418. {
  419. if($express['out'] != $outtype)
  420. {
  421. $smlx = ($express['out']=='1')?'运单':'发货单';
  422. echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  423. }
  424. }
  425. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  426. {
  427. $y['waybill'] = trim($y['waybill'],' ');
  428. if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 63 && $y['express'] != 70)
  429. {
  430. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
  431. }
  432. else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42)
  433. {
  434. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
  435. }
  436. else if(strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67)
  437. {
  438. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
  439. }
  440. }
  441. if(stripos($weight,',') !== false){
  442. $tmp_arr = explode(",",$weight);
  443. $weight = end($tmp_arr);
  444. $numweight = (float)$weight;
  445. $weight = $numweight."kg";
  446. }
  447. $numweight = str_replace('kg','',$weight);
  448. // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  449. // {
  450. // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  451. // {
  452. // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  453. // }
  454. // $yzweight = explode('.',$numweight);
  455. // if($yzweight[0] == '')
  456. // {
  457. // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  458. // }
  459. // if($numweight < ($y['jweight']/1000))
  460. // {
  461. // echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  462. // }
  463. // if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
  464. // {
  465. // echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
  466. // }
  467. // if($numweight > '0.98' && $y['express'] == '3')
  468. // {
  469. // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  470. // }
  471. // if($numweight > '2' && $y['express'] == '37')
  472. // {
  473. // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  474. // }
  475. // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  476. // {
  477. // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  478. // }
  479. // }
  480. //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  481. //还有翔文仓库的 不执行
  482. //源代码是
  483. //所有快递必须称重
  484. //所有快递必须称重 翔文除外
  485. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
  486. if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65])){
  487. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  488. {
  489. echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  490. }
  491. $yzweight = explode('.',$numweight);
  492. if($yzweight[0] == '')
  493. {
  494. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  495. }
  496. if(empty($numweight)){
  497. echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
  498. }
  499. //$this->logic_ding->sendToDing("检测订单---------------------标记需要认证的东西".$y['number']);
  500. }
  501. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']);
  502. $express_info = $this->express->read($y['express']);
  503. if(empty($express_info)){
  504. echo json_encode(array('msg'=>'该快递信息异常,请联系技术!','success'=>false));exit;
  505. }
  506. $weight_limit = $express_info['weight_limit']*1;
  507. if($weight_limit > 0){
  508. $yzweight = explode('.',$numweight);
  509. if($yzweight[0] == '')
  510. {
  511. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  512. }
  513. if($numweight < ($y['jweight']/1000)){
  514. echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  515. }
  516. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  517. if(in_array($y['express'],[3,24,42])){
  518. //规定实际重量不允许超过 净重为1kg
  519. if($numweight -($y['jweight']/1000) > 1 )
  520. {
  521. echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false));exit;
  522. }
  523. }
  524. if($weight_limit < $numweight){
  525. echo json_encode(array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false));exit;
  526. }
  527. }
  528. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  529. {
  530. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  531. }
  532. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  533. {
  534. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  535. echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
  536. }
  537. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  538. {
  539. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  540. }
  541. $this->db->trans_begin();
  542. $warehouse = $this->warehouse->read($y['type']);
  543. $bdck = $warehouse['bdck'];
  544. if($warehouse['zd'] == '1')
  545. {
  546. if($warehouse['bdck'] == '')
  547. {
  548. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  549. }
  550. $wh = $this->_fout_db($y,$warehouse,$bdck);
  551. if($wh['fh'] == 2)
  552. {
  553. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  554. if($kcyz['t'] == '0')
  555. {
  556. if($kcyz['fpdata'] != '')
  557. {
  558. $x['whlabel'] = $kcyz['whlabel'];
  559. $x['fpdata'] = $kcyz['fpdata'];
  560. $y['whlabel'] = $x['whlabel'];
  561. $this->$fullorder_name->save($x,$y['id']);
  562. }
  563. }
  564. $wh = $this->_fout_db($y,$warehouse,$bdck);
  565. if($wh['fh'] == 2)
  566. {
  567. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  568. }
  569. }
  570. foreach ($wh['sj'] as $v)
  571. {
  572. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  573. }
  574. }
  575. /**
  576. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  577. {
  578. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  579. $cpsl = 0;
  580. $pp = explode('|',trim($y['whlabel'],'|'));
  581. foreach ($pp as $va)
  582. {
  583. $num = explode('-',$va);
  584. $cpsl += $num[1];
  585. }
  586. if(count($whlabel) != $cpsl)
  587. {
  588. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  589. }
  590. foreach ($whlabel as $v)
  591. {
  592. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  593. }
  594. }
  595. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  596. {
  597. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  598. $cpsl = 0;
  599. $pp = explode('|',trim($y['whlabel'],'|'));
  600. foreach ($pp as $va)
  601. {
  602. $num = explode('-',$va);
  603. if(stripos($num[2],'z') !== false)//如果是特殊库存
  604. {
  605. $cpsl += $num[1];
  606. }
  607. }
  608. if(count($wh) != $cpsl)
  609. {
  610. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  611. }
  612. foreach ($wh as $v)
  613. {
  614. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  615. {
  616. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  617. }
  618. }
  619. }
  620. **/
  621. /**
  622. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  623. {
  624. $d = $this->apiyy->get_chd($y);
  625. if($d['Data'][0]['m_isSucess'] != 1)
  626. {
  627. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  628. }
  629. }
  630. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  631. if(isset($systemtransfer[0]))
  632. {
  633. foreach ($systemtransfer as $v)
  634. {
  635. if($v['dbapi'] != 99)
  636. {
  637. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  638. }
  639. }
  640. $y['ts'] = count($systemtransfer);
  641. $d = $this->apiyy->get_chd($y);
  642. if($d['Data'][0]['m_isSucess'] != 1)
  643. {
  644. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  645. }
  646. }
  647. **/
  648. $shop = $this->shop->read($y['shop']);
  649. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  650. {
  651. $type = $this->typeclass->read($shop['type']);
  652. $y['shoptype'] = $type['title'];
  653. $y['weight'] = $weight;
  654. $d = $this->dhl->get_data_9610($y);
  655. if($d != 1)
  656. {
  657. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  658. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  659. }
  660. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  661. }
  662. if($fullorder_name == 'fullordersmt')
  663. {
  664. $stt = ($y['waybill']!='')?209:$y['state'];
  665. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  666. /**
  667. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  668. {
  669. echo json_encode(array('success'=>true));exit;
  670. }
  671. else
  672. {
  673. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  674. }
  675. **/
  676. }
  677. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
  678. {
  679. /**
  680. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  681. {
  682. echo json_encode(array('success'=>true));exit;
  683. }
  684. else
  685. {
  686. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  687. }
  688. **/
  689. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  690. }
  691. else
  692. {
  693. /**
  694. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  695. {
  696. echo json_encode(array('success'=>true));exit;
  697. }
  698. else
  699. {
  700. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  701. }
  702. **/
  703. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  704. }
  705. /**
  706. if($fullorder_name == 'fullorder')
  707. {
  708. $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
  709. $post['incrementId'] = $orderinfo;
  710. $post['trackingNumber'] = $y['waybill'];
  711. $ex = $this->express->read($y['express']);
  712. $post['carrier'] = $ex['iscode'];
  713. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  714. $ch = curl_init();
  715. curl_setopt($ch,CURLOPT_URL,$url);
  716. curl_setopt($ch, CURLOPT_POST, 1);
  717. curl_setopt($ch, CURLOPT_HEADER, 0);
  718. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  719. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  720. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  721. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  722. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  723. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  724. $res = curl_exec($ch);
  725. curl_close($ch);
  726. $res = json_decode($res,true);
  727. if($res['success'] == 0)
  728. {
  729. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
  730. }
  731. else
  732. {
  733. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
  734. }
  735. }
  736. **/
  737. if($outtype == 2 && $y['printnumber'] > 1)
  738. {
  739. $p = json_encode($post);
  740. echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
  741. }
  742. $this->$fullorder_name->save($post,$y['id']);
  743. //开始录入执行u9队列的数据
  744. $quque_u9_list = [];
  745. $queue_u9_list[] = [
  746. 'platform'=>$fullorder_name,
  747. 'warehouse'=>$y['type'],
  748. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  749. 'order_no'=>$y['number'],
  750. 'status'=>0,
  751. 'create_time'=>time(),
  752. 'update_time'=>time(),
  753. ];
  754. //合并订单自动发货
  755. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  756. $post['waybill'] = $y['waybill'];
  757. $post['express'] = $y['express'];
  758. $post['printtype'] = $y['printtype'];
  759. $post['ioss'] = $y['ioss'];
  760. $post['review'] = 6;
  761. $post['bx'] = $y['bx'];
  762. $post['qm'] = $y['qm'];
  763. $post['js'] = $y['js'];
  764. //$post['state'] = 216;
  765. $post['print'] = $y['print'];
  766. $post['printtime'] = $y['printtime'];
  767. $post['library'] = 2;
  768. $post['librarytime'] = $time;
  769. $post['libraryconfirm'] = 2;
  770. $post['librarynot'] = '';
  771. foreach ($hb as $v)
  772. {
  773. $post['state'] = $v['state'];
  774. $vshop = $this->shop->read($v['shop']);
  775. $vwarehouse = $this->warehouse->read($v['type']);
  776. $this->$fullorder_name->save($post,$v['id']);
  777. //2025年1月25日发现翔文合并订单发现此问题
  778. if($warehouse['zd'] == '1'){
  779. $wh = $this->_fout_db($v,$warehouse,$bdck);
  780. foreach ($wh['sj'] as $vv)
  781. {
  782. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  783. }
  784. }
  785. //添加队列的录入 合并单没有产品信息和价格不再执行了
  786. // $queue_u9_list[] = [
  787. // 'platform'=>$fullorder_name,
  788. // 'warehouse'=>$v['type'],
  789. // 'type'=>($y['type'] == 5)?11:10,
  790. // 'order_no'=>$v['number'],
  791. // 'status'=>0,
  792. // 'create_time'=>time(),
  793. // 'update_time'=>time(),
  794. // ];
  795. // $wh = $this->_fout_db($v,$warehouse,$bdck);
  796. // foreach ($wh['sj'] as $vv)
  797. // {
  798. // $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  799. // }
  800. //$this->ck->get_kc($post['state'],$vwarehouse,$vshop,$v['number'],$v['whlabel'],$v['fpdata']);
  801. }
  802. //$this->logic_ding->sendToDing("u9小单队列监听数据".json_encode($queue_u9_list,JSON_UNESCAPED_UNICODE));
  803. //将要执行的队列数据添加进去
  804. foreach($queue_u9_list as $item){
  805. if($item['platform'] != 'fullorderxw'){
  806. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  807. // $this->zzquque_u9->insert($item);
  808. // }
  809. if( !in_array($item['warehouse'],[5,7,8,9]) ){
  810. $this->zzquque_u9->insert($item);
  811. }
  812. }
  813. }
  814. if ($this->db->trans_status() === TRUE)
  815. {
  816. $this->db->trans_commit();
  817. echo json_encode(array('success'=>true));
  818. }
  819. else
  820. {
  821. $this->db->trans_rollback();
  822. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  823. }
  824. }
  825. }
  826. public function _outnumber()//对比占单是否正确
  827. {
  828. $post = $this->input->post(NULL, TRUE);
  829. if(isset($post['outnumber']))
  830. {
  831. $post = $this->input->post('post',true);
  832. $fullorder_name = $this->input->post('fullorder_name',true);
  833. $outnumber = $this->input->post('outnumber',true);
  834. $post = json_decode($post,true);
  835. $this->$fullorder_name->save($post,$outnumber);
  836. }
  837. }
  838. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  839. {
  840. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  841. $cpsl = 0;
  842. $pp = explode('|',trim($y['whlabel'],'|'));
  843. foreach ($pp as $va)
  844. {
  845. $num = explode('-',$va);
  846. if(isset($num[2]))
  847. {
  848. if(stripos($num[2],$warehouse['hz']) !== false)
  849. {
  850. $cpsl += $num[1];
  851. }
  852. }
  853. }
  854. if(count($wh) == $cpsl)
  855. {
  856. return array('fh'=>1,'sj'=>$wh);
  857. }
  858. else
  859. {
  860. return array('fh'=>2);
  861. }
  862. }
  863. public function _fedexhz()
  864. {
  865. $post = $this->input->post(NULL, TRUE);
  866. if(isset($post['id']))
  867. {
  868. $id = $this->input->post('id',true);
  869. $fullorder_name = $this->input->post('name',true);
  870. $express = $this->input->post('express',true);
  871. $express = $this->express->read($express);
  872. $fullorder = $this->$fullorder_name->read($id);
  873. if($fullorder['type'] == '2')
  874. {
  875. $fullorder['type'] = 1;
  876. }
  877. $time = time();
  878. $fullorder = $this->_text($fullorder);//获取所需信息
  879. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  880. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  881. $time = time();
  882. if($express['printcode'] == "FEDEXGF")
  883. {
  884. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  885. //升级的api
  886. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  887. if($barcode['x'] == 1)
  888. {
  889. $bctime = date('Ymd',$time);
  890. $Hwaybill = $barcode['waybill'];
  891. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  892. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  893. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  894. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  895. if(isset($barcode['label']) && isset($Hwaybill))
  896. {
  897. if($fullorder['waybill'] != "")
  898. {
  899. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  900. }
  901. else
  902. {
  903. $oldwaybill = $fullorder['oldwaybill'];
  904. }
  905. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  906. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  907. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  908. {
  909. $warehouse = $this->warehouse->read($fullorder['type']);
  910. $text = array();
  911. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  912. $text['number'] = $fullorder['number'];
  913. $text['mode'] = '95';
  914. $text['pdfnum'] = 1;
  915. $rows = array('text'=>$text);
  916. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  917. }
  918. else
  919. {
  920. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  921. }
  922. }
  923. }
  924. else
  925. {
  926. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  927. }
  928. }
  929. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  930. {
  931. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  932. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  933. if($barcode['x'] == 1)
  934. {
  935. $bctime = date('Ymd',$time);
  936. $Hwaybill = $barcode['waybill'];
  937. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  938. if(isset($barcode['label']) && isset($Hwaybill))
  939. {
  940. if($fullorder['waybill'] != "")
  941. {
  942. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  943. }
  944. else
  945. {
  946. $oldwaybill = $fullorder['oldwaybill'];
  947. }
  948. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  949. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  950. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  951. {
  952. $type = 1;
  953. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  954. }
  955. }
  956. }
  957. else
  958. {
  959. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  960. }
  961. }
  962. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  963. {
  964. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  965. if($barcode['c'] == 1)
  966. {
  967. $bctime = date('Ymd',$time);
  968. $Hwaybill = $barcode['data']['waybill'];
  969. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  970. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  971. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  972. {
  973. if($fullorder['waybill'] != "")
  974. {
  975. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  976. }
  977. else
  978. {
  979. $oldwaybill = $fullorder['oldwaybill'];
  980. }
  981. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  982. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  983. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  984. {
  985. $warehouse = $this->warehouse->read($fullorder['type']);
  986. $text = array();
  987. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  988. $text['number'] = $fullorder['number'];
  989. $text['mode'] = '95';
  990. $text['pdfnum'] = 1;
  991. $rows = array('text'=>$text);
  992. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  993. }
  994. }
  995. }
  996. else
  997. {
  998. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  999. }
  1000. }
  1001. else
  1002. {
  1003. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1004. }
  1005. }
  1006. }
  1007. public function _text($fullorder)
  1008. {
  1009. /** 发票地址信息暂时无用
  1010. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1011. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1012. $fullorder['baddress'][1] = $country['ename'];
  1013. **/
  1014. //获取所用相关信息
  1015. $warehouse = $this->warehouse->read($fullorder['type']);
  1016. $country = $this->country->read($fullorder['country']);//订单国家信息
  1017. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1018. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1019. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1020. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1021. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1022. $fullorder['country'] = $country['ename'];//订单国家名
  1023. $fullorder['zhou'] = $country['continent'];//所属州
  1024. $express = $this->express->read($fullorder['express']);
  1025. $fullorder['express'] = $express['servicename'];
  1026. $fullorder['account'] = $express['account'];
  1027. $fullorder['printcode'] = $express['printcode'];
  1028. $fullorder['time'] = date('Y-m-d',time());
  1029. $fullorder['times'] = date('Y-m-d H:i',time());
  1030. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1031. // 修复报关编码问题
  1032. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1033. $sbbm = "";
  1034. if(empty($declara_info)){
  1035. $sbbm = "";
  1036. }else{
  1037. $sbbm = $declara_info['bname'];
  1038. }
  1039. $fullorder['sbbm']= $sbbm;
  1040. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1041. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1042. $shop = $this->shop->read($fullorder['shop']);
  1043. $fullorder['shop'] = $shop['shopname'];
  1044. return $fullorder;
  1045. }
  1046. public function _lowe()
  1047. {
  1048. $post = $this->input->post(NULL, TRUE);
  1049. if(isset($post['lowe']))
  1050. {
  1051. $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
  1052. echo json_encode(array('msg'=>$lowe));exit;
  1053. }
  1054. }
  1055. public function _pdf($pdf,$title,$bctime)
  1056. {
  1057. $pdf_path = './data/pdf/'.$bctime.'/';
  1058. $file_base64 = $pdf;
  1059. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1060. $file_base64 = base64_decode($file_base64);
  1061. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1062. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1063. return $bctime;
  1064. }
  1065. public function _pdfurl($pdf,$title,$bctime)
  1066. {
  1067. $pdf_path = './data/pdf/'.$bctime.'/';
  1068. $pdf = fopen($pdf,"r");
  1069. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1070. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1071. return $bctime;
  1072. }
  1073. public function _excel()
  1074. {
  1075. $xw = '';
  1076. if(isset($_SESSION['api']))
  1077. {
  1078. $user = $this->user->get_api($_SESSION['api']);
  1079. $usp = $user;
  1080. $fgshop = "";$sid = "";$wid="";$wtype="";
  1081. $usersp = explode('|',trim($user['shop'],'|'));
  1082. $userwh = explode('|',trim($user['warehouse'],'|'));
  1083. foreach ($usersp as $value)
  1084. {
  1085. $fgshop .= " shop = ".$value." or";
  1086. $sid .= " id = ".$value." or";
  1087. }
  1088. foreach ($userwh as $value)
  1089. {
  1090. $wid .= " id = ".$value." or";
  1091. $wtype .= " type = ".$value." or";
  1092. }
  1093. if($user['userid'] == 'xw')
  1094. {
  1095. $xw = 1;
  1096. }
  1097. }
  1098. if(isset($_GET['fexcel']))
  1099. {
  1100. $dowid = $this->input->get('a');
  1101. $wid = "";
  1102. if($dowid != "")
  1103. {
  1104. $id_arr = explode(',',rtrim($dowid,','));
  1105. foreach ($id_arr as $v)
  1106. {
  1107. $wid .= " id = '$v' or";
  1108. }
  1109. $wid = " and".rtrim($wid,'or');
  1110. }
  1111. $t = $this->input->get('t',true);
  1112. $timetk = $this->input->get('timetk',true);
  1113. $timetj = $this->input->get('timetj',true);
  1114. $shop = $this->input->get('shop',true);
  1115. $source = $this->input->get('source',true);
  1116. $orderinfo = $this->input->get('orderinfo',true);
  1117. $number = $this->input->get('number',true);
  1118. $library = $this->input->get('library',true);
  1119. $waybill = $this->input->get('waybill',true);
  1120. $express = $this->input->get('express',true);
  1121. $type = $this->input->get('type',true);
  1122. $so = $this->input->get('so',true);
  1123. $timetk = strtotime($timetk);
  1124. $timetj = strtotime($timetj);
  1125. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1126. if($timetk && $timetj && $library == 1)
  1127. {
  1128. //$cxtime = 'reviewtime';
  1129. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1130. $where .= " and state != 217";
  1131. }
  1132. else if($timetk && $timetj && $library == 2)
  1133. {
  1134. $cxtime = 'librarytime';
  1135. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1136. }
  1137. /**
  1138. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1139. if($timetk && $timetj && $library == 1)
  1140. {
  1141. //$cxtime = 'reviewtime';
  1142. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1143. }
  1144. else if($timetk && $timetj && $library == 2)
  1145. {
  1146. $cxtime = 'librarytime';
  1147. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1148. }
  1149. **/
  1150. if(isset($_SESSION['api']))
  1151. {
  1152. if($type)
  1153. {
  1154. $where .= " and type = '$type'";
  1155. }
  1156. else
  1157. {
  1158. $uw = '';
  1159. $u = $this->user->get_api($_SESSION['api']);
  1160. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1161. foreach ($u['warehouse'] as $v)
  1162. {
  1163. $uw .= " type = '$v' or";
  1164. }
  1165. $uw = rtrim($uw,'or');
  1166. $uw = " and (".ltrim($uw,' ').")";
  1167. $where .= $uw;
  1168. }
  1169. }
  1170. else
  1171. {
  1172. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1173. }
  1174. if($shop)
  1175. {
  1176. $where .= " and shop = '$shop'";
  1177. }
  1178. if($number)
  1179. {
  1180. $where .= " and number = '$number'";
  1181. }
  1182. if($library)
  1183. {
  1184. $where .= " and library = '$library'";
  1185. }
  1186. if($waybill)
  1187. {
  1188. $where .= " and waybill = '$waybill'";
  1189. }
  1190. if($express)
  1191. {
  1192. $where .= " and express = '$express'";
  1193. }
  1194. if($orderinfo)
  1195. {
  1196. $where .= " and orderinfo = '$orderinfo'";
  1197. }
  1198. if($so)
  1199. {
  1200. $where .= " and shipremarks like '%$so%'";
  1201. }
  1202. //数据排序
  1203. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1204. $order_str = "librarytime desc";
  1205. if(empty($page))
  1206. {
  1207. $start = 0;
  1208. $perpage = 1;
  1209. }
  1210. else
  1211. {
  1212. $start = ($page - 1)*$perpage;
  1213. }
  1214. $typeclass = array();
  1215. $tclass = $this->typeclass->find_all();
  1216. foreach ($tclass as $v)
  1217. {
  1218. $typeclass[$v['id']] = $v;
  1219. }
  1220. //取得信息列表
  1221. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1222. //格式化数据
  1223. foreach ($info_list as $key=>$value)
  1224. {
  1225. $shop = $this->shop->read($value['shop']);
  1226. $info_list[$key]['shop'] = $shop['shopname'];
  1227. if($value['waybill'] == '0')
  1228. {
  1229. $info_list[$key]['waybill'] = "";
  1230. }
  1231. $express = $this->express->read($value['express']);
  1232. $info_list[$key]['express'] = $express['servicename'];
  1233. $warehouse = $this->warehouse->read($value['type']);
  1234. $info_list[$key]['type'] = $warehouse['title'];
  1235. if($value['print'] == 1)
  1236. {
  1237. $info_list[$key]['print'] = '不可打印';
  1238. }
  1239. else if($value['print'] == 2)
  1240. {
  1241. $info_list[$key]['print'] = '未打印';
  1242. }
  1243. else if($value['print'] == 3)
  1244. {
  1245. $info_list[$key]['print'] = '已打印';
  1246. }
  1247. if($value['library'] == 1)
  1248. {
  1249. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1250. }
  1251. else if($value['library'] == 2)
  1252. {
  1253. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1254. }
  1255. else if($value['library'] == 3)
  1256. {
  1257. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1258. }
  1259. if($value['librarytime'] == '0')
  1260. {
  1261. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1262. }
  1263. else
  1264. {
  1265. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1266. }
  1267. $classid = $classid = $this->classid->sku();
  1268. $dbapi = explode(';',trim($value['fpdata'],';'));
  1269. foreach ($dbapi as $va)
  1270. {
  1271. $pm = $classid;
  1272. $jm = $classid;
  1273. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1274. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1275. $ts = explode('|',trim($features,'|'));
  1276. if(stripos($ts[0],',') !== false)
  1277. {
  1278. $ft = explode(',',$ts[0]);
  1279. $features = explode('-',trim($ft[1],'-'));
  1280. $features[] = $ft[0];
  1281. }
  1282. else
  1283. {
  1284. $features = explode('-',trim($ts[0],'-'));
  1285. }
  1286. foreach($features as $k=>$v)
  1287. {
  1288. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1289. {
  1290. if($typeclass[$v]['bm'] != '')
  1291. {
  1292. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1293. }
  1294. }
  1295. if($v != 0 && isset($typeclass[$v]))
  1296. {
  1297. if($typeclass[$v]['classid'] == 13)
  1298. {
  1299. $dj = $typeclass[$v]['title'];
  1300. }
  1301. if($typeclass[$v]['classid'] == 8)
  1302. {
  1303. $ys = $typeclass[$v]['title'];
  1304. }
  1305. if($typeclass[$v]['classid'] == 15)
  1306. {
  1307. $hx = $typeclass[$v]['title'];
  1308. }
  1309. if(isset($pm[$typeclass[$v]['classid']]))
  1310. {
  1311. if($typeclass[$v]['title'] == '9A')
  1312. {
  1313. $pm[$typeclass[$v]['classid']] = '9A';
  1314. }
  1315. else if($typeclass[$v]['title'] == '10A')
  1316. {
  1317. $pm[$typeclass[$v]['classid']] = '10A';
  1318. }
  1319. else
  1320. {
  1321. $clzh = $typeclass[$v]['zh'];
  1322. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1323. {
  1324. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1325. $clzh = $clzh[0];
  1326. }
  1327. $pm[$typeclass[$v]['classid']] = $clzh;
  1328. }
  1329. }
  1330. if(isset($jm[$typeclass[$v]['classid']]))
  1331. {
  1332. if($typeclass[$v]['jm'])
  1333. {
  1334. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1335. }
  1336. }
  1337. }
  1338. }
  1339. $jm = array_filter($jm);//去除空值
  1340. $jm = implode("-",$jm);
  1341. $pm = array_filter($pm);//去除空值
  1342. $zh = implode(" ",$pm);
  1343. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1344. }
  1345. $info_list[$key]['jm'] = $jm;
  1346. $info_list[$key]['zh'] = $zh;
  1347. }
  1348. //取得信息列表
  1349. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1350. //格式化数据
  1351. foreach ($info_listsmt as $key=>$value)
  1352. {
  1353. $shop = $this->shop->read($value['shop']);
  1354. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1355. if($value['waybill'] == '0')
  1356. {
  1357. $info_listsmt[$key]['waybill'] = "";
  1358. }
  1359. $express = $this->express->read($value['express']);
  1360. $info_listsmt[$key]['express'] = $express['servicename'];
  1361. $warehouse = $this->warehouse->read($value['type']);
  1362. $info_listsmt[$key]['type'] = $warehouse['title'];
  1363. if($value['print'] == 1)
  1364. {
  1365. $info_listsmt[$key]['print'] = '不可打印';
  1366. }
  1367. else if($value['print'] == 2)
  1368. {
  1369. $info_listsmt[$key]['print'] = '未打印';
  1370. }
  1371. else if($value['print'] == 3)
  1372. {
  1373. $info_listsmt[$key]['print'] = '已打印';
  1374. }
  1375. if($value['library'] == 1)
  1376. {
  1377. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1378. }
  1379. else if($value['library'] == 2)
  1380. {
  1381. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1382. }
  1383. else if($value['library'] == 3)
  1384. {
  1385. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1386. }
  1387. if($value['librarytime'] == '0')
  1388. {
  1389. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1390. }
  1391. else
  1392. {
  1393. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1394. }
  1395. $classid = $classid = $this->classid->sku();
  1396. $dbapi = explode(';',trim($value['fpdata'],';'));
  1397. foreach ($dbapi as $va)
  1398. {
  1399. $pm = $classid;
  1400. $jm = $classid;
  1401. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1402. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1403. $ts = explode('|',trim($features,'|'));
  1404. if(stripos($ts[0],',') !== false)
  1405. {
  1406. $ft = explode(',',$ts[0]);
  1407. $features = explode('-',trim($ft[1],'-'));
  1408. $features[] = $ft[0];
  1409. }
  1410. else
  1411. {
  1412. $features = explode('-',trim($ts[0],'-'));
  1413. }
  1414. foreach($features as $k=>$v)
  1415. {
  1416. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1417. {
  1418. if($typeclass[$v]['bm'] != '')
  1419. {
  1420. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1421. }
  1422. }
  1423. if($v != 0 && isset($typeclass[$v]))
  1424. {
  1425. if($typeclass[$v]['classid'] == 13)
  1426. {
  1427. $dj = $typeclass[$v]['title'];
  1428. }
  1429. if($typeclass[$v]['classid'] == 8)
  1430. {
  1431. $ys = $typeclass[$v]['title'];
  1432. }
  1433. if($typeclass[$v]['classid'] == 15)
  1434. {
  1435. $hx = $typeclass[$v]['title'];
  1436. }
  1437. if(isset($pm[$typeclass[$v]['classid']]))
  1438. {
  1439. if($typeclass[$v]['title'] == '9A')
  1440. {
  1441. $pm[$typeclass[$v]['classid']] = '9A';
  1442. }
  1443. else if($typeclass[$v]['title'] == '10A')
  1444. {
  1445. $pm[$typeclass[$v]['classid']] = '10A';
  1446. }
  1447. else
  1448. {
  1449. $clzh = $typeclass[$v]['zh'];
  1450. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1451. {
  1452. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1453. $clzh = $clzh[0];
  1454. }
  1455. $pm[$typeclass[$v]['classid']] = $clzh;
  1456. }
  1457. }
  1458. if(isset($jm[$typeclass[$v]['classid']]))
  1459. {
  1460. if($typeclass[$v]['jm'])
  1461. {
  1462. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1463. }
  1464. }
  1465. }
  1466. }
  1467. $jm = array_filter($jm);//去除空值
  1468. $jm = implode("-",$jm);
  1469. $pm = array_filter($pm);//去除空值
  1470. $zh = implode(" ",$pm);
  1471. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1472. }
  1473. $info_listsmt[$key]['jm'] = $jm;
  1474. $info_listsmt[$key]['zh'] = $zh;
  1475. }
  1476. //取得信息列表
  1477. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1478. //格式化数据
  1479. foreach ($info_listtt as $key=>$value)
  1480. {
  1481. $shop = $this->shop->read($value['shop']);
  1482. $info_listtt[$key]['shop'] = $shop['shopname'];
  1483. if($value['waybill'] == '0')
  1484. {
  1485. $info_listtt[$key]['waybill'] = "";
  1486. }
  1487. $express = $this->express->read($value['express']);
  1488. $info_listtt[$key]['express'] = $express['servicename'];
  1489. $warehouse = $this->warehouse->read($value['type']);
  1490. $info_listtt[$key]['type'] = $warehouse['title'];
  1491. if($value['print'] == 1)
  1492. {
  1493. $info_listtt[$key]['print'] = '不可打印';
  1494. }
  1495. else if($value['print'] == 2)
  1496. {
  1497. $info_listtt[$key]['print'] = '未打印';
  1498. }
  1499. else if($value['print'] == 3)
  1500. {
  1501. $info_listtt[$key]['print'] = '已打印';
  1502. }
  1503. if($value['library'] == 1)
  1504. {
  1505. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1506. }
  1507. else if($value['library'] == 2)
  1508. {
  1509. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1510. }
  1511. else if($value['library'] == 3)
  1512. {
  1513. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1514. }
  1515. if($value['librarytime'] == '0')
  1516. {
  1517. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1518. }
  1519. else
  1520. {
  1521. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1522. }
  1523. $classid = $classid = $this->classid->sku();
  1524. $dbapi = explode(';',trim($value['fpdata'],';'));
  1525. foreach ($dbapi as $va)
  1526. {
  1527. $pm = $classid;
  1528. $jm = $classid;
  1529. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1530. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1531. $ts = explode('|',trim($features,'|'));
  1532. if(stripos($ts[0],',') !== false)
  1533. {
  1534. $ft = explode(',',$ts[0]);
  1535. $features = explode('-',trim($ft[1],'-'));
  1536. $features[] = $ft[0];
  1537. }
  1538. else
  1539. {
  1540. $features = explode('-',trim($ts[0],'-'));
  1541. }
  1542. foreach($features as $k=>$v)
  1543. {
  1544. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1545. {
  1546. if($typeclass[$v]['bm'] != '')
  1547. {
  1548. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1549. }
  1550. }
  1551. if($v != 0 && isset($typeclass[$v]))
  1552. {
  1553. if($typeclass[$v]['classid'] == 13)
  1554. {
  1555. $dj = $typeclass[$v]['title'];
  1556. }
  1557. if($typeclass[$v]['classid'] == 8)
  1558. {
  1559. $ys = $typeclass[$v]['title'];
  1560. }
  1561. if($typeclass[$v]['classid'] == 15)
  1562. {
  1563. $hx = $typeclass[$v]['title'];
  1564. }
  1565. if(isset($pm[$typeclass[$v]['classid']]))
  1566. {
  1567. if($typeclass[$v]['title'] == '9A')
  1568. {
  1569. $pm[$typeclass[$v]['classid']] = '9A';
  1570. }
  1571. else if($typeclass[$v]['title'] == '10A')
  1572. {
  1573. $pm[$typeclass[$v]['classid']] = '10A';
  1574. }
  1575. else
  1576. {
  1577. $clzh = $typeclass[$v]['zh'];
  1578. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1579. {
  1580. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1581. $clzh = $clzh[0];
  1582. }
  1583. $pm[$typeclass[$v]['classid']] = $clzh;
  1584. }
  1585. }
  1586. if(isset($jm[$typeclass[$v]['classid']]))
  1587. {
  1588. if($typeclass[$v]['jm'])
  1589. {
  1590. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1591. }
  1592. }
  1593. }
  1594. }
  1595. $jm = array_filter($jm);//去除空值
  1596. $jm = implode("-",$jm);
  1597. $pm = array_filter($pm);//去除空值
  1598. $zh = implode(" ",$pm);
  1599. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1600. }
  1601. $info_listtt[$key]['jm'] = $jm;
  1602. $info_listtt[$key]['zh'] = $zh;
  1603. }
  1604. //取得信息列表
  1605. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1606. //格式化数据
  1607. foreach ($info_listamz as $key=>$value)
  1608. {
  1609. $shop = $this->shop->read($value['shop']);
  1610. $info_listamz[$key]['shop'] = $shop['shopname'];
  1611. if($value['waybill'] == '0')
  1612. {
  1613. $info_listamz[$key]['waybill'] = "";
  1614. }
  1615. $express = $this->express->read($value['express']);
  1616. $info_listamz[$key]['express'] = $express['servicename'];
  1617. $warehouse = $this->warehouse->read($value['type']);
  1618. $info_listamz[$key]['type'] = $warehouse['title'];
  1619. if($value['print'] == 1)
  1620. {
  1621. $info_listamz[$key]['print'] = '不可打印';
  1622. }
  1623. else if($value['print'] == 2)
  1624. {
  1625. $info_listamz[$key]['print'] = '未打印';
  1626. }
  1627. else if($value['print'] == 3)
  1628. {
  1629. $info_listamz[$key]['print'] = '已打印';
  1630. }
  1631. if($value['library'] == 1)
  1632. {
  1633. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  1634. }
  1635. else if($value['library'] == 2)
  1636. {
  1637. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  1638. }
  1639. else if($value['library'] == 3)
  1640. {
  1641. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  1642. }
  1643. if($value['librarytime'] == '0')
  1644. {
  1645. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  1646. }
  1647. else
  1648. {
  1649. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1650. }
  1651. $classid = $classid = $this->classid->sku();
  1652. $dbapi = explode(';',trim($value['fpdata'],';'));
  1653. foreach ($dbapi as $va)
  1654. {
  1655. $pm = $classid;
  1656. $jm = $classid;
  1657. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1658. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1659. $ts = explode('|',trim($features,'|'));
  1660. if(stripos($ts[0],',') !== false)
  1661. {
  1662. $ft = explode(',',$ts[0]);
  1663. $features = explode('-',trim($ft[1],'-'));
  1664. $features[] = $ft[0];
  1665. }
  1666. else
  1667. {
  1668. $features = explode('-',trim($ts[0],'-'));
  1669. }
  1670. foreach($features as $k=>$v)
  1671. {
  1672. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1673. {
  1674. if($typeclass[$v]['bm'] != '')
  1675. {
  1676. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1677. }
  1678. }
  1679. if($v != 0 && isset($typeclass[$v]))
  1680. {
  1681. if($typeclass[$v]['classid'] == 13)
  1682. {
  1683. $dj = $typeclass[$v]['title'];
  1684. }
  1685. if($typeclass[$v]['classid'] == 8)
  1686. {
  1687. $ys = $typeclass[$v]['title'];
  1688. }
  1689. if($typeclass[$v]['classid'] == 15)
  1690. {
  1691. $hx = $typeclass[$v]['title'];
  1692. }
  1693. if(isset($pm[$typeclass[$v]['classid']]))
  1694. {
  1695. if($typeclass[$v]['title'] == '9A')
  1696. {
  1697. $pm[$typeclass[$v]['classid']] = '9A';
  1698. }
  1699. else if($typeclass[$v]['title'] == '10A')
  1700. {
  1701. $pm[$typeclass[$v]['classid']] = '10A';
  1702. }
  1703. else
  1704. {
  1705. $clzh = $typeclass[$v]['zh'];
  1706. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1707. {
  1708. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1709. $clzh = $clzh[0];
  1710. }
  1711. $pm[$typeclass[$v]['classid']] = $clzh;
  1712. }
  1713. }
  1714. if(isset($jm[$typeclass[$v]['classid']]))
  1715. {
  1716. if($typeclass[$v]['jm'])
  1717. {
  1718. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1719. }
  1720. }
  1721. }
  1722. }
  1723. $jm = array_filter($jm);//去除空值
  1724. $jm = implode("-",$jm);
  1725. $pm = array_filter($pm);//去除空值
  1726. $zh = implode(" ",$pm);
  1727. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1728. }
  1729. $info_listamz[$key]['jm'] = $jm;
  1730. $info_listamz[$key]['zh'] = $zh;
  1731. }
  1732. //取得信息列表
  1733. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1734. //格式化数据
  1735. foreach ($info_listxw as $key=>$value)
  1736. {
  1737. $shop = $this->shop->read($value['shop']);
  1738. $info_listxw[$key]['shop'] = $shop['shopname'];
  1739. if($value['waybill'] == '0')
  1740. {
  1741. $info_listxw[$key]['waybill'] = "";
  1742. }
  1743. $express = $this->express->read($value['express']);
  1744. $info_listxw[$key]['express'] = $express['servicename'];
  1745. $warehouse = $this->warehouse->read($value['type']);
  1746. $info_listxw[$key]['type'] = $warehouse['title'];
  1747. if($value['print'] == 1)
  1748. {
  1749. $info_listxw[$key]['print'] = '不可打印';
  1750. }
  1751. else if($value['print'] == 2)
  1752. {
  1753. $info_listxw[$key]['print'] = '未打印';
  1754. }
  1755. else if($value['print'] == 3)
  1756. {
  1757. $info_listxw[$key]['print'] = '已打印';
  1758. }
  1759. if($value['library'] == 1)
  1760. {
  1761. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  1762. }
  1763. else if($value['library'] == 2)
  1764. {
  1765. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  1766. }
  1767. else if($value['library'] == 3)
  1768. {
  1769. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  1770. }
  1771. if($value['librarytime'] == '0')
  1772. {
  1773. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  1774. }
  1775. else
  1776. {
  1777. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1778. }
  1779. $classid = $classid = $this->classid->sku();
  1780. $dbapi = explode(';',trim($value['fpdata'],';'));
  1781. foreach ($dbapi as $va)
  1782. {
  1783. $pm = $classid;
  1784. $jm = $classid;
  1785. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1786. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1787. $ts = explode('|',trim($features,'|'));
  1788. if(stripos($ts[0],',') !== false)
  1789. {
  1790. $ft = explode(',',$ts[0]);
  1791. $features = explode('-',trim($ft[1],'-'));
  1792. $features[] = $ft[0];
  1793. }
  1794. else
  1795. {
  1796. $features = explode('-',trim($ts[0],'-'));
  1797. }
  1798. foreach($features as $k=>$v)
  1799. {
  1800. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1801. {
  1802. if($typeclass[$v]['bm'] != '')
  1803. {
  1804. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1805. }
  1806. }
  1807. if($v != 0 && isset($typeclass[$v]))
  1808. {
  1809. if($typeclass[$v]['classid'] == 13)
  1810. {
  1811. $dj = $typeclass[$v]['title'];
  1812. }
  1813. if($typeclass[$v]['classid'] == 8)
  1814. {
  1815. $ys = $typeclass[$v]['title'];
  1816. }
  1817. if($typeclass[$v]['classid'] == 15)
  1818. {
  1819. $hx = $typeclass[$v]['title'];
  1820. }
  1821. if(isset($pm[$typeclass[$v]['classid']]))
  1822. {
  1823. if($typeclass[$v]['title'] == '9A')
  1824. {
  1825. $pm[$typeclass[$v]['classid']] = '9A';
  1826. }
  1827. else if($typeclass[$v]['title'] == '10A')
  1828. {
  1829. $pm[$typeclass[$v]['classid']] = '10A';
  1830. }
  1831. else
  1832. {
  1833. $clzh = $typeclass[$v]['zh'];
  1834. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1835. {
  1836. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1837. $clzh = $clzh[0];
  1838. }
  1839. $pm[$typeclass[$v]['classid']] = $clzh;
  1840. }
  1841. }
  1842. if(isset($jm[$typeclass[$v]['classid']]))
  1843. {
  1844. if($typeclass[$v]['jm'])
  1845. {
  1846. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1847. }
  1848. }
  1849. }
  1850. }
  1851. $jm = array_filter($jm);//去除空值
  1852. $jm = implode("-",$jm);
  1853. $pm = array_filter($pm);//去除空值
  1854. $zh = implode(" ",$pm);
  1855. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1856. }
  1857. $info_listxw[$key]['jm'] = $jm;
  1858. $info_listxw[$key]['zh'] = $zh;
  1859. }
  1860. $title = '订单出库-'.date('Ymd',time());
  1861. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  1862. $tail = "\n";
  1863. $filename = $title.".xls";
  1864. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  1865. }
  1866. }
  1867. public function _cpexcel()
  1868. {
  1869. if(isset($_SESSION['api']))
  1870. {
  1871. $user = $this->user->get_api($_SESSION['api']);
  1872. $usp = $user;
  1873. $fgshop = "";$sid = "";$excelshop="";
  1874. $usersp = explode('|',trim($user['shop'],'|'));
  1875. foreach ($usersp as $value)
  1876. {
  1877. $fgshop .= " shop = ".$value." or";
  1878. $sid .= " id = ".$value." or";
  1879. }
  1880. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1881. foreach ($userexcel as $value)
  1882. {
  1883. $excelshop .= " shop = ".$value." or";
  1884. }
  1885. if($excelshop != "")
  1886. {
  1887. $excelshop = "(".rtrim($excelshop,'or').")";
  1888. }
  1889. }
  1890. if(isset($_GET['excel']))
  1891. {
  1892. $timetk = $this->input->get('timetk',true);
  1893. $timetj = $this->input->get('timetj',true);
  1894. $shop = $this->input->get('shop',true);
  1895. $library = $this->input->get('library',true);
  1896. $type = $this->input->get('type',true);
  1897. $number = $this->input->get('number',true);
  1898. $orderinfo = $this->input->get('orderinfo',true);
  1899. $so = $this->input->get('so',true);
  1900. $number = $this->input->get('number',true);
  1901. $express = $this->input->get('express',true);
  1902. $timetk = strtotime($timetk);
  1903. $timetj = strtotime($timetj);
  1904. $where = "mergeid = 0";
  1905. if($timetk && $timetj && $library == 2)
  1906. {
  1907. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1908. }
  1909. else
  1910. {
  1911. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1912. }
  1913. if(isset($_SESSION['api']))
  1914. {
  1915. if($type)
  1916. {
  1917. $where .= " and type = '$type'";
  1918. }
  1919. else
  1920. {
  1921. $uw = '';
  1922. $u = $this->user->get_api($_SESSION['api']);
  1923. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1924. foreach ($u['warehouse'] as $v)
  1925. {
  1926. $uw .= " type = '$v' or";
  1927. }
  1928. $uw = rtrim($uw,'or');
  1929. $uw = " and (".ltrim($uw,' ').")";
  1930. $where .= $uw;
  1931. }
  1932. }
  1933. else
  1934. {
  1935. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1936. }
  1937. if($shop)
  1938. {
  1939. $where .= " and shop = '$shop'";
  1940. }
  1941. else
  1942. {
  1943. $where .= " and ".$excelshop;
  1944. }
  1945. if($library)
  1946. {
  1947. $where .= " and library = '$library'";
  1948. }
  1949. if($number)
  1950. {
  1951. $where .= " and number = '$number'";
  1952. }
  1953. if($orderinfo)
  1954. {
  1955. $where .= " and orderinfo = '$orderinfo'";
  1956. }
  1957. if($so)
  1958. {
  1959. $where .= " and shipremarks like '%$so%'";
  1960. }
  1961. if($express)
  1962. {
  1963. $where .= " and express = '$express'";
  1964. }
  1965. /* 匹配ID加入 */
  1966. $tc = array();
  1967. $typeclass = $this->typeclass->find_all();
  1968. foreach ($typeclass as $v)
  1969. {
  1970. $tc[$v['id']] = $v['title'];
  1971. }
  1972. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  1973. //取得信息列表
  1974. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  1975. $info_listb = $this->fullorder->find_all($where,'fpdata');
  1976. $info_list = array_merge($info_lista,$info_listb);
  1977. //格式化数据
  1978. $i = 0;$cpexcel = array();
  1979. foreach ($info_list as $key=>$value)
  1980. {
  1981. if(stripos($value['fpdata'],';') !== false)
  1982. {
  1983. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  1984. foreach ($fpdata as $ke=>$va)
  1985. {
  1986. $title = '';
  1987. $fg = explode('|',$va);
  1988. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  1989. $cp = explode('-',rtrim($fg[0],'-'));
  1990. $dj = $tc[$cp[2]];
  1991. if(!isset($cp[3]))
  1992. {
  1993. $ys = json_encode($cp);
  1994. }
  1995. else
  1996. {
  1997. $ys = $tc[$cp[3]];
  1998. }
  1999. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  2000. foreach ($cp as $v)
  2001. {
  2002. $title .= $tc[$v].' ';
  2003. }
  2004. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  2005. }
  2006. }
  2007. $i++;
  2008. }
  2009. $title = "统计信息";
  2010. $titlename = "<table border=1>
  2011. <tr>
  2012. <td>尺寸</td>
  2013. <td>等级</td>
  2014. <td>颜色</td>
  2015. <td>花型</td>
  2016. <td>数量</td>
  2017. </tr>
  2018. </table>";
  2019. $filename = $title.".xls";
  2020. $tail = "\n";
  2021. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  2022. }
  2023. }
  2024. public function _orderyz()
  2025. {
  2026. $post = $this->input->post(NULL, TRUE);
  2027. if(isset($post['yz']))
  2028. {
  2029. $yz = $this->input->post('yz',true);
  2030. $number = $this->input->post('number',true);
  2031. $y = $this->fullorder->get_number($number);
  2032. if(!$y)
  2033. {
  2034. $y = $this->fullordersmt->get_number($number);
  2035. if(!$y)
  2036. {
  2037. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2038. }
  2039. }
  2040. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2041. foreach($whlabel as $k=>$v)
  2042. {
  2043. $w = explode('-',trim($v,'-'));
  2044. $wldata[$w[0]] = $w;
  2045. }
  2046. $whlabellabel = $this->whlabellabel->get_label($yz);
  2047. if(!$whlabellabel)
  2048. {
  2049. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2050. }
  2051. else
  2052. {
  2053. if(isset($wldata[$whlabellabel['number']]))
  2054. {
  2055. if(!isset($wldata[$whlabellabel['number']][2]))
  2056. {
  2057. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2058. }
  2059. else if($wldata[$whlabellabel['number']][2] == 0)
  2060. {
  2061. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2062. }
  2063. }
  2064. else
  2065. {
  2066. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2067. }
  2068. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2069. }
  2070. }
  2071. if(isset($post['number']))
  2072. {
  2073. $number = $this->input->post('number',true);
  2074. $f = 'fullorder';
  2075. $y = $this->fullorder->get_number($number);
  2076. if(!$y)
  2077. {
  2078. $f = 'fullordersmt';
  2079. $y = $this->fullordersmt->get_number($number);
  2080. if(!$y)
  2081. {
  2082. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2083. }
  2084. }
  2085. if($y['librarytime'] > 0)
  2086. {
  2087. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2088. }
  2089. $warehouse = $this->warehouse->read($y['type']);
  2090. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2091. {
  2092. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  2093. }
  2094. $data = explode('|',trim($y['whlabel'],'|'));
  2095. $fpdata = explode(';',trim($y['fpdata'],';'));
  2096. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2097. foreach($fpdata as $val)
  2098. {
  2099. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2100. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2101. $fp = explode('|',$val);
  2102. $fp[0] = str_replace(',','-',$fp[0]);
  2103. $value = explode('-',$fp[0]);
  2104. foreach($value as $v)
  2105. {
  2106. $typeclass = $this->typeclass->read($v);
  2107. $zh = explode('|',trim($typeclass['zh'],'|'));
  2108. $pm[$typeclass['classid']] = $zh[0];
  2109. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2110. }
  2111. $scsku = implode("-",$scsku);
  2112. $zh = implode(" ",$pm);
  2113. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2114. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2115. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2116. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2117. $data[$i] = explode('-',$data[$i]);
  2118. for($j=0;$j<$data[$i][1];$j++)
  2119. {
  2120. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2121. {
  2122. $znum++;//只计算现货
  2123. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2124. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2125. }
  2126. else
  2127. {
  2128. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2129. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2130. }
  2131. $x++;//所有数量
  2132. }
  2133. $i++;
  2134. }
  2135. //ksort($cp);//区别位置模式,暂不使用
  2136. $cp = array_values($cp);
  2137. if($this->$f->save(array('yhs'=>1),$y['id']))
  2138. {
  2139. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2140. }
  2141. else
  2142. {
  2143. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2144. }
  2145. }
  2146. if(isset($post['tid']))
  2147. {
  2148. $typeclass = array();
  2149. $tc = $this->typeclass->find_all();
  2150. foreach($tc as $v)
  2151. {
  2152. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2153. }
  2154. $tid = $this->input->post('tid',true);
  2155. $id = $this->input->post('id',true);
  2156. $number = $this->input->post('n',true);
  2157. $ful = 'fullorder';
  2158. $y = $this->fullorder->get_number($number);
  2159. if(!$y)
  2160. {
  2161. $ful = 'fullordersmt';
  2162. $y = $this->fullordersmt->get_number($number);
  2163. if(!$y)
  2164. {
  2165. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2166. }
  2167. }
  2168. $wtid = $this->whlabellabel->get_label($tid);
  2169. if(!$wtid)
  2170. {
  2171. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2172. }
  2173. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2174. $fpdata = explode(';',trim($y['fpdata'],';'));
  2175. $warehouse = $this->warehouse->read($y['type']);
  2176. $zdkc = $warehouse['bdck'];
  2177. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2178. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2179. if((count($ptc)+count($zsc)) < 1)
  2180. {
  2181. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2182. }
  2183. $this->db->trans_begin();
  2184. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2185. if($zsc)
  2186. {
  2187. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2188. $xrid = $zsc[0]['id'];
  2189. }
  2190. else if($ptc)
  2191. {
  2192. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2193. $xrid = $ptc[0]['id'];
  2194. }
  2195. $xr = $this->$zdkc->read($xrid);
  2196. $features = explode('-',trim($xr['features'],'-'));
  2197. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2198. foreach($features as $kk=>$v)
  2199. {
  2200. if($typeclass[$v]['classid'] == 14)
  2201. {
  2202. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2203. unset($kk);
  2204. }
  2205. }
  2206. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2207. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2208. $wldata = array();
  2209. $fdata = array();
  2210. foreach($whlabel as $k=>$v)
  2211. {
  2212. $w = explode('-',trim($v,'-'));
  2213. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2214. }
  2215. if(!isset($wldata[$id]))
  2216. {
  2217. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2218. }
  2219. if(isset($wldata[$wtid['number']]['sj']))
  2220. {
  2221. $tw = $wldata[$wtid['number']]['sj'];
  2222. if($wtid['number'] != $id)
  2223. {
  2224. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2225. }
  2226. else
  2227. {
  2228. if(isset($tw[2]) && $tw[2] != 0)
  2229. {
  2230. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2231. }
  2232. }
  2233. if($tw[1] > 1)
  2234. {
  2235. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2236. }
  2237. }
  2238. $thfpdata = $y['thfpdata'];
  2239. $w = $wldata[$id]['sj'];
  2240. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2241. $zdkc = $warehouse['bdck'];
  2242. if($w[1] > 1)
  2243. {
  2244. if(isset($w[2]) && $w[2] != 0)
  2245. {
  2246. $hz = explode('~',trim($w[2],'~'));
  2247. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2248. $zd = str_replace($hz[0],'',$w[2]);
  2249. $zd = trim($zd,'~');
  2250. $w[2] = $zd;
  2251. }
  2252. foreach($w as $kk=>$v)
  2253. {
  2254. if($kk == 1)
  2255. {
  2256. $v = $v-1;
  2257. }
  2258. $ww .= $v .'-';
  2259. }
  2260. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2261. foreach($f as $kk=>$v)
  2262. {
  2263. if($kk == 2)
  2264. {
  2265. $v = $v-1;
  2266. $thff .= '1|';
  2267. }
  2268. else
  2269. {
  2270. $thff .= $v .'|';
  2271. }
  2272. $ff .= $v .'|';
  2273. }
  2274. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2275. $thfpdata .= trim($thff,'|');
  2276. }
  2277. else
  2278. {
  2279. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2280. unset($whlabel[$wldata[$id]['wz']]);
  2281. unset($fpdata[$wldata[$id]['wz']]);
  2282. }
  2283. $thfpdata .= '~'.$dataf;
  2284. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2285. $fpdata = implode(";",$fpdata).';'.$dataf;
  2286. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2287. if ($this->db->trans_status() === TRUE)
  2288. {
  2289. $this->db->trans_commit();
  2290. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2291. }
  2292. else
  2293. {
  2294. $this->db->trans_rollback();
  2295. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2296. }
  2297. }
  2298. if(isset($post['yhs']))
  2299. {
  2300. $f = 'fullorder';
  2301. $number = $this->input->post('yhs',true);
  2302. $y = $this->fullorder->get_number($number);
  2303. if(!$y)
  2304. {
  2305. $f = 'fullordersmt';
  2306. $y = $this->fullordersmt->get_number($number);
  2307. }
  2308. if($this->$f->save(array('yhs'=>0),$y['id']))
  2309. {
  2310. echo json_encode(array('success'=>true));exit;
  2311. }
  2312. else
  2313. {
  2314. echo json_encode(array('success'=>false));exit;
  2315. }
  2316. }
  2317. $this->_Template('systemfout_orderyz',$this->data);
  2318. }
  2319. public function _hwyz()
  2320. {
  2321. $post = $this->input->post(NULL, TRUE);
  2322. if(isset($post['yz']))
  2323. {
  2324. $yz = $this->input->post('yz',true);
  2325. $number = $this->input->post('number',true);
  2326. $y = $this->fullorder->get_number($number);
  2327. if(!$y)
  2328. {
  2329. $y = $this->fullordersmt->get_number($number);
  2330. if(!$y)
  2331. {
  2332. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2333. }
  2334. }
  2335. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2336. foreach($whlabel as $k=>$v)
  2337. {
  2338. $w = explode('-',trim($v,'-'));
  2339. $wldata[$w[0]] = $w;
  2340. }
  2341. $whlabellabel = $this->whlabellabel->get_label($yz);
  2342. if(!$whlabellabel)
  2343. {
  2344. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2345. }
  2346. else
  2347. {
  2348. if(isset($wldata[$whlabellabel['number']]))
  2349. {
  2350. if(!isset($wldata[$whlabellabel['number']][2]))
  2351. {
  2352. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2353. }
  2354. else if($wldata[$whlabellabel['number']][2] == 0)
  2355. {
  2356. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2357. }
  2358. }
  2359. else
  2360. {
  2361. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2362. }
  2363. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2364. }
  2365. }
  2366. if(isset($post['number']))
  2367. {
  2368. $number = $this->input->post('number',true);
  2369. $f = 'fullorder';
  2370. $y = $this->fullorder->get_number($number);
  2371. if(!$y)
  2372. {
  2373. $f = 'fullordersmt';
  2374. $y = $this->fullordersmt->get_number($number);
  2375. if(!$y)
  2376. {
  2377. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2378. }
  2379. }
  2380. if($y['librarytime'] > 0)
  2381. {
  2382. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2383. }
  2384. $warehouse = $this->warehouse->read($y['type']);
  2385. $data = explode('|',trim($y['whlabel'],'|'));
  2386. $fpdata = explode(';',trim($y['fpdata'],';'));
  2387. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2388. foreach($fpdata as $val)
  2389. {
  2390. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2391. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2392. $fp = explode('|',$val);
  2393. $fp[0] = str_replace(',','-',$fp[0]);
  2394. $value = explode('-',$fp[0]);
  2395. foreach($value as $v)
  2396. {
  2397. $typeclass = $this->typeclass->read($v);
  2398. $zh = explode('|',trim($typeclass['zh'],'|'));
  2399. $pm[$typeclass['classid']] = $zh[0];
  2400. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2401. }
  2402. $scsku = implode("-",$scsku);
  2403. $zh = implode(" ",$pm);
  2404. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2405. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2406. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2407. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2408. $data[$i] = explode('-',$data[$i]);
  2409. for($j=0;$j<$data[$i][1];$j++)
  2410. {
  2411. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2412. {
  2413. $znum++;//只计算现货
  2414. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2415. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2416. }
  2417. else
  2418. {
  2419. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2420. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2421. }
  2422. $x++;//所有数量
  2423. }
  2424. $i++;
  2425. }
  2426. //ksort($cp);//区别位置模式,暂不使用
  2427. $cp = array_values($cp);
  2428. if($this->$f->save(array('yhs'=>1),$y['id']))
  2429. {
  2430. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2431. {
  2432. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2433. }
  2434. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2435. }
  2436. else
  2437. {
  2438. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2439. }
  2440. }
  2441. if(isset($post['tid']))
  2442. {
  2443. $typeclass = array();
  2444. $tc = $this->typeclass->find_all();
  2445. foreach($tc as $v)
  2446. {
  2447. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2448. }
  2449. $tid = $this->input->post('tid',true);
  2450. $id = $this->input->post('id',true);
  2451. $number = $this->input->post('n',true);
  2452. $ful = 'fullorder';
  2453. $y = $this->fullorder->get_number($number);
  2454. if(!$y)
  2455. {
  2456. $ful = 'fullordersmt';
  2457. $y = $this->fullordersmt->get_number($number);
  2458. if(!$y)
  2459. {
  2460. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2461. }
  2462. }
  2463. $wtid = $this->whlabellabel->get_label($tid);
  2464. if(!$wtid)
  2465. {
  2466. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2467. }
  2468. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2469. $fpdata = explode(';',trim($y['fpdata'],';'));
  2470. $warehouse = $this->warehouse->read($y['type']);
  2471. $zdkc = $warehouse['bdck'];
  2472. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2473. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2474. if((count($ptc)+count($zsc)) < 1)
  2475. {
  2476. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2477. }
  2478. $this->db->trans_begin();
  2479. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2480. if($zsc)
  2481. {
  2482. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2483. $xrid = $zsc[0]['id'];
  2484. }
  2485. else if($ptc)
  2486. {
  2487. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2488. $xrid = $ptc[0]['id'];
  2489. }
  2490. $xr = $this->$zdkc->read($xrid);
  2491. $features = explode('-',trim($xr['features'],'-'));
  2492. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2493. foreach($features as $kk=>$v)
  2494. {
  2495. if($typeclass[$v]['classid'] == 14)
  2496. {
  2497. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2498. unset($kk);
  2499. }
  2500. }
  2501. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2502. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2503. $wldata = array();
  2504. $fdata = array();
  2505. foreach($whlabel as $k=>$v)
  2506. {
  2507. $w = explode('-',trim($v,'-'));
  2508. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2509. }
  2510. if(!isset($wldata[$id]))
  2511. {
  2512. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2513. }
  2514. if(isset($wldata[$wtid['number']]['sj']))
  2515. {
  2516. $tw = $wldata[$wtid['number']]['sj'];
  2517. if($wtid['number'] != $id)
  2518. {
  2519. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2520. }
  2521. else
  2522. {
  2523. if(isset($tw[2]) && $tw[2] != 0)
  2524. {
  2525. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2526. }
  2527. }
  2528. if($tw[1] > 1)
  2529. {
  2530. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2531. }
  2532. }
  2533. $thfpdata = $y['thfpdata'];
  2534. $w = $wldata[$id]['sj'];
  2535. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2536. $zdkc = $warehouse['bdck'];
  2537. if($w[1] > 1)
  2538. {
  2539. if(isset($w[2]) && $w[2] != 0)
  2540. {
  2541. $hz = explode('~',trim($w[2],'~'));
  2542. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2543. $zd = str_replace($hz[0],'',$w[2]);
  2544. $zd = trim($zd,'~');
  2545. $w[2] = $zd;
  2546. }
  2547. foreach($w as $kk=>$v)
  2548. {
  2549. if($kk == 1)
  2550. {
  2551. $v = $v-1;
  2552. }
  2553. $ww .= $v .'-';
  2554. }
  2555. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2556. foreach($f as $kk=>$v)
  2557. {
  2558. if($kk == 2)
  2559. {
  2560. $v = $v-1;
  2561. $thff .= '1|';
  2562. }
  2563. else
  2564. {
  2565. $thff .= $v .'|';
  2566. }
  2567. $ff .= $v .'|';
  2568. }
  2569. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2570. $thfpdata .= trim($thff,'|');
  2571. }
  2572. else
  2573. {
  2574. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2575. unset($whlabel[$wldata[$id]['wz']]);
  2576. unset($fpdata[$wldata[$id]['wz']]);
  2577. }
  2578. $thfpdata .= '~'.$dataf;
  2579. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2580. $fpdata = implode(";",$fpdata).';'.$dataf;
  2581. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2582. if ($this->db->trans_status() === TRUE)
  2583. {
  2584. $this->db->trans_commit();
  2585. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2586. }
  2587. else
  2588. {
  2589. $this->db->trans_rollback();
  2590. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2591. }
  2592. }
  2593. if(isset($post['yhs']))
  2594. {
  2595. $f = 'fullorder';
  2596. $number = $this->input->post('yhs',true);
  2597. $y = $this->fullorder->get_number($number);
  2598. if(!$y)
  2599. {
  2600. $f = 'fullordersmt';
  2601. $y = $this->fullordersmt->get_number($number);
  2602. }
  2603. if($this->$f->save(array('yhs'=>0),$y['id']))
  2604. {
  2605. echo json_encode(array('success'=>true));exit;
  2606. }
  2607. else
  2608. {
  2609. echo json_encode(array('success'=>false));exit;
  2610. }
  2611. }
  2612. $this->_Template('systemfout_hwyz',$this->data);
  2613. }
  2614. public function _fouthb()
  2615. {
  2616. $post = $this->input->post(NULL, TRUE);
  2617. $xw = '';
  2618. if(isset($_SESSION['api']))
  2619. {
  2620. $user = $this->user->get_api($_SESSION['api']);
  2621. $usp = $user;
  2622. $fgshop = "";$sid = "";$wid="";$wtype="";
  2623. $usersp = explode('|',trim($user['shop'],'|'));
  2624. $userwh = explode('|',trim($user['warehouse'],'|'));
  2625. foreach ($usersp as $value)
  2626. {
  2627. $fgshop .= " shop = ".$value." or";
  2628. $sid .= " id = ".$value." or";
  2629. }
  2630. foreach ($userwh as $value)
  2631. {
  2632. $wid .= " id = ".$value." or";
  2633. $wtype .= " type = ".$value." or";
  2634. }
  2635. if($user['userid'] == 'xw')
  2636. {
  2637. $xw = 1;
  2638. }
  2639. }
  2640. if(isset($post['page']))
  2641. {
  2642. $page = $this->input->post('page',true);
  2643. $perpage = $this->input->post('perpage',true);
  2644. $timetk = $this->input->post('timetk',true);
  2645. $timetj = $this->input->post('timetj',true);
  2646. $shop = $this->input->post('shop',true);
  2647. $type = $this->input->post('type',true);
  2648. $express = $this->input->post('express',true);
  2649. $number = $this->input->post('number',true);
  2650. $waybill = $this->input->post('waybill',true);
  2651. $librarytime = $this->input->post('librarytime',true);
  2652. $timetk = strtotime($timetk);
  2653. $timetj = strtotime($timetj);
  2654. $where = "mergeid = '1'";
  2655. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2656. if($shop)
  2657. {
  2658. $where .= " and shop = '$shop'";
  2659. }
  2660. if($number)
  2661. {
  2662. $where .= " and number like '$number%'";
  2663. }
  2664. if($waybill)
  2665. {
  2666. $where .= " and waybill = '$waybill'";
  2667. }
  2668. if($type)
  2669. {
  2670. $where .= " and type = '$type'";
  2671. }
  2672. if($express)
  2673. {
  2674. $where .= " and express = '$express'";
  2675. }
  2676. //数据排序
  2677. $order_str = "librarytime desc";
  2678. if(empty($page))
  2679. {
  2680. $start = 0;
  2681. $perpage = 1;
  2682. }
  2683. else
  2684. {
  2685. $start = ($page - 1)*$perpage;
  2686. }
  2687. //取得信息列表
  2688. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2689. //格式化数据
  2690. foreach ($info_list as $key=>$value)
  2691. {
  2692. $shop = $this->shop->read($value['shop']);
  2693. $info_list[$key]['shop'] = $shop['shopname'];
  2694. $express = $this->express->read($value['express']);
  2695. $info_list[$key]['express'] = $express['servicename'];
  2696. $warehouse = $this->warehouse->read($value['type']);
  2697. $info_list[$key]['type'] = $warehouse['title'];
  2698. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2699. }
  2700. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2701. //格式化数据
  2702. foreach ($info_listtt as $key=>$value)
  2703. {
  2704. $shop = $this->shop->read($value['shop']);
  2705. $info_listtt[$key]['shop'] = $shop['shopname'];
  2706. $express = $this->express->read($value['express']);
  2707. $info_listtt[$key]['express'] = $express['servicename'];
  2708. $warehouse = $this->warehouse->read($value['type']);
  2709. $info_listtt[$key]['type'] = $warehouse['title'];
  2710. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2711. }
  2712. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2713. //格式化数据
  2714. foreach ($info_listamz as $key=>$value)
  2715. {
  2716. $shop = $this->shop->read($value['shop']);
  2717. $info_listamz[$key]['shop'] = $shop['shopname'];
  2718. $express = $this->express->read($value['express']);
  2719. $info_listamz[$key]['express'] = $express['servicename'];
  2720. $warehouse = $this->warehouse->read($value['type']);
  2721. $info_listamz[$key]['type'] = $warehouse['title'];
  2722. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2723. }
  2724. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2725. //格式化数据
  2726. foreach ($info_listxw as $key=>$value)
  2727. {
  2728. $shop = $this->shop->read($value['shop']);
  2729. $info_listxw[$key]['shop'] = $shop['shopname'];
  2730. $express = $this->express->read($value['express']);
  2731. $info_listxw[$key]['express'] = $express['servicename'];
  2732. $warehouse = $this->warehouse->read($value['type']);
  2733. $info_listxw[$key]['type'] = $warehouse['title'];
  2734. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2735. }
  2736. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2737. //格式化数据
  2738. foreach ($info_listsmt as $key=>$value)
  2739. {
  2740. $shop = $this->shop->read($value['shop']);
  2741. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2742. $express = $this->express->read($value['express']);
  2743. $info_listsmt[$key]['express'] = $express['servicename'];
  2744. $warehouse = $this->warehouse->read($value['type']);
  2745. $info_listsmt[$key]['type'] = $warehouse['title'];
  2746. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2747. }
  2748. $total = $this->fullorder->find_count($where);
  2749. $total += $this->fullordertt->find_count($where);
  2750. $total += $this->fullorderamz->find_count($where);
  2751. $total += $this->fullorderxw->find_count($where);
  2752. $total += $this->fullordersmt->find_count($where);
  2753. $pagenum = ceil($total/$perpage);
  2754. $over = $total-($start+$perpage);
  2755. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  2756. echo json_encode($rows);exit;
  2757. }
  2758. if(isset($_SESSION['api']))
  2759. {
  2760. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2761. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2762. $this->data['wlshop'] = $wlshop;
  2763. $this->data['warehouse'] = $warehouse;
  2764. }
  2765. $this->data['xw'] = $xw;
  2766. $this->_Template('systemfout_fouthb',$this->data);
  2767. }
  2768. public function _hb()
  2769. {
  2770. $post = $this->input->post(NULL, TRUE);
  2771. $xw = '';
  2772. if(isset($_SESSION['api']))
  2773. {
  2774. $user = $this->user->get_api($_SESSION['api']);
  2775. $usp = $user;
  2776. $fgshop = "";$sid = "";$wid="";$wtype="";
  2777. $usersp = explode('|',trim($user['shop'],'|'));
  2778. $userwh = explode('|',trim($user['warehouse'],'|'));
  2779. foreach ($usersp as $value)
  2780. {
  2781. $fgshop .= " shop = ".$value." or";
  2782. $sid .= " id = ".$value." or";
  2783. }
  2784. foreach ($userwh as $value)
  2785. {
  2786. $wid .= " id = ".$value." or";
  2787. $wtype .= " type = ".$value." or";
  2788. }
  2789. if($user['userid'] == 'xw')
  2790. {
  2791. $xw = 1;
  2792. }
  2793. }
  2794. if(isset($post['page']))
  2795. {
  2796. $page = $this->input->post('page',true);
  2797. $perpage = $this->input->post('perpage',true);
  2798. $timetk = $this->input->post('timetk',true);
  2799. $timetj = $this->input->post('timetj',true);
  2800. $shop = $this->input->post('shop',true);
  2801. $source = $this->input->post('source',true);
  2802. $orderinfo = $this->input->post('orderinfo',true);
  2803. $number = $this->input->post('number',true);
  2804. $library = $this->input->post('library',true);
  2805. $waybill = $this->input->post('waybill',true);
  2806. $express = $this->input->post('express',true);
  2807. $type = $this->input->post('type',true);
  2808. $lowe = $this->input->post('lowe',true);
  2809. $so = $this->input->post('so',true);
  2810. $librarytime = $this->input->post('librarytime',true);
  2811. $timetk = strtotime($timetk);
  2812. $timetj = strtotime($timetj);
  2813. $cxtime = 'id';
  2814. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  2815. if($timetk && $timetj && $library == 1)
  2816. {
  2817. //$cxtime = 'reviewtime';
  2818. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  2819. $where .= " and state != 217";
  2820. }
  2821. else if($timetk && $timetj && $library == 2)
  2822. {
  2823. $cxtime = 'librarytime';
  2824. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2825. }
  2826. if($shop)
  2827. {
  2828. $where .= " and shop = '$shop'";
  2829. }
  2830. if($number)
  2831. {
  2832. $where .= " and number = '$number'";
  2833. }
  2834. if($library)
  2835. {
  2836. $where .= " and library = '$library'";
  2837. }
  2838. if($waybill)
  2839. {
  2840. $where .= " and waybill = '$waybill'";
  2841. }
  2842. if($express)
  2843. {
  2844. $where .= " and express = '$express'";
  2845. }
  2846. if($orderinfo)
  2847. {
  2848. $where .= " and orderinfo = '$orderinfo'";
  2849. }
  2850. if($type)
  2851. {
  2852. $where .= " and type = '$type'";
  2853. }
  2854. if($lowe)
  2855. {
  2856. $where .= " and shipremarks like '%$lowe%'";
  2857. }
  2858. if($so)
  2859. {
  2860. $where .= " and shipremarks like '%$so%'";
  2861. }
  2862. //数据排序
  2863. $order_str = $cxtime." desc";
  2864. if(empty($page))
  2865. {
  2866. $start = 0;
  2867. $perpage = 1;
  2868. }
  2869. else
  2870. {
  2871. $start = ($page - 1)*$perpage;
  2872. }
  2873. //取得信息列表
  2874. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2875. //格式化数据
  2876. foreach ($info_list as $key=>$value)
  2877. {
  2878. $shop = $this->shop->read($value['shop']);
  2879. $info_list[$key]['shop'] = $shop['shopname'];
  2880. if($value['waybill'] == '0')
  2881. {
  2882. $info_list[$key]['waybill'] = "";
  2883. }
  2884. $express = $this->express->read($value['express']);
  2885. $info_list[$key]['express'] = $express['servicename'];
  2886. $warehouse = $this->warehouse->read($value['type']);
  2887. $info_list[$key]['type'] = $warehouse['title'];
  2888. if($value['print'] == 1)
  2889. {
  2890. $info_list[$key]['print'] = '不可打印';
  2891. }
  2892. else if($value['print'] == 2)
  2893. {
  2894. $info_list[$key]['print'] = '未打印';
  2895. }
  2896. else if($value['print'] == 3)
  2897. {
  2898. $info_list[$key]['print'] = '已打印';
  2899. }
  2900. if($value['library'] == 1)
  2901. {
  2902. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2903. }
  2904. else if($value['library'] == 2)
  2905. {
  2906. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2907. }
  2908. else if($value['library'] == 3)
  2909. {
  2910. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2911. }
  2912. if($value['librarytime'] == '0')
  2913. {
  2914. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2915. }
  2916. else
  2917. {
  2918. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2919. }
  2920. $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  2921. }
  2922. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2923. //格式化数据
  2924. foreach ($info_listtt as $key=>$value)
  2925. {
  2926. $shop = $this->shop->read($value['shop']);
  2927. $info_listtt[$key]['shop'] = $shop['shopname'];
  2928. if($value['waybill'] == '0')
  2929. {
  2930. $info_listtt[$key]['waybill'] = "";
  2931. }
  2932. $express = $this->express->read($value['express']);
  2933. $info_listtt[$key]['express'] = $express['servicename'];
  2934. $warehouse = $this->warehouse->read($value['type']);
  2935. $info_listtt[$key]['type'] = $warehouse['title'];
  2936. if($value['print'] == 1)
  2937. {
  2938. $info_listtt[$key]['print'] = '不可打印';
  2939. }
  2940. else if($value['print'] == 2)
  2941. {
  2942. $info_listtt[$key]['print'] = '未打印';
  2943. }
  2944. else if($value['print'] == 3)
  2945. {
  2946. $info_listtt[$key]['print'] = '已打印';
  2947. }
  2948. if($value['library'] == 1)
  2949. {
  2950. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2951. }
  2952. else if($value['library'] == 2)
  2953. {
  2954. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2955. }
  2956. else if($value['library'] == 3)
  2957. {
  2958. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2959. }
  2960. if($value['librarytime'] == '0')
  2961. {
  2962. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  2963. }
  2964. else
  2965. {
  2966. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2967. }
  2968. }
  2969. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2970. //格式化数据
  2971. foreach ($info_listamz as $key=>$value)
  2972. {
  2973. $shop = $this->shop->read($value['shop']);
  2974. $info_listamz[$key]['shop'] = $shop['shopname'];
  2975. if($value['waybill'] == '0')
  2976. {
  2977. $info_listamz[$key]['waybill'] = "";
  2978. }
  2979. $express = $this->express->read($value['express']);
  2980. $info_listamz[$key]['express'] = $express['servicename'];
  2981. $warehouse = $this->warehouse->read($value['type']);
  2982. $info_listamz[$key]['type'] = $warehouse['title'];
  2983. if($value['print'] == 1)
  2984. {
  2985. $info_listamz[$key]['print'] = '不可打印';
  2986. }
  2987. else if($value['print'] == 2)
  2988. {
  2989. $info_listamz[$key]['print'] = '未打印';
  2990. }
  2991. else if($value['print'] == 3)
  2992. {
  2993. $info_listamz[$key]['print'] = '已打印';
  2994. }
  2995. if($value['library'] == 1)
  2996. {
  2997. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2998. }
  2999. else if($value['library'] == 2)
  3000. {
  3001. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  3002. }
  3003. else if($value['library'] == 3)
  3004. {
  3005. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  3006. }
  3007. if($value['librarytime'] == '0')
  3008. {
  3009. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  3010. }
  3011. else
  3012. {
  3013. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3014. }
  3015. }
  3016. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3017. //格式化数据
  3018. foreach ($info_listxw as $key=>$value)
  3019. {
  3020. $shop = $this->shop->read($value['shop']);
  3021. $info_listxw[$key]['shop'] = $shop['shopname'];
  3022. if($value['waybill'] == '0')
  3023. {
  3024. $info_listxw[$key]['waybill'] = "";
  3025. }
  3026. $express = $this->express->read($value['express']);
  3027. $info_listxw[$key]['express'] = $express['servicename'];
  3028. $warehouse = $this->warehouse->read($value['type']);
  3029. $info_listxw[$key]['type'] = $warehouse['title'];
  3030. if($value['print'] == 1)
  3031. {
  3032. $info_listxw[$key]['print'] = '不可打印';
  3033. }
  3034. else if($value['print'] == 2)
  3035. {
  3036. $info_listxw[$key]['print'] = '未打印';
  3037. }
  3038. else if($value['print'] == 3)
  3039. {
  3040. $info_listxw[$key]['print'] = '已打印';
  3041. }
  3042. if($value['library'] == 1)
  3043. {
  3044. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  3045. }
  3046. else if($value['library'] == 2)
  3047. {
  3048. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  3049. }
  3050. else if($value['library'] == 3)
  3051. {
  3052. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  3053. }
  3054. if($value['librarytime'] == '0')
  3055. {
  3056. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  3057. }
  3058. else
  3059. {
  3060. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3061. }
  3062. }
  3063. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3064. //格式化数据
  3065. foreach ($info_listsmt as $key=>$value)
  3066. {
  3067. $shop = $this->shop->read($value['shop']);
  3068. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3069. if($value['waybill'] == '0')
  3070. {
  3071. $info_listsmt[$key]['waybill'] = "";
  3072. }
  3073. $express = $this->express->read($value['express']);
  3074. $info_listsmt[$key]['express'] = $express['servicename'];
  3075. $warehouse = $this->warehouse->read($value['type']);
  3076. $info_listsmt[$key]['type'] = $warehouse['title'];
  3077. if($value['print'] == 1)
  3078. {
  3079. $info_listsmt[$key]['print'] = '不可打印';
  3080. }
  3081. else if($value['print'] == 2)
  3082. {
  3083. $info_listsmt[$key]['print'] = '未打印';
  3084. }
  3085. else if($value['print'] == 3)
  3086. {
  3087. $info_listsmt[$key]['print'] = '已打印';
  3088. }
  3089. if($value['library'] == 1)
  3090. {
  3091. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  3092. }
  3093. else if($value['library'] == 2)
  3094. {
  3095. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  3096. }
  3097. else if($value['library'] == 3)
  3098. {
  3099. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  3100. }
  3101. if($value['librarytime'] == '0')
  3102. {
  3103. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  3104. }
  3105. else
  3106. {
  3107. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3108. }
  3109. }
  3110. $total = $this->fullorder->find_count($where);
  3111. $total += $this->fullordertt->find_count($where);
  3112. $total += $this->fullorderamz->find_count($where);
  3113. $total += $this->fullorderxw->find_count($where);
  3114. $total += $this->fullordersmt->find_count($where);
  3115. $pagenum = ceil($total/$perpage);
  3116. $over = $total-($start+$perpage);
  3117. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt)));
  3118. echo json_encode($rows);exit;
  3119. }
  3120. if(isset($_SESSION['api']))
  3121. {
  3122. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3123. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3124. $this->data['wlshop'] = $wlshop;
  3125. $this->data['warehouse'] = $warehouse;
  3126. }
  3127. $this->data['xw'] = $xw;
  3128. $this->_Template('systemfout_hb',$this->data);
  3129. }
  3130. }