Systemfout.php 124 KB

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