Systemfout.php 112 KB

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