Systemfout.php 110 KB

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